@utilitywarehouse/hearth-react-native 0.30.4-testid-fix-2 → 0.31.0
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 +4 -5
- package/.turbo/turbo-lint.log +62 -70
- package/CHANGELOG.md +155 -0
- package/build/components/Badge/Badge.js +2 -2
- package/build/components/Badge/Badge.props.d.ts +1 -0
- package/build/components/Badge/BadgeText.d.ts +1 -1
- package/build/components/Badge/BadgeText.js +2 -2
- package/build/components/Container/Container.props.d.ts +2 -2
- package/build/components/ExpandableCard/ExpandableCard.d.ts +1 -1
- package/build/components/ExpandableCard/ExpandableCard.js +13 -2
- package/build/components/ExpandableCard/ExpandableCard.props.d.ts +43 -23
- package/build/components/ExpandableCard/ExpandableCardText.js +1 -1
- package/build/components/ExpandableCard/ExpandableCardTrigger.d.ts +3 -3
- package/build/components/ExpandableCard/ExpandableCardTrigger.props.d.ts +31 -6
- package/build/components/ExpandableCard/ExpandableCardTriggerRoot.d.ts +1 -1
- package/build/components/ExpandableCard/ExpandableCardTriggerRoot.js +13 -2
- package/build/components/Flex/Flex.props.d.ts +2 -2
- package/build/components/FormField/FormField.d.ts +5 -5
- package/build/components/FormField/FormField.js +3 -2
- package/build/components/Modal/Modal.d.ts +1 -1
- package/build/components/Modal/Modal.js +33 -39
- package/build/components/Modal/Modal.props.d.ts +8 -3
- package/build/components/Modal/Modal.shared.types.d.ts +19 -4
- package/build/components/Modal/Modal.web.d.ts +1 -1
- package/build/components/Modal/Modal.web.js +6 -3
- package/build/components/NavModal/NavModal.d.ts +1 -1
- package/build/components/NavModal/NavModal.js +10 -7
- package/build/components/NavModal/NavModal.props.d.ts +4 -3
- package/build/components/Textarea/Textarea.d.ts +1 -1
- package/build/components/Textarea/Textarea.js +64 -5
- package/build/components/Textarea/Textarea.props.d.ts +10 -0
- package/build/components/Textarea/TextareaRoot.js +4 -1
- package/docs/changelog.mdx +21 -0
- package/package.json +4 -4
- package/src/components/Badge/Badge.props.ts +1 -0
- package/src/components/Badge/Badge.tsx +6 -1
- package/src/components/Badge/BadgeText.tsx +8 -2
- package/src/components/Container/Container.props.ts +10 -1
- package/src/components/ExpandableCard/ExpandableCard.docs.mdx +89 -37
- package/src/components/ExpandableCard/ExpandableCard.props.ts +51 -27
- package/src/components/ExpandableCard/ExpandableCard.stories.tsx +67 -17
- package/src/components/ExpandableCard/ExpandableCard.tsx +15 -7
- package/src/components/ExpandableCard/ExpandableCardText.tsx +1 -1
- package/src/components/ExpandableCard/ExpandableCardTrigger.props.ts +37 -7
- package/src/components/ExpandableCard/ExpandableCardTriggerRoot.tsx +36 -2
- package/src/components/Flex/Flex.props.ts +16 -2
- package/src/components/FormField/FormField.tsx +2 -1
- package/src/components/List/List.stories.tsx +35 -0
- package/src/components/Modal/Modal.docs.mdx +52 -1
- package/src/components/Modal/Modal.props.ts +21 -6
- package/src/components/Modal/Modal.shared.types.ts +23 -4
- package/src/components/Modal/Modal.stories.tsx +165 -1
- package/src/components/Modal/Modal.tsx +101 -81
- package/src/components/Modal/Modal.web.tsx +29 -23
- package/src/components/NavModal/NavModal.docs.mdx +29 -0
- package/src/components/NavModal/NavModal.props.ts +11 -3
- package/src/components/NavModal/NavModal.stories.tsx +29 -0
- package/src/components/NavModal/NavModal.tsx +39 -33
- package/src/components/Textarea/Textarea.docs.mdx +33 -1
- package/src/components/Textarea/Textarea.props.ts +11 -2
- package/src/components/Textarea/Textarea.stories.tsx +21 -1
- package/src/components/Textarea/Textarea.tsx +107 -3
- package/src/components/Textarea/TextareaRoot.tsx +6 -2
- package/build/components/DatePicker/TimePicker.d.ts +0 -3
- package/build/components/DatePicker/TimePicker.js +0 -84
- package/build/components/DatePicker/time-picker/animated-math.d.ts +0 -4
- package/build/components/DatePicker/time-picker/animated-math.js +0 -19
- package/build/components/DatePicker/time-picker/period-native.d.ts +0 -6
- package/build/components/DatePicker/time-picker/period-native.js +0 -17
- package/build/components/DatePicker/time-picker/period-picker.d.ts +0 -6
- package/build/components/DatePicker/time-picker/period-picker.js +0 -10
- package/build/components/DatePicker/time-picker/period-web.d.ts +0 -6
- package/build/components/DatePicker/time-picker/period-web.js +0 -21
- package/build/components/DatePicker/time-picker/wheel-native.d.ts +0 -8
- package/build/components/DatePicker/time-picker/wheel-native.js +0 -19
- package/build/components/DatePicker/time-picker/wheel-picker/index.d.ts +0 -2
- package/build/components/DatePicker/time-picker/wheel-picker/index.js +0 -2
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.d.ts +0 -16
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.js +0 -97
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.d.ts +0 -21
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.js +0 -88
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.d.ts +0 -23
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.js +0 -21
- package/build/components/DatePicker/time-picker/wheel-web.d.ts +0 -8
- package/build/components/DatePicker/time-picker/wheel-web.js +0 -146
- package/build/components/DatePicker/time-picker/wheel.d.ts +0 -8
- package/build/components/DatePicker/time-picker/wheel.js +0 -10
- package/build/components/SafeAreaView/SafeAreaView.d.ts +0 -5
- package/build/components/SafeAreaView/SafeAreaView.js +0 -117
- package/build/components/SafeAreaView/SafeAreaView.props.d.ts +0 -17
- package/build/components/SafeAreaView/SafeAreaView.props.js +0 -1
- package/build/components/SafeAreaView/index.d.ts +0 -2
- package/build/components/SafeAreaView/index.js +0 -1
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { Animated, Platform, View, } from 'react-native';
|
|
4
|
-
import WheelPickerItem from './wheel-picker-item';
|
|
5
|
-
import styles from './wheel-picker.style';
|
|
6
|
-
const WheelPicker = ({ value, options, onChange, selectedIndicatorStyle = {}, containerStyle = {}, itemStyle = {}, itemHeight = 40, scaleFunction = (x) => 1.0 ** x, rotationFunction = (x) => 1 - Math.pow(1 / 2, x), opacityFunction = (x) => Math.pow(1 / 3, x), visibleRest = 2, decelerationRate = 'normal', containerProps = {}, flatListProps = {}, }) => {
|
|
7
|
-
const momentumStarted = useRef(false);
|
|
8
|
-
const selectedIndex = options.findIndex(item => item.value === value);
|
|
9
|
-
const flatListRef = useRef(null);
|
|
10
|
-
const [scrollY] = useState(new Animated.Value(selectedIndex * itemHeight));
|
|
11
|
-
const containerHeight = (1 + visibleRest * 2) * itemHeight;
|
|
12
|
-
const paddedOptions = useMemo(() => {
|
|
13
|
-
const array = [...options];
|
|
14
|
-
for (let i = 0; i < visibleRest; i++) {
|
|
15
|
-
array.unshift(null);
|
|
16
|
-
array.push(null);
|
|
17
|
-
}
|
|
18
|
-
return array;
|
|
19
|
-
}, [options, visibleRest]);
|
|
20
|
-
const offsets = useMemo(() => [...Array(paddedOptions.length)].map((_, i) => i * itemHeight), [paddedOptions, itemHeight]);
|
|
21
|
-
const currentScrollIndex = useMemo(() => Animated.add(Animated.divide(scrollY, itemHeight), visibleRest), [visibleRest, scrollY, itemHeight]);
|
|
22
|
-
const handleScrollEnd = (event) => {
|
|
23
|
-
const offsetY = Math.min(itemHeight * (options.length - 1), Math.max(event.nativeEvent.contentOffset.y, 0));
|
|
24
|
-
let index = Math.floor(offsetY / itemHeight);
|
|
25
|
-
const remainder = offsetY % itemHeight;
|
|
26
|
-
if (remainder > itemHeight / 2) {
|
|
27
|
-
index++;
|
|
28
|
-
}
|
|
29
|
-
if (index !== selectedIndex) {
|
|
30
|
-
onChange(options[index]?.value || 0);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const handleMomentumScrollBegin = () => {
|
|
34
|
-
momentumStarted.current = true;
|
|
35
|
-
};
|
|
36
|
-
const handleMomentumScrollEnd = (event) => {
|
|
37
|
-
momentumStarted.current = false;
|
|
38
|
-
handleScrollEnd(event);
|
|
39
|
-
};
|
|
40
|
-
const handleScrollEndDrag = (event) => {
|
|
41
|
-
// Capture the offset value immediately
|
|
42
|
-
const offsetY = event.nativeEvent.contentOffset?.y;
|
|
43
|
-
// We'll start a short timer to see if momentum scroll begins
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
// If momentum scroll hasn't started within the timeout,
|
|
46
|
-
// then it was a slow scroll that won't trigger momentum
|
|
47
|
-
if (!momentumStarted.current && offsetY !== undefined) {
|
|
48
|
-
// Create a synthetic event with just the data we need
|
|
49
|
-
const syntheticEvent = {
|
|
50
|
-
nativeEvent: {
|
|
51
|
-
contentOffset: { y: offsetY },
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
handleScrollEnd(syntheticEvent);
|
|
55
|
-
}
|
|
56
|
-
}, 50);
|
|
57
|
-
};
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (selectedIndex < 0 || selectedIndex >= options.length) {
|
|
60
|
-
throw new Error(`Selected index ${selectedIndex} is out of bounds [0, ${options.length - 1}]`);
|
|
61
|
-
}
|
|
62
|
-
}, [selectedIndex, options]);
|
|
63
|
-
/**
|
|
64
|
-
* If selectedIndex is changed from outside (not via onChange) we need to scroll to the specified index.
|
|
65
|
-
* This ensures that what the user sees as selected in the picker always corresponds to the value state.
|
|
66
|
-
*/
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
flatListRef.current?.scrollToIndex({
|
|
69
|
-
index: selectedIndex,
|
|
70
|
-
animated: Platform.OS === 'ios',
|
|
71
|
-
});
|
|
72
|
-
}, [selectedIndex, itemHeight]);
|
|
73
|
-
return (_jsxs(View, { style: [styles.container, { height: containerHeight }, containerStyle], ...containerProps, children: [_jsx(View, { style: [
|
|
74
|
-
styles.selectedIndicator,
|
|
75
|
-
selectedIndicatorStyle,
|
|
76
|
-
{
|
|
77
|
-
transform: [{ translateY: -itemHeight / 2 }],
|
|
78
|
-
height: itemHeight,
|
|
79
|
-
},
|
|
80
|
-
] }), _jsx(Animated.FlatList, { ...flatListProps, ref: flatListRef, nestedScrollEnabled: true, style: styles.scrollView, showsVerticalScrollIndicator: false, onScroll: Animated.event([{ nativeEvent: { contentOffset: { y: scrollY } } }], {
|
|
81
|
-
useNativeDriver: true,
|
|
82
|
-
}), onScrollEndDrag: handleScrollEndDrag, onMomentumScrollBegin: handleMomentumScrollBegin, onMomentumScrollEnd: handleMomentumScrollEnd, snapToOffsets: offsets, decelerationRate: decelerationRate, initialScrollIndex: selectedIndex, getItemLayout: (_, index) => ({
|
|
83
|
-
length: itemHeight,
|
|
84
|
-
offset: itemHeight * index,
|
|
85
|
-
index,
|
|
86
|
-
}), data: paddedOptions, keyExtractor: (item, index) => item ? `${item.value}-${item.text}-${index}` : `null-${index}`, renderItem: ({ item: option, index }) => (_jsx(WheelPickerItem, { index: index, option: option, style: itemStyle, height: itemHeight, currentScrollIndex: currentScrollIndex, scaleFunction: scaleFunction, rotationFunction: rotationFunction, opacityFunction: opacityFunction, visibleRest: visibleRest }, `option-${index}`)) })] }));
|
|
87
|
-
};
|
|
88
|
-
export default memo(WheelPicker);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
container: {
|
|
3
|
-
position: "relative";
|
|
4
|
-
};
|
|
5
|
-
selectedIndicator: {
|
|
6
|
-
position: "absolute";
|
|
7
|
-
width: "100%";
|
|
8
|
-
top: "50%";
|
|
9
|
-
};
|
|
10
|
-
scrollView: {
|
|
11
|
-
overflow: "hidden";
|
|
12
|
-
flex: number;
|
|
13
|
-
};
|
|
14
|
-
option: {
|
|
15
|
-
alignItems: "center";
|
|
16
|
-
justifyContent: "center";
|
|
17
|
-
paddingHorizontal: number;
|
|
18
|
-
zIndex: number;
|
|
19
|
-
};
|
|
20
|
-
} & {
|
|
21
|
-
useVariants: (variants: never) => void;
|
|
22
|
-
};
|
|
23
|
-
export default _default;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
export default StyleSheet.create({
|
|
3
|
-
container: {
|
|
4
|
-
position: 'relative',
|
|
5
|
-
},
|
|
6
|
-
selectedIndicator: {
|
|
7
|
-
position: 'absolute',
|
|
8
|
-
width: '100%',
|
|
9
|
-
top: '50%',
|
|
10
|
-
},
|
|
11
|
-
scrollView: {
|
|
12
|
-
overflow: 'hidden',
|
|
13
|
-
flex: 1,
|
|
14
|
-
},
|
|
15
|
-
option: {
|
|
16
|
-
alignItems: 'center',
|
|
17
|
-
justifyContent: 'center',
|
|
18
|
-
paddingHorizontal: 16,
|
|
19
|
-
zIndex: 100,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
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;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useMemo, useRef } from 'react';
|
|
3
|
-
import { Animated, PanResponder, Platform, View } from 'react-native';
|
|
4
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
-
import { isEqual } from '../../../utils';
|
|
6
|
-
import { BodyText } from '../../BodyText';
|
|
7
|
-
import { CONTAINER_HEIGHT } from '../enums';
|
|
8
|
-
import { sin } from './animated-math';
|
|
9
|
-
const ITEM_HEIGHT = 44;
|
|
10
|
-
const WheelWeb = ({ value, setValue = () => { }, items }) => {
|
|
11
|
-
const displayCount = 5;
|
|
12
|
-
const translateY = useRef(new Animated.Value(0)).current;
|
|
13
|
-
const renderCount = displayCount * 2 < items.length ? displayCount * 8 : displayCount * 2 - 1;
|
|
14
|
-
const circular = items.length >= displayCount;
|
|
15
|
-
const height = 140;
|
|
16
|
-
const radius = height / 2;
|
|
17
|
-
const valueIndex = useMemo(() => {
|
|
18
|
-
return Math.max(0, items.findIndex(item => item.value === value));
|
|
19
|
-
}, [items, value]);
|
|
20
|
-
const panResponder = useMemo(() => {
|
|
21
|
-
return PanResponder.create({
|
|
22
|
-
onMoveShouldSetPanResponder: () => true,
|
|
23
|
-
onStartShouldSetPanResponderCapture: () => true,
|
|
24
|
-
onPanResponderGrant: () => {
|
|
25
|
-
translateY.setValue(0);
|
|
26
|
-
},
|
|
27
|
-
onPanResponderMove: (evt, gestureState) => {
|
|
28
|
-
translateY.setValue(gestureState.dy);
|
|
29
|
-
evt.stopPropagation();
|
|
30
|
-
},
|
|
31
|
-
onPanResponderRelease: (_, gestureState) => {
|
|
32
|
-
translateY.extractOffset();
|
|
33
|
-
let newValueIndex = valueIndex - Math.round(gestureState.dy / ((radius * 2) / displayCount));
|
|
34
|
-
if (circular) {
|
|
35
|
-
newValueIndex = (newValueIndex + items.length) % items.length;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
if (newValueIndex < 0) {
|
|
39
|
-
newValueIndex = 0;
|
|
40
|
-
}
|
|
41
|
-
else if (newValueIndex >= items.length) {
|
|
42
|
-
newValueIndex = items.length - 1;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const newValue = items[newValueIndex];
|
|
46
|
-
if (newValue?.value === value) {
|
|
47
|
-
translateY.setOffset(0);
|
|
48
|
-
translateY.setValue(0);
|
|
49
|
-
}
|
|
50
|
-
else if (newValue?.value) {
|
|
51
|
-
setValue(newValue.value);
|
|
52
|
-
}
|
|
53
|
-
else if (items[0]?.value) {
|
|
54
|
-
setValue(items[0].value);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}, [circular, displayCount, radius, setValue, value, valueIndex, items, translateY]);
|
|
59
|
-
const displayValues = useMemo(() => {
|
|
60
|
-
const centerIndex = Math.floor(renderCount / 2);
|
|
61
|
-
return Array.from({ length: renderCount }, (_, index) => {
|
|
62
|
-
let targetIndex = valueIndex + index - centerIndex;
|
|
63
|
-
if (circular) {
|
|
64
|
-
targetIndex = ((targetIndex % items.length) + items.length) % items.length;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
targetIndex = Math.max(0, Math.min(targetIndex, items.length - 1));
|
|
68
|
-
}
|
|
69
|
-
return items[targetIndex] || items[0];
|
|
70
|
-
});
|
|
71
|
-
}, [renderCount, valueIndex, items, circular]);
|
|
72
|
-
const animatedAngles = useMemo(() => {
|
|
73
|
-
//translateY.setValue(0);
|
|
74
|
-
translateY.setOffset(0);
|
|
75
|
-
const currentIndex = displayValues.findIndex(item => item?.value === value);
|
|
76
|
-
return displayValues && displayValues.length > 0
|
|
77
|
-
? displayValues.map((_, index) => translateY
|
|
78
|
-
.interpolate({
|
|
79
|
-
inputRange: [-radius, radius],
|
|
80
|
-
outputRange: [
|
|
81
|
-
-radius + ((radius * 2) / displayCount) * (index - currentIndex),
|
|
82
|
-
radius + ((radius * 2) / displayCount) * (index - currentIndex),
|
|
83
|
-
],
|
|
84
|
-
extrapolate: 'extend',
|
|
85
|
-
})
|
|
86
|
-
.interpolate({
|
|
87
|
-
inputRange: [-radius, radius],
|
|
88
|
-
outputRange: [-Math.PI / 2, Math.PI / 2],
|
|
89
|
-
extrapolate: 'clamp',
|
|
90
|
-
}))
|
|
91
|
-
: [];
|
|
92
|
-
}, [displayValues, radius, value, displayCount, translateY]);
|
|
93
|
-
return (_jsxs(View, { style: [styles.container], ...panResponder.panHandlers, children: [_jsx(View, { style: [
|
|
94
|
-
styles.selectedIndicator,
|
|
95
|
-
{
|
|
96
|
-
transform: [{ translateY: -ITEM_HEIGHT / 2 }],
|
|
97
|
-
height: ITEM_HEIGHT,
|
|
98
|
-
},
|
|
99
|
-
] }), displayValues?.map((displayValue, index) => {
|
|
100
|
-
const animatedAngle = animatedAngles[index];
|
|
101
|
-
return (_jsx(Animated.View, { style: {
|
|
102
|
-
position: 'absolute',
|
|
103
|
-
height: ITEM_HEIGHT - 10,
|
|
104
|
-
transform: animatedAngle
|
|
105
|
-
? [
|
|
106
|
-
{
|
|
107
|
-
translateY: Animated.multiply(radius, sin(animatedAngle)),
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
rotateX: animatedAngle.interpolate({
|
|
111
|
-
inputRange: [-Math.PI / 2, Math.PI / 2],
|
|
112
|
-
outputRange: ['-89deg', '89deg'],
|
|
113
|
-
extrapolate: 'clamp',
|
|
114
|
-
}),
|
|
115
|
-
},
|
|
116
|
-
]
|
|
117
|
-
: [],
|
|
118
|
-
opacity: displayValue?.value !== value ? 0.3 : 1,
|
|
119
|
-
}, children: _jsx(BodyText, { children: displayValue?.text }) }, `${displayValue?.text}-${index}`));
|
|
120
|
-
})] }));
|
|
121
|
-
};
|
|
122
|
-
const styles = StyleSheet.create({
|
|
123
|
-
container: {
|
|
124
|
-
minWidth: 30,
|
|
125
|
-
overflow: 'hidden',
|
|
126
|
-
alignItems: 'center',
|
|
127
|
-
justifyContent: 'center',
|
|
128
|
-
height: CONTAINER_HEIGHT / 2,
|
|
129
|
-
...Platform.select({
|
|
130
|
-
web: {
|
|
131
|
-
cursor: 'pointer',
|
|
132
|
-
userSelect: 'none',
|
|
133
|
-
},
|
|
134
|
-
}),
|
|
135
|
-
},
|
|
136
|
-
selectedIndicator: {
|
|
137
|
-
position: 'absolute',
|
|
138
|
-
width: '100%',
|
|
139
|
-
top: '50%',
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
const customComparator = (prev, next) => {
|
|
143
|
-
const areEqual = prev.value === next.value && prev.setValue === next.setValue && isEqual(prev.items, next.items);
|
|
144
|
-
return areEqual;
|
|
145
|
-
};
|
|
146
|
-
export default memo(WheelWeb, customComparator);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PickerOption } from '../DatePicker.props';
|
|
2
|
-
type WheelProps = {
|
|
3
|
-
value: number | string;
|
|
4
|
-
setValue?: (value: any) => void;
|
|
5
|
-
items: PickerOption[];
|
|
6
|
-
};
|
|
7
|
-
declare const _default: import("react").MemoExoticComponent<(props: WheelProps) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
-
export default _default;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from 'react';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
|
-
import WheelNative from './wheel-native';
|
|
5
|
-
import WheelWeb from './wheel-web';
|
|
6
|
-
const Wheel = (props) => {
|
|
7
|
-
const Component = Platform.OS === 'web' ? WheelWeb : WheelNative;
|
|
8
|
-
return _jsx(Component, { ...props });
|
|
9
|
-
};
|
|
10
|
-
export default memo(Wheel);
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { StyleSheet as RNStyleSheet, useWindowDimensions, View, } from 'react-native';
|
|
4
|
-
import { UnistylesRuntime } from '../../core';
|
|
5
|
-
const DEFAULT_EDGES = ['top', 'right', 'bottom', 'left'];
|
|
6
|
-
const EMPTY_INSETS = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
7
|
-
const EDGE_EPSILON = 1;
|
|
8
|
-
const getNumericStyleValue = (value) => {
|
|
9
|
-
return typeof value === 'number' ? value : 0;
|
|
10
|
-
};
|
|
11
|
-
const getStyleInsetValue = (style, mode, edge) => {
|
|
12
|
-
const prefix = mode === 'margin' ? 'margin' : 'padding';
|
|
13
|
-
if (!style) {
|
|
14
|
-
// No style specified at all; treat as zero inset for safe-area calculations.
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
if (edge === 'top') {
|
|
18
|
-
const raw = style[`${prefix}Top`] ?? style[`${prefix}Vertical`] ?? style[prefix];
|
|
19
|
-
if (raw == null) {
|
|
20
|
-
return 0;
|
|
21
|
-
}
|
|
22
|
-
return getNumericStyleValue(raw);
|
|
23
|
-
}
|
|
24
|
-
if (edge === 'bottom') {
|
|
25
|
-
const raw = style[`${prefix}Bottom`] ?? style[`${prefix}Vertical`] ?? style[prefix];
|
|
26
|
-
if (raw == null) {
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
29
|
-
return getNumericStyleValue(raw);
|
|
30
|
-
}
|
|
31
|
-
if (edge === 'left') {
|
|
32
|
-
const raw = style[`${prefix}Left`] ?? style[`${prefix}Horizontal`] ?? style[prefix];
|
|
33
|
-
if (raw == null) {
|
|
34
|
-
return 0;
|
|
35
|
-
}
|
|
36
|
-
return getNumericStyleValue(raw);
|
|
37
|
-
}
|
|
38
|
-
const raw = style[`${prefix}Right`] ?? style[`${prefix}Horizontal`] ?? style[prefix];
|
|
39
|
-
if (raw == null) {
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
|
-
return getNumericStyleValue(raw);
|
|
43
|
-
};
|
|
44
|
-
const SafeAreaView = forwardRef(({ children, edges = DEFAULT_EDGES, mode = 'padding', onLayout, style, ...props }, ref) => {
|
|
45
|
-
const viewRef = useRef(null);
|
|
46
|
-
const { width: windowWidth, height: windowHeight } = useWindowDimensions();
|
|
47
|
-
const [edgeInsets, setEdgeInsets] = useState(EMPTY_INSETS);
|
|
48
|
-
const flattenedStyle = useMemo(() => RNStyleSheet.flatten(style), [style]);
|
|
49
|
-
const updateEdgeInsets = useCallback(() => {
|
|
50
|
-
const currentView = viewRef.current;
|
|
51
|
-
if (!currentView) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
currentView.measureInWindow((x, y, width, height) => {
|
|
55
|
-
const runtimeInsets = UnistylesRuntime.insets ?? EMPTY_INSETS;
|
|
56
|
-
const nextEdgeInsets = {
|
|
57
|
-
top: edges.includes('top') ? Math.max(runtimeInsets.top - Math.max(y, 0), 0) : 0,
|
|
58
|
-
right: edges.includes('right')
|
|
59
|
-
? Math.max(runtimeInsets.right - Math.max(windowWidth - (x + width), 0), 0)
|
|
60
|
-
: 0,
|
|
61
|
-
bottom: edges.includes('bottom')
|
|
62
|
-
? Math.max(runtimeInsets.bottom - Math.max(windowHeight - (y + height), 0), 0)
|
|
63
|
-
: 0,
|
|
64
|
-
left: edges.includes('left') ? Math.max(runtimeInsets.left - Math.max(x, 0), 0) : 0,
|
|
65
|
-
};
|
|
66
|
-
setEdgeInsets(previousInsets => {
|
|
67
|
-
const hasChanged = Object.keys(nextEdgeInsets).some(edge => Math.abs(previousInsets[edge] - nextEdgeInsets[edge]) > EDGE_EPSILON);
|
|
68
|
-
return hasChanged ? nextEdgeInsets : previousInsets;
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}, [edges, windowHeight, windowWidth]);
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
const frame = requestAnimationFrame(updateEdgeInsets);
|
|
74
|
-
return () => cancelAnimationFrame(frame);
|
|
75
|
-
}, [updateEdgeInsets]);
|
|
76
|
-
const handleRef = useCallback((node) => {
|
|
77
|
-
viewRef.current = node;
|
|
78
|
-
if (typeof ref === 'function') {
|
|
79
|
-
ref(node);
|
|
80
|
-
}
|
|
81
|
-
else if (ref) {
|
|
82
|
-
ref.current = node;
|
|
83
|
-
}
|
|
84
|
-
}, [ref]);
|
|
85
|
-
const handleLayout = useCallback((event) => {
|
|
86
|
-
onLayout?.(event);
|
|
87
|
-
requestAnimationFrame(updateEdgeInsets);
|
|
88
|
-
}, [onLayout, updateEdgeInsets]);
|
|
89
|
-
const safeAreaStyle = useMemo(() => {
|
|
90
|
-
const nextStyle = {};
|
|
91
|
-
if (mode === 'padding') {
|
|
92
|
-
nextStyle.paddingTop = getStyleInsetValue(flattenedStyle, mode, 'top') + edgeInsets.top;
|
|
93
|
-
nextStyle.paddingRight =
|
|
94
|
-
getStyleInsetValue(flattenedStyle, mode, 'right') + edgeInsets.right;
|
|
95
|
-
nextStyle.paddingBottom =
|
|
96
|
-
getStyleInsetValue(flattenedStyle, mode, 'bottom') + edgeInsets.bottom;
|
|
97
|
-
nextStyle.paddingLeft = getStyleInsetValue(flattenedStyle, mode, 'left') + edgeInsets.left;
|
|
98
|
-
return nextStyle;
|
|
99
|
-
}
|
|
100
|
-
nextStyle.marginTop = getStyleInsetValue(flattenedStyle, mode, 'top') + edgeInsets.top;
|
|
101
|
-
nextStyle.marginRight = getStyleInsetValue(flattenedStyle, mode, 'right') + edgeInsets.right;
|
|
102
|
-
nextStyle.marginBottom =
|
|
103
|
-
getStyleInsetValue(flattenedStyle, mode, 'bottom') + edgeInsets.bottom;
|
|
104
|
-
nextStyle.marginLeft = getStyleInsetValue(flattenedStyle, mode, 'left') + edgeInsets.left;
|
|
105
|
-
return nextStyle;
|
|
106
|
-
}, [
|
|
107
|
-
edgeInsets.bottom,
|
|
108
|
-
edgeInsets.left,
|
|
109
|
-
edgeInsets.right,
|
|
110
|
-
edgeInsets.top,
|
|
111
|
-
flattenedStyle,
|
|
112
|
-
mode,
|
|
113
|
-
]);
|
|
114
|
-
return (_jsx(View, { ref: handleRef, onLayout: handleLayout, style: [style, safeAreaStyle], ...props, children: children }));
|
|
115
|
-
});
|
|
116
|
-
SafeAreaView.displayName = 'SafeAreaView';
|
|
117
|
-
export default SafeAreaView;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ViewProps } from 'react-native';
|
|
2
|
-
export type SafeAreaEdge = 'top' | 'right' | 'bottom' | 'left';
|
|
3
|
-
interface SafeAreaViewProps extends ViewProps {
|
|
4
|
-
/**
|
|
5
|
-
* Which edges should receive safe area compensation.
|
|
6
|
-
*
|
|
7
|
-
* @default ['top', 'right', 'bottom', 'left']
|
|
8
|
-
*/
|
|
9
|
-
edges?: SafeAreaEdge[];
|
|
10
|
-
/**
|
|
11
|
-
* Whether safe area compensation should be applied as padding or margin.
|
|
12
|
-
*
|
|
13
|
-
* @default 'padding'
|
|
14
|
-
*/
|
|
15
|
-
mode?: 'padding' | 'margin';
|
|
16
|
-
}
|
|
17
|
-
export default SafeAreaViewProps;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as SafeAreaView } from './SafeAreaView';
|