@momo-kits/date-picker 0.0.66-alpha.1 → 0.0.66-alpha.10

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.
@@ -11,7 +11,7 @@ import {
11
11
  SwitchLanguage,
12
12
  Spacing,
13
13
  Colors,
14
- } from '@momo-kits/core';
14
+ } from '@momo-kits/core-v2';
15
15
  import WheelPicker from './WheelPicker';
16
16
  import DatePickerHelper from './helper/DatePickerHelper';
17
17
 
@@ -73,7 +73,20 @@ class DatePicker extends Component {
73
73
  this.initDefault(props);
74
74
  }
75
75
 
76
+ // onBackPress = () => {
77
+ // this.hide();
78
+ // return true;
79
+ // }
80
+
76
81
  componentDidMount() {
82
+ // BackHandler.removeEventListener('hardwareBackPress', this.onBackPress);
83
+ // BackHandler.addEventListener('hardwareBackPress', this.onBackPress);
84
+
85
+ // setTimeout(() => {
86
+ // BackHandler.removeEventListener('hardwareBackPress', this.onBackPress);
87
+ // BackHandler.addEventListener('hardwareBackPress', this.onBackPress);
88
+ // }, 200);
89
+
77
90
  this.setStateMonth(this.dayIndex, this.monthIndex, this.yearIndex);
78
91
  const {onCreateRef} = this.props;
79
92
  if (typeof onCreateRef === 'function') onCreateRef(this);
@@ -191,8 +204,6 @@ class DatePicker extends Component {
191
204
  this.minutes = DatePickerHelper.makeRange(0, 59, true);
192
205
  }
193
206
  this.ranged = rangeHour || DatePickerHelper.arrayRange;
194
- this.startTime = startTime || DatePickerHelper.arrayRange;
195
- this.endTime = endTime || DatePickerHelper.arrayRange;
196
207
  }
197
208
 
