@utilitywarehouse/hearth-react-native 0.28.0 → 0.28.1-testid-fix-2
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/.turbo/turbo-build.log +5 -4
- package/.turbo/turbo-lint.log +70 -68
- package/CHANGELOG.md +6 -0
- package/build/components/DatePicker/TimePicker.d.ts +3 -0
- package/build/components/DatePicker/TimePicker.js +84 -0
- package/build/components/DatePicker/time-picker/animated-math.d.ts +4 -0
- package/build/components/DatePicker/time-picker/animated-math.js +19 -0
- package/build/components/DatePicker/time-picker/period-native.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-native.js +17 -0
- package/build/components/DatePicker/time-picker/period-picker.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-picker.js +10 -0
- package/build/components/DatePicker/time-picker/period-web.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-web.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-native.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-native.js +19 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.d.ts +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.js +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.d.ts +16 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.js +97 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.d.ts +21 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.js +88 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.d.ts +23 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-web.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-web.js +146 -0
- package/build/components/DatePicker/time-picker/wheel.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel.js +10 -0
- package/build/components/Select/Select.d.ts +1 -1
- package/build/components/Select/Select.js +4 -4
- package/build/components/Select/Select.props.d.ts +4 -0
- package/build/components/Select/SelectOption.d.ts +1 -1
- package/build/components/Select/SelectOption.js +2 -2
- package/build/components/VerificationInput/VerificationInput.js +3 -3
- package/docs/all-components.mdx +2 -2
- package/docs/changelog.mdx +178 -1
- package/docs/components/AllComponents.web.tsx +65 -125
- package/docs/components/NextPrevPage.tsx +28 -44
- package/docs/components/index.ts +1 -0
- package/docs/getting-started.mdx +3 -3
- package/docs/hooks.mdx +2 -2
- package/docs/introduction.mdx +1 -1
- package/docs/layout-components.docs.mdx +11 -2
- package/docs/styling.mdx +3 -3
- package/package.json +3 -3
- package/scripts/copyChangelog.js +8 -1
- package/src/components/Banner/Banner.docs.mdx +2 -1
- package/src/components/Center/Center.docs.mdx +6 -5
- package/src/components/Checkbox/Checkbox.docs.mdx +2 -1
- package/src/components/CurrencyInput/CurrencyInput.docs.mdx +2 -1
- package/src/components/HighlightBanner/HighlightBanner.docs.mdx +2 -1
- package/src/components/Input/Input.docs.mdx +2 -1
- package/src/components/Menu/Menu.docs.mdx +2 -1
- package/src/components/Modal/Modal.docs.mdx +2 -1
- package/src/components/Radio/Radio.docs.mdx +2 -1
- package/src/components/Select/Select.docs.mdx +2 -1
- package/src/components/Select/Select.props.ts +4 -0
- package/src/components/Select/Select.tsx +9 -2
- package/src/components/Select/SelectOption.tsx +2 -0
- package/src/components/Switch/Switch.docs.mdx +3 -2
- package/src/components/VerificationInput/VerificationInput.tsx +3 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @utilitywarehouse/hearth-react-native@0.28.1-testid-fix-1 build /Users/filmondaniels/Projects/Work/hearth/packages/react-native
|
|
4
|
+
> tsc
|
|
5
|
+
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,68 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
no-
|
|
62
|
-
react-hooks/
|
|
63
|
-
no-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
no-misleading-character-class
|
|
67
|
-
no-
|
|
68
|
-
no-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @utilitywarehouse/hearth-react-native@0.27.2 lint /Users/filmondaniels/Projects/Work/hearth/packages/react-native
|
|
4
|
+
> TIMING=1 eslint .
|
|
5
|
+
|
|
6
|
+
[0m[0m
|
|
7
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/Carousel/Carousel.context.tsx[24m[0m
|
|
8
|
+
[0m [2m6:14[22m [33mwarning[39m Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components [2mreact-refresh/only-export-components[22m[0m
|
|
9
|
+
[0m[0m
|
|
10
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/Carousel/Carousel.tsx[24m[0m
|
|
11
|
+
[0m [2m146:6[22m [33mwarning[39m React Hook useMemo has a missing dependency: 'hasCarouselControlsInTree'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
12
|
+
[0m[0m
|
|
13
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/DatePicker/DatePicker.tsx[24m[0m
|
|
14
|
+
[0m [2m109:6[22m [33mwarning[39m React Hook useCallback has an unnecessary dependency: 'modalRef.current'. Either exclude it or remove the dependency array. Mutable values like 'modalRef.current' aren't valid dependencies because mutating them doesn't re-render the component [2mreact-hooks/exhaustive-deps[22m[0m
|
|
15
|
+
[0m [2m259:6[22m [33mwarning[39m React Hook useEffect has a missing dependency: 'initialState'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
16
|
+
[0m [2m346:6[22m [33mwarning[39m React Hook useEffect has a missing dependency: 'onChange'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
17
|
+
[0m [2m468:5[22m [33mwarning[39m React Hook useCallback has a missing dependency: 'onChange'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
18
|
+
[0m [2m536:6[22m [33mwarning[39m React Hook useEffect has a missing dependency: 'onSelectMonth'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
19
|
+
[0m [2m542:6[22m [33mwarning[39m React Hook useEffect has a missing dependency: 'onSelectYear'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
20
|
+
[0m[0m
|
|
21
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/DatePicker/DatePickerDay.tsx[24m[0m
|
|
22
|
+
[0m [2m76:6[22m [33mwarning[39m React Hook useMemo has an unnecessary dependency: 'styles.rangeRoot'. Either exclude it or remove the dependency array. Outer scope values like 'styles.rangeRoot' aren't valid dependencies because mutating them doesn't re-render the component [2mreact-hooks/exhaustive-deps[22m[0m
|
|
23
|
+
[0m [2m84:6[22m [33mwarning[39m React Hook useMemo has a missing dependency: 'isSelected'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
24
|
+
[0m[0m
|
|
25
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/DatePicker/DatePickerDays.tsx[24m[0m
|
|
26
|
+
[0m [2m179:6[22m [33mwarning[39m React Hook useMemo has unnecessary dependencies: 'month' and 'year'. Either exclude them or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
27
|
+
[0m[0m
|
|
28
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/DatePicker/DatePickerYears.tsx[24m[0m
|
|
29
|
+
[0m [2m52:6[22m [33mwarning[39m React Hook useCallback has a missing dependency: 'containerHeight'. Either include it or remove the dependency array. Outer scope values like 'styles' aren't valid dependencies because mutating them doesn't re-render the component [2mreact-hooks/exhaustive-deps[22m[0m
|
|
30
|
+
[0m[0m
|
|
31
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/Input/Input.tsx[24m[0m
|
|
32
|
+
[0m [2m78:8[22m [33mwarning[39m React Hook useEffect has a missing dependency: 'formFieldContext'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
33
|
+
[0m[0m
|
|
34
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/Modal/Modal.tsx[24m[0m
|
|
35
|
+
[0m [2m93:6[22m [33mwarning[39m React Hook useCallback has an unnecessary dependency: 'Platform.OS'. Either exclude it or remove the dependency array. Outer scope values like 'Platform.OS' aren't valid dependencies because mutating them doesn't re-render the component [2mreact-hooks/exhaustive-deps[22m[0m
|
|
36
|
+
[0m [2m330:5[22m [33mwarning[39m React Hook useCallback has a missing dependency: 'footer'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
37
|
+
[0m[0m
|
|
38
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/Modal/Modal.web.tsx[24m[0m
|
|
39
|
+
[0m [2m66:6[22m [33mwarning[39m React Hook useCallback has an unnecessary dependency: 'Platform.OS'. Either exclude it or remove the dependency array. Outer scope values like 'Platform.OS' aren't valid dependencies because mutating them doesn't re-render the component [2mreact-hooks/exhaustive-deps[22m[0m
|
|
40
|
+
[0m[0m
|
|
41
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/PillGroup/PillGroup.tsx[24m[0m
|
|
42
|
+
[0m [2m17:9[22m [33mwarning[39m The 'normalizedValue' conditional could make the dependencies of useMemo Hook (at line 33) change on every render. Move it inside the useMemo callback. Alternatively, wrap the initialization of 'normalizedValue' in its own useMemo() Hook [2mreact-hooks/exhaustive-deps[22m[0m
|
|
43
|
+
[0m[0m
|
|
44
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/Tabs/Tabs.tsx[24m[0m
|
|
45
|
+
[0m [2m53:6[22m [33mwarning[39m React Hook useEffect has a missing dependency: 'tabValues'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
46
|
+
[0m [2m53:7[22m [33mwarning[39m React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked [2mreact-hooks/exhaustive-deps[22m[0m
|
|
47
|
+
[0m [2m104:5[22m [33mwarning[39m React Hook useMemo has an unnecessary dependency: 'tabValues'. Either exclude it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
48
|
+
[0m [2m127:62[22m [33mwarning[39m React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked [2mreact-hooks/exhaustive-deps[22m[0m
|
|
49
|
+
[0m[0m
|
|
50
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/Textarea/Textarea.tsx[24m[0m
|
|
51
|
+
[0m [2m45:6[22m [33mwarning[39m React Hook useEffect has a missing dependency: 'formFieldContext'. Either include it or remove the dependency array [2mreact-hooks/exhaustive-deps[22m[0m
|
|
52
|
+
[0m[0m
|
|
53
|
+
[0m[4m/Users/filmondaniels/Projects/Work/hearth/packages/react-native/src/components/Toast/Toast.context.tsx[24m[0m
|
|
54
|
+
[0m [2m14:14[22m [33mwarning[39m Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components [2mreact-refresh/only-export-components[22m[0m
|
|
55
|
+
[0m [2m106:14[22m [33mwarning[39m Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components [2mreact-refresh/only-export-components[22m[0m
|
|
56
|
+
[0m[0m
|
|
57
|
+
[0m[33m[1m✖ 24 problems (0 errors, 24 warnings)[22m[39m[0m
|
|
58
|
+
[0m[33m[1m[22m[39m[0m
|
|
59
|
+
Rule | Time (ms) | Relative
|
|
60
|
+
:-----------------------------------------|----------:|--------:
|
|
61
|
+
@typescript-eslint/no-unused-vars | 436.390 | 62.5%
|
|
62
|
+
react-hooks/exhaustive-deps | 28.433 | 4.1%
|
|
63
|
+
no-global-assign | 25.595 | 3.7%
|
|
64
|
+
react-hooks/rules-of-hooks | 20.152 | 2.9%
|
|
65
|
+
@typescript-eslint/ban-ts-comment | 17.023 | 2.4%
|
|
66
|
+
no-misleading-character-class | 12.606 | 1.8%
|
|
67
|
+
@typescript-eslint/no-unused-expressions | 9.189 | 1.3%
|
|
68
|
+
no-unexpected-multiline | 8.943 | 1.3%
|
|
69
|
+
@typescript-eslint/triple-slash-reference | 8.378 | 1.2%
|
|
70
|
+
no-loss-of-precision | 8.049 | 1.2%
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @utilitywarehouse/hearth-react-native
|
|
2
2
|
|
|
3
|
+
## 0.28.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1018](https://github.com/utilitywarehouse/hearth/pull/1018) [`1c5e02e`](https://github.com/utilitywarehouse/hearth/commit/1c5e02ea4b61329e7c55e52f9aa4ae44abc0da23) Thanks [@fillyD](https://github.com/fillyD)! - 🐛 [FIX]: Adds missing `testID` to `Select`, `SelectOption` and `VerificationInput` component
|
|
8
|
+
|
|
3
9
|
## 0.28.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { useCallback, useMemo } from 'react';
|
|
4
|
+
import { ScrollView, View } from 'react-native';
|
|
5
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
6
|
+
import { BodyText } from '../BodyText';
|
|
7
|
+
import { useDatePickerContext } from './DatePicker.context';
|
|
8
|
+
import { CONTAINER_HEIGHT } from './enums';
|
|
9
|
+
import PeriodPicker from './time-picker/period-picker';
|
|
10
|
+
import Wheel from './time-picker/wheel';
|
|
11
|
+
import { formatNumber, getParsedDate } from './utils';
|
|
12
|
+
const createNumberList = (num, numerals, startFrom = 0) => {
|
|
13
|
+
return Array.from({ length: num }, (_, i) => ({
|
|
14
|
+
value: i + startFrom,
|
|
15
|
+
text: i + startFrom < 10
|
|
16
|
+
? `${formatNumber(0, numerals)}${formatNumber(i + startFrom, numerals)}`
|
|
17
|
+
: `${formatNumber(i + startFrom, numerals)}`,
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
const TimePicker = () => {
|
|
21
|
+
const { currentDate, date, onSelectDate, timeZone, numerals = 'latn', use12Hours, } = useDatePickerContext();
|
|
22
|
+
const hours = useMemo(() => createNumberList(use12Hours ? 12 : 24, numerals, use12Hours ? 1 : 0), [numerals, use12Hours]);
|
|
23
|
+
const minutes = useMemo(() => createNumberList(60, numerals), [numerals]);
|
|
24
|
+
const { hour, hour12, minute, period } = getParsedDate(date || currentDate);
|
|
25
|
+
const handleChangeHour = useCallback((value) => {
|
|
26
|
+
let hour24 = value;
|
|
27
|
+
if (use12Hours) {
|
|
28
|
+
if (period === 'AM' && value === 12) {
|
|
29
|
+
hour24 = 0;
|
|
30
|
+
}
|
|
31
|
+
else if (period === 'PM' && value < 12) {
|
|
32
|
+
hour24 = value + 12;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
hour24 = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const newDate = dayjs.tz(date, timeZone).hour(hour24).minute(minute);
|
|
39
|
+
onSelectDate(newDate);
|
|
40
|
+
}, [date, onSelectDate, timeZone, use12Hours, period, minute]);
|
|
41
|
+
const handleChangeMinute = useCallback((value) => {
|
|
42
|
+
const newDate = dayjs.tz(date, timeZone).minute(value);
|
|
43
|
+
onSelectDate(newDate);
|
|
44
|
+
}, [date, onSelectDate, timeZone]);
|
|
45
|
+
const handlePeriodChange = useCallback((newPeriod) => {
|
|
46
|
+
let newHour = hour12;
|
|
47
|
+
if (newPeriod === 'PM' && hour12 < 12) {
|
|
48
|
+
newHour = hour12 + 12;
|
|
49
|
+
}
|
|
50
|
+
else if (newPeriod === 'AM' && hour12 === 12) {
|
|
51
|
+
newHour = 0;
|
|
52
|
+
}
|
|
53
|
+
else if (newPeriod === 'AM' && hour >= 12) {
|
|
54
|
+
newHour = hour12;
|
|
55
|
+
}
|
|
56
|
+
const newDate = dayjs.tz(date || currentDate, timeZone).hour(newHour);
|
|
57
|
+
onSelectDate(newDate);
|
|
58
|
+
}, [date, currentDate, onSelectDate, timeZone, hour, hour12]);
|
|
59
|
+
return (_jsxs(ScrollView, { horizontal: true, scrollEnabled: false, contentContainerStyle: styles.container, testID: "time-selector", children: [_jsxs(View, { style: styles.timePickerContainer, children: [_jsx(View, { style: styles.wheelContainer, children: _jsx(Wheel, { value: use12Hours ? hour12 : hour, items: hours, setValue: handleChangeHour }) }), _jsx(BodyText, { style: styles.timeSeparator, children: ":" }), _jsx(View, { style: styles.wheelContainer, children: _jsx(Wheel, { value: minute, items: minutes, setValue: handleChangeMinute }) })] }), use12Hours && period ? (_jsx(View, { style: styles.periodContainer, children: _jsx(PeriodPicker, { value: period, setValue: handlePeriodChange }) })) : null] }));
|
|
60
|
+
};
|
|
61
|
+
const styles = StyleSheet.create({
|
|
62
|
+
container: {
|
|
63
|
+
flex: 1,
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
},
|
|
67
|
+
wheelContainer: {
|
|
68
|
+
flex: 1,
|
|
69
|
+
},
|
|
70
|
+
timePickerContainer: {
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
width: CONTAINER_HEIGHT / 2,
|
|
74
|
+
height: CONTAINER_HEIGHT / 2,
|
|
75
|
+
flexDirection: 'row',
|
|
76
|
+
},
|
|
77
|
+
timeSeparator: {
|
|
78
|
+
marginHorizontal: 5,
|
|
79
|
+
},
|
|
80
|
+
periodContainer: {
|
|
81
|
+
marginLeft: 10,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
export default TimePicker;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
const FACTORIAL_3 = 3 * 2;
|
|
3
|
+
const FACTORIAL_5 = 5 * 4 * FACTORIAL_3;
|
|
4
|
+
const FACTORIAL_7 = 7 * 6 * FACTORIAL_5;
|
|
5
|
+
function sin(animated) {
|
|
6
|
+
const normalized = normalize(animated);
|
|
7
|
+
const square = Animated.multiply(normalized, normalized);
|
|
8
|
+
const pow3 = Animated.multiply(normalized, square);
|
|
9
|
+
const pow5 = Animated.multiply(pow3, square);
|
|
10
|
+
const pow7 = Animated.multiply(pow5, square);
|
|
11
|
+
return Animated.add(Animated.add(normalized, Animated.multiply(pow3, -1 / FACTORIAL_3)), Animated.add(Animated.multiply(pow5, 1 / FACTORIAL_5), Animated.multiply(pow7, -1 / FACTORIAL_7)));
|
|
12
|
+
}
|
|
13
|
+
function normalize(animated) {
|
|
14
|
+
return Animated.add(Animated.modulo(Animated.add(animated, Math.PI), Math.PI * 2), -Math.PI).interpolate({
|
|
15
|
+
inputRange: [-Math.PI, -Math.PI / 2, Math.PI / 2, Math.PI],
|
|
16
|
+
outputRange: [0, -Math.PI / 2, Math.PI / 2, 0],
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export { sin, normalize };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import WheelPicker from './wheel-picker';
|
|
4
|
+
const options = [
|
|
5
|
+
{ value: 'AM', text: 'AM' },
|
|
6
|
+
{ value: 'PM', text: 'PM' },
|
|
7
|
+
];
|
|
8
|
+
const PeriodNative = ({ value, setValue = () => { } }) => {
|
|
9
|
+
return (_jsx(WheelPicker, { value: value, options: options, onChange: setValue,
|
|
10
|
+
//containerStyle={defaultStyles.container}
|
|
11
|
+
itemHeight: 44, decelerationRate: "fast" }));
|
|
12
|
+
};
|
|
13
|
+
const customComparator = (prev, next) => {
|
|
14
|
+
const areEqual = prev.value === next.value && prev.setValue === next.setValue;
|
|
15
|
+
return areEqual;
|
|
16
|
+
};
|
|
17
|
+
export default memo(PeriodNative, customComparator);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import PeriodNative from './period-native';
|
|
5
|
+
import PeriodWeb from './period-web';
|
|
6
|
+
const PeriodPicker = (props) => {
|
|
7
|
+
const Component = Platform.OS === 'web' ? PeriodWeb : PeriodNative;
|
|
8
|
+
return _jsx(Component, { ...props });
|
|
9
|
+
};
|
|
10
|
+
export default memo(PeriodPicker);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { Pressable, View } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import { BodyText } from '../../BodyText';
|
|
6
|
+
const PeriodWeb = ({ value, setValue = () => { } }) => {
|
|
7
|
+
return (_jsx(Pressable, { onPress: () => setValue(value == 'AM' ? 'PM' : 'AM'), children: _jsx(View, { style: [styles.period], children: _jsx(BodyText, { children: value }) }) }));
|
|
8
|
+
};
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
period: {
|
|
11
|
+
width: 65,
|
|
12
|
+
height: 44,
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
const customComparator = (prev, next) => {
|
|
18
|
+
const areEqual = prev.value === next.value && prev.setValue === next.setValue;
|
|
19
|
+
return areEqual;
|
|
20
|
+
};
|
|
21
|
+
export default memo(PeriodWeb, customComparator);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PickerOption } from '../DatePicker.props';
|
|
2
|
+
interface WheelProps {
|
|
3
|
+
value: number | string;
|
|
4
|
+
setValue?: (value: any) => void;
|
|
5
|
+
items: PickerOption[];
|
|
6
|
+
}
|
|
7
|
+
declare const _default: import("react").MemoExoticComponent<({ value, setValue, items }: WheelProps) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import WheelPicker from './wheel-picker';
|
|
6
|
+
const WheelNative = ({ value, setValue = () => { }, items }) => {
|
|
7
|
+
return (_jsx(WheelPicker, { value: value, options: items, onChange: setValue, containerStyle: styles.container, itemHeight: 44, decelerationRate: "fast" }));
|
|
8
|
+
};
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
container: {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
...Platform.select({
|
|
13
|
+
web: {
|
|
14
|
+
userSelect: 'none',
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
export default memo(WheelNative);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Animated, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { PickerOption } from '../../DatePicker.props';
|
|
4
|
+
interface ItemProps {
|
|
5
|
+
style: StyleProp<ViewStyle>;
|
|
6
|
+
option: PickerOption | null;
|
|
7
|
+
height: number;
|
|
8
|
+
index: number;
|
|
9
|
+
currentScrollIndex: Animated.AnimatedAddition<number>;
|
|
10
|
+
visibleRest: number;
|
|
11
|
+
rotationFunction: (x: number) => number;
|
|
12
|
+
opacityFunction: (x: number) => number;
|
|
13
|
+
scaleFunction: (x: number) => number;
|
|
14
|
+
}
|
|
15
|
+
declare const _default: React.NamedExoticComponent<ItemProps>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
import { BodyText } from '../../../BodyText';
|
|
5
|
+
import styles from './wheel-picker.style';
|
|
6
|
+
const WheelPickerItem = ({ style, height, option, index, visibleRest, currentScrollIndex, opacityFunction, rotationFunction, scaleFunction, }) => {
|
|
7
|
+
const relativeScrollIndex = Animated.subtract(index, currentScrollIndex);
|
|
8
|
+
const translateY = relativeScrollIndex.interpolate({
|
|
9
|
+
inputRange: (() => {
|
|
10
|
+
const range = [0];
|
|
11
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
12
|
+
range.unshift(-i);
|
|
13
|
+
range.push(i);
|
|
14
|
+
}
|
|
15
|
+
return range;
|
|
16
|
+
})(),
|
|
17
|
+
outputRange: (() => {
|
|
18
|
+
const range = [0];
|
|
19
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
20
|
+
let y = (height / 2) * (1 - Math.sin(Math.PI / 2 - rotationFunction(i)));
|
|
21
|
+
for (let j = 1; j < i; j++) {
|
|
22
|
+
y += height * (1 - Math.sin(Math.PI / 2 - rotationFunction(j)));
|
|
23
|
+
}
|
|
24
|
+
range.unshift(y);
|
|
25
|
+
range.push(-y);
|
|
26
|
+
}
|
|
27
|
+
return range;
|
|
28
|
+
})(),
|
|
29
|
+
});
|
|
30
|
+
const opacity = relativeScrollIndex.interpolate({
|
|
31
|
+
inputRange: (() => {
|
|
32
|
+
const range = [0];
|
|
33
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
34
|
+
range.unshift(-i);
|
|
35
|
+
range.push(i);
|
|
36
|
+
}
|
|
37
|
+
return range;
|
|
38
|
+
})(),
|
|
39
|
+
outputRange: (() => {
|
|
40
|
+
const range = [1];
|
|
41
|
+
for (let x = 1; x <= visibleRest + 1; x++) {
|
|
42
|
+
const y = opacityFunction(x);
|
|
43
|
+
range.unshift(y);
|
|
44
|
+
range.push(y);
|
|
45
|
+
}
|
|
46
|
+
return range;
|
|
47
|
+
})(),
|
|
48
|
+
});
|
|
49
|
+
const scale = relativeScrollIndex.interpolate({
|
|
50
|
+
inputRange: (() => {
|
|
51
|
+
const range = [0];
|
|
52
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
53
|
+
range.unshift(-i);
|
|
54
|
+
range.push(i);
|
|
55
|
+
}
|
|
56
|
+
return range;
|
|
57
|
+
})(),
|
|
58
|
+
outputRange: (() => {
|
|
59
|
+
const range = [1.0];
|
|
60
|
+
for (let x = 1; x <= visibleRest + 1; x++) {
|
|
61
|
+
const y = scaleFunction(x);
|
|
62
|
+
range.unshift(y);
|
|
63
|
+
range.push(y);
|
|
64
|
+
}
|
|
65
|
+
return range;
|
|
66
|
+
})(),
|
|
67
|
+
});
|
|
68
|
+
const rotateX = relativeScrollIndex.interpolate({
|
|
69
|
+
inputRange: (() => {
|
|
70
|
+
const range = [0];
|
|
71
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
72
|
+
range.unshift(-i);
|
|
73
|
+
range.push(i);
|
|
74
|
+
}
|
|
75
|
+
return range;
|
|
76
|
+
})(),
|
|
77
|
+
outputRange: (() => {
|
|
78
|
+
const range = ['0deg'];
|
|
79
|
+
for (let x = 1; x <= visibleRest + 1; x++) {
|
|
80
|
+
const y = rotationFunction(x);
|
|
81
|
+
range.unshift(`${y}deg`);
|
|
82
|
+
range.push(`${y}deg`);
|
|
83
|
+
}
|
|
84
|
+
return range;
|
|
85
|
+
})(),
|
|
86
|
+
});
|
|
87
|
+
return (_jsx(Animated.View, { style: [
|
|
88
|
+
styles.option,
|
|
89
|
+
style,
|
|
90
|
+
{
|
|
91
|
+
height,
|
|
92
|
+
opacity,
|
|
93
|
+
transform: [{ translateY }, { rotateX }, { scale }],
|
|
94
|
+
},
|
|
95
|
+
], children: _jsx(BodyText, { children: option?.text }) }));
|
|
96
|
+
};
|
|
97
|
+
export default React.memo(WheelPickerItem);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlatListProps, StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
import { PickerOption } from '../../DatePicker.props';
|
|
4
|
+
interface Props {
|
|
5
|
+
value: number | string;
|
|
6
|
+
options: PickerOption[];
|
|
7
|
+
onChange: (index: number | string) => void;
|
|
8
|
+
selectedIndicatorStyle?: StyleProp<ViewStyle>;
|
|
9
|
+
itemStyle?: ViewStyle;
|
|
10
|
+
itemHeight?: number;
|
|
11
|
+
containerStyle?: ViewStyle;
|
|
12
|
+
containerProps?: Omit<ViewProps, 'style'>;
|
|
13
|
+
scaleFunction?: (x: number) => number;
|
|
14
|
+
rotationFunction?: (x: number) => number;
|
|
15
|
+
opacityFunction?: (x: number) => number;
|
|
16
|
+
visibleRest?: number;
|
|
17
|
+
decelerationRate?: 'normal' | 'fast' | number;
|
|
18
|
+
flatListProps?: Omit<FlatListProps<PickerOption | null>, 'data' | 'renderItem'>;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
21
|
+
export default _default;
|