@momo-kits/date-picker 0.92.8-beta.1 → 0.92.8-beta.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.
- package/WheelPicker.tsx +3 -16
- package/index.tsx +9 -8
- package/package.json +16 -16
package/WheelPicker.tsx
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
memo,
|
|
4
|
-
useCallback,
|
|
5
|
-
useContext,
|
|
6
|
-
useEffect,
|
|
7
|
-
useRef,
|
|
8
|
-
} from 'react';
|
|
9
|
-
import {Animated, Platform, View} from 'react-native';
|
|
1
|
+
import React, {FC, useCallback, useContext, useEffect, useRef} from 'react';
|
|
2
|
+
import {Animated, View} from 'react-native';
|
|
10
3
|
import {FlatList} from 'react-native-gesture-handler';
|
|
11
4
|
import styles from './styles';
|
|
12
5
|
import {ApplicationContext, scaleSize} from '@momo-kits/foundation';
|
|
@@ -46,12 +39,6 @@ const WheelPicker: FC<WheelPickerProps> = ({
|
|
|
46
39
|
};
|
|
47
40
|
}, [data.length]);
|
|
48
41
|
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (Platform.OS === 'android') {
|
|
51
|
-
onMomentumScrollEnd();
|
|
52
|
-
}
|
|
53
|
-
}, []);
|
|
54
|
-
|
|
55
42
|
const findClosestIndex = (array: string[], value: string) => {
|
|
56
43
|
let closest = array.reduce((a, b) => {
|
|
57
44
|
let aDiff = Math.abs(Number(a) - Number(value));
|
|
@@ -218,4 +205,4 @@ const WheelPicker: FC<WheelPickerProps> = ({
|
|
|
218
205
|
);
|
|
219
206
|
};
|
|
220
207
|
|
|
221
|
-
export default
|
|
208
|
+
export default WheelPicker;
|
package/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {FC,
|
|
1
|
+
import React, {FC, useEffect, useState} from 'react';
|
|
2
2
|
import {Dimensions, LayoutChangeEvent, View} from 'react-native';
|
|
3
3
|
import {Spacing} from '@momo-kits/foundation';
|
|
4
4
|
import WheelPicker from './WheelPicker';
|
|
@@ -42,9 +42,9 @@ const DateTimePicker: FC<DateTimePickerProps> = ({
|
|
|
42
42
|
useEffect(() => {
|
|
43
43
|
setupData();
|
|
44
44
|
return () => {};
|
|
45
|
-
}, []);
|
|
45
|
+
}, [selectedValue, currentDate]);
|
|
46
46
|
|
|
47
|
-
const setupData =
|
|
47
|
+
const setupData = () => {
|
|
48
48
|
const formatParts = format.split(/[^A-Za-z]+/);
|
|
49
49
|
const isOnlyHour = formatParts.length === 1 && formatParts[0] === 'HH';
|
|
50
50
|
|
|
@@ -85,7 +85,7 @@ const DateTimePicker: FC<DateTimePickerProps> = ({
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
setData(initialData);
|
|
88
|
-
}
|
|
88
|
+
};
|
|
89
89
|
|
|
90
90
|
const numOfColumns = data.length;
|
|
91
91
|
|
|
@@ -119,9 +119,7 @@ const DateTimePicker: FC<DateTimePickerProps> = ({
|
|
|
119
119
|
const paddingArray = ['', ''];
|
|
120
120
|
|
|
121
121
|
const onLayout = (e: LayoutChangeEvent) => {
|
|
122
|
-
|
|
123
|
-
setContainerWidth(e.nativeEvent.layout.width);
|
|
124
|
-
}
|
|
122
|
+
setContainerWidth(e.nativeEvent.layout.width);
|
|
125
123
|
};
|
|
126
124
|
|
|
127
125
|
return (
|
|
@@ -136,7 +134,9 @@ const DateTimePicker: FC<DateTimePickerProps> = ({
|
|
|
136
134
|
name={dataItem.name}
|
|
137
135
|
style={{
|
|
138
136
|
width:
|
|
139
|
-
(
|
|
137
|
+
(containerWidth -
|
|
138
|
+
Spacing.M * 2 -
|
|
139
|
+
(numOfColumns - 1) * Spacing.M) /
|
|
140
140
|
numOfColumns,
|
|
141
141
|
}}
|
|
142
142
|
/>
|
|
@@ -146,4 +146,5 @@ const DateTimePicker: FC<DateTimePickerProps> = ({
|
|
|
146
146
|
);
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
+
export type {DateTimePickerProps};
|
|
149
150
|
export {DateTimePicker};
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
"name": "@momo-kits/date-picker",
|
|
3
|
+
"version": "0.92.8-beta.10",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.tsx",
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"@momo-kits/foundation": "latest",
|
|
8
|
+
"react-native-gesture-handler": "1.10.3",
|
|
9
|
+
"react": "16.9.0",
|
|
10
|
+
"react-native": ">=0.55",
|
|
11
|
+
"prop-types": "^15.7.2"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@momo-platform/versions": "4.1.11"
|
|
15
|
+
},
|
|
16
|
+
"license": "MoMo",
|
|
17
|
+
"dependencies": {}
|
|
18
18
|
}
|