@webority-technologies/mobile 0.0.14 → 0.0.20
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 +60 -19
- package/lib/commonjs/components/AppBar/AppBar.js +29 -20
- package/lib/commonjs/components/Avatar/Avatar.js +38 -8
- package/lib/commonjs/components/Badge/Badge.js +66 -4
- package/lib/commonjs/components/Banner/Banner.js +146 -66
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +37 -15
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +85 -50
- package/lib/commonjs/components/Button/Button.js +12 -5
- package/lib/commonjs/components/Card/Card.js +106 -16
- package/lib/commonjs/components/Carousel/Carousel.js +66 -12
- package/lib/commonjs/components/Checkbox/Checkbox.js +11 -7
- package/lib/commonjs/components/Chip/Chip.js +44 -12
- package/lib/commonjs/components/DatePicker/DatePicker.js +185 -76
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +133 -59
- package/lib/commonjs/components/Dialog/Dialog.js +16 -10
- package/lib/commonjs/components/Drawer/Drawer.js +13 -10
- package/lib/commonjs/components/FieldBase/FieldBase.js +306 -0
- package/lib/commonjs/components/FieldBase/index.js +32 -0
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +69 -44
- package/lib/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
- package/lib/commonjs/components/FormField/FormField.js +3 -2
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +132 -44
- package/lib/commonjs/components/Input/Input.js +144 -181
- package/lib/commonjs/components/ListItem/ListItem.js +90 -11
- package/lib/commonjs/components/Modal/Modal.js +55 -27
- package/lib/commonjs/components/NumberInput/NumberInput.js +60 -106
- package/lib/commonjs/components/OTPInput/OTPInput.js +65 -58
- package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +185 -0
- package/lib/commonjs/components/{AppIcon → PickerTrigger}/index.js +4 -4
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +19 -11
- package/lib/commonjs/components/Radio/Radio.js +11 -6
- package/lib/commonjs/components/Rating/Rating.js +85 -19
- package/lib/commonjs/components/SearchBar/SearchBar.js +84 -107
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +22 -11
- package/lib/commonjs/components/Select/Select.js +62 -91
- package/lib/commonjs/components/Skeleton/Skeleton.js +131 -174
- package/lib/commonjs/components/Skeleton/SkeletonClock.js +117 -0
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +164 -81
- package/lib/commonjs/components/Skeleton/SkeletonProvider.js +72 -10
- package/lib/commonjs/components/Skeleton/index.js +17 -16
- package/lib/commonjs/components/Slider/Slider.js +44 -25
- package/lib/commonjs/components/Stepper/Stepper.js +199 -29
- package/lib/commonjs/components/Swipeable/Swipeable.js +36 -19
- package/lib/commonjs/components/Switch/Switch.js +9 -2
- package/lib/commonjs/components/Tabs/Tabs.js +84 -21
- package/lib/commonjs/components/TimePicker/TimePicker.js +123 -45
- package/lib/commonjs/components/Toast/Toast.js +27 -16
- package/lib/commonjs/components/Tooltip/Tooltip.js +56 -32
- package/lib/commonjs/components/index.js +37 -37
- package/lib/commonjs/theme/tokens.js +55 -7
- package/lib/module/components/Accordion/Accordion.js +61 -20
- package/lib/module/components/AppBar/AppBar.js +29 -20
- package/lib/module/components/Avatar/Avatar.js +39 -9
- package/lib/module/components/Badge/Badge.js +67 -5
- package/lib/module/components/Banner/Banner.js +147 -67
- package/lib/module/components/BottomNavigation/BottomNavigation.js +37 -15
- package/lib/module/components/BottomSheet/BottomSheet.js +87 -52
- package/lib/module/components/Button/Button.js +12 -5
- package/lib/module/components/Card/Card.js +107 -17
- package/lib/module/components/Carousel/Carousel.js +67 -13
- package/lib/module/components/Checkbox/Checkbox.js +11 -7
- package/lib/module/components/Chip/Chip.js +45 -13
- package/lib/module/components/DatePicker/DatePicker.js +185 -76
- package/lib/module/components/DateRangePicker/DateRangePicker.js +134 -60
- package/lib/module/components/Dialog/Dialog.js +16 -10
- package/lib/module/components/Drawer/Drawer.js +13 -10
- package/lib/module/components/FieldBase/FieldBase.js +297 -0
- package/lib/module/components/FieldBase/index.js +4 -0
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +69 -44
- package/lib/module/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
- package/lib/module/components/FormField/FormField.js +3 -2
- package/lib/module/components/ImageGallery/ImageGallery.js +128 -40
- package/lib/module/components/Input/Input.js +144 -179
- package/lib/module/components/ListItem/ListItem.js +91 -12
- package/lib/module/components/Modal/Modal.js +55 -27
- package/lib/module/components/NumberInput/NumberInput.js +60 -106
- package/lib/module/components/OTPInput/OTPInput.js +65 -58
- package/lib/module/components/PickerTrigger/PickerTrigger.js +181 -0
- package/lib/module/components/PickerTrigger/index.js +4 -0
- package/lib/module/components/ProgressBar/ProgressBar.js +19 -11
- package/lib/module/components/Radio/Radio.js +11 -6
- package/lib/module/components/Rating/Rating.js +86 -20
- package/lib/module/components/SearchBar/SearchBar.js +84 -107
- package/lib/module/components/SegmentedControl/SegmentedControl.js +22 -11
- package/lib/module/components/Select/Select.js +62 -91
- package/lib/module/components/Skeleton/Skeleton.js +135 -175
- package/lib/module/components/Skeleton/SkeletonClock.js +110 -0
- package/lib/module/components/Skeleton/SkeletonContent.js +167 -84
- package/lib/module/components/Skeleton/SkeletonProvider.js +71 -10
- package/lib/module/components/Skeleton/index.js +3 -2
- package/lib/module/components/Slider/Slider.js +44 -25
- package/lib/module/components/Stepper/Stepper.js +201 -31
- package/lib/module/components/Swipeable/Swipeable.js +36 -19
- package/lib/module/components/Switch/Switch.js +9 -2
- package/lib/module/components/Tabs/Tabs.js +84 -21
- package/lib/module/components/TimePicker/TimePicker.js +123 -45
- package/lib/module/components/Toast/Toast.js +27 -16
- package/lib/module/components/Tooltip/Tooltip.js +56 -32
- package/lib/module/components/index.js +2 -2
- package/lib/module/theme/tokens.js +55 -7
- package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +10 -5
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +8 -0
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +12 -6
- package/lib/typescript/commonjs/components/Badge/Badge.d.ts +7 -6
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +17 -6
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +7 -0
- package/lib/typescript/commonjs/components/Card/Card.d.ts +17 -6
- package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +7 -6
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +9 -1
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +13 -6
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +38 -3
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +36 -3
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +141 -0
- package/lib/typescript/commonjs/components/FieldBase/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
- package/lib/typescript/commonjs/components/FloatingActionButton/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +7 -0
- package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +6 -4
- package/lib/typescript/commonjs/components/Input/Input.d.ts +6 -0
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +13 -6
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +3 -0
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +57 -0
- package/lib/typescript/commonjs/components/PickerTrigger/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +3 -0
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +9 -6
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +49 -20
- package/lib/typescript/commonjs/components/Skeleton/SkeletonClock.d.ts +60 -0
- package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +80 -19
- package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +39 -5
- package/lib/typescript/commonjs/components/Skeleton/index.d.ts +6 -4
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +12 -1
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +18 -6
- package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +2 -0
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +1 -0
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +26 -2
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +36 -3
- package/lib/typescript/commonjs/components/Toast/Toast.d.ts +8 -0
- package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +7 -1
- package/lib/typescript/commonjs/components/index.d.ts +5 -5
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/types.d.ts +553 -11
- package/lib/typescript/module/components/Accordion/Accordion.d.ts +10 -5
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +8 -0
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +12 -6
- package/lib/typescript/module/components/Badge/Badge.d.ts +7 -6
- package/lib/typescript/module/components/Banner/Banner.d.ts +17 -6
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +7 -0
- package/lib/typescript/module/components/Card/Card.d.ts +17 -6
- package/lib/typescript/module/components/Carousel/Carousel.d.ts +7 -6
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +9 -1
- package/lib/typescript/module/components/Chip/Chip.d.ts +13 -6
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +38 -3
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +36 -3
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +141 -0
- package/lib/typescript/module/components/FieldBase/index.d.ts +3 -0
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
- package/lib/typescript/module/components/FloatingActionButton/index.d.ts +1 -1
- package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
- package/lib/typescript/module/components/FormField/FormField.d.ts +7 -0
- package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +6 -4
- package/lib/typescript/module/components/Input/Input.d.ts +6 -0
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +13 -6
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +3 -0
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +57 -0
- package/lib/typescript/module/components/PickerTrigger/index.d.ts +3 -0
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/module/components/Radio/Radio.d.ts +3 -0
- package/lib/typescript/module/components/Rating/Rating.d.ts +9 -6
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +49 -20
- package/lib/typescript/module/components/Skeleton/SkeletonClock.d.ts +60 -0
- package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +80 -19
- package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +39 -5
- package/lib/typescript/module/components/Skeleton/index.d.ts +6 -4
- package/lib/typescript/module/components/Slider/Slider.d.ts +12 -1
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +18 -6
- package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +2 -0
- package/lib/typescript/module/components/Switch/Switch.d.ts +1 -0
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +26 -2
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +36 -3
- package/lib/typescript/module/components/Toast/Toast.d.ts +8 -0
- package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +7 -1
- package/lib/typescript/module/components/index.d.ts +5 -5
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/theme/index.d.ts +1 -1
- package/lib/typescript/module/theme/types.d.ts +553 -11
- package/package.json +2 -6
- package/lib/commonjs/components/AppIcon/AppIcon.js +0 -120
- package/lib/commonjs/types/vector-icons.d.js +0 -2
- package/lib/module/components/AppIcon/AppIcon.js +0 -111
- package/lib/module/components/AppIcon/index.js +0 -4
- package/lib/module/types/vector-icons.d.js +0 -2
- package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +0 -20
- package/lib/typescript/commonjs/components/AppIcon/index.d.ts +0 -3
- package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +0 -20
- package/lib/typescript/module/components/AppIcon/index.d.ts +0 -3
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { forwardRef, useEffect, useMemo, useRef } from 'react';
|
|
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
6
|
import { triggerHaptic } from "../../utils/hapticUtils.js";
|
|
7
|
-
import {
|
|
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;
|
|
10
10
|
const PULSE_SIZE = 32;
|
|
11
|
+
const PULSE_DURATION = 1100;
|
|
11
12
|
const toneColorFor = (theme, tone) => {
|
|
12
13
|
switch (tone) {
|
|
13
14
|
case 'success':
|
|
@@ -28,13 +29,19 @@ const StepCircle = ({
|
|
|
28
29
|
upcomingTextColor,
|
|
29
30
|
interactive,
|
|
30
31
|
totalSteps,
|
|
31
|
-
onPress
|
|
32
|
+
onPress,
|
|
33
|
+
circleSize,
|
|
34
|
+
pulseSize,
|
|
35
|
+
pulseEnabled,
|
|
36
|
+
pulseDuration,
|
|
37
|
+
pressHapticEnabled,
|
|
38
|
+
circleSlotStyle
|
|
32
39
|
}) => {
|
|
33
40
|
const isActive = status === 'active';
|
|
34
41
|
const pulseScale = useRef(createAnimatedValue(1)).current;
|
|
35
42
|
const pulseOpacity = useRef(createAnimatedValue(0.5)).current;
|
|
36
43
|
useEffect(() => {
|
|
37
|
-
if (!isActive) {
|
|
44
|
+
if (!isActive || !pulseEnabled) {
|
|
38
45
|
pulseScale.setValue(1);
|
|
39
46
|
pulseOpacity.setValue(0);
|
|
40
47
|
return;
|
|
@@ -46,7 +53,7 @@ const StepCircle = ({
|
|
|
46
53
|
// positioned view is negligible.
|
|
47
54
|
const loop = Animated.loop(Animated.parallel([Animated.sequence([Animated.timing(pulseScale, {
|
|
48
55
|
toValue: 1.4,
|
|
49
|
-
duration:
|
|
56
|
+
duration: pulseDuration,
|
|
50
57
|
easing: Easing.out(Easing.ease),
|
|
51
58
|
useNativeDriver: false
|
|
52
59
|
}), Animated.timing(pulseScale, {
|
|
@@ -55,7 +62,7 @@ const StepCircle = ({
|
|
|
55
62
|
useNativeDriver: false
|
|
56
63
|
})]), Animated.sequence([Animated.timing(pulseOpacity, {
|
|
57
64
|
toValue: 0,
|
|
58
|
-
duration:
|
|
65
|
+
duration: pulseDuration,
|
|
59
66
|
easing: Easing.out(Easing.ease),
|
|
60
67
|
useNativeDriver: false
|
|
61
68
|
}), Animated.timing(pulseOpacity, {
|
|
@@ -65,7 +72,7 @@ const StepCircle = ({
|
|
|
65
72
|
})])]));
|
|
66
73
|
loop.start();
|
|
67
74
|
return () => loop.stop();
|
|
68
|
-
}, [isActive, pulseScale, pulseOpacity]);
|
|
75
|
+
}, [isActive, pulseScale, pulseOpacity, pulseEnabled, pulseDuration]);
|
|
69
76
|
const bgColor = status === 'upcoming' ? upcomingFillColor : toneColor;
|
|
70
77
|
const borderColor = status === 'upcoming' ? upcomingColor : toneColor;
|
|
71
78
|
const textColor = status === 'upcoming' ? upcomingTextColor : textOnColor;
|
|
@@ -74,17 +81,17 @@ const StepCircle = ({
|
|
|
74
81
|
const canPress = interactive && status === 'complete';
|
|
75
82
|
const handlePress = () => {
|
|
76
83
|
if (!canPress) return;
|
|
77
|
-
triggerHaptic('selection');
|
|
84
|
+
if (pressHapticEnabled) triggerHaptic('selection');
|
|
78
85
|
onPress?.(index);
|
|
79
86
|
};
|
|
80
87
|
const inner = /*#__PURE__*/_jsxs(View, {
|
|
81
88
|
style: circleStyles.relative,
|
|
82
|
-
children: [isActive ? /*#__PURE__*/_jsx(Animated.View, {
|
|
89
|
+
children: [isActive && pulseEnabled ? /*#__PURE__*/_jsx(Animated.View, {
|
|
83
90
|
pointerEvents: "none",
|
|
84
91
|
style: [circleStyles.pulse, {
|
|
85
|
-
width:
|
|
86
|
-
height:
|
|
87
|
-
borderRadius:
|
|
92
|
+
width: pulseSize,
|
|
93
|
+
height: pulseSize,
|
|
94
|
+
borderRadius: pulseSize / 2,
|
|
88
95
|
backgroundColor: toneColor,
|
|
89
96
|
opacity: pulseOpacity,
|
|
90
97
|
transform: [{
|
|
@@ -93,12 +100,12 @@ const StepCircle = ({
|
|
|
93
100
|
}]
|
|
94
101
|
}) : null, /*#__PURE__*/_jsx(View, {
|
|
95
102
|
style: [circleStyles.circle, {
|
|
96
|
-
width:
|
|
97
|
-
height:
|
|
98
|
-
borderRadius:
|
|
103
|
+
width: circleSize,
|
|
104
|
+
height: circleSize,
|
|
105
|
+
borderRadius: circleSize / 2,
|
|
99
106
|
backgroundColor: bgColor,
|
|
100
107
|
borderColor
|
|
101
|
-
}],
|
|
108
|
+
}, circleSlotStyle],
|
|
102
109
|
children: step.icon ? step.icon : isComplete ? /*#__PURE__*/_jsx(Text, {
|
|
103
110
|
style: [circleStyles.glyph, {
|
|
104
111
|
color: textColor
|
|
@@ -159,21 +166,32 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
159
166
|
steps,
|
|
160
167
|
activeStep,
|
|
161
168
|
onStepPress,
|
|
169
|
+
allowStepPress = false,
|
|
162
170
|
variant = 'horizontal',
|
|
163
171
|
tone = 'primary',
|
|
164
172
|
loading = false,
|
|
165
173
|
accessibilityLabel,
|
|
166
174
|
style,
|
|
175
|
+
containerStyle,
|
|
176
|
+
circleStyle,
|
|
177
|
+
labelStyle,
|
|
178
|
+
connectorStyle,
|
|
167
179
|
testID
|
|
168
180
|
} = props;
|
|
169
181
|
const theme = useTheme();
|
|
182
|
+
const stepperTheme = theme.components.stepper;
|
|
183
|
+
const circleSize = stepperTheme?.circleSize ?? CIRCLE_SIZE;
|
|
184
|
+
const pulseSize = stepperTheme?.pulseSize ?? PULSE_SIZE;
|
|
185
|
+
const pulseEnabled = stepperTheme?.pulseAnimation ?? false;
|
|
186
|
+
const pulseDuration = stepperTheme?.pulseDuration ?? PULSE_DURATION;
|
|
187
|
+
const pressHapticEnabled = stepperTheme?.pressHaptic ?? false;
|
|
170
188
|
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
171
189
|
const toneColor = toneColorFor(theme, tone);
|
|
172
190
|
const upcomingColor = theme.colors.border.primary;
|
|
173
191
|
const upcomingFillColor = theme.colors.background.primary;
|
|
174
192
|
const upcomingTextColor = theme.colors.text.secondary;
|
|
175
193
|
const textOnColor = theme.colors.text.inverse;
|
|
176
|
-
const interactive = typeof onStepPress === 'function';
|
|
194
|
+
const interactive = allowStepPress && typeof onStepPress === 'function';
|
|
177
195
|
const total = steps.length;
|
|
178
196
|
|
|
179
197
|
// Connector progress: animates as activeStep changes.
|
|
@@ -200,15 +218,22 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
200
218
|
outputRange: ['0%', '100%']
|
|
201
219
|
});
|
|
202
220
|
const a11yLabel = accessibilityLabel ?? `Progress: step ${activeStep + 1} of ${total}`;
|
|
203
|
-
|
|
221
|
+
|
|
222
|
+
// Measure row width and inset the connector in pixels so it lines up
|
|
223
|
+
// with the flex-computed circle centres. Percentage insets (50/total%)
|
|
224
|
+
// round independently from flex layout on fractional-density screens
|
|
225
|
+
// and can leave the line poking past the first/last node by a pixel.
|
|
226
|
+
const [hRowWidth, setHRowWidth] = useState(0);
|
|
227
|
+
const connectorInset = total > 0 && hRowWidth > 0 ? hRowWidth / (2 * total) : 0;
|
|
204
228
|
const renderHorizontal = () => /*#__PURE__*/_jsxs(View, {
|
|
205
229
|
style: styles.hRow,
|
|
230
|
+
onLayout: e => setHRowWidth(e.nativeEvent.layout.width),
|
|
206
231
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
207
232
|
pointerEvents: "none",
|
|
208
233
|
style: [styles.hConnectorContainer, {
|
|
209
|
-
left:
|
|
210
|
-
right:
|
|
211
|
-
}],
|
|
234
|
+
left: connectorInset,
|
|
235
|
+
right: connectorInset
|
|
236
|
+
}, connectorStyle],
|
|
212
237
|
children: [/*#__PURE__*/_jsx(View, {
|
|
213
238
|
style: [styles.hConnectorTrack, {
|
|
214
239
|
backgroundColor: upcomingColor
|
|
@@ -235,12 +260,18 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
235
260
|
upcomingTextColor: upcomingTextColor,
|
|
236
261
|
interactive: interactive,
|
|
237
262
|
totalSteps: total,
|
|
238
|
-
onPress: onStepPress
|
|
263
|
+
onPress: onStepPress,
|
|
264
|
+
circleSize: circleSize,
|
|
265
|
+
pulseSize: pulseSize,
|
|
266
|
+
pulseEnabled: pulseEnabled,
|
|
267
|
+
pulseDuration: pulseDuration,
|
|
268
|
+
pressHapticEnabled: pressHapticEnabled,
|
|
269
|
+
circleSlotStyle: circleStyle
|
|
239
270
|
}), /*#__PURE__*/_jsx(Text, {
|
|
240
271
|
style: [styles.hLabel, {
|
|
241
272
|
color: status === 'upcoming' ? theme.colors.text.tertiary : theme.colors.text.primary,
|
|
242
273
|
fontSize: theme.typography.fontSize.xs
|
|
243
|
-
}],
|
|
274
|
+
}, labelStyle],
|
|
244
275
|
numberOfLines: 1,
|
|
245
276
|
children: step?.label ?? ' '
|
|
246
277
|
})]
|
|
@@ -268,9 +299,15 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
268
299
|
upcomingTextColor: upcomingTextColor,
|
|
269
300
|
interactive: interactive,
|
|
270
301
|
totalSteps: total,
|
|
271
|
-
onPress: onStepPress
|
|
302
|
+
onPress: onStepPress,
|
|
303
|
+
circleSize: circleSize,
|
|
304
|
+
pulseSize: pulseSize,
|
|
305
|
+
pulseEnabled: pulseEnabled,
|
|
306
|
+
pulseDuration: pulseDuration,
|
|
307
|
+
pressHapticEnabled: pressHapticEnabled,
|
|
308
|
+
circleSlotStyle: circleStyle
|
|
272
309
|
}), !isLast ? /*#__PURE__*/_jsxs(View, {
|
|
273
|
-
style: styles.vConnectorContainer,
|
|
310
|
+
style: [styles.vConnectorContainer, connectorStyle],
|
|
274
311
|
children: [/*#__PURE__*/_jsx(View, {
|
|
275
312
|
style: [styles.vConnectorTrack, {
|
|
276
313
|
backgroundColor: upcomingColor
|
|
@@ -289,7 +326,7 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
289
326
|
color: status === 'upcoming' ? theme.colors.text.tertiary : theme.colors.text.primary,
|
|
290
327
|
fontSize: theme.typography.fontSize.base,
|
|
291
328
|
fontWeight: theme.typography.fontWeight.semibold
|
|
292
|
-
}],
|
|
329
|
+
}, labelStyle],
|
|
293
330
|
numberOfLines: 1,
|
|
294
331
|
children: step?.label ?? ' '
|
|
295
332
|
}), step.description ? /*#__PURE__*/_jsx(Text, {
|
|
@@ -306,7 +343,7 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
306
343
|
});
|
|
307
344
|
const rendered = /*#__PURE__*/_jsx(View, {
|
|
308
345
|
ref: ref,
|
|
309
|
-
style: [styles.container, style],
|
|
346
|
+
style: [styles.container, containerStyle, style],
|
|
310
347
|
testID: testID,
|
|
311
348
|
accessibilityRole: "progressbar",
|
|
312
349
|
accessibilityLabel: a11yLabel,
|
|
@@ -318,15 +355,148 @@ const Stepper = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
318
355
|
children: variant === 'horizontal' ? renderHorizontal() : renderVertical()
|
|
319
356
|
});
|
|
320
357
|
if (loading) {
|
|
321
|
-
return /*#__PURE__*/_jsx(
|
|
322
|
-
|
|
323
|
-
mode: "auto",
|
|
324
|
-
children: rendered
|
|
358
|
+
return /*#__PURE__*/_jsx(StepperSkeleton, {
|
|
359
|
+
...props
|
|
325
360
|
});
|
|
326
361
|
}
|
|
327
362
|
return rendered;
|
|
328
363
|
});
|
|
329
364
|
Stepper.displayName = 'Stepper';
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Authored placeholder shape for `<Stepper>`. Mirrors the real horizontal
|
|
368
|
+
* layout — a row of circles spaced evenly with a flat connector bar passing
|
|
369
|
+
* through their centers — so the on-screen footprint doesn't reflow when
|
|
370
|
+
* data loads. Vertical variant gets a stacked column with the same circle +
|
|
371
|
+
* label + description pattern.
|
|
372
|
+
*
|
|
373
|
+
* Attached as the `Skeleton` static so `<SkeletonContent>` and any consumer
|
|
374
|
+
* of the auto-walker substitutes this shape automatically. Also rendered
|
|
375
|
+
* directly when `loading` is true on the live `<Stepper>`.
|
|
376
|
+
*/
|
|
377
|
+
const StepperSkeleton = ({
|
|
378
|
+
steps,
|
|
379
|
+
variant = 'horizontal',
|
|
380
|
+
containerStyle,
|
|
381
|
+
style,
|
|
382
|
+
testID
|
|
383
|
+
}) => {
|
|
384
|
+
const theme = useTheme();
|
|
385
|
+
const stepperTheme = theme.components.stepper;
|
|
386
|
+
const circleSize = stepperTheme?.circleSize ?? CIRCLE_SIZE;
|
|
387
|
+
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
388
|
+
const total = steps.length || 3;
|
|
389
|
+
if (variant === 'vertical') {
|
|
390
|
+
return /*#__PURE__*/_jsx(View, {
|
|
391
|
+
style: [styles.container, containerStyle, style],
|
|
392
|
+
testID: testID,
|
|
393
|
+
accessibilityRole: "progressbar",
|
|
394
|
+
accessibilityState: {
|
|
395
|
+
busy: true
|
|
396
|
+
},
|
|
397
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
398
|
+
style: skeletonStyles.vCol,
|
|
399
|
+
children: Array.from({
|
|
400
|
+
length: total
|
|
401
|
+
}).map((_, i) => {
|
|
402
|
+
const isLast = i === total - 1;
|
|
403
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
404
|
+
style: skeletonStyles.vRow,
|
|
405
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
406
|
+
style: [skeletonStyles.vLeft, {
|
|
407
|
+
width: circleSize + 8
|
|
408
|
+
}],
|
|
409
|
+
children: [/*#__PURE__*/_jsx(Skeleton, {
|
|
410
|
+
shape: "circle",
|
|
411
|
+
width: circleSize,
|
|
412
|
+
height: circleSize
|
|
413
|
+
}), !isLast ? /*#__PURE__*/_jsx(Skeleton, {
|
|
414
|
+
width: 2,
|
|
415
|
+
height: 28,
|
|
416
|
+
style: {
|
|
417
|
+
marginTop: 4,
|
|
418
|
+
marginBottom: 4
|
|
419
|
+
}
|
|
420
|
+
}) : null]
|
|
421
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
422
|
+
style: skeletonStyles.vBody,
|
|
423
|
+
children: [/*#__PURE__*/_jsx(Skeleton, {
|
|
424
|
+
shape: "text",
|
|
425
|
+
width: "55%",
|
|
426
|
+
height: 16,
|
|
427
|
+
style: {
|
|
428
|
+
marginBottom: 4
|
|
429
|
+
}
|
|
430
|
+
}), /*#__PURE__*/_jsx(Skeleton, {
|
|
431
|
+
shape: "text",
|
|
432
|
+
width: "80%",
|
|
433
|
+
height: 12
|
|
434
|
+
})]
|
|
435
|
+
})]
|
|
436
|
+
}, `sk-step-${i}`);
|
|
437
|
+
})
|
|
438
|
+
})
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
return /*#__PURE__*/_jsx(View, {
|
|
442
|
+
style: [styles.container, containerStyle, style],
|
|
443
|
+
testID: testID,
|
|
444
|
+
accessibilityRole: "progressbar",
|
|
445
|
+
accessibilityState: {
|
|
446
|
+
busy: true
|
|
447
|
+
},
|
|
448
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
449
|
+
style: styles.hRow,
|
|
450
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
451
|
+
pointerEvents: "none",
|
|
452
|
+
style: [styles.hConnectorContainer, {
|
|
453
|
+
left: `${50 / total}%`,
|
|
454
|
+
right: `${50 / total}%`
|
|
455
|
+
}],
|
|
456
|
+
children: /*#__PURE__*/_jsx(Skeleton, {
|
|
457
|
+
width: "100%",
|
|
458
|
+
height: 2,
|
|
459
|
+
radius: 1
|
|
460
|
+
})
|
|
461
|
+
}), Array.from({
|
|
462
|
+
length: total
|
|
463
|
+
}).map((_, i) => /*#__PURE__*/_jsxs(View, {
|
|
464
|
+
style: styles.hStepItem,
|
|
465
|
+
children: [/*#__PURE__*/_jsx(Skeleton, {
|
|
466
|
+
shape: "circle",
|
|
467
|
+
width: circleSize,
|
|
468
|
+
height: circleSize
|
|
469
|
+
}), /*#__PURE__*/_jsx(Skeleton, {
|
|
470
|
+
shape: "text",
|
|
471
|
+
width: "80%",
|
|
472
|
+
height: 12,
|
|
473
|
+
style: {
|
|
474
|
+
marginTop: theme.spacing.xs
|
|
475
|
+
}
|
|
476
|
+
})]
|
|
477
|
+
}, `sk-step-${i}`))]
|
|
478
|
+
})
|
|
479
|
+
});
|
|
480
|
+
};
|
|
481
|
+
StepperSkeleton.displayName = 'StepperSkeleton';
|
|
482
|
+
Stepper.Skeleton = StepperSkeleton;
|
|
483
|
+
const skeletonStyles = StyleSheet.create({
|
|
484
|
+
vCol: {
|
|
485
|
+
flexDirection: 'column'
|
|
486
|
+
},
|
|
487
|
+
vRow: {
|
|
488
|
+
flexDirection: 'row',
|
|
489
|
+
alignItems: 'flex-start'
|
|
490
|
+
},
|
|
491
|
+
vLeft: {
|
|
492
|
+
alignItems: 'center'
|
|
493
|
+
},
|
|
494
|
+
vBody: {
|
|
495
|
+
flex: 1,
|
|
496
|
+
paddingLeft: 12,
|
|
497
|
+
paddingBottom: 16
|
|
498
|
+
}
|
|
499
|
+
});
|
|
330
500
|
const buildStyles = theme => StyleSheet.create({
|
|
331
501
|
container: {
|
|
332
502
|
width: '100%'
|
|
@@ -31,6 +31,7 @@ const SPRING_CONFIG = {
|
|
|
31
31
|
};
|
|
32
32
|
const DRAG_ACTIVATION_OFFSET = 10;
|
|
33
33
|
const RUBBER_BAND_FACTOR = 0.35;
|
|
34
|
+
const FAIL_OFFSET_Y = 15;
|
|
34
35
|
const toneToBg = (theme, tone) => {
|
|
35
36
|
switch (tone) {
|
|
36
37
|
case 'primary':
|
|
@@ -51,16 +52,32 @@ const Swipeable = props => {
|
|
|
51
52
|
children,
|
|
52
53
|
leftActions,
|
|
53
54
|
rightActions,
|
|
54
|
-
threshold
|
|
55
|
-
fullSwipeThreshold
|
|
55
|
+
threshold: thresholdProp,
|
|
56
|
+
fullSwipeThreshold: fullSwipeThresholdProp,
|
|
56
57
|
onSwipeOpen,
|
|
57
58
|
onSwipeClose,
|
|
58
59
|
disabled = false,
|
|
59
60
|
containerStyle,
|
|
61
|
+
contentStyle: contentSlotStyle,
|
|
62
|
+
actionStyle,
|
|
60
63
|
accessibilityLabel,
|
|
61
64
|
testID
|
|
62
65
|
} = props;
|
|
63
66
|
const theme = useTheme();
|
|
67
|
+
const swipeTheme = theme.components.swipeable;
|
|
68
|
+
const threshold = thresholdProp ?? swipeTheme?.threshold ?? 80;
|
|
69
|
+
const fullSwipeThreshold = fullSwipeThresholdProp ?? swipeTheme?.fullSwipeThreshold ?? 200;
|
|
70
|
+
const dragActivationOffset = swipeTheme?.dragActivationOffset ?? DRAG_ACTIVATION_OFFSET;
|
|
71
|
+
const rubberBandFactor = swipeTheme?.rubberBandFactor ?? RUBBER_BAND_FACTOR;
|
|
72
|
+
const failOffsetY = swipeTheme?.failOffsetY ?? FAIL_OFFSET_Y;
|
|
73
|
+
const springConfig = {
|
|
74
|
+
damping: swipeTheme?.springDamping ?? SPRING_CONFIG.damping,
|
|
75
|
+
stiffness: swipeTheme?.springStiffness ?? SPRING_CONFIG.stiffness,
|
|
76
|
+
mass: swipeTheme?.springMass ?? SPRING_CONFIG.mass
|
|
77
|
+
};
|
|
78
|
+
const fullSwipeHapticEnabled = swipeTheme?.fullSwipeHaptic ?? true;
|
|
79
|
+
const actionPressHapticEnabled = swipeTheme?.actionPressHaptic ?? true;
|
|
80
|
+
const a11yActionHapticEnabled = swipeTheme?.a11yActionHaptic ?? true;
|
|
64
81
|
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
65
82
|
const hasLeft = !!leftActions && leftActions.length > 0;
|
|
66
83
|
const hasRight = !!rightActions && rightActions.length > 0;
|
|
@@ -100,22 +117,22 @@ const Swipeable = props => {
|
|
|
100
117
|
const list = side === 'left' ? leftActions : rightActions;
|
|
101
118
|
const first = list?.[0];
|
|
102
119
|
if (!first) return;
|
|
103
|
-
triggerHaptic('notificationSuccess');
|
|
120
|
+
if (fullSwipeHapticEnabled) triggerHaptic('notificationSuccess');
|
|
104
121
|
first.onPress();
|
|
105
122
|
// After the off-screen slide, snap back to 0 silently.
|
|
106
|
-
translateX.value = withSpring(0,
|
|
123
|
+
translateX.value = withSpring(0, springConfig);
|
|
107
124
|
openSideRef.current = null;
|
|
108
125
|
onSwipeClose?.();
|
|
109
|
-
}, [leftActions, rightActions, translateX, onSwipeClose]);
|
|
126
|
+
}, [leftActions, rightActions, translateX, onSwipeClose, springConfig, fullSwipeHapticEnabled]);
|
|
110
127
|
const close = useCallback(() => {
|
|
111
|
-
translateX.value = withSpring(0,
|
|
128
|
+
translateX.value = withSpring(0, springConfig);
|
|
112
129
|
notifyClose();
|
|
113
|
-
}, [translateX, notifyClose]);
|
|
130
|
+
}, [translateX, notifyClose, springConfig]);
|
|
114
131
|
const handleActionPress = useCallback(action => {
|
|
115
|
-
triggerHaptic('selection');
|
|
132
|
+
if (actionPressHapticEnabled) triggerHaptic('selection');
|
|
116
133
|
action.onPress();
|
|
117
134
|
close();
|
|
118
|
-
}, [close]);
|
|
135
|
+
}, [close, actionPressHapticEnabled]);
|
|
119
136
|
|
|
120
137
|
// ───────── Pan gesture (UI thread) ─────────
|
|
121
138
|
const panGesture = useMemo(() => {
|
|
@@ -128,7 +145,7 @@ const Swipeable = props => {
|
|
|
128
145
|
const openThreshold = threshold;
|
|
129
146
|
const allowLeft = hasLeft;
|
|
130
147
|
const allowRight = hasRight;
|
|
131
|
-
return Gesture.Pan().enabled(!disabled).activeOffsetX([-
|
|
148
|
+
return Gesture.Pan().enabled(!disabled).activeOffsetX([-dragActivationOffset, dragActivationOffset]).failOffsetY([-failOffsetY, failOffsetY]).onStart(() => {
|
|
132
149
|
'worklet';
|
|
133
150
|
|
|
134
151
|
dragStartX.value = translateX.value;
|
|
@@ -147,9 +164,9 @@ const Swipeable = props => {
|
|
|
147
164
|
}
|
|
148
165
|
// Rubber-band past the open position so it still feels physical past the cap.
|
|
149
166
|
if (next > leftCap && allowLeft) {
|
|
150
|
-
translateX.value = leftCap + (next - leftCap) *
|
|
167
|
+
translateX.value = leftCap + (next - leftCap) * rubberBandFactor;
|
|
151
168
|
} else if (next < -rightCap && allowRight) {
|
|
152
|
-
translateX.value = -rightCap + (next + rightCap) *
|
|
169
|
+
translateX.value = -rightCap + (next + rightCap) * rubberBandFactor;
|
|
153
170
|
} else {
|
|
154
171
|
translateX.value = next;
|
|
155
172
|
}
|
|
@@ -183,10 +200,10 @@ const Swipeable = props => {
|
|
|
183
200
|
}
|
|
184
201
|
|
|
185
202
|
// Otherwise → spring back closed.
|
|
186
|
-
translateX.value = withSpring(0,
|
|
203
|
+
translateX.value = withSpring(0, springConfig);
|
|
187
204
|
runOnJS(notifyClose)();
|
|
188
205
|
});
|
|
189
|
-
}, [disabled, dragStartX, fireFirstAction, fullSwipeThreshold, hasLeft, hasRight, leftRevealWidth, notifyClose, notifyOpen, rightRevealWidth, screenWidth, threshold, translateX]);
|
|
206
|
+
}, [disabled, dragStartX, fireFirstAction, fullSwipeThreshold, hasLeft, hasRight, leftRevealWidth, notifyClose, notifyOpen, rightRevealWidth, screenWidth, threshold, translateX, dragActivationOffset, failOffsetY, rubberBandFactor, springConfig]);
|
|
190
207
|
|
|
191
208
|
// ───────── Animated styles ─────────
|
|
192
209
|
const contentStyle = useAnimatedStyle(() => ({
|
|
@@ -221,10 +238,10 @@ const Swipeable = props => {
|
|
|
221
238
|
const all = [...(leftActions ?? []), ...(rightActions ?? [])];
|
|
222
239
|
const match = all.find(a => a.key === name);
|
|
223
240
|
if (match) {
|
|
224
|
-
triggerHaptic('selection');
|
|
241
|
+
if (a11yActionHapticEnabled) triggerHaptic('selection');
|
|
225
242
|
match.onPress();
|
|
226
243
|
}
|
|
227
|
-
}, [leftActions, rightActions]);
|
|
244
|
+
}, [leftActions, rightActions, a11yActionHapticEnabled]);
|
|
228
245
|
|
|
229
246
|
// ───────── Render ─────────
|
|
230
247
|
// No actions configured → render children directly; zero gesture overhead.
|
|
@@ -243,7 +260,7 @@ const Swipeable = props => {
|
|
|
243
260
|
children: [hasLeft ? /*#__PURE__*/_jsx(Animated.View, {
|
|
244
261
|
style: [styles.actionsRow, styles.actionsLeft, {
|
|
245
262
|
width: leftRevealWidth
|
|
246
|
-
}, leftBgStyle],
|
|
263
|
+
}, actionStyle, leftBgStyle],
|
|
247
264
|
pointerEvents: "box-none",
|
|
248
265
|
children: leftActions?.map(action => /*#__PURE__*/_jsx(ActionButton, {
|
|
249
266
|
action: action,
|
|
@@ -254,7 +271,7 @@ const Swipeable = props => {
|
|
|
254
271
|
}) : null, hasRight ? /*#__PURE__*/_jsx(Animated.View, {
|
|
255
272
|
style: [styles.actionsRow, styles.actionsRight, {
|
|
256
273
|
width: rightRevealWidth
|
|
257
|
-
}, rightBgStyle],
|
|
274
|
+
}, actionStyle, rightBgStyle],
|
|
258
275
|
pointerEvents: "box-none",
|
|
259
276
|
children: rightActions?.map(action => /*#__PURE__*/_jsx(ActionButton, {
|
|
260
277
|
action: action,
|
|
@@ -265,7 +282,7 @@ const Swipeable = props => {
|
|
|
265
282
|
}) : null, /*#__PURE__*/_jsx(GestureDetector, {
|
|
266
283
|
gesture: panGesture,
|
|
267
284
|
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
268
|
-
style: [styles.content, contentStyle],
|
|
285
|
+
style: [styles.content, contentSlotStyle, contentStyle],
|
|
269
286
|
children: children
|
|
270
287
|
})
|
|
271
288
|
})]
|
|
@@ -50,6 +50,7 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
50
50
|
haptic = 'selection',
|
|
51
51
|
bounce = false,
|
|
52
52
|
style,
|
|
53
|
+
containerStyle,
|
|
53
54
|
trackStyle,
|
|
54
55
|
thumbStyle,
|
|
55
56
|
testID,
|
|
@@ -162,9 +163,15 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
162
163
|
})
|
|
163
164
|
})
|
|
164
165
|
});
|
|
165
|
-
if (!label)
|
|
166
|
+
if (!label) {
|
|
167
|
+
if (!containerStyle) return switchEl;
|
|
168
|
+
return /*#__PURE__*/_jsx(View, {
|
|
169
|
+
style: containerStyle,
|
|
170
|
+
children: switchEl
|
|
171
|
+
});
|
|
172
|
+
}
|
|
166
173
|
return /*#__PURE__*/_jsxs(View, {
|
|
167
|
-
style: [styles.row, style],
|
|
174
|
+
style: [styles.row, containerStyle, style],
|
|
168
175
|
children: [switchEl, /*#__PURE__*/_jsx(Text, {
|
|
169
176
|
style: [styles.label, {
|
|
170
177
|
color: disabled ? theme.colors.text.disabled : theme.colors.text.primary,
|