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

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
 
@@ -204,8 +204,6 @@ 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;
209
207
  }
210
208
 
211
209
  selectedIndexDate() {
@@ -334,6 +332,7 @@ class DatePicker extends Component {
334
332
  if (isRanged && format === 'hh:mm') {
335
333
  const from = this.ranged[this.hourRangeIndex_1];
336
334
  const to = this.ranged[this.hourRangeIndex_2];
335
+
337
336
  if (onSelected && typeof onSelected === 'function') {
338
337
  onSelected({
339
338
  from,
@@ -515,7 +514,6 @@ class DatePicker extends Component {
515
514
  bottomOffset,
516
515
  callback,
517
516
  reversePreFix,
518
- showLabel,
519
517
  ) {
520
518
  if (!this.arrayRef) {
521
519
  this.arrayRef = {};
@@ -531,7 +529,7 @@ class DatePicker extends Component {
531
529
  value={valueInput}
532
530
  arrayValue={arrayValue}
533
531
  reversePreFix={reversePreFix}
534
- preFix={showLabel ? label : ''}
532
+ preFix={label}
535
533
  onBeginDrag={this.onBeginDrag}
536
534
  onEndDrag={this.onEndDrag}
537
535
  onValueChange={value => {
@@ -574,9 +572,9 @@ class DatePicker extends Component {
574
572
  const {description, descriptionStyle, renderDescription} = this.props;
575
573
  if (renderDescription) return renderDescription;
576
574
  return description ? (
577
- <Text.Title style={[{marginBottom: Spacing.S}, descriptionStyle]}>
575
+ <Text.Paragraph style={[{marginBottom: Spacing.S}, descriptionStyle]}>
578
576
  {description}
579
- </Text.Title>
577
+ </Text.Paragraph>
580
578
  ) : null;
581
579
  };
582
580
 
@@ -590,8 +588,8 @@ class DatePicker extends Component {
590
588
  labelMinute,
591
589
  labelHour,
592
590
  isRanged,
593
- showLabel = true,
594
591
  } = this.props;
592
+
595
593
  if (isRanged && format === 'hh:mm') {
596
594
  return (
597
595
  <View style={styles.container}>
@@ -600,7 +598,7 @@ class DatePicker extends Component {
600
598
  {this.renderColumn(
601
599
  'HourRange1',
602
600
  this.hourRangeIndex_1,
603
- this.startTime,
601
+ this.ranged,
604
602
  SwitchLanguage.from,
605
603
  bottomOffset,
606
604
  value => {
@@ -611,7 +609,7 @@ class DatePicker extends Component {
611
609
  {this.renderColumn(
612
610
  'HourRange2',
613
611
  this.hourRangeIndex_2,
614
- this.endTime,
612
+ this.ranged,
615
613
  SwitchLanguage.to,
616
614
  bottomOffset,
617
615
  value => {
@@ -637,7 +635,6 @@ class DatePicker extends Component {
637
635
  value => {
638
636
  this.renderUpdate({day: value});
639
637
  },
640
- showLabel,
641
638
  )
642
639
  : null}
643
640
  {format.indexOf('MM') !== -1
@@ -650,7 +647,6 @@ class DatePicker extends Component {
650
647
  value => {
651
648
  this.setStateDate(this.dayIndex, value, this.yearIndex);
652
649
  },
653
- showLabel,
654
650
  )
655
651
  : null}
656
652
  {format.indexOf('YYYY') !== -1
@@ -663,7 +659,6 @@ class DatePicker extends Component {
663
659
  value => {
664
660
  this.setStateMonth(this.dayIndex, this.monthIndex, value);
665
661
  },
666
- showLabel,
667
662
  )
668
663
  : null}
669
664
  {format.indexOf('hh') !== -1
@@ -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
  });