@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
|
@@ -98,7 +98,6 @@ const BottomSheet = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
98
98
|
return () => sub.remove();
|
|
99
99
|
}, []);
|
|
100
100
|
const closedY = screenHeight; // fully off-screen
|
|
101
|
-
const minSnapPoint = resolvedSnapPoints[0] ?? 0;
|
|
102
101
|
const maxSnapPoint = resolvedSnapPoints[resolvedSnapPoints.length - 1] ?? 0;
|
|
103
102
|
|
|
104
103
|
// translateY: 0 = top of screen, screenHeight = fully closed.
|
|
@@ -132,6 +131,13 @@ const BottomSheet = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
132
131
|
currentIndexShared.value = next;
|
|
133
132
|
onChange?.(next);
|
|
134
133
|
}, [currentIndex, currentIndexShared, onChange]);
|
|
134
|
+
const markAnimationDone = useCallback(() => {
|
|
135
|
+
isAnimatingRef.current = false;
|
|
136
|
+
// If we just finished a close animation, unmount the sheet wrapper.
|
|
137
|
+
if (currentIndexShared.value < 0) {
|
|
138
|
+
if (mode === 'modal') setModalVisible(false);else setInlineMounted(false);
|
|
139
|
+
}
|
|
140
|
+
}, [mode, currentIndexShared]);
|
|
135
141
|
const animateTo = useCallback((to, fromIndex, toIndex) => {
|
|
136
142
|
isAnimatingRef.current = true;
|
|
137
143
|
onAnimate?.(fromIndex, toIndex);
|
|
@@ -142,14 +148,7 @@ const BottomSheet = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
142
148
|
runOnJS(markAnimationDone)();
|
|
143
149
|
}
|
|
144
150
|
});
|
|
145
|
-
}, [onAnimate, translateY]);
|
|
146
|
-
const markAnimationDone = useCallback(() => {
|
|
147
|
-
isAnimatingRef.current = false;
|
|
148
|
-
// If we just finished a close animation, unmount the sheet wrapper.
|
|
149
|
-
if (currentIndexShared.value < 0) {
|
|
150
|
-
if (mode === 'modal') setModalVisible(false);else setInlineMounted(false);
|
|
151
|
-
}
|
|
152
|
-
}, [mode, currentIndexShared]);
|
|
151
|
+
}, [onAnimate, translateY, markAnimationDone]);
|
|
153
152
|
const expand = useCallback(idx => {
|
|
154
153
|
const target = typeof idx === 'number' ? clamp(idx, 0, resolvedSnapPoints.length - 1) : currentIndex >= 0 ? currentIndex : 0;
|
|
155
154
|
const fromIndex = currentIndexShared.value;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { useTheme } from "../../theme/index.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const space = (theme, token) => token == null ? undefined : theme.spacing[token];
|
|
8
|
+
export const resolveBoxStyle = (theme, p) => {
|
|
9
|
+
const style = {};
|
|
10
|
+
if (p.p != null) style.padding = space(theme, p.p);
|
|
11
|
+
if (p.px != null) style.paddingHorizontal = space(theme, p.px);
|
|
12
|
+
if (p.py != null) style.paddingVertical = space(theme, p.py);
|
|
13
|
+
if (p.pt != null) style.paddingTop = space(theme, p.pt);
|
|
14
|
+
if (p.pr != null) style.paddingRight = space(theme, p.pr);
|
|
15
|
+
if (p.pb != null) style.paddingBottom = space(theme, p.pb);
|
|
16
|
+
if (p.pl != null) style.paddingLeft = space(theme, p.pl);
|
|
17
|
+
if (p.m != null) style.margin = space(theme, p.m);
|
|
18
|
+
if (p.mx != null) style.marginHorizontal = space(theme, p.mx);
|
|
19
|
+
if (p.my != null) style.marginVertical = space(theme, p.my);
|
|
20
|
+
if (p.mt != null) style.marginTop = space(theme, p.mt);
|
|
21
|
+
if (p.mr != null) style.marginRight = space(theme, p.mr);
|
|
22
|
+
if (p.mb != null) style.marginBottom = space(theme, p.mb);
|
|
23
|
+
if (p.ml != null) style.marginLeft = space(theme, p.ml);
|
|
24
|
+
if (p.gap != null) style.gap = space(theme, p.gap);
|
|
25
|
+
if (p.bg != null) {
|
|
26
|
+
const bgTokens = theme.colors.background;
|
|
27
|
+
style.backgroundColor = bgTokens[p.bg] ?? p.bg;
|
|
28
|
+
}
|
|
29
|
+
if (p.radius != null) style.borderRadius = theme.radius[p.radius];
|
|
30
|
+
if (p.border) {
|
|
31
|
+
style.borderWidth = theme.colors.border.width;
|
|
32
|
+
style.borderColor = theme.colors.border.primary;
|
|
33
|
+
}
|
|
34
|
+
if (p.flex != null) style.flex = p.flex;
|
|
35
|
+
if (p.align != null) style.alignItems = p.align;
|
|
36
|
+
if (p.justify != null) style.justifyContent = p.justify;
|
|
37
|
+
if (p.direction != null) style.flexDirection = p.direction;
|
|
38
|
+
if (p.wrap) style.flexWrap = 'wrap';
|
|
39
|
+
return style;
|
|
40
|
+
};
|
|
41
|
+
const Box = /*#__PURE__*/forwardRef((props, ref) => {
|
|
42
|
+
const theme = useTheme();
|
|
43
|
+
const {
|
|
44
|
+
// layout props consumed by the resolver — kept out of the View spread
|
|
45
|
+
p,
|
|
46
|
+
px,
|
|
47
|
+
py,
|
|
48
|
+
pt,
|
|
49
|
+
pr,
|
|
50
|
+
pb,
|
|
51
|
+
pl,
|
|
52
|
+
m,
|
|
53
|
+
mx,
|
|
54
|
+
my,
|
|
55
|
+
mt,
|
|
56
|
+
mr,
|
|
57
|
+
mb,
|
|
58
|
+
ml,
|
|
59
|
+
gap,
|
|
60
|
+
bg,
|
|
61
|
+
radius,
|
|
62
|
+
border,
|
|
63
|
+
flex,
|
|
64
|
+
align,
|
|
65
|
+
justify,
|
|
66
|
+
direction,
|
|
67
|
+
wrap,
|
|
68
|
+
style,
|
|
69
|
+
children,
|
|
70
|
+
...viewProps
|
|
71
|
+
} = props;
|
|
72
|
+
const boxStyle = resolveBoxStyle(theme, {
|
|
73
|
+
p,
|
|
74
|
+
px,
|
|
75
|
+
py,
|
|
76
|
+
pt,
|
|
77
|
+
pr,
|
|
78
|
+
pb,
|
|
79
|
+
pl,
|
|
80
|
+
m,
|
|
81
|
+
mx,
|
|
82
|
+
my,
|
|
83
|
+
mt,
|
|
84
|
+
mr,
|
|
85
|
+
mb,
|
|
86
|
+
ml,
|
|
87
|
+
gap,
|
|
88
|
+
bg,
|
|
89
|
+
radius,
|
|
90
|
+
border,
|
|
91
|
+
flex,
|
|
92
|
+
align,
|
|
93
|
+
justify,
|
|
94
|
+
direction,
|
|
95
|
+
wrap
|
|
96
|
+
});
|
|
97
|
+
return /*#__PURE__*/_jsx(View, {
|
|
98
|
+
ref: ref,
|
|
99
|
+
style: [boxStyle, style],
|
|
100
|
+
...viewProps,
|
|
101
|
+
children: children
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
Box.displayName = 'Box';
|
|
105
|
+
/** Vertical flex container with token spacing between children (default gap `md`). */
|
|
106
|
+
const Stack = /*#__PURE__*/forwardRef(({
|
|
107
|
+
gap = 'md',
|
|
108
|
+
...rest
|
|
109
|
+
}, ref) => /*#__PURE__*/_jsx(Box, {
|
|
110
|
+
ref: ref,
|
|
111
|
+
direction: "column",
|
|
112
|
+
gap: gap,
|
|
113
|
+
...rest
|
|
114
|
+
}));
|
|
115
|
+
Stack.displayName = 'Stack';
|
|
116
|
+
/** Horizontal flex container (default `align="center"`, gap `sm`). */
|
|
117
|
+
const Row = /*#__PURE__*/forwardRef(({
|
|
118
|
+
gap = 'sm',
|
|
119
|
+
align = 'center',
|
|
120
|
+
...rest
|
|
121
|
+
}, ref) => /*#__PURE__*/_jsx(Box, {
|
|
122
|
+
ref: ref,
|
|
123
|
+
direction: "row",
|
|
124
|
+
gap: gap,
|
|
125
|
+
align: align,
|
|
126
|
+
...rest
|
|
127
|
+
}));
|
|
128
|
+
Row.displayName = 'Row';
|
|
129
|
+
/** Fixed gap (`size`) or a flexible push (`flex: 1`) between siblings. */
|
|
130
|
+
const Spacer = ({
|
|
131
|
+
size,
|
|
132
|
+
style,
|
|
133
|
+
testID
|
|
134
|
+
}) => {
|
|
135
|
+
const theme = useTheme();
|
|
136
|
+
if (size != null) {
|
|
137
|
+
const value = theme.spacing[size];
|
|
138
|
+
return /*#__PURE__*/_jsx(View, {
|
|
139
|
+
testID: testID,
|
|
140
|
+
style: [{
|
|
141
|
+
width: value,
|
|
142
|
+
height: value
|
|
143
|
+
}, style]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return /*#__PURE__*/_jsx(View, {
|
|
147
|
+
testID: testID,
|
|
148
|
+
style: [{
|
|
149
|
+
flex: 1
|
|
150
|
+
}, style]
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
Spacer.displayName = 'Spacer';
|
|
154
|
+
export { Box, Stack, Row, Spacer };
|
|
155
|
+
export default Box;
|
|
156
|
+
//# sourceMappingURL=Box.js.map
|
|
@@ -67,7 +67,7 @@ const Button = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
67
67
|
style: styles.contentRow,
|
|
68
68
|
children: loading ? /*#__PURE__*/_jsx(Spinner, {
|
|
69
69
|
variant: "circular",
|
|
70
|
-
size: "
|
|
70
|
+
size: "sm",
|
|
71
71
|
color: variantStyles.textColor,
|
|
72
72
|
accessibilityLabel: "Loading"
|
|
73
73
|
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -184,7 +184,7 @@ const toneFor = (theme, tone) => {
|
|
|
184
184
|
base: theme.colors.primary,
|
|
185
185
|
hover: theme.colors.primaryHover,
|
|
186
186
|
pressed: theme.colors.primaryPressed,
|
|
187
|
-
on: theme.colors.
|
|
187
|
+
on: theme.colors.onPrimary,
|
|
188
188
|
muted: theme.colors.primaryMuted
|
|
189
189
|
};
|
|
190
190
|
case 'secondary':
|
|
@@ -192,7 +192,7 @@ const toneFor = (theme, tone) => {
|
|
|
192
192
|
base: theme.colors.secondary,
|
|
193
193
|
hover: theme.colors.secondaryHover,
|
|
194
194
|
pressed: theme.colors.secondaryHover,
|
|
195
|
-
on: theme.colors.
|
|
195
|
+
on: theme.colors.onSecondary,
|
|
196
196
|
muted: theme.colors.secondary
|
|
197
197
|
};
|
|
198
198
|
case 'success':
|
|
@@ -200,7 +200,7 @@ const toneFor = (theme, tone) => {
|
|
|
200
200
|
base: theme.colors.success,
|
|
201
201
|
hover: theme.colors.success,
|
|
202
202
|
pressed: theme.colors.success,
|
|
203
|
-
on: theme.colors.
|
|
203
|
+
on: theme.colors.onSuccess,
|
|
204
204
|
muted: theme.colors.background.secondary
|
|
205
205
|
};
|
|
206
206
|
case 'warning':
|
|
@@ -208,15 +208,15 @@ const toneFor = (theme, tone) => {
|
|
|
208
208
|
base: theme.colors.warning,
|
|
209
209
|
hover: theme.colors.warning,
|
|
210
210
|
pressed: theme.colors.warning,
|
|
211
|
-
on: theme.colors.
|
|
211
|
+
on: theme.colors.onWarning,
|
|
212
212
|
muted: theme.colors.background.secondary
|
|
213
213
|
};
|
|
214
|
-
case '
|
|
214
|
+
case 'error':
|
|
215
215
|
return {
|
|
216
216
|
base: theme.colors.error,
|
|
217
217
|
hover: theme.colors.error,
|
|
218
218
|
pressed: theme.colors.error,
|
|
219
|
-
on: theme.colors.
|
|
219
|
+
on: theme.colors.onError,
|
|
220
220
|
muted: theme.colors.background.secondary
|
|
221
221
|
};
|
|
222
222
|
case 'neutral':
|
|
@@ -4,7 +4,7 @@ import React, { forwardRef, useMemo } from 'react';
|
|
|
4
4
|
import { Animated, Image, Pressable, StyleSheet, View } from 'react-native';
|
|
5
5
|
import { Gradient, useTheme } from "../../theme/index.js";
|
|
6
6
|
import { usePressAnimation } from "../../hooks/usePressAnimation.js";
|
|
7
|
-
import { triggerHaptic } from "../../utils/hapticUtils.js";
|
|
7
|
+
import { resolveHaptic, triggerHaptic } from "../../utils/hapticUtils.js";
|
|
8
8
|
import { Skeleton, SkeletonText } from "../Skeleton/index.js";
|
|
9
9
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
const paddingMap = {
|
|
@@ -31,6 +31,7 @@ const Card = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
31
31
|
loading = false,
|
|
32
32
|
gradient,
|
|
33
33
|
onPress,
|
|
34
|
+
haptic,
|
|
34
35
|
accessibilityLabel,
|
|
35
36
|
accessibilityHint,
|
|
36
37
|
accessibilityRole,
|
|
@@ -150,9 +151,8 @@ const Card = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
150
151
|
let rendered;
|
|
151
152
|
if (isInteractive) {
|
|
152
153
|
const handlePress = event => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
154
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
155
|
+
if (h) triggerHaptic(h);
|
|
156
156
|
onPress?.(event);
|
|
157
157
|
};
|
|
158
158
|
rendered = /*#__PURE__*/_jsx(Animated.View, {
|
|
@@ -437,12 +437,14 @@ const ThumbnailItem = ({
|
|
|
437
437
|
}) => {
|
|
438
438
|
const scale = useRef(createAnimatedValue(isActive ? 1.1 : 1)).current;
|
|
439
439
|
useEffect(() => {
|
|
440
|
-
Animated.spring(scale, {
|
|
440
|
+
const anim = Animated.spring(scale, {
|
|
441
441
|
toValue: isActive ? 1.1 : 1,
|
|
442
442
|
useNativeDriver: true,
|
|
443
443
|
friction: 6,
|
|
444
444
|
tension: 80
|
|
445
|
-
})
|
|
445
|
+
});
|
|
446
|
+
anim.start();
|
|
447
|
+
return () => anim.stop();
|
|
446
448
|
}, [isActive, scale]);
|
|
447
449
|
const content = useMemo(() => {
|
|
448
450
|
if (renderThumbnail) return renderThumbnail(item, index);
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import React, { forwardRef, useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import { Animated, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { useTheme, createAnimatedValue } from "../../theme/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useControllableState } from "../../hooks/index.js";
|
|
7
|
+
import { triggerHaptic, resolveHaptic } from "../../utils/hapticUtils.js";
|
|
7
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
9
|
const sizeMap = {
|
|
9
10
|
sm: 16,
|
|
@@ -26,6 +27,7 @@ const toneColor = (theme, tone) => {
|
|
|
26
27
|
const Checkbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
27
28
|
const {
|
|
28
29
|
checked,
|
|
30
|
+
defaultChecked,
|
|
29
31
|
onChange,
|
|
30
32
|
indeterminate = false,
|
|
31
33
|
disabled = false,
|
|
@@ -33,7 +35,7 @@ const Checkbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
33
35
|
size = 'md',
|
|
34
36
|
tone = 'primary',
|
|
35
37
|
accessibilityLabel,
|
|
36
|
-
haptic
|
|
38
|
+
haptic,
|
|
37
39
|
style,
|
|
38
40
|
boxStyle,
|
|
39
41
|
checkIconStyle,
|
|
@@ -43,22 +45,29 @@ const Checkbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
43
45
|
testID,
|
|
44
46
|
...rest
|
|
45
47
|
} = props;
|
|
48
|
+
const [current, setCurrent] = useControllableState({
|
|
49
|
+
value: checked,
|
|
50
|
+
defaultValue: defaultChecked ?? false,
|
|
51
|
+
onChange
|
|
52
|
+
});
|
|
46
53
|
const theme = useTheme();
|
|
47
54
|
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
48
55
|
const boxSize = theme.components.checkbox?.[size]?.boxSize ?? sizeMap[size];
|
|
49
56
|
const checkboxBorderWidth = theme.colors.border.width;
|
|
50
57
|
const checkboxLabelGap = theme.components.checkbox?.labelGap ?? 10;
|
|
51
58
|
const fillColor = toneColor(theme, tone);
|
|
52
|
-
const isActive =
|
|
59
|
+
const isActive = current || indeterminate;
|
|
53
60
|
const progress = useRef(createAnimatedValue(isActive ? 1 : 0)).current;
|
|
54
61
|
useEffect(() => {
|
|
55
|
-
Animated.spring(progress, {
|
|
62
|
+
const anim = Animated.spring(progress, {
|
|
56
63
|
toValue: isActive ? 1 : 0,
|
|
57
64
|
damping: theme.motion.spring.snappy.damping,
|
|
58
65
|
stiffness: theme.motion.spring.snappy.stiffness,
|
|
59
66
|
mass: theme.motion.spring.snappy.mass,
|
|
60
67
|
useNativeDriver: true
|
|
61
|
-
})
|
|
68
|
+
});
|
|
69
|
+
anim.start();
|
|
70
|
+
return () => anim.stop();
|
|
62
71
|
}, [isActive, progress, theme.motion.spring.snappy]);
|
|
63
72
|
const scale = progress.interpolate({
|
|
64
73
|
inputRange: [0, 1],
|
|
@@ -66,8 +75,9 @@ const Checkbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
66
75
|
});
|
|
67
76
|
const handlePress = event => {
|
|
68
77
|
if (disabled) return;
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
79
|
+
if (h) triggerHaptic(h);
|
|
80
|
+
setCurrent(!current);
|
|
71
81
|
rest.onPressOut?.(event);
|
|
72
82
|
};
|
|
73
83
|
const accessibleLabel = accessibilityLabel ?? label;
|
|
@@ -84,7 +94,7 @@ const Checkbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
84
94
|
accessibilityRole: "checkbox",
|
|
85
95
|
accessibilityLabel: accessibleLabel,
|
|
86
96
|
accessibilityState: {
|
|
87
|
-
checked: indeterminate ? 'mixed' :
|
|
97
|
+
checked: indeterminate ? 'mixed' : current,
|
|
88
98
|
disabled
|
|
89
99
|
},
|
|
90
100
|
testID: testID,
|
|
@@ -4,7 +4,7 @@ import React, { forwardRef, useMemo } from 'react';
|
|
|
4
4
|
import { Animated, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { fontFor, useTheme } from "../../theme/index.js";
|
|
6
6
|
import { usePressAnimation } from "../../hooks/usePressAnimation.js";
|
|
7
|
-
import { triggerHaptic } from "../../utils/hapticUtils.js";
|
|
7
|
+
import { resolveHaptic, triggerHaptic } from "../../utils/hapticUtils.js";
|
|
8
8
|
import { Skeleton } from "../Skeleton/index.js";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
const toneFor = (theme, tone) => {
|
|
@@ -99,6 +99,7 @@ const Chip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
99
99
|
disabled = false,
|
|
100
100
|
loading = false,
|
|
101
101
|
accessibilityLabel,
|
|
102
|
+
haptic,
|
|
102
103
|
style,
|
|
103
104
|
textStyle,
|
|
104
105
|
containerStyle,
|
|
@@ -145,12 +146,13 @@ const Chip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
145
146
|
const borderWidth = isFilled ? 0 : theme.colors.border.width;
|
|
146
147
|
const handlePress = () => {
|
|
147
148
|
if (!isPressable) return;
|
|
148
|
-
|
|
149
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
150
|
+
if (h) triggerHaptic(h);
|
|
149
151
|
onPress?.();
|
|
150
152
|
};
|
|
151
153
|
const handleClose = () => {
|
|
152
154
|
if (disabled) return;
|
|
153
|
-
if (
|
|
155
|
+
if (haptic !== false) triggerHaptic('impactLight');
|
|
154
156
|
onClose?.();
|
|
155
157
|
};
|
|
156
158
|
const a11yLabel = accessibilityLabel ?? label;
|
|
@@ -4,20 +4,20 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
4
4
|
import { AccessibilityInfo, Animated, Easing, Modal, 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/index.js";
|
|
7
|
+
import { resolveHaptic, triggerHaptic } from "../../utils/index.js";
|
|
8
8
|
import { PickerTrigger } from "../PickerTrigger/index.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* DatePicker operates in two modes:
|
|
12
12
|
*
|
|
13
|
-
* 1. **Controlled-modal mode** — pass `visible` (plus `
|
|
13
|
+
* 1. **Controlled-modal mode** — pass `visible` (plus `onChange` / `onClose`)
|
|
14
14
|
* and own the open state externally. The component renders only the modal.
|
|
15
15
|
* 2. **Trigger mode** — omit `visible`. The component renders a built-in
|
|
16
16
|
* PickerTrigger field (label / value / placeholder / chevron / clear /
|
|
17
17
|
* helper / error / size / variant) and manages its own open state. The
|
|
18
18
|
* field opens the modal on press and closes it on confirm/cancel.
|
|
19
19
|
*
|
|
20
|
-
* `
|
|
20
|
+
* `onChange` / `onClose` are typed optional to support trigger-only usage
|
|
21
21
|
* where the consumer may not need either callback. In controlled-modal mode
|
|
22
22
|
* they remain semantically required.
|
|
23
23
|
*/
|
|
@@ -99,7 +99,7 @@ const buildDecadeCells = anchorYear => {
|
|
|
99
99
|
const DatePicker = props => {
|
|
100
100
|
const {
|
|
101
101
|
value,
|
|
102
|
-
|
|
102
|
+
onChange,
|
|
103
103
|
onClose,
|
|
104
104
|
minDate,
|
|
105
105
|
maxDate,
|
|
@@ -115,6 +115,7 @@ const DatePicker = props => {
|
|
|
115
115
|
headerLabelStyle,
|
|
116
116
|
navButtonStyle,
|
|
117
117
|
footerButtonStyle,
|
|
118
|
+
haptic,
|
|
118
119
|
testID,
|
|
119
120
|
label,
|
|
120
121
|
placeholder,
|
|
@@ -174,7 +175,7 @@ const DatePicker = props => {
|
|
|
174
175
|
if (open) {
|
|
175
176
|
backdrop.setValue(0);
|
|
176
177
|
setNativeValue(sheet, 0);
|
|
177
|
-
Animated.parallel([Animated.timing(backdrop, {
|
|
178
|
+
const anim = Animated.parallel([Animated.timing(backdrop, {
|
|
178
179
|
toValue: 1,
|
|
179
180
|
duration: theme.motion.duration.normal,
|
|
180
181
|
easing: Easing.out(Easing.cubic),
|
|
@@ -185,7 +186,9 @@ const DatePicker = props => {
|
|
|
185
186
|
stiffness: theme.motion.spring.gentle.stiffness,
|
|
186
187
|
mass: theme.motion.spring.gentle.mass,
|
|
187
188
|
useNativeDriver: true
|
|
188
|
-
})])
|
|
189
|
+
})]);
|
|
190
|
+
anim.start();
|
|
191
|
+
return () => anim.stop();
|
|
189
192
|
}
|
|
190
193
|
}, [open, mode, backdrop, sheet, theme.motion]);
|
|
191
194
|
const disabledIsoSet = useMemo(() => {
|
|
@@ -228,7 +231,7 @@ const DatePicker = props => {
|
|
|
228
231
|
return false;
|
|
229
232
|
}, [minDay, maxDay]);
|
|
230
233
|
const animateMonthChange = useCallback(delta => {
|
|
231
|
-
if (
|
|
234
|
+
if (haptic !== false) triggerHaptic('impactLight');
|
|
232
235
|
const direction = delta > 0 ? 1 : -1;
|
|
233
236
|
const distance = theme.components.datePicker?.monthSlideDistance ?? 32;
|
|
234
237
|
const outDuration = theme.components.datePicker?.monthSlideOutDuration ?? theme.motion.duration.fast ?? 140;
|
|
@@ -259,31 +262,31 @@ const DatePicker = props => {
|
|
|
259
262
|
const next = addMonths(anchor, delta);
|
|
260
263
|
setAnchor(next);
|
|
261
264
|
AccessibilityInfo.announceForAccessibility(formatMonthYear(next, locale));
|
|
262
|
-
}, [anchor, locale, monthFade, monthSlide, theme.components.datePicker, theme.motion.duration.fast]);
|
|
265
|
+
}, [anchor, haptic, locale, monthFade, monthSlide, theme.components.datePicker, theme.motion.duration.fast]);
|
|
263
266
|
const goPrev = useCallback(() => {
|
|
264
267
|
if (viewMode === 'days') {
|
|
265
268
|
animateMonthChange(-1);
|
|
266
269
|
return;
|
|
267
270
|
}
|
|
268
|
-
if (
|
|
271
|
+
if (haptic !== false) triggerHaptic('impactLight');
|
|
269
272
|
if (viewMode === 'years') {
|
|
270
273
|
setAnchor(prev => new Date(prev.getFullYear() - GRID_SIZE, prev.getMonth(), 1));
|
|
271
274
|
} else {
|
|
272
275
|
setAnchor(prev => new Date(prev.getFullYear() - GRID_SIZE * DECADE_SPAN, prev.getMonth(), 1));
|
|
273
276
|
}
|
|
274
|
-
}, [animateMonthChange, viewMode,
|
|
277
|
+
}, [animateMonthChange, viewMode, haptic]);
|
|
275
278
|
const goNext = useCallback(() => {
|
|
276
279
|
if (viewMode === 'days') {
|
|
277
280
|
animateMonthChange(1);
|
|
278
281
|
return;
|
|
279
282
|
}
|
|
280
|
-
if (
|
|
283
|
+
if (haptic !== false) triggerHaptic('impactLight');
|
|
281
284
|
if (viewMode === 'years') {
|
|
282
285
|
setAnchor(prev => new Date(prev.getFullYear() + GRID_SIZE, prev.getMonth(), 1));
|
|
283
286
|
} else {
|
|
284
287
|
setAnchor(prev => new Date(prev.getFullYear() + GRID_SIZE * DECADE_SPAN, prev.getMonth(), 1));
|
|
285
288
|
}
|
|
286
|
-
}, [animateMonthChange, viewMode,
|
|
289
|
+
}, [animateMonthChange, viewMode, haptic]);
|
|
287
290
|
|
|
288
291
|
// View-mode transition: fade + scale, native driver.
|
|
289
292
|
const animateViewTransition = useCallback(() => {
|
|
@@ -303,7 +306,8 @@ const DatePicker = props => {
|
|
|
303
306
|
})]).start();
|
|
304
307
|
}, [viewFade, viewScale, theme.components.datePicker, theme.motion.duration.normal]);
|
|
305
308
|
const cycleViewMode = useCallback(() => {
|
|
306
|
-
|
|
309
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
310
|
+
if (h) triggerHaptic(h);
|
|
307
311
|
const pressDur = theme.components.datePicker?.headerPressDuration ?? 80;
|
|
308
312
|
const releaseDur = theme.components.datePicker?.headerReleaseDuration ?? 100;
|
|
309
313
|
Animated.sequence([Animated.timing(headerScale, {
|
|
@@ -321,23 +325,26 @@ const DatePicker = props => {
|
|
|
321
325
|
return 'years';
|
|
322
326
|
});
|
|
323
327
|
animateViewTransition();
|
|
324
|
-
}, [animateViewTransition, headerScale, theme.components.datePicker]);
|
|
328
|
+
}, [animateViewTransition, headerScale, haptic, theme.components.datePicker]);
|
|
325
329
|
const pickYear = useCallback(year => {
|
|
326
|
-
|
|
330
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
331
|
+
if (h) triggerHaptic(h);
|
|
327
332
|
setAnchor(prev => new Date(year, prev.getMonth(), 1));
|
|
328
333
|
setViewMode('days');
|
|
329
334
|
animateViewTransition();
|
|
330
|
-
}, [animateViewTransition,
|
|
335
|
+
}, [animateViewTransition, haptic]);
|
|
331
336
|
const pickDecade = useCallback(decadeStart => {
|
|
332
|
-
|
|
337
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
338
|
+
if (h) triggerHaptic(h);
|
|
333
339
|
// Anchor mid-decade so the year grid centers nicely on this decade.
|
|
334
340
|
setAnchor(prev => new Date(decadeStart + 4, prev.getMonth(), 1));
|
|
335
341
|
setViewMode('years');
|
|
336
342
|
animateViewTransition();
|
|
337
|
-
}, [animateViewTransition,
|
|
343
|
+
}, [animateViewTransition, haptic]);
|
|
338
344
|
const pressDay = useCallback(cell => {
|
|
339
345
|
if (isDisabled(cell.date)) return;
|
|
340
|
-
|
|
346
|
+
const h = resolveHaptic(haptic, 'selection');
|
|
347
|
+
if (h) triggerHaptic(h);
|
|
341
348
|
setPendingDate(cell.date);
|
|
342
349
|
if (!cell.inMonth) {
|
|
343
350
|
setAnchor(new Date(cell.date.getFullYear(), cell.date.getMonth(), 1));
|
|
@@ -350,7 +357,7 @@ const DatePicker = props => {
|
|
|
350
357
|
mass: theme.motion.spring.bouncy.mass,
|
|
351
358
|
useNativeDriver: true
|
|
352
359
|
}).start();
|
|
353
|
-
}, [isDisabled, selectScale, theme.motion.spring.bouncy,
|
|
360
|
+
}, [isDisabled, selectScale, theme.motion.spring.bouncy, haptic]);
|
|
354
361
|
const finalizeClose = useCallback(() => {
|
|
355
362
|
if (isControlled) {
|
|
356
363
|
onClose?.();
|
|
@@ -379,15 +386,15 @@ const DatePicker = props => {
|
|
|
379
386
|
});
|
|
380
387
|
}, [backdrop, mode, finalizeClose, sheet, theme.motion.duration.fast]);
|
|
381
388
|
const handleCancel = useCallback(() => {
|
|
382
|
-
if (
|
|
389
|
+
if (haptic !== false) triggerHaptic('selection');
|
|
383
390
|
handleClose();
|
|
384
|
-
}, [handleClose,
|
|
391
|
+
}, [handleClose, haptic]);
|
|
385
392
|
const handleConfirm = useCallback(() => {
|
|
386
393
|
if (!pendingDate) return;
|
|
387
|
-
if (
|
|
388
|
-
|
|
394
|
+
if (haptic !== false) triggerHaptic('notificationSuccess');
|
|
395
|
+
onChange?.(pendingDate);
|
|
389
396
|
handleClose();
|
|
390
|
-
}, [handleClose,
|
|
397
|
+
}, [handleClose, onChange, pendingDate, haptic]);
|
|
391
398
|
const sheetTranslate = sheet.interpolate({
|
|
392
399
|
inputRange: [0, 1],
|
|
393
400
|
outputRange: [320, 0]
|