@webority-technologies/mobile 0.0.22 → 0.0.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.
- package/lib/commonjs/components/Accordion/Accordion.js +9 -7
- package/lib/commonjs/components/AnimatePresence/AnimatePresence.js +69 -0
- package/lib/commonjs/components/AnimatePresence/index.js +13 -0
- package/lib/commonjs/components/AppBar/AppBar.js +9 -6
- package/lib/commonjs/components/Avatar/Avatar.js +4 -2
- package/lib/commonjs/components/Badge/Badge.js +5 -5
- package/lib/commonjs/components/Banner/Banner.js +20 -6
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +6 -4
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +8 -9
- package/lib/commonjs/components/Box/Box.js +162 -0
- package/lib/commonjs/components/Box/index.js +37 -0
- package/lib/commonjs/components/Button/Button.js +7 -7
- package/lib/commonjs/components/Card/Card.js +3 -3
- package/lib/commonjs/components/Carousel/Carousel.js +4 -2
- package/lib/commonjs/components/Checkbox/Checkbox.js +17 -7
- package/lib/commonjs/components/Chip/Chip.js +4 -2
- package/lib/commonjs/components/DatePicker/DatePicker.js +31 -24
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +16 -11
- package/lib/commonjs/components/Dialog/Dialog.js +6 -4
- package/lib/commonjs/components/Drawer/Drawer.js +4 -2
- package/lib/commonjs/components/FieldBase/FieldBase.js +8 -4
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +23 -13
- package/lib/commonjs/components/FormField/FormField.js +61 -25
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +17 -15
- package/lib/commonjs/components/Input/Input.js +41 -29
- package/lib/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +102 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +13 -0
- package/lib/commonjs/components/KeyboardToolbar/KeyboardToolbar.js +130 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +13 -0
- package/lib/commonjs/components/ListItem/ListItem.js +4 -3
- package/lib/commonjs/components/Modal/Modal.js +21 -9
- package/lib/commonjs/components/NumberInput/NumberInput.js +38 -29
- package/lib/commonjs/components/OTPInput/OTPInput.js +37 -22
- package/lib/commonjs/components/Radio/Radio.js +9 -8
- package/lib/commonjs/components/Radio/RadioGroup.js +10 -3
- package/lib/commonjs/components/Rating/Rating.js +4 -3
- package/lib/commonjs/components/SearchBar/SearchBar.js +11 -6
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +23 -12
- package/lib/commonjs/components/Select/Select.js +40 -36
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +5 -2
- package/lib/commonjs/components/Slider/Slider.js +241 -225
- package/lib/commonjs/components/Spinner/Spinner.js +5 -5
- package/lib/commonjs/components/Stepper/Stepper.js +6 -5
- package/lib/commonjs/components/Swipeable/Swipeable.js +8 -9
- package/lib/commonjs/components/Switch/Switch.js +29 -16
- package/lib/commonjs/components/Tabs/Tabs.js +8 -5
- package/lib/commonjs/components/Text/Text.js +142 -0
- package/lib/commonjs/components/Text/index.js +13 -0
- package/lib/commonjs/components/TimePicker/TimePicker.js +23 -15
- package/lib/commonjs/components/Toast/Toast.js +22 -10
- package/lib/commonjs/components/Tooltip/Tooltip.js +6 -2
- package/lib/commonjs/components/index.js +156 -103
- package/lib/commonjs/form/FormContext.js +40 -0
- package/lib/commonjs/form/index.js +68 -0
- package/lib/commonjs/form/path.js +79 -0
- package/lib/commonjs/form/rules.js +67 -0
- package/lib/commonjs/form/types.js +2 -0
- package/lib/commonjs/form/useField.js +54 -0
- package/lib/commonjs/form/useForm.js +316 -0
- package/lib/commonjs/hooks/index.js +14 -0
- package/lib/commonjs/hooks/useControllableState.js +30 -0
- package/lib/commonjs/hooks/useReducedMotion.js +31 -0
- package/lib/commonjs/index.js +96 -11
- package/lib/commonjs/theme/ThemeContext.js +30 -2
- package/lib/commonjs/theme/tokens.js +12 -0
- package/lib/commonjs/utils/hapticUtils.js +11 -1
- package/lib/commonjs/utils/index.js +6 -0
- package/lib/module/components/Accordion/Accordion.js +10 -8
- package/lib/module/components/AnimatePresence/AnimatePresence.js +63 -0
- package/lib/module/components/AnimatePresence/index.js +4 -0
- package/lib/module/components/AppBar/AppBar.js +10 -7
- package/lib/module/components/Avatar/Avatar.js +4 -2
- package/lib/module/components/Badge/Badge.js +5 -5
- package/lib/module/components/Banner/Banner.js +20 -6
- package/lib/module/components/BottomNavigation/BottomNavigation.js +6 -4
- package/lib/module/components/BottomSheet/BottomSheet.js +8 -9
- package/lib/module/components/Box/Box.js +156 -0
- package/lib/module/components/Box/index.js +4 -0
- package/lib/module/components/Button/Button.js +7 -7
- package/lib/module/components/Card/Card.js +4 -4
- package/lib/module/components/Carousel/Carousel.js +4 -2
- package/lib/module/components/Checkbox/Checkbox.js +18 -8
- package/lib/module/components/Chip/Chip.js +5 -3
- package/lib/module/components/DatePicker/DatePicker.js +32 -25
- package/lib/module/components/DateRangePicker/DateRangePicker.js +17 -12
- package/lib/module/components/Dialog/Dialog.js +7 -5
- package/lib/module/components/Drawer/Drawer.js +5 -3
- package/lib/module/components/FieldBase/FieldBase.js +8 -4
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +24 -14
- package/lib/module/components/FormField/FormField.js +62 -26
- package/lib/module/components/ImageGallery/ImageGallery.js +18 -16
- package/lib/module/components/Input/Input.js +41 -29
- package/lib/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +98 -0
- package/lib/module/components/KeyboardAwareScrollView/index.js +4 -0
- package/lib/module/components/KeyboardToolbar/KeyboardToolbar.js +125 -0
- package/lib/module/components/KeyboardToolbar/index.js +4 -0
- package/lib/module/components/ListItem/ListItem.js +5 -4
- package/lib/module/components/Modal/Modal.js +22 -10
- package/lib/module/components/NumberInput/NumberInput.js +36 -27
- package/lib/module/components/OTPInput/OTPInput.js +37 -22
- package/lib/module/components/Radio/Radio.js +10 -9
- package/lib/module/components/Radio/RadioGroup.js +10 -3
- package/lib/module/components/Rating/Rating.js +5 -4
- package/lib/module/components/SearchBar/SearchBar.js +12 -7
- package/lib/module/components/SegmentedControl/SegmentedControl.js +24 -13
- package/lib/module/components/Select/Select.js +41 -37
- package/lib/module/components/Skeleton/SkeletonContent.js +5 -2
- package/lib/module/components/Slider/Slider.js +244 -228
- package/lib/module/components/Spinner/Spinner.js +5 -5
- package/lib/module/components/Stepper/Stepper.js +7 -6
- package/lib/module/components/Swipeable/Swipeable.js +9 -10
- package/lib/module/components/Switch/Switch.js +29 -16
- package/lib/module/components/Tabs/Tabs.js +9 -6
- package/lib/module/components/Text/Text.js +138 -0
- package/lib/module/components/Text/index.js +4 -0
- package/lib/module/components/TimePicker/TimePicker.js +24 -16
- package/lib/module/components/Toast/Toast.js +22 -10
- package/lib/module/components/Tooltip/Tooltip.js +6 -2
- package/lib/module/components/index.js +5 -0
- package/lib/module/form/FormContext.js +32 -0
- package/lib/module/form/index.js +12 -0
- package/lib/module/form/path.js +72 -0
- package/lib/module/form/rules.js +52 -0
- package/lib/module/form/types.js +2 -0
- package/lib/module/form/useField.js +49 -0
- package/lib/module/form/useForm.js +312 -0
- package/lib/module/hooks/index.js +2 -0
- package/lib/module/hooks/useControllableState.js +26 -0
- package/lib/module/hooks/useReducedMotion.js +27 -0
- package/lib/module/index.js +3 -1
- package/lib/module/theme/ThemeContext.js +30 -2
- package/lib/module/theme/tokens.js +12 -0
- package/lib/module/utils/hapticUtils.js +9 -0
- package/lib/module/utils/index.js +1 -1
- package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +3 -0
- package/lib/typescript/commonjs/components/AnimatePresence/AnimatePresence.d.ts +30 -0
- package/lib/typescript/commonjs/components/AnimatePresence/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +6 -0
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +3 -0
- package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +1 -1
- package/lib/typescript/commonjs/components/Box/Box.d.ts +60 -0
- package/lib/typescript/commonjs/components/Box/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Button/Button.d.ts +1 -1
- package/lib/typescript/commonjs/components/Card/Card.d.ts +3 -0
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +4 -2
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +3 -0
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +6 -3
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +6 -0
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +5 -2
- package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +3 -0
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +5 -0
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +13 -2
- package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +6 -0
- package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +20 -0
- package/lib/typescript/commonjs/components/KeyboardAwareScrollView/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/KeyboardToolbar/KeyboardToolbar.d.ts +29 -0
- package/lib/typescript/commonjs/components/KeyboardToolbar/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +3 -0
- package/lib/typescript/commonjs/components/Modal/Modal.d.ts +6 -0
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +6 -2
- package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +9 -2
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +2 -2
- package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +3 -2
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +6 -0
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +3 -0
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +6 -2
- package/lib/typescript/commonjs/components/Select/Select.d.ts +6 -0
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +9 -4
- package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +1 -1
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +6 -0
- package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +3 -0
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -2
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +3 -0
- package/lib/typescript/commonjs/components/Text/Text.d.ts +25 -0
- package/lib/typescript/commonjs/components/Text/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +6 -3
- package/lib/typescript/commonjs/components/index.d.ts +10 -0
- package/lib/typescript/commonjs/form/FormContext.d.ts +17 -0
- package/lib/typescript/commonjs/form/index.d.ts +9 -0
- package/lib/typescript/commonjs/form/path.d.ts +10 -0
- package/lib/typescript/commonjs/form/rules.d.ts +31 -0
- package/lib/typescript/commonjs/form/types.d.ts +94 -0
- package/lib/typescript/commonjs/form/useField.d.ts +27 -0
- package/lib/typescript/commonjs/form/useForm.d.ts +10 -0
- package/lib/typescript/commonjs/hooks/index.d.ts +3 -0
- package/lib/typescript/commonjs/hooks/useControllableState.d.ts +17 -0
- package/lib/typescript/commonjs/hooks/useReducedMotion.d.ts +8 -0
- package/lib/typescript/commonjs/index.d.ts +4 -2
- package/lib/typescript/commonjs/theme/types.d.ts +17 -67
- package/lib/typescript/commonjs/utils/hapticUtils.d.ts +8 -0
- package/lib/typescript/commonjs/utils/index.d.ts +1 -1
- package/lib/typescript/module/components/Accordion/Accordion.d.ts +3 -0
- package/lib/typescript/module/components/AnimatePresence/AnimatePresence.d.ts +30 -0
- package/lib/typescript/module/components/AnimatePresence/index.d.ts +3 -0
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +6 -0
- package/lib/typescript/module/components/Banner/Banner.d.ts +3 -0
- package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +1 -1
- package/lib/typescript/module/components/Box/Box.d.ts +60 -0
- package/lib/typescript/module/components/Box/index.d.ts +3 -0
- package/lib/typescript/module/components/Button/Button.d.ts +1 -1
- package/lib/typescript/module/components/Card/Card.d.ts +3 -0
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +4 -2
- package/lib/typescript/module/components/Chip/Chip.d.ts +3 -0
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +6 -3
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +6 -0
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +5 -2
- package/lib/typescript/module/components/Drawer/Drawer.d.ts +3 -0
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +5 -0
- package/lib/typescript/module/components/FormField/FormField.d.ts +13 -2
- package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +6 -0
- package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +20 -0
- package/lib/typescript/module/components/KeyboardAwareScrollView/index.d.ts +3 -0
- package/lib/typescript/module/components/KeyboardToolbar/KeyboardToolbar.d.ts +29 -0
- package/lib/typescript/module/components/KeyboardToolbar/index.d.ts +3 -0
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +3 -0
- package/lib/typescript/module/components/Modal/Modal.d.ts +6 -0
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +6 -2
- package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +9 -2
- package/lib/typescript/module/components/Radio/Radio.d.ts +2 -2
- package/lib/typescript/module/components/Radio/RadioGroup.d.ts +3 -2
- package/lib/typescript/module/components/Rating/Rating.d.ts +6 -0
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +3 -0
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +6 -2
- package/lib/typescript/module/components/Select/Select.d.ts +6 -0
- package/lib/typescript/module/components/Slider/Slider.d.ts +9 -4
- package/lib/typescript/module/components/Spinner/Spinner.d.ts +1 -1
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +6 -0
- package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +3 -0
- package/lib/typescript/module/components/Switch/Switch.d.ts +3 -2
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +3 -0
- package/lib/typescript/module/components/Text/Text.d.ts +25 -0
- package/lib/typescript/module/components/Text/index.d.ts +3 -0
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +6 -3
- package/lib/typescript/module/components/index.d.ts +10 -0
- package/lib/typescript/module/form/FormContext.d.ts +17 -0
- package/lib/typescript/module/form/index.d.ts +9 -0
- package/lib/typescript/module/form/path.d.ts +10 -0
- package/lib/typescript/module/form/rules.d.ts +31 -0
- package/lib/typescript/module/form/types.d.ts +94 -0
- package/lib/typescript/module/form/useField.d.ts +27 -0
- package/lib/typescript/module/form/useForm.d.ts +10 -0
- package/lib/typescript/module/hooks/index.d.ts +3 -0
- package/lib/typescript/module/hooks/useControllableState.d.ts +17 -0
- package/lib/typescript/module/hooks/useReducedMotion.d.ts +8 -0
- package/lib/typescript/module/index.d.ts +4 -2
- package/lib/typescript/module/theme/types.d.ts +17 -67
- package/lib/typescript/module/utils/hapticUtils.d.ts +8 -0
- package/lib/typescript/module/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React, { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { Animated, Easing, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { useTheme, createAnimatedValue } from "../../theme/index.js";
|
|
6
|
-
import { triggerHaptic } from "../../utils/hapticUtils.js";
|
|
6
|
+
import { triggerHaptic, resolveHaptic } from "../../utils/hapticUtils.js";
|
|
7
7
|
import { Skeleton } from "../Skeleton/index.js";
|
|
8
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
const CIRCLE_SIZE = 24;
|
|
@@ -34,7 +34,7 @@ const StepCircle = ({
|
|
|
34
34
|
pulseSize,
|
|
35
35
|
pulseEnabled,
|
|
36
36
|
pulseDuration,
|
|
37
|
-
|
|
37
|
+
pressHaptic,
|
|
38
38
|
circleSlotStyle
|
|
39
39
|
}) => {
|
|
40
40
|
const isActive = status === 'active';
|
|
@@ -81,7 +81,7 @@ const StepCircle = ({
|
|
|
81
81
|
const canPress = interactive && status === 'complete';
|
|
82
82
|
const handlePress = () => {
|
|
83
83
|
if (!canPress) return;
|
|
84
|
-
if (
|
|
84
|
+
if (pressHaptic) triggerHaptic(pressHaptic);
|
|
85
85
|
onPress?.(index);
|
|
86
86
|
};
|
|
87
87
|
const inner = /*#__PURE__*/_jsxs(View, {
|
|
@@ -176,6 +176,7 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
176
176
|
circleStyle,
|
|
177
177
|
labelStyle,
|
|
178
178
|
connectorStyle,
|
|
179
|
+
haptic,
|
|
179
180
|
testID
|
|
180
181
|
} = props;
|
|
181
182
|
const theme = useTheme();
|
|
@@ -184,7 +185,7 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
184
185
|
const pulseSize = stepperTheme?.pulseSize ?? PULSE_SIZE;
|
|
185
186
|
const pulseEnabled = stepperTheme?.pulseAnimation ?? false;
|
|
186
187
|
const pulseDuration = stepperTheme?.pulseDuration ?? PULSE_DURATION;
|
|
187
|
-
const
|
|
188
|
+
const pressHaptic = resolveHaptic(haptic, 'selection');
|
|
188
189
|
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
189
190
|
const toneColor = toneColorFor(theme, tone);
|
|
190
191
|
const upcomingColor = theme.colors.border.primary;
|
|
@@ -265,7 +266,7 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
265
266
|
pulseSize: pulseSize,
|
|
266
267
|
pulseEnabled: pulseEnabled,
|
|
267
268
|
pulseDuration: pulseDuration,
|
|
268
|
-
|
|
269
|
+
pressHaptic: pressHaptic,
|
|
269
270
|
circleSlotStyle: circleStyle
|
|
270
271
|
}), /*#__PURE__*/_jsx(Text, {
|
|
271
272
|
style: [styles.hLabel, {
|
|
@@ -304,7 +305,7 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
304
305
|
pulseSize: pulseSize,
|
|
305
306
|
pulseEnabled: pulseEnabled,
|
|
306
307
|
pulseDuration: pulseDuration,
|
|
307
|
-
|
|
308
|
+
pressHaptic: pressHaptic,
|
|
308
309
|
circleSlotStyle: circleStyle
|
|
309
310
|
}), !isLast ? /*#__PURE__*/_jsxs(View, {
|
|
310
311
|
style: [styles.vConnectorContainer, connectorStyle],
|
|
@@ -22,7 +22,7 @@ import { Dimensions, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
|
22
22
|
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
23
23
|
import Animated, { cancelAnimation, runOnJS, useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
24
24
|
import { useTheme } from "../../theme/index.js";
|
|
25
|
-
import { triggerHaptic } from "../../utils/index.js";
|
|
25
|
+
import { resolveHaptic, triggerHaptic } from "../../utils/index.js";
|
|
26
26
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
27
|
const SPRING_CONFIG = {
|
|
28
28
|
damping: 22,
|
|
@@ -57,6 +57,7 @@ const Swipeable = props => {
|
|
|
57
57
|
onSwipeOpen,
|
|
58
58
|
onSwipeClose,
|
|
59
59
|
disabled = false,
|
|
60
|
+
haptic,
|
|
60
61
|
containerStyle,
|
|
61
62
|
contentStyle: contentSlotStyle,
|
|
62
63
|
actionStyle,
|
|
@@ -75,9 +76,6 @@ const Swipeable = props => {
|
|
|
75
76
|
stiffness: swipeTheme?.springStiffness ?? SPRING_CONFIG.stiffness,
|
|
76
77
|
mass: swipeTheme?.springMass ?? SPRING_CONFIG.mass
|
|
77
78
|
};
|
|
78
|
-
const fullSwipeHapticEnabled = swipeTheme?.fullSwipeHaptic ?? true;
|
|
79
|
-
const actionPressHapticEnabled = swipeTheme?.actionPressHaptic ?? true;
|
|
80
|
-
const a11yActionHapticEnabled = swipeTheme?.a11yActionHaptic ?? true;
|
|
81
79
|
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
82
80
|
const hasLeft = !!leftActions && leftActions.length > 0;
|
|
83
81
|
const hasRight = !!rightActions && rightActions.length > 0;
|
|
@@ -117,22 +115,23 @@ const Swipeable = props => {
|
|
|
117
115
|
const list = side === 'left' ? leftActions : rightActions;
|
|
118
116
|
const first = list?.[0];
|
|
119
117
|
if (!first) return;
|
|
120
|
-
if (
|
|
118
|
+
if (haptic !== false) triggerHaptic('notificationSuccess');
|
|
121
119
|
first.onPress();
|
|
122
120
|
// After the off-screen slide, snap back to 0 silently.
|
|
123
121
|
translateX.value = withSpring(0, springConfig);
|
|
124
122
|
openSideRef.current = null;
|
|
125
123
|
onSwipeClose?.();
|
|
126
|
-
}, [leftActions, rightActions, translateX, onSwipeClose, springConfig,
|
|
124
|
+
}, [leftActions, rightActions, translateX, onSwipeClose, springConfig, haptic]);
|
|
127
125
|
const close = useCallback(() => {
|
|
128
126
|
translateX.value = withSpring(0, springConfig);
|
|
129
127
|
notifyClose();
|
|
130
128
|
}, [translateX, notifyClose, springConfig]);
|
|
131
129
|
const handleActionPress = useCallback(action => {
|
|
132
|
-
|
|
130
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
131
|
+
if (h) triggerHaptic(h);
|
|
133
132
|
action.onPress();
|
|
134
133
|
close();
|
|
135
|
-
}, [close,
|
|
134
|
+
}, [close, haptic]);
|
|
136
135
|
|
|
137
136
|
// ───────── Pan gesture (UI thread) ─────────
|
|
138
137
|
const panGesture = useMemo(() => {
|
|
@@ -238,10 +237,10 @@ const Swipeable = props => {
|
|
|
238
237
|
const all = [...(leftActions ?? []), ...(rightActions ?? [])];
|
|
239
238
|
const match = all.find(a => a.key === name);
|
|
240
239
|
if (match) {
|
|
241
|
-
if (
|
|
240
|
+
if (haptic !== false) triggerHaptic('selection');
|
|
242
241
|
match.onPress();
|
|
243
242
|
}
|
|
244
|
-
}, [leftActions, rightActions,
|
|
243
|
+
}, [leftActions, rightActions, haptic]);
|
|
245
244
|
|
|
246
245
|
// ───────── Render ─────────
|
|
247
246
|
// No actions configured → render children directly; zero gesture overhead.
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import React, { forwardRef, useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import { Animated, Easing, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { useTheme, createAnimatedValue } from "../../theme/index.js";
|
|
6
|
+
import { useControllableState } from "../../hooks/index.js";
|
|
6
7
|
import { triggerHaptic } from "../../utils/hapticUtils.js";
|
|
7
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
9
|
const sizeMap = {
|
|
@@ -41,7 +42,8 @@ const toneColor = (theme, tone) => {
|
|
|
41
42
|
const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
42
43
|
const {
|
|
43
44
|
value,
|
|
44
|
-
|
|
45
|
+
defaultValue,
|
|
46
|
+
onChange,
|
|
45
47
|
disabled = false,
|
|
46
48
|
size = 'md',
|
|
47
49
|
tone = 'primary',
|
|
@@ -56,6 +58,11 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
56
58
|
testID,
|
|
57
59
|
...rest
|
|
58
60
|
} = props;
|
|
61
|
+
const [current, setCurrent] = useControllableState({
|
|
62
|
+
value,
|
|
63
|
+
defaultValue: defaultValue ?? false,
|
|
64
|
+
onChange
|
|
65
|
+
});
|
|
59
66
|
const theme = useTheme();
|
|
60
67
|
const sizeStyles = {
|
|
61
68
|
...sizeMap[size],
|
|
@@ -65,25 +72,29 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
65
72
|
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
66
73
|
const offTrackColor = theme.mode === 'dark' ? theme.colors.secondary : theme.colors.surface.disabled;
|
|
67
74
|
const onTrackColor = toneColor(theme, tone);
|
|
68
|
-
const progress = useRef(createAnimatedValue(
|
|
75
|
+
const progress = useRef(createAnimatedValue(current ? 1 : 0)).current;
|
|
69
76
|
useEffect(() => {
|
|
70
|
-
Animated.spring(progress, {
|
|
71
|
-
toValue:
|
|
77
|
+
const anim = Animated.spring(progress, {
|
|
78
|
+
toValue: current ? 1 : 0,
|
|
72
79
|
damping: theme.motion.spring.snappy.damping,
|
|
73
80
|
stiffness: theme.motion.spring.snappy.stiffness,
|
|
74
81
|
mass: theme.motion.spring.snappy.mass,
|
|
75
82
|
useNativeDriver: true
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
});
|
|
84
|
+
anim.start();
|
|
85
|
+
return () => anim.stop();
|
|
86
|
+
}, [current, progress, theme.motion.spring.snappy]);
|
|
87
|
+
const trackBgAnim = useRef(createAnimatedValue(current ? 1 : 0)).current;
|
|
79
88
|
useEffect(() => {
|
|
80
|
-
Animated.timing(trackBgAnim, {
|
|
81
|
-
toValue:
|
|
89
|
+
const anim = Animated.timing(trackBgAnim, {
|
|
90
|
+
toValue: current ? 1 : 0,
|
|
82
91
|
duration: theme.motion.duration.fast,
|
|
83
92
|
easing: Easing.out(Easing.ease),
|
|
84
93
|
useNativeDriver: false
|
|
85
|
-
})
|
|
86
|
-
|
|
94
|
+
});
|
|
95
|
+
anim.start();
|
|
96
|
+
return () => anim.stop();
|
|
97
|
+
}, [current, trackBgAnim, theme.motion.duration.fast]);
|
|
87
98
|
const offX = sizeStyles.padding;
|
|
88
99
|
const onX = sizeStyles.trackWidth - sizeStyles.thumbSize - sizeStyles.padding;
|
|
89
100
|
const translateX = progress.interpolate({
|
|
@@ -102,7 +113,7 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
102
113
|
isFirstRender.current = false;
|
|
103
114
|
return;
|
|
104
115
|
}
|
|
105
|
-
Animated.sequence([Animated.spring(bounceScale, {
|
|
116
|
+
const anim = Animated.sequence([Animated.spring(bounceScale, {
|
|
106
117
|
toValue: 1.15,
|
|
107
118
|
damping: 10,
|
|
108
119
|
stiffness: 220,
|
|
@@ -114,12 +125,14 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
114
125
|
stiffness: 240,
|
|
115
126
|
mass: 1,
|
|
116
127
|
useNativeDriver: true
|
|
117
|
-
})])
|
|
118
|
-
|
|
128
|
+
})]);
|
|
129
|
+
anim.start();
|
|
130
|
+
return () => anim.stop();
|
|
131
|
+
}, [current, bounce, bounceScale]);
|
|
119
132
|
const handlePress = event => {
|
|
120
133
|
if (disabled) return;
|
|
121
134
|
if (haptic !== false) triggerHaptic(haptic);
|
|
122
|
-
|
|
135
|
+
setCurrent(!current);
|
|
123
136
|
rest.onPressOut?.(event);
|
|
124
137
|
};
|
|
125
138
|
const accessibleLabel = accessibilityLabel ?? label;
|
|
@@ -130,7 +143,7 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
130
143
|
accessibilityRole: "switch",
|
|
131
144
|
accessibilityLabel: accessibleLabel,
|
|
132
145
|
accessibilityState: {
|
|
133
|
-
checked:
|
|
146
|
+
checked: current,
|
|
134
147
|
disabled
|
|
135
148
|
},
|
|
136
149
|
testID: testID,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
15
15
|
import { Animated, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
|
|
16
16
|
import { useTheme, createAnimatedValue } from "../../theme/index.js";
|
|
17
|
-
import { triggerHaptic } from "../../utils/index.js";
|
|
17
|
+
import { triggerHaptic, resolveHaptic } from "../../utils/index.js";
|
|
18
18
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
19
|
const Tabs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
20
20
|
const {
|
|
@@ -33,6 +33,7 @@ const Tabs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
33
33
|
dividerStyle,
|
|
34
34
|
indicatorStyle,
|
|
35
35
|
progress,
|
|
36
|
+
haptic,
|
|
36
37
|
accessibilityLabel,
|
|
37
38
|
testID
|
|
38
39
|
} = props;
|
|
@@ -46,7 +47,6 @@ const Tabs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
46
47
|
const pillInset = tabsTokens?.pillInset ?? 4;
|
|
47
48
|
const disabledOpacity = tabsTokens?.disabledOpacity ?? 0.45;
|
|
48
49
|
const badgeGap = tabsTokens?.badgeGap ?? 6;
|
|
49
|
-
const hapticOnPress = tabsTokens?.hapticOnPress ?? false;
|
|
50
50
|
|
|
51
51
|
// Per-tab measured layouts (key → {x, width}).
|
|
52
52
|
const [layouts, setLayouts] = useState({});
|
|
@@ -82,7 +82,7 @@ const Tabs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
82
82
|
if (!activeLayout) return;
|
|
83
83
|
if (useProgress) return;
|
|
84
84
|
const spring = theme.motion.spring.snappy;
|
|
85
|
-
Animated.parallel([
|
|
85
|
+
const anim = Animated.parallel([
|
|
86
86
|
// Both must use the JS driver: width can't run on native, and mixing
|
|
87
87
|
// drivers on the same view (transform native + width JS) trips RN's
|
|
88
88
|
// "node already moved to native" guard under the new architecture.
|
|
@@ -98,7 +98,9 @@ const Tabs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
98
98
|
stiffness: spring.stiffness,
|
|
99
99
|
mass: spring.mass,
|
|
100
100
|
useNativeDriver: false
|
|
101
|
-
})])
|
|
101
|
+
})]);
|
|
102
|
+
anim.start();
|
|
103
|
+
return () => anim.stop();
|
|
102
104
|
}, [activeLayout, activeKey, indicatorTranslateX, indicatorWidth, theme.motion.spring.snappy, useProgress]);
|
|
103
105
|
const handleLayout = useCallback(key => e => {
|
|
104
106
|
const {
|
|
@@ -120,9 +122,10 @@ const Tabs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
120
122
|
const handlePress = useCallback(tab => {
|
|
121
123
|
if (tab.disabled) return;
|
|
122
124
|
if (tab.key === activeKey) return;
|
|
123
|
-
|
|
125
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
126
|
+
if (h) triggerHaptic(h);
|
|
124
127
|
onChange(tab.key);
|
|
125
|
-
}, [activeKey, onChange,
|
|
128
|
+
}, [activeKey, onChange, haptic]);
|
|
126
129
|
const indicatorIsPill = variant === 'pills';
|
|
127
130
|
|
|
128
131
|
// Indicator visual.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
4
|
+
import { Text as RNText } from 'react-native';
|
|
5
|
+
import { fontFor, useTheme } from "../../theme/index.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const VARIANTS = {
|
|
8
|
+
display: {
|
|
9
|
+
size: '4xl',
|
|
10
|
+
weight: 'bold',
|
|
11
|
+
line: 'tight',
|
|
12
|
+
color: 'primary',
|
|
13
|
+
heading: true
|
|
14
|
+
},
|
|
15
|
+
h1: {
|
|
16
|
+
size: '3xl',
|
|
17
|
+
weight: 'bold',
|
|
18
|
+
line: 'tight',
|
|
19
|
+
color: 'primary',
|
|
20
|
+
heading: true
|
|
21
|
+
},
|
|
22
|
+
h2: {
|
|
23
|
+
size: '2xl',
|
|
24
|
+
weight: 'semibold',
|
|
25
|
+
line: 'tight',
|
|
26
|
+
color: 'primary',
|
|
27
|
+
heading: true
|
|
28
|
+
},
|
|
29
|
+
h3: {
|
|
30
|
+
size: 'xl',
|
|
31
|
+
weight: 'semibold',
|
|
32
|
+
line: 'tight',
|
|
33
|
+
color: 'primary',
|
|
34
|
+
heading: true
|
|
35
|
+
},
|
|
36
|
+
title: {
|
|
37
|
+
size: 'lg',
|
|
38
|
+
weight: 'semibold',
|
|
39
|
+
line: 'normal',
|
|
40
|
+
color: 'primary'
|
|
41
|
+
},
|
|
42
|
+
body: {
|
|
43
|
+
size: 'base',
|
|
44
|
+
weight: 'normal',
|
|
45
|
+
line: 'normal',
|
|
46
|
+
color: 'primary'
|
|
47
|
+
},
|
|
48
|
+
bodySmall: {
|
|
49
|
+
size: 'sm',
|
|
50
|
+
weight: 'normal',
|
|
51
|
+
line: 'normal',
|
|
52
|
+
color: 'secondary'
|
|
53
|
+
},
|
|
54
|
+
caption: {
|
|
55
|
+
size: 'xs',
|
|
56
|
+
weight: 'normal',
|
|
57
|
+
line: 'normal',
|
|
58
|
+
color: 'tertiary'
|
|
59
|
+
},
|
|
60
|
+
label: {
|
|
61
|
+
size: 'sm',
|
|
62
|
+
weight: 'medium',
|
|
63
|
+
line: 'normal',
|
|
64
|
+
color: 'secondary'
|
|
65
|
+
},
|
|
66
|
+
overline: {
|
|
67
|
+
size: 'xs',
|
|
68
|
+
weight: 'semibold',
|
|
69
|
+
line: 'normal',
|
|
70
|
+
color: 'secondary',
|
|
71
|
+
uppercase: true,
|
|
72
|
+
letterSpacing: 'wide'
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const TEXT_ROLES = {
|
|
76
|
+
primary: true,
|
|
77
|
+
secondary: true,
|
|
78
|
+
tertiary: true,
|
|
79
|
+
inverse: true,
|
|
80
|
+
disabled: true,
|
|
81
|
+
link: true
|
|
82
|
+
};
|
|
83
|
+
const SEMANTIC = {
|
|
84
|
+
success: true,
|
|
85
|
+
warning: true,
|
|
86
|
+
error: true,
|
|
87
|
+
info: true
|
|
88
|
+
};
|
|
89
|
+
const resolveColor = (theme, color) => {
|
|
90
|
+
// Text roles win over the same-named brand colour ('primary' -> text.primary),
|
|
91
|
+
// which is the intent the vast majority of the time for text.
|
|
92
|
+
if (TEXT_ROLES[color]) return theme.colors.text[color];
|
|
93
|
+
if (SEMANTIC[color]) return theme.colors[color];
|
|
94
|
+
return color; // raw colour string
|
|
95
|
+
};
|
|
96
|
+
const Text = /*#__PURE__*/forwardRef((props, ref) => {
|
|
97
|
+
const {
|
|
98
|
+
variant = 'body',
|
|
99
|
+
color,
|
|
100
|
+
weight,
|
|
101
|
+
size,
|
|
102
|
+
align,
|
|
103
|
+
italic,
|
|
104
|
+
underline,
|
|
105
|
+
style,
|
|
106
|
+
children,
|
|
107
|
+
...rest
|
|
108
|
+
} = props;
|
|
109
|
+
const theme = useTheme();
|
|
110
|
+
const textStyle = useMemo(() => {
|
|
111
|
+
const spec = VARIANTS[variant];
|
|
112
|
+
const fontSize = typeof size === 'number' ? size : theme.typography.fontSize[size ?? spec.size];
|
|
113
|
+
const lineHeight = Math.round(fontSize * theme.typography.lineHeight[spec.line]);
|
|
114
|
+
return {
|
|
115
|
+
fontSize,
|
|
116
|
+
lineHeight,
|
|
117
|
+
color: resolveColor(theme, color ?? spec.color),
|
|
118
|
+
textAlign: align,
|
|
119
|
+
textTransform: spec.uppercase ? 'uppercase' : undefined,
|
|
120
|
+
letterSpacing: spec.letterSpacing ? theme.typography.letterSpacing[spec.letterSpacing] : undefined,
|
|
121
|
+
fontStyle: italic ? 'italic' : undefined,
|
|
122
|
+
textDecorationLine: underline ? 'underline' : undefined,
|
|
123
|
+
...fontFor(theme, weight ?? spec.weight)
|
|
124
|
+
};
|
|
125
|
+
}, [theme, variant, color, weight, size, align, italic, underline]);
|
|
126
|
+
const heading = VARIANTS[variant].heading;
|
|
127
|
+
return /*#__PURE__*/_jsx(RNText, {
|
|
128
|
+
ref: ref,
|
|
129
|
+
style: [textStyle, style],
|
|
130
|
+
accessibilityRole: heading ? 'header' : rest.accessibilityRole,
|
|
131
|
+
...rest,
|
|
132
|
+
children: children
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
Text.displayName = 'Text';
|
|
136
|
+
export { Text };
|
|
137
|
+
export default Text;
|
|
138
|
+
//# sourceMappingURL=Text.js.map
|
|
@@ -4,19 +4,19 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
4
4
|
import { AccessibilityInfo, Animated, Easing, FlatList, Modal, Platform, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
6
6
|
import { useTheme, createAnimatedValue, setNativeValue } from "../../theme/index.js";
|
|
7
|
-
import { triggerHaptic } from "../../utils/hapticUtils.js";
|
|
7
|
+
import { resolveHaptic, triggerHaptic } from "../../utils/hapticUtils.js";
|
|
8
8
|
import Button from "../Button/Button.js";
|
|
9
9
|
import { PickerTrigger } from "../PickerTrigger/PickerTrigger.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* TimePicker supports two modes:
|
|
13
13
|
*
|
|
14
|
-
* 1. Controlled-modal mode — pass `visible`, `
|
|
14
|
+
* 1. Controlled-modal mode — pass `visible`, `onChange`, `onClose`. The
|
|
15
15
|
* component renders only the modal sheet and the caller owns open/close
|
|
16
16
|
* state plus its own trigger UI.
|
|
17
17
|
* 2. Trigger mode — omit `visible`. The component renders a PickerTrigger
|
|
18
18
|
* field (label / value / placeholder / chevron / clear / helper / error)
|
|
19
|
-
* and manages its own modal open state. `
|
|
19
|
+
* and manages its own modal open state. `onChange` is still called on
|
|
20
20
|
* confirm.
|
|
21
21
|
*/
|
|
22
22
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -70,6 +70,7 @@ const Wheel = ({
|
|
|
70
70
|
onIndexChange,
|
|
71
71
|
formatItem,
|
|
72
72
|
theme,
|
|
73
|
+
haptic,
|
|
73
74
|
testID
|
|
74
75
|
}) => {
|
|
75
76
|
const listRef = useRef(null);
|
|
@@ -92,7 +93,6 @@ const Wheel = ({
|
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
}, [selectedIndex, scrollY]);
|
|
95
|
-
const hapticEnabled = theme.components.timePicker?.haptic ?? false;
|
|
96
96
|
const hapticDebounceMs = theme.components.timePicker?.hapticDebounceMs ?? HAPTIC_DEBOUNCE_MS;
|
|
97
97
|
const onScroll = useMemo(() => Animated.event([{
|
|
98
98
|
nativeEvent: {
|
|
@@ -107,14 +107,15 @@ const Wheel = ({
|
|
|
107
107
|
const idx = Math.round(y / ITEM_HEIGHT);
|
|
108
108
|
if (idx !== lastIndexRef.current && idx >= 0 && idx < data.length) {
|
|
109
109
|
const now = Date.now();
|
|
110
|
-
if (
|
|
111
|
-
|
|
110
|
+
if (now - lastHapticAtRef.current >= hapticDebounceMs) {
|
|
111
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
112
|
+
if (h) triggerHaptic(h);
|
|
112
113
|
lastHapticAtRef.current = now;
|
|
113
114
|
}
|
|
114
115
|
lastIndexRef.current = idx;
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
|
-
}), [scrollY, data.length,
|
|
118
|
+
}), [scrollY, data.length, haptic, hapticDebounceMs]);
|
|
118
119
|
const onMomentumScrollEnd = useCallback(event => {
|
|
119
120
|
const y = event.nativeEvent.contentOffset.y;
|
|
120
121
|
const idx = Math.max(0, Math.min(data.length - 1, Math.round(y / ITEM_HEIGHT)));
|
|
@@ -217,7 +218,7 @@ const TimePicker = props => {
|
|
|
217
218
|
const {
|
|
218
219
|
visible,
|
|
219
220
|
value,
|
|
220
|
-
|
|
221
|
+
onChange,
|
|
221
222
|
onClose,
|
|
222
223
|
format = '12h',
|
|
223
224
|
minuteStep = 1,
|
|
@@ -240,7 +241,8 @@ const TimePicker = props => {
|
|
|
240
241
|
clearable,
|
|
241
242
|
onClear,
|
|
242
243
|
formatValue,
|
|
243
|
-
triggerStyle
|
|
244
|
+
triggerStyle,
|
|
245
|
+
haptic
|
|
244
246
|
} = props;
|
|
245
247
|
const isControlled = props.visible !== undefined;
|
|
246
248
|
const [internalOpen, setInternalOpen] = useState(false);
|
|
@@ -304,8 +306,9 @@ const TimePicker = props => {
|
|
|
304
306
|
const opacity = useRef(createAnimatedValue(0)).current;
|
|
305
307
|
const translateY = useRef(createAnimatedValue(40)).current;
|
|
306
308
|
useEffect(() => {
|
|
309
|
+
let anim;
|
|
307
310
|
if (open) {
|
|
308
|
-
Animated.parallel([
|
|
311
|
+
anim = Animated.parallel([
|
|
309
312
|
// Backdrop opacity uses JS driver — see Modal.tsx for the Fabric reason.
|
|
310
313
|
Animated.timing(opacity, {
|
|
311
314
|
toValue: 1,
|
|
@@ -318,11 +321,13 @@ const TimePicker = props => {
|
|
|
318
321
|
stiffness: theme.motion.spring.snappy.stiffness,
|
|
319
322
|
mass: theme.motion.spring.snappy.mass,
|
|
320
323
|
useNativeDriver: true
|
|
321
|
-
})])
|
|
324
|
+
})]);
|
|
325
|
+
anim.start();
|
|
322
326
|
} else {
|
|
323
327
|
opacity.setValue(0);
|
|
324
328
|
setNativeValue(translateY, 40);
|
|
325
329
|
}
|
|
330
|
+
return () => anim?.stop();
|
|
326
331
|
}, [open, opacity, translateY, theme.motion]);
|
|
327
332
|
const announce = useCallback(msg => {
|
|
328
333
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
@@ -342,21 +347,21 @@ const TimePicker = props => {
|
|
|
342
347
|
announce(periods[idx] ?? '');
|
|
343
348
|
}, [periods, announce]);
|
|
344
349
|
const handleCancel = useCallback(() => {
|
|
345
|
-
if (
|
|
350
|
+
if (haptic !== false) triggerHaptic('selection');
|
|
346
351
|
handleCloseModal();
|
|
347
|
-
}, [handleCloseModal,
|
|
352
|
+
}, [handleCloseModal, haptic]);
|
|
348
353
|
const handleConfirm = useCallback(() => {
|
|
349
354
|
const displayHour = hours[hourIndex] ?? 0;
|
|
350
355
|
const period = periods[periodIndex] ?? 'AM';
|
|
351
356
|
const hour24 = to24h(displayHour, period, format);
|
|
352
357
|
const minute = minutes[minuteIndex] ?? 0;
|
|
353
|
-
if (
|
|
354
|
-
|
|
358
|
+
if (haptic !== false) triggerHaptic('notificationSuccess');
|
|
359
|
+
onChange?.({
|
|
355
360
|
hour: hour24,
|
|
356
361
|
minute
|
|
357
362
|
});
|
|
358
363
|
handleCloseModal();
|
|
359
|
-
}, [hours, hourIndex, periods, periodIndex, minutes, minuteIndex, format,
|
|
364
|
+
}, [hours, hourIndex, periods, periodIndex, minutes, minuteIndex, format, onChange, handleCloseModal, haptic]);
|
|
360
365
|
const summary = useMemo(() => {
|
|
361
366
|
const displayHour = hours[hourIndex] ?? 0;
|
|
362
367
|
const minute = minutes[minuteIndex] ?? 0;
|
|
@@ -440,6 +445,7 @@ const TimePicker = props => {
|
|
|
440
445
|
onIndexChange: handleHourIndex,
|
|
441
446
|
formatItem: formatHourItem,
|
|
442
447
|
theme: theme,
|
|
448
|
+
haptic: haptic,
|
|
443
449
|
testID: "time-picker-hour"
|
|
444
450
|
}), /*#__PURE__*/_jsx(Text, {
|
|
445
451
|
style: styles.separator,
|
|
@@ -452,6 +458,7 @@ const TimePicker = props => {
|
|
|
452
458
|
onIndexChange: handleMinuteIndex,
|
|
453
459
|
formatItem: formatMinuteItem,
|
|
454
460
|
theme: theme,
|
|
461
|
+
haptic: haptic,
|
|
455
462
|
testID: "time-picker-minute"
|
|
456
463
|
}), format === '12h' ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
457
464
|
children: [/*#__PURE__*/_jsx(View, {
|
|
@@ -464,6 +471,7 @@ const TimePicker = props => {
|
|
|
464
471
|
onIndexChange: handlePeriodIndex,
|
|
465
472
|
formatItem: formatPeriodItem,
|
|
466
473
|
theme: theme,
|
|
474
|
+
haptic: haptic,
|
|
467
475
|
testID: "time-picker-period"
|
|
468
476
|
})]
|
|
469
477
|
}) : null]
|
|
@@ -39,6 +39,18 @@ const Toast = ({
|
|
|
39
39
|
const translateX = useRef(createAnimatedValue(0)).current;
|
|
40
40
|
const opacity = useRef(createAnimatedValue(0)).current;
|
|
41
41
|
const dismissedRef = useRef(false);
|
|
42
|
+
const stackTranslate = position === 'top' ? index * stackOffset : -index * stackOffset;
|
|
43
|
+
const stackScale = Math.max(1 - index * stackScaleStep, stackMinScale);
|
|
44
|
+
|
|
45
|
+
// The stack offset rides on its own value so the enter spring (translateY)
|
|
46
|
+
// and the layout offset compose once instead of rebuilding a fresh
|
|
47
|
+
// `new Animated.Value` + `Animated.add` node on every render. setNativeValue
|
|
48
|
+
// keeps it in sync after the node has moved to the native driver.
|
|
49
|
+
const stackTranslateY = useRef(createAnimatedValue(stackTranslate)).current;
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
setNativeValue(stackTranslateY, stackTranslate);
|
|
52
|
+
}, [stackTranslate, stackTranslateY]);
|
|
53
|
+
const composedTranslateY = useMemo(() => Animated.add(translateY, stackTranslateY), [translateY, stackTranslateY]);
|
|
42
54
|
const dismiss = (animateOut = true) => {
|
|
43
55
|
if (dismissedRef.current) return;
|
|
44
56
|
dismissedRef.current = true;
|
|
@@ -57,7 +69,7 @@ const Toast = ({
|
|
|
57
69
|
}
|
|
58
70
|
};
|
|
59
71
|
useEffect(() => {
|
|
60
|
-
Animated.parallel([Animated.spring(translateY, {
|
|
72
|
+
const enter = Animated.parallel([Animated.spring(translateY, {
|
|
61
73
|
toValue: 0,
|
|
62
74
|
damping: enterSpringDamping,
|
|
63
75
|
stiffness: enterSpringStiffness,
|
|
@@ -67,13 +79,17 @@ const Toast = ({
|
|
|
67
79
|
toValue: 1,
|
|
68
80
|
duration: theme.motion.duration.fast,
|
|
69
81
|
useNativeDriver: true
|
|
70
|
-
})])
|
|
82
|
+
})]);
|
|
83
|
+
enter.start();
|
|
71
84
|
const duration = toast.duration ?? defaultDurationMs;
|
|
72
85
|
if (duration > 0) {
|
|
73
86
|
const timer = setTimeout(() => dismiss(true), duration);
|
|
74
|
-
return () =>
|
|
87
|
+
return () => {
|
|
88
|
+
enter.stop();
|
|
89
|
+
clearTimeout(timer);
|
|
90
|
+
};
|
|
75
91
|
}
|
|
76
|
-
return
|
|
92
|
+
return () => enter.stop();
|
|
77
93
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
94
|
}, []);
|
|
79
95
|
const panResponder = useMemo(() => PanResponder.create({
|
|
@@ -108,11 +124,7 @@ const Toast = ({
|
|
|
108
124
|
})]).start();
|
|
109
125
|
}
|
|
110
126
|
}
|
|
111
|
-
}),
|
|
112
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
|
-
[]);
|
|
114
|
-
const stackTranslate = position === 'top' ? index * stackOffset : -index * stackOffset;
|
|
115
|
-
const stackScale = Math.max(1 - index * stackScaleStep, stackMinScale);
|
|
127
|
+
}), [translateX, opacity, swipeDismissThreshold, swipeVelocityThreshold, theme.motion.duration.fast, onDismiss, toast.id]);
|
|
116
128
|
const handleActionPress = () => {
|
|
117
129
|
toast.action?.onPress();
|
|
118
130
|
dismiss(true);
|
|
@@ -152,7 +164,7 @@ const Toast = ({
|
|
|
152
164
|
shadowColor: theme.shadows.md.shadowColor,
|
|
153
165
|
opacity,
|
|
154
166
|
transform: [{
|
|
155
|
-
translateY:
|
|
167
|
+
translateY: composedTranslateY
|
|
156
168
|
}, {
|
|
157
169
|
translateX
|
|
158
170
|
}, {
|