198
209
  selectedIndexDate() {
@@ -321,6 +332,7 @@ class DatePicker extends Component {
321
332
  if (isRanged && format === 'hh:mm') {
322
333
  const from = this.ranged[this.hourRangeIndex_1];
323
334
  const to = this.ranged[this.hourRangeIndex_2];
335
+
324
336
  if (onSelected && typeof onSelected === 'function') {
325
337
  onSelected({
326
338
  from,
@@ -560,9 +572,9 @@ class DatePicker extends Component {
560
572
  const {description, descriptionStyle, renderDescription} = this.props;
561
573
  if (renderDescription) return renderDescription;
562
574
  return description ? (
563
- <Text.Title style={[{marginBottom: Spacing.S}, descriptionStyle]}>
575
+ <Text.Paragraph style={[{marginBottom: Spacing.S}, descriptionStyle]}>
564
576
  {description}
565
- </Text.Title>
577
+ </Text.Paragraph>
566
578
  ) : null;
567
579
  };
568
580
 
@@ -577,6 +589,7 @@ class DatePicker extends Component {
577
589
  labelHour,
578
590
  isRanged,
579
591
  } = this.props;
592
+
580
593
  if (isRanged && format === 'hh:mm') {
581
594
  return (
582
595
  <View style={styles.container}>
@@ -585,7 +598,7 @@ class DatePicker extends Component {
585
598
  {this.renderColumn(
586
599
  'HourRange1',
587
600
  this.hourRangeIndex_1,
588
- this.startTime,
601
+ this.ranged,
589
602
  SwitchLanguage.from,
590
603
  bottomOffset,
591
604
  value => {
@@ -596,7 +609,7 @@ class DatePicker extends Component {
596
609
  {this.renderColumn(
597
610
  'HourRange2',
598
611
  this.hourRangeIndex_2,
599
- this.endTime,
612
+ this.ranged,
600
613
  SwitchLanguage.to,
601
614
  bottomOffset,
602
615
  value => {
@@ -1,139 +1,136 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { useState } from 'react';
3
- import { StyleSheet } from 'react-native';
4
- import { isEmpty } from 'lodash';
2
+ import React, {useState} from 'react';
3
+ import {StyleSheet} from 'react-native';
4
+ import {isEmpty} from 'lodash';
5
5
  import {
6
- IconSource,
7
- TouchableOpacity,
8
- Text,
9
- Colors,
10
- ValueUtil,
11
- Image,
12
- } from '@momo-kits/core';
6
+ IconSource,
7
+ TouchableOpacity,
8
+ Text,
9
+ Colors,
10
+ ValueUtil,
11
+ Image,
12
+ Radius,
13
+ } from '@momo-kits/core-v2';
13
14
  import DatePicker from './DatePicker';
14
15
 
15
16
  const DatePickerInput = ({
16
- navigator,
17
- defaultDate,
18
- maxDate,
19
- minDate,
20
- format = 'dd/MM/YYYY',
21
- onSelected,
22
- onClose,
23
- style,
24
- textStyle,
25
- icon,
26
- iconStyle,
27
- error,
28
- disabled,
29
- minuteArray,
30
- title,
31
- showRightIcon,
17
+ navigator,
18
+ defaultDate,
19
+ maxDate,
20
+ minDate,
21
+ format = 'dd/MM/YYYY',
22
+ onSelected,
23
+ onClose,
24
+ style,
25
+ textStyle,
26
+ icon,
27
+ iconStyle,
28
+ error,
29
+ disabled,
30
+ minuteArray,
31
+ title,
32
+ showRightIcon,
32
33
  }) => {
33
- const [selected, setSelected] = useState(defaultDate || '');
34
+ const [selected, setSelected] = useState(defaultDate || '');
34
35
 
35
- const onPress = () => {
36
- navigator?.showBottom?.({
37
- screen: DatePicker,
38
- params: {
39
- dragDisabled: true,
40
- minDate,
41
- maxDate,
42
- format,
43
- title,
44
- selectedDate: selected,
45
- onClose,
46
- minuteArray,
47
- onSelected: (dateSelected) => {
48
- onSelected?.(dateSelected);
49
- setSelected(dateSelected);
50
- },
51
- },
52
- });
53
- };
54
- let otherStyle = {};
55
- if (error) otherStyle = styles.error;
56
- if (disabled) otherStyle = styles.disabled;
36
+ const onPress = () => {
37
+ navigator?.showBottom?.({
38
+ screen: DatePicker,
39
+ params: {
40
+ dragDisabled: true,
41
+ minDate,
42
+ maxDate,
43
+ format,
44
+ title,
45
+ selectedDate: selected,
46
+ onClose,
47
+ minuteArray,
48
+ onSelected: dateSelected => {
49
+ onSelected?.(dateSelected);
50
+ setSelected(dateSelected);
51
+ },
52
+ },
53
+ });
54
+ };
55
+ let otherStyle = {};
56
+ if (error) otherStyle = styles.error;
57
+ if (disabled) otherStyle = styles.disabled;
57
58
 
58
- return (
59
- <TouchableOpacity
60
- disabled={disabled}
61
- onPress={onPress}
62
- style={[
63
- styles.container,
64
- ValueUtil.extractStyle(style),
65
- otherStyle,
66
- ]}>
67
- <Text.Title
68
- style={[
69
- styles.defaultText,
70
- ValueUtil.extractStyle(textStyle),
71
- isEmpty(selected) ? { color: Colors.black_09 } : {},
72
- ]}>
73
- {isEmpty(selected) ? format : selected}
74
- </Text.Title>
75
- {showRightIcon ? (
76
- <Image
77
- source={icon || IconSource.ic_calendar}
78
- style={[styles.icon, ValueUtil.extractStyle(iconStyle)]}
79
- />
80
- ) : (
81
- <View />
82
- )}
83
- </TouchableOpacity>
84
- );
59
+ return (
60
+ <TouchableOpacity
61
+ disabled={disabled}
62
+ onPress={onPress}
63
+ style={[styles.container, ValueUtil.extractStyle(style), otherStyle]}>
64
+ <Text.Paragraph
65
+ style={[
66
+ styles.defaultText,
67
+ ValueUtil.extractStyle(textStyle),
68
+ isEmpty(selected) ? {color: Colors.black_09} : {},
69
+ ]}>
70
+ {isEmpty(selected) ? format : selected}
71
+ </Text.Paragraph>
72
+ {showRightIcon ? (
73
+ <Image
74
+ source={icon || IconSource.ic_calendar}
75
+ style={[styles.icon, ValueUtil.extractStyle(iconStyle)]}
76
+ />
77
+ ) : (
78
+ <View />
79
+ )}
80
+ </TouchableOpacity>
81
+ );
85
82
  };
86
83
 
87
84
  DatePickerInput.propTypes = {
88
- defaultDate: PropTypes.string,
89
- format: PropTypes.oneOf(['hh:mm', 'MM/YYYY', 'dd/MM', 'dd/MM/YYYY']),
90
- icon: PropTypes.any,
91
- maxDate: PropTypes.string,
92
- minDate: PropTypes.string,
93
- navigator: PropTypes.object,
94
- onClose: PropTypes.func,
95
- onSelected: PropTypes.func,
96
- iconStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
97
- style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
98
- textStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
99
- error: PropTypes.bool,
100
- disabled: PropTypes.bool,
101
- minuteArray: PropTypes.arrayOf(PropTypes.string),
102
- showRightIcon: PropTypes.bool,
103
- title: PropTypes.string,
85
+ defaultDate: PropTypes.string,
86
+ format: PropTypes.oneOf(['hh:mm', 'MM/YYYY', 'dd/MM', 'dd/MM/YYYY']),
87
+ icon: PropTypes.any,
88
+ maxDate: PropTypes.string,
89
+ minDate: PropTypes.string,
90
+ navigator: PropTypes.object,
91
+ onClose: PropTypes.func,
92
+ onSelected: PropTypes.func,
93
+ iconStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
94
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
95
+ textStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
96
+ error: PropTypes.bool,
97
+ disabled: PropTypes.bool,
98
+ minuteArray: PropTypes.arrayOf(PropTypes.string),
99
+ showRightIcon: PropTypes.bool,
100
+ title: PropTypes.string,
104
101
  };
105
102
  DatePickerInput.defaultProps = {
106
- showRightIcon: true,
103
+ showRightIcon: true,
107
104
  };
108
105
 
109
106
  export default DatePickerInput;
110
107
 
111
108
  const styles = StyleSheet.create({
112
- icon: {
113
- width: 16,
114
- height: 16,
115
- resizeMode: 'contain',
116
- tintColor: Colors.black_09,
117
- },
118
- container: {
119
- flexDirection: 'row',
120
- height: 42,
121
- borderRadius: 4,
122
- borderColor: Colors.black_06,
123
- borderWidth: 1,
124
- alignItems: 'center',
125
- justifyContent: 'space-between',
126
- paddingHorizontal: 12,
127
- backgroundColor: Colors.black_01,
128
- },
129
- error: {
130
- borderColor: Colors.red_05,
131
- },
132
- defaultText: {
133
- // fontSize: 14
134
- },
135
- disabled: {
136
- backgroundColor: Colors.black_05,
137
- borderWidth: 0,
138
- },
109
+ icon: {
110
+ width: 16,
111
+ height: 16,
112
+ resizeMode: 'contain',
113
+ tintColor: Colors.black_09,
114
+ },
115
+ container: {
116
+ flexDirection: 'row',
117
+ height: 42,
118
+ borderRadius: Radius.S,
119
+ borderColor: Colors.black_06,
120
+ borderWidth: 1,
121
+ alignItems: 'center',
122
+ justifyContent: 'space-between',
123
+ paddingHorizontal: 12,
124
+ backgroundColor: Colors.black_01,
125
+ },
126
+ error: {
127
+ borderColor: Colors.red_03,
128
+ },
129
+ defaultText: {
130
+ // fontSize: 14
131
+ },
132
+ disabled: {
133
+ backgroundColor: Colors.black_05,
134
+ borderWidth: 0,
135
+ },
139
136
  });
@@ -1,197 +1,208 @@
1
- import React, { Component } from 'react';
2
- import { Dimensions, StyleSheet, View } from 'react-native';
1
+ import React, {Component} from 'react';
2
+ import {Dimensions, StyleSheet, View} from 'react-native';
3
3
  import {
4
- Button,
5
- IconSource,
6
- TouchableOpacity,
7
- Text,
8
- Colors,
9
- Image,
10
- DeviceUtils,
11
- SwitchLanguage,
12
- } from '@momo-kits/core';
4
+ Button,
5
+ IconSource,
6
+ TouchableOpacity,
7
+ Text,
8
+ Colors,
9
+ Image,
10
+ DeviceUtils,
11
+ SwitchLanguage,
12
+ } from '@momo-kits/core-v2';
13
13
  import WheelPicker from './WheelPicker';
14
14
 
15
- const { isIphoneX } = DeviceUtils;
15
+ const {isIphoneX} = DeviceUtils;
16
16
 
17
17
  const widthScreen = Dimensions.get('window').width;
18
18
 
19
19
  export default class ListPicker extends Component {
20
- constructor(props) {
21
- super(props);
22
- this.data = 0;
23
- }
20
+ constructor(props) {
21
+ super(props);
22
+ this.data = 0;
23
+ }
24
24
 
25
- hide = () => {
26
- const { onClose, requestClose } = this.props;
27
- if (requestClose && typeof requestClose === 'function') {
28
- requestClose(() => {
29
- if (onClose && typeof onClose === 'function') {
30
- onClose();
31
- }
32
- });
25
+ hide = () => {
26
+ const {onClose, requestClose} = this.props;
27
+ if (requestClose && typeof requestClose === 'function') {
28
+ requestClose(() => {
29
+ if (onClose && typeof onClose === 'function') {
30
+ onClose();
33
31
  }
34
- };
32
+ });
33
+ }
34
+ };
35
35
 
36
- onBeginDrag = () => {
37
- if (this.refs.picker) {
38
- this.refs.picker.setScrollEnabled(false);
39
- }
40
- };
36
+ onBeginDrag = () => {
37
+ if (this.refs.picker) {
38
+ this.refs.picker.setScrollEnabled(false);
39
+ }
40
+ };
41
41
 
42
- onEndDrag = () => {
43
- if (this.refs.picker) {
44
- this.refs.picker.setScrollEnabled(true);
45
- }
46
- };
42
+ onEndDrag = () => {
43
+ if (this.refs.picker) {
44
+ this.refs.picker.setScrollEnabled(true);
45
+ }
46
+ };
47
47
 
48
- onChangeValue = (value) => {
49
- const { callback } = this.props;
50
- if (typeof callback === 'function') {
51
- callback(value);
52
- }
53
- };
48
+ onChangeValue = value => {
49
+ const {callback} = this.props;
50
+ if (typeof callback === 'function') {
51
+ callback(value);
52
+ }
53
+ };
54
54
 
55
- onPressClear = () => {
56
- this.hide();
57
- };
55
+ onPressClear = () => {
56
+ this.hide();
57
+ };
58
58
 
59
- onPressChoose = () => {
60
- this.onChangeValue(this.data);
61
- this.hide();
62
- };
59
+ onPressChoose = () => {
60
+ this.onChangeValue(this.data);
61
+ this.hide();
62
+ };
63
63
 
64
- renderRight = () => (
65
- <TouchableOpacity onPress={this.onPressChoose}>
66
- <Text.Title style={{ fontWeight: 'bold', color: Colors.pink_05 }}>
67
- {SwitchLanguage.save}
68
- </Text.Title>
69
- </TouchableOpacity>
70
- );
64
+ renderRight = () => (
65
+ <TouchableOpacity onPress={this.onPressChoose}>
66
+ <Text.Paragraph
67
+ style={{
68
+ fontWeight: 'bold',
69
+ color: Colors.pink_05,
70
+ }}>
71
+ {SwitchLanguage.save}
72
+ </Text.Paragraph>
73
+ </TouchableOpacity>
74
+ );
71
75
 
72
- renderLeftIcon = () => (
73
- <TouchableOpacity onPress={() => this.hide()}>
74
- <Image
75
- source={IconSource.ic_close_x_24}
76
- style={{ width: 25, height: 25, tintColor: Colors.black_17 }}
77
- />
78
- </TouchableOpacity>
79
- );
76
+ renderLeftIcon = () => (
77
+ <TouchableOpacity onPress={() => this.hide()}>
78
+ <Image
79
+ source={IconSource.ic_close_x_24}
80
+ style={{
81
+ width: 25,
82
+ height: 25,
83
+ tintColor: Colors.black_17,
84
+ }}
85
+ />
86
+ </TouchableOpacity>
87
+ );
80
88
 
81
- renderHeader() {
82
- const { title = '' } = this.props;
83
- return (
84
- <View style={styles.header}>
85
- {this.renderLeftIcon()}
86
- <Text style={styles.title}>{title}</Text>
87
- {this.props.typeStyle === 'aboveAction' ? (
88
- this.renderRight()
89
- ) : (
90
- <View style={{ width: 25 }} />
91
- )}
92
- </View>
93
- );
94
- }
89
+ renderHeader() {
90
+ const {title = ''} = this.props;
91
+ return (
92
+ <View style={styles.header}>
93
+ {this.renderLeftIcon()}
94
+ <Text style={styles.title}>{title}</Text>
95
+ {this.props.typeStyle === 'aboveAction' ? (
96
+ this.renderRight()
97
+ ) : (
98
+ <View style={{width: 25}} />
99
+ )}
100
+ </View>
101
+ );
102
+ }
95
103
 
96
- renderContent() {
97
- const { arrData = [], stylePicker, initValue } = this.props;
98
- return (
99
- <View style={styles.contentStyle}>
100
- <WheelPicker
101
- stylePicker={stylePicker}
102
- bottomOffset={1}
103
- value={initValue}
104
- key="picker"
105
- ref="picker"
106
- arrayValue={arrData}
107
- onBeginDrag={this.onBeginDrag}
108
- onEndDrag={this.onEndDrag}
109
- onValueChange={(value) => {
110
- this.data = value;
111
- }}
112
- />
113
- </View>
114
- );
115
- }
104
+ renderContent() {
105
+ const {arrData = [], stylePicker, initValue} = this.props;
106
+ return (
107
+ <View style={styles.contentStyle}>
108
+ <WheelPicker
109
+ stylePicker={stylePicker}
110
+ bottomOffset={1}
111
+ value={initValue}
112
+ key="picker"
113
+ ref="picker"
114
+ arrayValue={arrData}
115
+ onBeginDrag={this.onBeginDrag}
116
+ onEndDrag={this.onEndDrag}
117
+ onValueChange={value => {
118
+ this.data = value;
119
+ }}
120
+ />
121
+ </View>
122
+ );
123
+ }
116
124
 
117
- render() {
118
- return (
119
- <View style={styles.view}>
120
- {this.renderHeader()}
121
- {this.renderContent()}
122
- {this.props.typeStyle === 'aboveAction' ? null : (
123
- <View style={styles.btnView}>
124
- <Button
125
- style={{ flex: 1 }}
126
- title={SwitchLanguage.cancel}
127
- buttonStyle={{
128
- backgroundColor: Colors.second_text_color,
129
- }}
130
- onPress={this.onPressClear}
131
- />
132
- <Button
133
- style={{ flex: 1, marginLeft: 15 }}
134
- title={SwitchLanguage.choose}
135
- type="primary"
136
- onPress={this.onPressChoose}
137
- />
138
- </View>
139
- )}
140
- </View>
141
- );
142
- }
125
+ render() {
126
+ return (
127
+ <View style={styles.view}>
128
+ {this.renderHeader()}
129
+ {this.renderContent()}
130
+ {this.props.typeStyle === 'aboveAction' ? null : (
131
+ <View style={styles.btnView}>
132
+ <Button
133
+ style={{flex: 1}}
134
+ title={SwitchLanguage.cancel}
135
+ buttonStyle={{
136
+ backgroundColor: Colors.second_text_color,
137
+ }}
138
+ onPress={this.onPressClear}
139
+ />
140
+ <Button
141
+ style={{
142
+ flex: 1,
143
+ marginLeft: 15,
144
+ }}
145
+ title={SwitchLanguage.choose}
146
+ type="primary"
147
+ onPress={this.onPressChoose}
148
+ />
149
+ </View>
150
+ )}
151
+ </View>
152
+ );
153
+ }
143
154
  }
144
155
 
145
156
  const styles = StyleSheet.create({
146
- container: {
147
- flexDirection: 'row',
148
- width: widthScreen,
149
- alignItems: 'center',
150
- justifyContent: 'center',
151
- },
152
- contentStyle: {
153
- height: 230,
154
- },
155
- column: {
156
- borderWidth: 2,
157
- borderColor: 'red',
158
- },
159
- header: {
160
- flexDirection: 'row',
161
- height: 50,
162
- width: widthScreen,
163
- paddingHorizontal: 16,
164
- alignItems: 'center',
165
- justifyContent: 'space-between',
166
- backgroundColor: '#fff',
167
- borderBottomWidth: 1,
168
- borderColor: '#DADADA',
169
- },
170
- view: {
171
- backgroundColor: 'white',
172
- paddingBottom: 10 + (isIphoneX() ? 10 : 0),
173
- },
174
- title: {
175
- fontWeight: 'bold',
176
- color: Colors.black_17,
177
- flex: 1,
178
- fontSize: 16,
179
- textAlign: 'center',
180
- },
181
- titleCancel: {
182
- fontSize: 17,
183
- color: '#4A90E2',
184
- },
185
- titleConfirm: {
186
- fontSize: 17,
187
- color: '#4A90E2',
188
- textAlign: 'right',
189
- },
190
- btnView: {
191
- flexDirection: 'row',
192
- justifyContent: 'space-between',
193
- marginHorizontal: 15,
194
- height: 60,
195
- alignItems: 'center',
196
- },
157
+ container: {
158
+ flexDirection: 'row',
159
+ width: widthScreen,
160
+ alignItems: 'center',
161
+ justifyContent: 'center',
162
+ },
163
+ contentStyle: {
164
+ height: 230,
165
+ },
166
+ column: {
167
+ borderWidth: 2,
168
+ borderColor: 'red',
169
+ },
170
+ header: {
171
+ flexDirection: 'row',
172
+ height: 50,
173
+ width: widthScreen,
174
+ paddingHorizontal: 16,
175
+ alignItems: 'center',
176
+ justifyContent: 'space-between',
177
+ backgroundColor: '#fff',
178
+ borderBottomWidth: 1,
179
+ borderColor: '#DADADA',
180
+ },
181
+ view: {
182
+ backgroundColor: 'white',
183
+ paddingBottom: 10 + (isIphoneX() ? 10 : 0),
184
+ },
185
+ title: {
186
+ fontWeight: 'bold',
187
+ color: Colors.black_17,
188
+ flex: 1,
189
+ fontSize: 16,
190
+ textAlign: 'center',
191
+ },
192
+ titleCancel: {
193
+ fontSize: 17,
194
+ color: '#4A90E2',
195
+ },
196
+ titleConfirm: {
197
+ fontSize: 17,
198
+ color: '#4A90E2',
199
+ textAlign: 'right',
200
+ },
201
+ btnView: {
202
+ flexDirection: 'row',
203
+ justifyContent: 'space-between',
204
+ marginHorizontal: 15,
205
+ height: 60,
206
+ alignItems: 'center',
207
+ },
197
208
  });
@@ -1,6 +1,6 @@
1
1
  import React, {Component} from 'react';
2
2
  import {Dimensions, View} from 'react-native';
3
- import {LinearGradient, Text, Colors, ScaleSize} from '@momo-kits/core';
3
+ import {LinearGradient, Text, Colors, ScaleSize} from '@momo-kits/core-v2';
4
4
  import ScrollCustom from './custom/ScrollCustom';
5
5
  import DatePickerHelper from './helper/DatePickerHelper';
6
6
 
@@ -27,6 +27,7 @@ export default class WheelPicker extends Component {
27
27
 
28
28
  componentDidMount() {
29
29
  const {value} = this.props;
30
+ console.log(value);
30
31
  this.scrollToPosition(value);
31
32
  }
32
33
 
@@ -186,20 +187,19 @@ export default class WheelPicker extends Component {
186
187
  flex: 1,
187
188
  height: heightContain + 40,
188
189
  }}>
189
- <Text.SubTitle
190
- weight="bold"
190
+ <Text.Description2
191
+ weight="semibold"
191
192
  style={{
192
193
  color: Colors.black_17,
193
194
  marginLeft: 6,
194
195
  marginBottom: 3,
195
196
  }}>
196
197
  {DatePickerHelper.capitalizeFirstLetter(preFix || '')}
197
- </Text.SubTitle>
198
+ </Text.Description2>
198
199
  <View
199
200
  style={{
200
201
  flex: 1,
201
202
  height: heightContain,
202
- //backgroundColor: 'blue',
203
203
  marginHorizontal: 6,
204
204
  paddingBottom: 20,
205
205
  borderWidth: 1,
@@ -233,7 +233,6 @@ export default class WheelPicker extends Component {
233
233
  />
234
234
 
235
235
  <ScrollCustom
236
- accessibilityLabel={`Select ${preFix}/ScrollView`}
237
236
  ref={refName => {
238
237
  this.ScrollWheelPicker = refName;
239
238
  }}
@@ -261,24 +260,24 @@ export default class WheelPicker extends Component {
261
260
  {this.renderHiddenItem(this.numberItem, this.heightItem)}
262
261
  {items.map((valueItem, index) => (
263
262
  <View
264
- // eslint-disable-next-line react/no-array-index-key=
263
+ // eslint-disable-next-line react/no-array-index-key
265
264
  key={index}
266
- accessibilityLabel={`Selected/${valueItem}/${preFix}`}
267
- access
268
265
  style={{
269
266
  flex: 1,
270
267
  height: this.heightItem,
271
268
  justifyContent: 'center',
272
269
  alignItems: 'center',
273
270
  }}>
274
- <Text
271
+ <Text.Action2
272
+ weight={value === index ? 'bold' : 'semibold'}
275
273
  style={{
276
- color: value === index ? Colors.black_17 : '#909090',
277
- fontWeight: value === index ? 'bold' : '700',
278
- fontSize: value === index ? ScaleSize(20) : ScaleSize(16),
274
+ color: value === index ? Colors.black_17 : Colors.black_12,
275
+
276
+ fontSize: 15,
279
277
  }}>
280
278
  {valueItem}
281
- </Text>
279
+ {/* {reversePreFix ? `${valueItem} ${preFix}` : `${preFix} ${valueItem}`} */}
280
+ </Text.Action2>
282
281
  </View>
283
282
  ))}
284
283
  {this.renderHiddenItem(
@@ -49,7 +49,7 @@ export default class DatePickerHelper {
49
49
  '22:00',
50
50
  '22:30',
51
51
  '23:00',
52
- '23:30'
52
+ '23:30',
53
53
  ];
54
54
 
55
55
  static makeRange(min, max, isDouble) {
@@ -57,7 +57,8 @@ export default class DatePickerHelper {
57
57
  // eslint-disable-next-line no-plusplus
58
58
  for (let i = min; i <= max; i++) {
59
59
  const string = String(i);
60
- const value = string.length === 1 && isDouble ? `0${string}` : string;
60
+ const value =
61
+ string.length === 1 && isDouble ? `0${string}` : string;
61
62
  array.push(value);
62
63
  }
63
64
  return array;
@@ -69,7 +70,14 @@ export default class DatePickerHelper {
69
70
  const day = current.getDate().toString();
70
71
  const month = (current.getMonth() + 1).toString();
71
72
  const year = current.getFullYear().toString();
72
- return DatePickerHelper.toString(day, month, year, null, null, format);
73
+ return DatePickerHelper.toString(
74
+ day,
75
+ month,
76
+ year,
77
+ null,
78
+ null,
79
+ format,
80
+ );
73
81
  }
74
82
  return '';
75
83
  }
@@ -77,10 +85,17 @@ export default class DatePickerHelper {
77
85
  static formatDate(date, format) {
78
86
  if (date && format) {
79
87
  const {
80
- year, month, day, hour, minute, second = 0
88
+ year,
89
+ month,
90
+ day,
91
+ hour,
92
+ minute,
93
+ second = 0,
81
94
  } = DatePickerHelper.getDateTimeFromFormat(date, format);
82
- if (DatePickerHelper.checkValidDate(year, month, day)
83
- && DatePickerHelper.checkValidTime(hour, minute, second)) {
95
+ if (
96
+ DatePickerHelper.checkValidDate(year, month, day) &&
97
+ DatePickerHelper.checkValidTime(hour, minute, second)
98
+ ) {
84
99
  return new Date(year, month, day, hour, minute, second);
85
100
  }
86
101
  return null;
@@ -119,8 +134,14 @@ export default class DatePickerHelper {
119
134
 
120
135
  const today = new Date();
121
136
 
122
- const year = yearIndex > -1 ? dateItems?.[yearIndex] : today.getFullYear();
123
- const month = monthIndex > -1 ? dateItems?.[monthIndex] - 1 : today.getMonth() === 0 ? 1 : today.getMonth() - 1;
137
+ const year =
138
+ yearIndex > -1 ? dateItems?.[yearIndex] : today.getFullYear();
139
+ const month =
140
+ monthIndex > -1
141
+ ? dateItems?.[monthIndex] - 1
142
+ : today.getMonth() === 0
143
+ ? 1
144
+ : today.getMonth() - 1;
124
145
  const day = dayIndex > -1 ? dateItems?.[dayIndex] : today.getDate();
125
146
 
126
147
  const hour = hourIndex > -1 ? dateItems[hourIndex] : 0;
@@ -142,7 +163,7 @@ export default class DatePickerHelper {
142
163
  return number;
143
164
  }
144
165
  return `0${number}`;
145
- }
166
+ };
146
167
 
147
168
  static toString(day, month, year, hour, minute, format) {
148
169
  if (day && month && year && format) {
@@ -160,24 +181,32 @@ export default class DatePickerHelper {
160
181
  const year = parseInt(y);
161
182
  const month = parseInt(m);
162
183
  const day = parseInt(d);
163
- const months31 = [0, 2, 4, 6, 7, 9, 11];
164
- const months30 = [3, 5, 8, 10];
165
- const months28 = [1];
166
- const isLeap = ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0);
184
+ const months31 = [1, 3, 5, 7, 8, 10, 12];
185
+ const months30 = [4, 6, 9, 11];
186
+ const months28 = [2];
187
+ const isLeap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
167
188
  if (year != null && month != null && day != null) {
168
189
  const isDayValid = day > 0;
169
- const isMonthValid = (months31.indexOf(parseInt(month)) != -1 && day <= 31)
170
- || (months30.indexOf(month) != -1 && day <= 30)
171
- || (months30.indexOf(month) != -1 && day <= 31)
172
- || (months28.indexOf(month) != -1 && day <= 28)
173
- || (months28.indexOf(month) != -1 && day <= 29 && isLeap);
190
+ const isMonthValid =
191
+ (months31.indexOf(parseInt(month)) != -1 && day <= 31) ||
192
+ (months30.indexOf(month) != -1 && day <= 30) ||
193
+ (months30.indexOf(month) != -1 && day <= 31) ||
194
+ (months28.indexOf(month) != -1 && day <= 28) ||
195
+ (months28.indexOf(month) != -1 && day <= 29 && isLeap);
174
196
  return isDayValid && isMonthValid;
175
197
  }
176
198
  return false;
177
199
  }
178
200
 
179
201
  static checkValidTime(hour, minute, second) {
180
- if ((hour >= 0 && hour < 24) && (minute >= 0 && minute < 60) && (second >= 0 && second < 60)) {
202
+ if (
203
+ hour >= 0 &&
204
+ hour < 24 &&
205
+ minute >= 0 &&
206
+ minute < 60 &&
207
+ second >= 0 &&
208
+ second < 60
209
+ ) {
181
210
  return true;
182
211
  }
183
212
  return false;
@@ -185,11 +214,18 @@ export default class DatePickerHelper {
185
214
 
186
215
  static calculateDateSinceYearAgo(yearAgo) {
187
216
  let nowDate = new Date();
188
- nowDate = new Date(nowDate.getFullYear() - yearAgo, nowDate.getMonth(), nowDate.getDate());
217
+ nowDate = new Date(
218
+ nowDate.getFullYear() - yearAgo,
219
+ nowDate.getMonth(),
220
+ nowDate.getDate(),
221
+ );
189
222
  return nowDate;
190
223
  }
191
224
 
192
- static getMaxDate(month = new Date().getMonth(), year = new Date().getFullYear()) {
225
+ static getMaxDate(
226
+ month = new Date().getMonth(),
227
+ year = new Date().getFullYear(),
228
+ ) {
193
229
  const monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
194
230
  // Adjust for leap years
195
231
  if (year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)) {
@@ -201,5 +237,5 @@ export default class DatePickerHelper {
201
237
 
202
238
  static capitalizeFirstLetter(string) {
203
239
  return string.charAt(0).toUpperCase() + string.slice(1);
204
- }
240
+ }
205
241
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
- "name": "@momo-kits/date-picker",
3
- "version": "0.0.66-alpha.1",
4
- "private": false,
5
- "main": "index.js",
6
- "dependencies": {},
7
- "peerDependencies": {
8
- "@momo-kits/core": ">=0.0.5-beta",
9
- "lodash": "^4.17.15",
10
- "prop-types": "^15.7.2",
11
- "react": "16.9.0",
12
- "react-native": ">=0.55"
13
- },
14
- "devDependencies": {},
15
- "license": "MoMo"
16
- }
2
+ "name": "@momo-kits/date-picker",
3
+ "version": "0.0.66-alpha.10",
4
+ "private": false,
5
+ "main": "index.js",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "@momo-kits/core-v2": ">=0.0.5-beta",
9
+ "lodash": "^4.17.15",
10
+ "prop-types": "^15.7.2",
11
+ "react": "16.9.0",
12
+ "react-native": ">=0.55"
13
+ },
14
+ "devDependencies": {},
15
+ "license": "MoMo"
16
+ }