@momo-kits/date-picker 0.0.65-beta.21 → 0.0.65-beta.23

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-v2';
14
+ } from '@momo-kits/core';
15
15
  import WheelPicker from './WheelPicker';
16
16
  import DatePickerHelper from './helper/DatePickerHelper';
17
17
 
@@ -204,6 +204,8 @@ class DatePicker extends Component {
204
204
  this.minutes = DatePickerHelper.makeRange(0, 59, true);
205
205
  }
206
206
  this.ranged = rangeHour || DatePickerHelper.arrayRange;
207
+ this.startTime = startTime || DatePickerHelper.arrayRange;
208
+ this.endTime = endTime || DatePickerHelper.arrayRange;
207
209
  }
208
210
 
209
211
  selectedIndexDate() {
@@ -332,7 +334,6 @@ class DatePicker extends Component {
332
334
  if (isRanged && format === 'hh:mm') {
333
335
  const from = this.ranged[this.hourRangeIndex_1];
334
336
  const to = this.ranged[this.hourRangeIndex_2];
335
-
336
337
  if (onSelected && typeof onSelected === 'function') {
337
338
  onSelected({
338
339
  from,
@@ -514,6 +515,7 @@ class DatePicker extends Component {
514
515
  bottomOffset,
515
516
  callback,
516
517
  reversePreFix,
518
+ showLabel,
517
519
  ) {
518
520
  if (!this.arrayRef) {
519
521
  this.arrayRef = {};
@@ -529,7 +531,7 @@ class DatePicker extends Component {
529
531
  value={valueInput}
530
532
  arrayValue={arrayValue}
531
533
  reversePreFix={reversePreFix}
532
- preFix={label}
534
+ preFix={showLabel ? label : ''}
533
535
  onBeginDrag={this.onBeginDrag}
534
536
  onEndDrag={this.onEndDrag}
535
537
  onValueChange={value => {
@@ -572,9 +574,9 @@ class DatePicker extends Component {
572
574
  const {description, descriptionStyle, renderDescription} = this.props;
573
575
  if (renderDescription) return renderDescription;
574
576
  return description ? (
575
- <Text.Paragraph style={[{marginBottom: Spacing.S}, descriptionStyle]}>
577
+ <Text.Title style={[{marginBottom: Spacing.S}, descriptionStyle]}>
576
578
  {description}
577
- </Text.Paragraph>
579
+ </Text.Title>
578
580
  ) : null;
579
581
  };
580
582
 
@@ -588,8 +590,8 @@ class DatePicker extends Component {
588
590
  labelMinute,
589
591
  labelHour,
590
592
  isRanged,
593
+ showLabel = true,
591
594
  } = this.props;
592
-
593
595
  if (isRanged && format === 'hh:mm') {
594
596
  return (
595
597
  <View style={styles.container}>
@@ -598,7 +600,7 @@ class DatePicker extends Component {
598
600
  {this.renderColumn(
599
601
  'HourRange1',
600
602
  this.hourRangeIndex_1,
601
- this.ranged,
603
+ this.startTime,
602
604
  SwitchLanguage.from,
603
605
  bottomOffset,
604
606
  value => {
@@ -609,7 +611,7 @@ class DatePicker extends Component {
609
611
  {this.renderColumn(
610
612
  'HourRange2',
611
613
  this.hourRangeIndex_2,
612
- this.ranged,
614
+ this.endTime,
613
615
  SwitchLanguage.to,
614
616
  bottomOffset,
615
617
  value => {
@@ -635,6 +637,7 @@ class DatePicker extends Component {
635
637
  value => {
636
638
  this.renderUpdate({day: value});
637
639
  },
640
+ showLabel,
638
641
  )
639
642
  : null}
640
643
  {format.indexOf('MM') !== -1
@@ -647,6 +650,7 @@ class DatePicker extends Component {
647
650
  value => {
648
651
  this.setStateDate(this.dayIndex, value, this.yearIndex);
649
652
  },
653
+ showLabel,
650
654
  )
651
655
  : null}
652
656
  {format.indexOf('YYYY') !== -1
@@ -659,6 +663,7 @@ class DatePicker extends Component {
659
663
  value => {
660
664
  this.setStateMonth(this.dayIndex, this.monthIndex, value);
661
665
  },
666
+ showLabel,
662
667
  )
663
668
  : null}
664
669
  {format.indexOf('hh') !== -1
@@ -1,136 +1,139 @@
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
- Radius,
13
- } from '@momo-kits/core-v2';
6
+ IconSource,
7
+ TouchableOpacity,
8
+ Text,
9
+ Colors,
10
+ ValueUtil,
11
+ Image,
12
+ } from '@momo-kits/core';
14
13
  import DatePicker from './DatePicker';
15
14
 
16
15
  const DatePickerInput = ({
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,
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,
33
32
  }) => {
34
- const [selected, setSelected] = useState(defaultDate || '');
33
+ const [selected, setSelected] = useState(defaultDate || '');
35
34
 
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;
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;
58
57
 
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
- );
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
+ );
82
85
  };
83
86
 
84
87
  DatePickerInput.propTypes = {
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,
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,
101
104
  };
102
105
  DatePickerInput.defaultProps = {
103
- showRightIcon: true,
106
+ showRightIcon: true,
104
107
  };
105
108
 
106
109
  export default DatePickerInput;
107
110
 
108
111
  const styles = StyleSheet.create({
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
- },
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
+ },
136
139
  });