react-native-wheel-pick 1.2.3 → 1.2.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/README.md +11 -3
- package/package.json +1 -1
- package/src/WheelCurvedPicker.web.js +6 -0
- package/src/date-picker.web.js +52 -0
- package/src/picker.js +26 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
# [react-native-wheel-pick](https://www.npmjs.com/package/react-native-wheel-pick)
|
|
3
3
|
|
|
4
|
-
React native wheel picker for both iOS and android.
|
|
4
|
+
React native wheel picker for both iOS and android.
|
|
5
5
|
|
|
6
6
|
This is not original but inspired by [react-native-wheel-datepicker](https://github.com/pinguinjkeke/react-native-wheel-datepicker)
|
|
7
7
|
|
|
@@ -79,7 +79,6 @@ onDateChange={(date: Date) => { console.log(date) }}
|
|
|
79
79
|
maximumDate={new Date('2050-12-31')}
|
|
80
80
|
onDateChange={date => { console.log(date) }}
|
|
81
81
|
/>
|
|
82
|
-
|
|
83
82
|
```
|
|
84
83
|
```jsx
|
|
85
84
|
// pickerData also support array of object. (Optional Way)
|
|
@@ -110,7 +109,7 @@ onDateChange={(date: Date) => { console.log(date) }}
|
|
|
110
109
|
```
|
|
111
110
|
```jsx
|
|
112
111
|
// Android Only.
|
|
113
|
-
// These is special props for Android. (iOS not work)
|
|
112
|
+
// These is special props for Android. (iOS and Web not work)
|
|
114
113
|
// You can also use these props for DatePicker, too.
|
|
115
114
|
<Picker
|
|
116
115
|
textSize={20}
|
|
@@ -129,6 +128,10 @@ onDateChange={(date: Date) => { console.log(date) }}
|
|
|
129
128
|
<DatePicker
|
|
130
129
|
order='D-M-Y' // Default is M-D-Y
|
|
131
130
|
/>
|
|
131
|
+
|
|
132
|
+
// Test on Web (Platform.OS === 'Web')
|
|
133
|
+
<Picker style={{ height: 50 }} />
|
|
134
|
+
// DatePicker still not supported on Web.
|
|
132
135
|
```
|
|
133
136
|
## FYI
|
|
134
137
|
|
|
@@ -142,6 +145,11 @@ You can sponsor me
|
|
|
142
145
|
OR you can fork this project instead.
|
|
143
146
|
|
|
144
147
|
## Release Note
|
|
148
|
+
### 1.2.4 (Feb 17 2025)
|
|
149
|
+
[Web]
|
|
150
|
+
- Test on `Platform.OS === 'web'`
|
|
151
|
+
- Only `<Picker />` can use on Web. `<DatePicker />` still not supported on Web.
|
|
152
|
+
|
|
145
153
|
### 1.2.3 (Feb 15 2024)
|
|
146
154
|
- Fix state is not updating after onValueChange in Picker Component. Thanks to [@spasma
|
|
147
155
|
](https://github.com/TronNatthakorn/react-native-wheel-pick/issues/52)
|
package/package.json
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
// import { DatePickerIOS } from 'react-native';
|
|
3
|
+
import DateTimePicker from '@react-native-community/datetimepicker';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
|
|
6
|
+
export default class DatePicker extends PureComponent {
|
|
7
|
+
static propTypes = {
|
|
8
|
+
date: PropTypes.instanceOf(Date),
|
|
9
|
+
maximumDate: PropTypes.instanceOf(Date),
|
|
10
|
+
minimumDate: PropTypes.instanceOf(Date),
|
|
11
|
+
mode: PropTypes.oneOf(['date', 'time', 'datetime']),
|
|
12
|
+
onDateChange: PropTypes.func.isRequired,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
static defaultProps = {
|
|
16
|
+
mode: 'date',
|
|
17
|
+
date: new Date(),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
state = {
|
|
21
|
+
date: new Date(),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// @react-native-community/datetimepicker
|
|
25
|
+
//2022 use value instead of date
|
|
26
|
+
//2022 use onChange instead of onDateChange (and first param not date anymore)
|
|
27
|
+
render() {
|
|
28
|
+
return (
|
|
29
|
+
<DateTimePicker
|
|
30
|
+
{...this.props}
|
|
31
|
+
onChange={(event, date) => this.onDateChange(date)}
|
|
32
|
+
display='spinner'
|
|
33
|
+
value={this.state.date}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
componentDidMount() {
|
|
39
|
+
this.setState({ date: this.props.date })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
componentDidUpdate(prevProps) {
|
|
43
|
+
if (this.props.date !== prevProps.date) {
|
|
44
|
+
this.setState({ date: this.props.date })
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
onDateChange = (date) => {
|
|
49
|
+
this.setState({ date });
|
|
50
|
+
this.props.onDateChange(date);
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/picker.js
CHANGED
|
@@ -82,9 +82,33 @@ export default class Picker extends Component {
|
|
|
82
82
|
this.validateDeprecateProps('indicatorSize', 'selectLineSize');
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
const propsForWeb = { ...props }
|
|
86
|
+
|
|
87
|
+
if(Platform.OS === 'web'){
|
|
88
|
+
propsForWeb.textcolor = propsForWeb.textColor
|
|
89
|
+
propsForWeb.textsize = propsForWeb.textSize
|
|
90
|
+
|
|
91
|
+
propsForWeb.selecttextcolor = propsForWeb.selectTextColor
|
|
92
|
+
propsForWeb.isshowselectbackground = propsForWeb.isShowSelectBackground.toString()
|
|
93
|
+
propsForWeb.selectbackgroundcolor = propsForWeb.selectBackgroundColor
|
|
94
|
+
propsForWeb.isshowselectline = propsForWeb.isShowSelectLine.toString()
|
|
95
|
+
propsForWeb.selectlinecolor = propsForWeb.selectLineColor
|
|
96
|
+
propsForWeb.selectlinesize = propsForWeb.selectLineSize
|
|
97
|
+
|
|
98
|
+
delete propsForWeb.textColor
|
|
99
|
+
delete propsForWeb.textSize
|
|
100
|
+
|
|
101
|
+
delete propsForWeb.selectTextColor
|
|
102
|
+
delete propsForWeb.isShowSelectBackground
|
|
103
|
+
delete propsForWeb.selectBackgroundColor
|
|
104
|
+
delete propsForWeb.isShowSelectLine
|
|
105
|
+
delete propsForWeb.selectLineColor
|
|
106
|
+
delete propsForWeb.selectLineSize
|
|
107
|
+
}
|
|
108
|
+
|
|
85
109
|
return (
|
|
86
110
|
<WheelCurvedPicker
|
|
87
|
-
{...props}
|
|
111
|
+
{...(Platform.OS === 'web'? propsForWeb: props)}
|
|
88
112
|
style={[styles.picker, style]}
|
|
89
113
|
selectedValue={this.state.selectedValue}
|
|
90
114
|
onValueChange={this.handleChange}
|
|
@@ -94,7 +118,7 @@ export default class Picker extends Component {
|
|
|
94
118
|
key={index}
|
|
95
119
|
value={typeof data.value !== 'undefined' ? data.value : data.toString()}
|
|
96
120
|
label={typeof data.label !== 'undefined' ? data.label : data.toString()}
|
|
97
|
-
color={props.textColor}
|
|
121
|
+
color={(Platform.OS === 'web'? propsForWeb.textcolor: props.textColor)}
|
|
98
122
|
/>
|
|
99
123
|
))}
|
|
100
124
|
</WheelCurvedPicker>
|