@webority-technologies/mobile 0.0.21 → 0.0.23
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 +4 -2
- 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 +8 -4
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +6 -4
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +69 -13
- package/lib/commonjs/components/BottomSheet/index.js +6 -0
- 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/Carousel/Carousel.js +4 -2
- package/lib/commonjs/components/Checkbox/Checkbox.js +14 -5
- package/lib/commonjs/components/DatePicker/DatePicker.js +9 -7
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +5 -2
- package/lib/commonjs/components/Dialog/Dialog.js +2 -2
- package/lib/commonjs/components/FieldBase/FieldBase.js +8 -4
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +13 -5
- package/lib/commonjs/components/FormField/FormField.js +61 -25
- 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/Modal/Modal.js +17 -6
- package/lib/commonjs/components/NumberInput/NumberInput.js +35 -28
- package/lib/commonjs/components/OTPInput/OTPInput.js +33 -18
- package/lib/commonjs/components/Radio/Radio.js +7 -5
- package/lib/commonjs/components/Radio/RadioGroup.js +10 -3
- package/lib/commonjs/components/SearchBar/SearchBar.js +4 -2
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +20 -10
- package/lib/commonjs/components/Select/Select.js +33 -32
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +5 -2
- package/lib/commonjs/components/Slider/Slider.js +42 -26
- package/lib/commonjs/components/Spinner/Spinner.js +5 -5
- package/lib/commonjs/components/Switch/Switch.js +29 -16
- package/lib/commonjs/components/Tabs/Tabs.js +4 -2
- 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 +10 -7
- package/lib/commonjs/components/Toast/Toast.js +22 -10
- package/lib/commonjs/components/Tooltip/Tooltip.js +6 -2
- package/lib/commonjs/components/index.js +141 -89
- 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/module/components/Accordion/Accordion.js +4 -2
- 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 +8 -4
- package/lib/module/components/BottomNavigation/BottomNavigation.js +6 -4
- package/lib/module/components/BottomSheet/BottomSheet.js +68 -13
- package/lib/module/components/BottomSheet/index.js +1 -1
- 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/Carousel/Carousel.js +4 -2
- package/lib/module/components/Checkbox/Checkbox.js +14 -5
- package/lib/module/components/DatePicker/DatePicker.js +9 -7
- package/lib/module/components/DateRangePicker/DateRangePicker.js +5 -2
- package/lib/module/components/Dialog/Dialog.js +2 -2
- package/lib/module/components/FieldBase/FieldBase.js +8 -4
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +13 -5
- package/lib/module/components/FormField/FormField.js +62 -26
- 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/Modal/Modal.js +17 -6
- package/lib/module/components/NumberInput/NumberInput.js +30 -23
- package/lib/module/components/OTPInput/OTPInput.js +30 -15
- package/lib/module/components/Radio/Radio.js +7 -5
- package/lib/module/components/Radio/RadioGroup.js +10 -3
- package/lib/module/components/SearchBar/SearchBar.js +4 -2
- package/lib/module/components/SegmentedControl/SegmentedControl.js +20 -10
- package/lib/module/components/Select/Select.js +33 -32
- package/lib/module/components/Skeleton/SkeletonContent.js +5 -2
- package/lib/module/components/Slider/Slider.js +42 -26
- package/lib/module/components/Spinner/Spinner.js +5 -5
- package/lib/module/components/Switch/Switch.js +29 -16
- package/lib/module/components/Tabs/Tabs.js +4 -2
- 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 +10 -7
- 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 -1
- 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/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +1 -1
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +41 -0
- package/lib/typescript/commonjs/components/BottomSheet/index.d.ts +2 -2
- 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/Checkbox/Checkbox.d.ts +3 -2
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +3 -3
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +2 -2
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +13 -2
- 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/NumberInput/NumberInput.d.ts +3 -2
- package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +3 -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/SegmentedControl/SegmentedControl.d.ts +3 -2
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +6 -4
- package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +1 -1
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -2
- 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 +3 -3
- package/lib/typescript/commonjs/components/index.d.ts +10 -2
- 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 +15 -0
- package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +1 -1
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +41 -0
- package/lib/typescript/module/components/BottomSheet/index.d.ts +2 -2
- 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/Checkbox/Checkbox.d.ts +3 -2
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +3 -3
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +2 -2
- package/lib/typescript/module/components/FormField/FormField.d.ts +13 -2
- 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/NumberInput/NumberInput.d.ts +3 -2
- package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +3 -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/SegmentedControl/SegmentedControl.d.ts +3 -2
- package/lib/typescript/module/components/Slider/Slider.d.ts +6 -4
- package/lib/typescript/module/components/Spinner/Spinner.d.ts +1 -1
- package/lib/typescript/module/components/Switch/Switch.d.ts +3 -2
- 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 +3 -3
- package/lib/typescript/module/components/index.d.ts +10 -2
- 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 +15 -0
- package/package.json +1 -1
|
@@ -114,7 +114,7 @@ const Accordion = props => {
|
|
|
114
114
|
// Skip animation when state matches the previous value (e.g. on mount).
|
|
115
115
|
if (lastExpandedRef.current === expanded) return;
|
|
116
116
|
lastExpandedRef.current = expanded;
|
|
117
|
-
_reactNative.Animated.parallel([_reactNative.Animated.timing(heightAnim, {
|
|
117
|
+
const anim = _reactNative.Animated.parallel([_reactNative.Animated.timing(heightAnim, {
|
|
118
118
|
toValue: expanded ? 1 : 0,
|
|
119
119
|
duration: theme.motion.duration.normal,
|
|
120
120
|
easing: _reactNative.Easing.bezier(...theme.motion.easing.standard),
|
|
@@ -133,7 +133,9 @@ const Accordion = props => {
|
|
|
133
133
|
duration: theme.motion.duration.normal,
|
|
134
134
|
easing: _reactNative.Easing.bezier(...theme.motion.easing.standard),
|
|
135
135
|
useNativeDriver: false
|
|
136
|
-
})])
|
|
136
|
+
})]);
|
|
137
|
+
anim.start();
|
|
138
|
+
return () => anim.stop();
|
|
137
139
|
}, [expanded, heightAnim, opacityAnim, rotateAnim, theme.motion]);
|
|
138
140
|
const onContentLayout = (0, _react.useCallback)(e => {
|
|
139
141
|
const h = e.nativeEvent.layout.height;
|
|
@@ -213,13 +213,15 @@ const AvatarGroupItem = ({
|
|
|
213
213
|
}) => {
|
|
214
214
|
const opacity = (0, _react.useRef)((0, _index.createAnimatedValue)(0)).current;
|
|
215
215
|
(0, _react.useEffect)(() => {
|
|
216
|
-
_reactNative.Animated.timing(opacity, {
|
|
216
|
+
const anim = _reactNative.Animated.timing(opacity, {
|
|
217
217
|
toValue: 1,
|
|
218
218
|
duration: ENTRANCE_DURATION_MS,
|
|
219
219
|
delay,
|
|
220
220
|
easing: _reactNative.Easing.out(_reactNative.Easing.cubic),
|
|
221
221
|
useNativeDriver: true
|
|
222
|
-
})
|
|
222
|
+
});
|
|
223
|
+
anim.start();
|
|
224
|
+
return () => anim.stop();
|
|
223
225
|
}, [delay, opacity]);
|
|
224
226
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
225
227
|
style: [groupStyles.item, {
|
|
@@ -15,22 +15,22 @@ const toneFor = (theme, tone) => {
|
|
|
15
15
|
case 'primary':
|
|
16
16
|
return {
|
|
17
17
|
background: theme.colors.primary,
|
|
18
|
-
text: theme.colors.
|
|
18
|
+
text: theme.colors.onPrimary
|
|
19
19
|
};
|
|
20
20
|
case 'success':
|
|
21
21
|
return {
|
|
22
22
|
background: theme.colors.success,
|
|
23
|
-
text: theme.colors.
|
|
23
|
+
text: theme.colors.onSuccess
|
|
24
24
|
};
|
|
25
25
|
case 'warning':
|
|
26
26
|
return {
|
|
27
27
|
background: theme.colors.warning,
|
|
28
|
-
text: theme.colors.
|
|
28
|
+
text: theme.colors.onWarning
|
|
29
29
|
};
|
|
30
30
|
case 'info':
|
|
31
31
|
return {
|
|
32
32
|
background: theme.colors.info,
|
|
33
|
-
text: theme.colors.
|
|
33
|
+
text: theme.colors.onInfo
|
|
34
34
|
};
|
|
35
35
|
case 'neutral':
|
|
36
36
|
return {
|
|
@@ -41,7 +41,7 @@ const toneFor = (theme, tone) => {
|
|
|
41
41
|
default:
|
|
42
42
|
return {
|
|
43
43
|
background: theme.colors.error,
|
|
44
|
-
text: theme.colors.
|
|
44
|
+
text: theme.colors.onError
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
};
|
|
@@ -44,9 +44,10 @@ const Banner = exports.Banner = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
44
44
|
isFirstRun.current = false;
|
|
45
45
|
if (!animateMount) return;
|
|
46
46
|
}
|
|
47
|
+
let anim;
|
|
47
48
|
if (visible) {
|
|
48
49
|
setMounted(true);
|
|
49
|
-
_reactNative.Animated.parallel([_reactNative.Animated.timing(translateY, {
|
|
50
|
+
anim = _reactNative.Animated.parallel([_reactNative.Animated.timing(translateY, {
|
|
50
51
|
toValue: 0,
|
|
51
52
|
duration: theme.motion.duration.normal,
|
|
52
53
|
useNativeDriver: true
|
|
@@ -54,9 +55,10 @@ const Banner = exports.Banner = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
54
55
|
toValue: 1,
|
|
55
56
|
duration: theme.motion.duration.normal,
|
|
56
57
|
useNativeDriver: true
|
|
57
|
-
})])
|
|
58
|
+
})]);
|
|
59
|
+
anim.start();
|
|
58
60
|
} else if (mounted) {
|
|
59
|
-
_reactNative.Animated.parallel([_reactNative.Animated.timing(translateY, {
|
|
61
|
+
anim = _reactNative.Animated.parallel([_reactNative.Animated.timing(translateY, {
|
|
60
62
|
toValue: -20,
|
|
61
63
|
duration: theme.motion.duration.fast,
|
|
62
64
|
useNativeDriver: true
|
|
@@ -64,10 +66,12 @@ const Banner = exports.Banner = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
64
66
|
toValue: 0,
|
|
65
67
|
duration: theme.motion.duration.fast,
|
|
66
68
|
useNativeDriver: true
|
|
67
|
-
})])
|
|
69
|
+
})]);
|
|
70
|
+
anim.start(() => {
|
|
68
71
|
setMounted(false);
|
|
69
72
|
});
|
|
70
73
|
}
|
|
74
|
+
return () => anim?.stop();
|
|
71
75
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
76
|
}, [visible]);
|
|
73
77
|
if (!mounted) return null;
|
|
@@ -51,7 +51,7 @@ const BottomNavigation = exports.BottomNavigation = /*#__PURE__*/(0, _react.forw
|
|
|
51
51
|
const {
|
|
52
52
|
tabs,
|
|
53
53
|
activeTab,
|
|
54
|
-
|
|
54
|
+
onChange,
|
|
55
55
|
haptic = 'selection',
|
|
56
56
|
showLabels = true,
|
|
57
57
|
variant = 'pill',
|
|
@@ -100,12 +100,14 @@ const BottomNavigation = exports.BottomNavigation = /*#__PURE__*/(0, _react.forw
|
|
|
100
100
|
// this value directly.
|
|
101
101
|
(0, _react.useEffect)(() => {
|
|
102
102
|
if (tabWidth <= 0) return;
|
|
103
|
-
_reactNative.Animated.spring(indicatorTranslateX, {
|
|
103
|
+
const anim = _reactNative.Animated.spring(indicatorTranslateX, {
|
|
104
104
|
toValue: activeIndex * tabWidth,
|
|
105
105
|
tension: 120,
|
|
106
106
|
friction: 14,
|
|
107
107
|
useNativeDriver: true
|
|
108
|
-
})
|
|
108
|
+
});
|
|
109
|
+
anim.start();
|
|
110
|
+
return () => anim.stop();
|
|
109
111
|
}, [activeIndex, tabWidth, indicatorTranslateX]);
|
|
110
112
|
const handleLayout = e => {
|
|
111
113
|
const total = e.nativeEvent.layout.width;
|
|
@@ -130,7 +132,7 @@ const BottomNavigation = exports.BottomNavigation = /*#__PURE__*/(0, _react.forw
|
|
|
130
132
|
useNativeDriver: true
|
|
131
133
|
})]).start();
|
|
132
134
|
}
|
|
133
|
-
|
|
135
|
+
onChange(tab.key);
|
|
134
136
|
};
|
|
135
137
|
const paddingBottom = Math.max(8, insets.bottom);
|
|
136
138
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.BottomSheet = void 0;
|
|
6
|
+
exports.useBottomSheet = exports.default = exports.BottomSheet = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
@@ -32,6 +32,33 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
32
32
|
* ref.current?.close(); // dismiss
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* State + actions exposed to anything rendered inside a `<BottomSheet>` —
|
|
37
|
+
* including the `header` and `footer` slots. Read via `useBottomSheet()`.
|
|
38
|
+
*
|
|
39
|
+
* `snapIndex` is the JS-thread mirror of the current snap point. -1 means the
|
|
40
|
+
* sheet is closed (mid-close-animation included). Use it to drive footer
|
|
41
|
+
* button enable state, conditional headers, etc. If you need per-frame
|
|
42
|
+
* progress (e.g. fade a header in as the sheet expands), reach for the
|
|
43
|
+
* animated value via a future enhancement — not exposed today to keep the
|
|
44
|
+
* surface minimal.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
const BottomSheetContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Access the enclosing `<BottomSheet>`'s state and imperative actions.
|
|
51
|
+
* Must be called from a component rendered inside a `<BottomSheet>` (as
|
|
52
|
+
* `children`, `header`, or `footer`).
|
|
53
|
+
*/
|
|
54
|
+
const useBottomSheet = () => {
|
|
55
|
+
const ctx = (0, _react.useContext)(BottomSheetContext);
|
|
56
|
+
if (!ctx) {
|
|
57
|
+
throw new Error('useBottomSheet must be used inside a <BottomSheet>.');
|
|
58
|
+
}
|
|
59
|
+
return ctx;
|
|
60
|
+
};
|
|
61
|
+
exports.useBottomSheet = useBottomSheet;
|
|
35
62
|
const SPRING_CONFIG = {
|
|
36
63
|
damping: 20,
|
|
37
64
|
stiffness: 240,
|
|
@@ -51,6 +78,10 @@ const BottomSheet = exports.BottomSheet = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
51
78
|
mode = 'modal',
|
|
52
79
|
handleIndicatorStyle,
|
|
53
80
|
containerStyle,
|
|
81
|
+
header,
|
|
82
|
+
footer,
|
|
83
|
+
headerStyle,
|
|
84
|
+
footerStyle,
|
|
54
85
|
children,
|
|
55
86
|
accessibilityLabel,
|
|
56
87
|
accessibilityViewIsModal,
|
|
@@ -73,7 +104,6 @@ const BottomSheet = exports.BottomSheet = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
73
104
|
return () => sub.remove();
|
|
74
105
|
}, []);
|
|
75
106
|
const closedY = screenHeight; // fully off-screen
|
|
76
|
-
const minSnapPoint = resolvedSnapPoints[0] ?? 0;
|
|
77
107
|
const maxSnapPoint = resolvedSnapPoints[resolvedSnapPoints.length - 1] ?? 0;
|
|
78
108
|
|
|
79
109
|
// translateY: 0 = top of screen, screenHeight = fully closed.
|
|
@@ -107,6 +137,13 @@ const BottomSheet = exports.BottomSheet = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
107
137
|
currentIndexShared.value = next;
|
|
108
138
|
onChange?.(next);
|
|
109
139
|
}, [currentIndex, currentIndexShared, onChange]);
|
|
140
|
+
const markAnimationDone = (0, _react.useCallback)(() => {
|
|
141
|
+
isAnimatingRef.current = false;
|
|
142
|
+
// If we just finished a close animation, unmount the sheet wrapper.
|
|
143
|
+
if (currentIndexShared.value < 0) {
|
|
144
|
+
if (mode === 'modal') setModalVisible(false);else setInlineMounted(false);
|
|
145
|
+
}
|
|
146
|
+
}, [mode, currentIndexShared]);
|
|
110
147
|
const animateTo = (0, _react.useCallback)((to, fromIndex, toIndex) => {
|
|
111
148
|
isAnimatingRef.current = true;
|
|
112
149
|
onAnimate?.(fromIndex, toIndex);
|
|
@@ -117,14 +154,7 @@ const BottomSheet = exports.BottomSheet = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
117
154
|
(0, _reactNativeReanimated.runOnJS)(markAnimationDone)();
|
|
118
155
|
}
|
|
119
156
|
});
|
|
120
|
-
}, [onAnimate, translateY]);
|
|
121
|
-
const markAnimationDone = (0, _react.useCallback)(() => {
|
|
122
|
-
isAnimatingRef.current = false;
|
|
123
|
-
// If we just finished a close animation, unmount the sheet wrapper.
|
|
124
|
-
if (currentIndexShared.value < 0) {
|
|
125
|
-
if (mode === 'modal') setModalVisible(false);else setInlineMounted(false);
|
|
126
|
-
}
|
|
127
|
-
}, [mode, currentIndexShared]);
|
|
157
|
+
}, [onAnimate, translateY, markAnimationDone]);
|
|
128
158
|
const expand = (0, _react.useCallback)(idx => {
|
|
129
159
|
const target = typeof idx === 'number' ? clamp(idx, 0, resolvedSnapPoints.length - 1) : currentIndex >= 0 ? currentIndex : 0;
|
|
130
160
|
const fromIndex = currentIndexShared.value;
|
|
@@ -336,6 +366,13 @@ const BottomSheet = exports.BottomSheet = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
336
366
|
if (!success) return;
|
|
337
367
|
(0, _reactNativeReanimated.runOnJS)(handleBackdropPress)();
|
|
338
368
|
}), [handleBackdropPress]);
|
|
369
|
+
const contextValue = (0, _react.useMemo)(() => ({
|
|
370
|
+
snapIndex: currentIndex,
|
|
371
|
+
snapPoints: resolvedSnapPoints,
|
|
372
|
+
expand,
|
|
373
|
+
collapse,
|
|
374
|
+
close
|
|
375
|
+
}), [currentIndex, resolvedSnapPoints, expand, collapse, close]);
|
|
339
376
|
|
|
340
377
|
// Don't render the backdrop / sheet tree when the sheet is fully closed.
|
|
341
378
|
// Inline: gated by `inlineMounted` (set in expand, cleared in
|
|
@@ -389,13 +426,23 @@ const BottomSheet = exports.BottomSheet = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
389
426
|
backgroundColor: theme.components.bottomSheet?.handleColor ?? theme.colors.border.primary
|
|
390
427
|
}, handleIndicatorStyle]
|
|
391
428
|
})
|
|
429
|
+
}), header != null && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
430
|
+
style: [styles.header, headerStyle],
|
|
431
|
+
children: header
|
|
392
432
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
393
433
|
style: styles.content,
|
|
394
434
|
children: children
|
|
435
|
+
}), footer != null && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
436
|
+
style: [styles.footer, footerStyle],
|
|
437
|
+
children: footer
|
|
395
438
|
})]
|
|
396
439
|
})
|
|
397
440
|
})]
|
|
398
441
|
});
|
|
442
|
+
const wrappedTree = /*#__PURE__*/(0, _jsxRuntime.jsx)(BottomSheetContext.Provider, {
|
|
443
|
+
value: contextValue,
|
|
444
|
+
children: sheetTree
|
|
445
|
+
});
|
|
399
446
|
if (mode === 'modal') {
|
|
400
447
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
|
|
401
448
|
transparent: true,
|
|
@@ -410,11 +457,11 @@ const BottomSheet = exports.BottomSheet = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
410
457
|
supportedOrientations: ['portrait', 'landscape'],
|
|
411
458
|
children: _reactNative.Platform.OS === 'android' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView, {
|
|
412
459
|
style: styles.modalRoot,
|
|
413
|
-
children:
|
|
414
|
-
}) :
|
|
460
|
+
children: wrappedTree
|
|
461
|
+
}) : wrappedTree
|
|
415
462
|
});
|
|
416
463
|
}
|
|
417
|
-
return
|
|
464
|
+
return wrappedTree;
|
|
418
465
|
});
|
|
419
466
|
BottomSheet.displayName = 'BottomSheet';
|
|
420
467
|
|
|
@@ -459,6 +506,15 @@ const buildStyles = _theme => _reactNative.StyleSheet.create({
|
|
|
459
506
|
paddingTop: 10,
|
|
460
507
|
paddingBottom: 8
|
|
461
508
|
},
|
|
509
|
+
header: {
|
|
510
|
+
// No opinionated padding — slot owns its own styling. Sits between the
|
|
511
|
+
// drag handle and the scrollable content; does not flex.
|
|
512
|
+
},
|
|
513
|
+
footer: {
|
|
514
|
+
// Pinned to the bottom of the sheet (above safe-area inset, which lives
|
|
515
|
+
// on the sheet's paddingBottom). Does not flex, does not scroll with
|
|
516
|
+
// content. Rides with the keyboard via the sheet's `top` animation.
|
|
517
|
+
},
|
|
462
518
|
handle: {
|
|
463
519
|
width: 36,
|
|
464
520
|
height: 4,
|
|
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "default", {
|
|
|
15
15
|
return _BottomSheet.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "useBottomSheet", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _BottomSheet.useBottomSheet;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
var _BottomSheet = _interopRequireWildcard(require("./BottomSheet.js"));
|
|
19
25
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveBoxStyle = exports.default = exports.Stack = exports.Spacer = exports.Row = exports.Box = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _index = require("../../theme/index.js");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
const space = (theme, token) => token == null ? undefined : theme.spacing[token];
|
|
13
|
+
const resolveBoxStyle = (theme, p) => {
|
|
14
|
+
const style = {};
|
|
15
|
+
if (p.p != null) style.padding = space(theme, p.p);
|
|
16
|
+
if (p.px != null) style.paddingHorizontal = space(theme, p.px);
|
|
17
|
+
if (p.py != null) style.paddingVertical = space(theme, p.py);
|
|
18
|
+
if (p.pt != null) style.paddingTop = space(theme, p.pt);
|
|
19
|
+
if (p.pr != null) style.paddingRight = space(theme, p.pr);
|
|
20
|
+
if (p.pb != null) style.paddingBottom = space(theme, p.pb);
|
|
21
|
+
if (p.pl != null) style.paddingLeft = space(theme, p.pl);
|
|
22
|
+
if (p.m != null) style.margin = space(theme, p.m);
|
|
23
|
+
if (p.mx != null) style.marginHorizontal = space(theme, p.mx);
|
|
24
|
+
if (p.my != null) style.marginVertical = space(theme, p.my);
|
|
25
|
+
if (p.mt != null) style.marginTop = space(theme, p.mt);
|
|
26
|
+
if (p.mr != null) style.marginRight = space(theme, p.mr);
|
|
27
|
+
if (p.mb != null) style.marginBottom = space(theme, p.mb);
|
|
28
|
+
if (p.ml != null) style.marginLeft = space(theme, p.ml);
|
|
29
|
+
if (p.gap != null) style.gap = space(theme, p.gap);
|
|
30
|
+
if (p.bg != null) {
|
|
31
|
+
const bgTokens = theme.colors.background;
|
|
32
|
+
style.backgroundColor = bgTokens[p.bg] ?? p.bg;
|
|
33
|
+
}
|
|
34
|
+
if (p.radius != null) style.borderRadius = theme.radius[p.radius];
|
|
35
|
+
if (p.border) {
|
|
36
|
+
style.borderWidth = theme.colors.border.width;
|
|
37
|
+
style.borderColor = theme.colors.border.primary;
|
|
38
|
+
}
|
|
39
|
+
if (p.flex != null) style.flex = p.flex;
|
|
40
|
+
if (p.align != null) style.alignItems = p.align;
|
|
41
|
+
if (p.justify != null) style.justifyContent = p.justify;
|
|
42
|
+
if (p.direction != null) style.flexDirection = p.direction;
|
|
43
|
+
if (p.wrap) style.flexWrap = 'wrap';
|
|
44
|
+
return style;
|
|
45
|
+
};
|
|
46
|
+
exports.resolveBoxStyle = resolveBoxStyle;
|
|
47
|
+
const Box = exports.Box = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
48
|
+
const theme = (0, _index.useTheme)();
|
|
49
|
+
const {
|
|
50
|
+
// layout props consumed by the resolver — kept out of the View spread
|
|
51
|
+
p,
|
|
52
|
+
px,
|
|
53
|
+
py,
|
|
54
|
+
pt,
|
|
55
|
+
pr,
|
|
56
|
+
pb,
|
|
57
|
+
pl,
|
|
58
|
+
m,
|
|
59
|
+
mx,
|
|
60
|
+
my,
|
|
61
|
+
mt,
|
|
62
|
+
mr,
|
|
63
|
+
mb,
|
|
64
|
+
ml,
|
|
65
|
+
gap,
|
|
66
|
+
bg,
|
|
67
|
+
radius,
|
|
68
|
+
border,
|
|
69
|
+
flex,
|
|
70
|
+
align,
|
|
71
|
+
justify,
|
|
72
|
+
direction,
|
|
73
|
+
wrap,
|
|
74
|
+
style,
|
|
75
|
+
children,
|
|
76
|
+
...viewProps
|
|
77
|
+
} = props;
|
|
78
|
+
const boxStyle = resolveBoxStyle(theme, {
|
|
79
|
+
p,
|
|
80
|
+
px,
|
|
81
|
+
py,
|
|
82
|
+
pt,
|
|
83
|
+
pr,
|
|
84
|
+
pb,
|
|
85
|
+
pl,
|
|
86
|
+
m,
|
|
87
|
+
mx,
|
|
88
|
+
my,
|
|
89
|
+
mt,
|
|
90
|
+
mr,
|
|
91
|
+
mb,
|
|
92
|
+
ml,
|
|
93
|
+
gap,
|
|
94
|
+
bg,
|
|
95
|
+
radius,
|
|
96
|
+
border,
|
|
97
|
+
flex,
|
|
98
|
+
align,
|
|
99
|
+
justify,
|
|
100
|
+
direction,
|
|
101
|
+
wrap
|
|
102
|
+
});
|
|
103
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
104
|
+
ref: ref,
|
|
105
|
+
style: [boxStyle, style],
|
|
106
|
+
...viewProps,
|
|
107
|
+
children: children
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
Box.displayName = 'Box';
|
|
111
|
+
/** Vertical flex container with token spacing between children (default gap `md`). */
|
|
112
|
+
const Stack = exports.Stack = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
113
|
+
gap = 'md',
|
|
114
|
+
...rest
|
|
115
|
+
}, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Box, {
|
|
116
|
+
ref: ref,
|
|
117
|
+
direction: "column",
|
|
118
|
+
gap: gap,
|
|
119
|
+
...rest
|
|
120
|
+
}));
|
|
121
|
+
Stack.displayName = 'Stack';
|
|
122
|
+
/** Horizontal flex container (default `align="center"`, gap `sm`). */
|
|
123
|
+
const Row = exports.Row = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
124
|
+
gap = 'sm',
|
|
125
|
+
align = 'center',
|
|
126
|
+
...rest
|
|
127
|
+
}, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Box, {
|
|
128
|
+
ref: ref,
|
|
129
|
+
direction: "row",
|
|
130
|
+
gap: gap,
|
|
131
|
+
align: align,
|
|
132
|
+
...rest
|
|
133
|
+
}));
|
|
134
|
+
Row.displayName = 'Row';
|
|
135
|
+
/** Fixed gap (`size`) or a flexible push (`flex: 1`) between siblings. */
|
|
136
|
+
const Spacer = ({
|
|
137
|
+
size,
|
|
138
|
+
style,
|
|
139
|
+
testID
|
|
140
|
+
}) => {
|
|
141
|
+
const theme = (0, _index.useTheme)();
|
|
142
|
+
if (size != null) {
|
|
143
|
+
const value = theme.spacing[size];
|
|
144
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
145
|
+
testID: testID,
|
|
146
|
+
style: [{
|
|
147
|
+
width: value,
|
|
148
|
+
height: value
|
|
149
|
+
}, style]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
153
|
+
testID: testID,
|
|
154
|
+
style: [{
|
|
155
|
+
flex: 1
|
|
156
|
+
}, style]
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
exports.Spacer = Spacer;
|
|
160
|
+
Spacer.displayName = 'Spacer';
|
|
161
|
+
var _default = exports.default = Box;
|
|
162
|
+
//# sourceMappingURL=Box.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Box", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Box.Box;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Row", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Box.Row;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "Spacer", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _Box.Spacer;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "Stack", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _Box.Stack;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "resolveBoxStyle", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _Box.resolveBoxStyle;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _Box = require("./Box.js");
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -72,7 +72,7 @@ const Button = exports.Button = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
72
72
|
style: styles.contentRow,
|
|
73
73
|
children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Spinner, {
|
|
74
74
|
variant: "circular",
|
|
75
|
-
size: "
|
|
75
|
+
size: "sm",
|
|
76
76
|
color: variantStyles.textColor,
|
|
77
77
|
accessibilityLabel: "Loading"
|
|
78
78
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
@@ -189,7 +189,7 @@ const toneFor = (theme, tone) => {
|
|
|
189
189
|
base: theme.colors.primary,
|
|
190
190
|
hover: theme.colors.primaryHover,
|
|
191
191
|
pressed: theme.colors.primaryPressed,
|
|
192
|
-
on: theme.colors.
|
|
192
|
+
on: theme.colors.onPrimary,
|
|
193
193
|
muted: theme.colors.primaryMuted
|
|
194
194
|
};
|
|
195
195
|
case 'secondary':
|
|
@@ -197,7 +197,7 @@ const toneFor = (theme, tone) => {
|
|
|
197
197
|
base: theme.colors.secondary,
|
|
198
198
|
hover: theme.colors.secondaryHover,
|
|
199
199
|
pressed: theme.colors.secondaryHover,
|
|
200
|
-
on: theme.colors.
|
|
200
|
+
on: theme.colors.onSecondary,
|
|
201
201
|
muted: theme.colors.secondary
|
|
202
202
|
};
|
|
203
203
|
case 'success':
|
|
@@ -205,7 +205,7 @@ const toneFor = (theme, tone) => {
|
|
|
205
205
|
base: theme.colors.success,
|
|
206
206
|
hover: theme.colors.success,
|
|
207
207
|
pressed: theme.colors.success,
|
|
208
|
-
on: theme.colors.
|
|
208
|
+
on: theme.colors.onSuccess,
|
|
209
209
|
muted: theme.colors.background.secondary
|
|
210
210
|
};
|
|
211
211
|
case 'warning':
|
|
@@ -213,15 +213,15 @@ const toneFor = (theme, tone) => {
|
|
|
213
213
|
base: theme.colors.warning,
|
|
214
214
|
hover: theme.colors.warning,
|
|
215
215
|
pressed: theme.colors.warning,
|
|
216
|
-
on: theme.colors.
|
|
216
|
+
on: theme.colors.onWarning,
|
|
217
217
|
muted: theme.colors.background.secondary
|
|
218
218
|
};
|
|
219
|
-
case '
|
|
219
|
+
case 'error':
|
|
220
220
|
return {
|
|
221
221
|
base: theme.colors.error,
|
|
222
222
|
hover: theme.colors.error,
|
|
223
223
|
pressed: theme.colors.error,
|
|
224
|
-
on: theme.colors.
|
|
224
|
+
on: theme.colors.onError,
|
|
225
225
|
muted: theme.colors.background.secondary
|
|
226
226
|
};
|
|
227
227
|
case 'neutral':
|
|
@@ -442,12 +442,14 @@ const ThumbnailItem = ({
|
|
|
442
442
|
}) => {
|
|
443
443
|
const scale = (0, _react.useRef)((0, _index.createAnimatedValue)(isActive ? 1.1 : 1)).current;
|
|
444
444
|
(0, _react.useEffect)(() => {
|
|
445
|
-
_reactNative.Animated.spring(scale, {
|
|
445
|
+
const anim = _reactNative.Animated.spring(scale, {
|
|
446
446
|
toValue: isActive ? 1.1 : 1,
|
|
447
447
|
useNativeDriver: true,
|
|
448
448
|
friction: 6,
|
|
449
449
|
tension: 80
|
|
450
|
-
})
|
|
450
|
+
});
|
|
451
|
+
anim.start();
|
|
452
|
+
return () => anim.stop();
|
|
451
453
|
}, [isActive, scale]);
|
|
452
454
|
const content = (0, _react.useMemo)(() => {
|
|
453
455
|
if (renderThumbnail) return renderThumbnail(item, index);
|
|
@@ -7,6 +7,7 @@ exports.default = exports.Checkbox = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _index = require("../../theme/index.js");
|
|
10
|
+
var _index2 = require("../../hooks/index.js");
|
|
10
11
|
var _hapticUtils = require("../../utils/hapticUtils.js");
|
|
11
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -31,6 +32,7 @@ const toneColor = (theme, tone) => {
|
|
|
31
32
|
const Checkbox = exports.Checkbox = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
32
33
|
const {
|
|
33
34
|
checked,
|
|
35
|
+
defaultChecked,
|
|
34
36
|
onChange,
|
|
35
37
|
indeterminate = false,
|
|
36
38
|
disabled = false,
|
|
@@ -48,22 +50,29 @@ const Checkbox = exports.Checkbox = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
48
50
|
testID,
|
|
49
51
|
...rest
|
|
50
52
|
} = props;
|
|
53
|
+
const [current, setCurrent] = (0, _index2.useControllableState)({
|
|
54
|
+
value: checked,
|
|
55
|
+
defaultValue: defaultChecked ?? false,
|
|
56
|
+
onChange
|
|
57
|
+
});
|
|
51
58
|
const theme = (0, _index.useTheme)();
|
|
52
59
|
const styles = (0, _react.useMemo)(() => buildStyles(theme), [theme]);
|
|
53
60
|
const boxSize = theme.components.checkbox?.[size]?.boxSize ?? sizeMap[size];
|
|
54
61
|
const checkboxBorderWidth = theme.colors.border.width;
|
|
55
62
|
const checkboxLabelGap = theme.components.checkbox?.labelGap ?? 10;
|
|
56
63
|
const fillColor = toneColor(theme, tone);
|
|
57
|
-
const isActive =
|
|
64
|
+
const isActive = current || indeterminate;
|
|
58
65
|
const progress = (0, _react.useRef)((0, _index.createAnimatedValue)(isActive ? 1 : 0)).current;
|
|
59
66
|
(0, _react.useEffect)(() => {
|
|
60
|
-
_reactNative.Animated.spring(progress, {
|
|
67
|
+
const anim = _reactNative.Animated.spring(progress, {
|
|
61
68
|
toValue: isActive ? 1 : 0,
|
|
62
69
|
damping: theme.motion.spring.snappy.damping,
|
|
63
70
|
stiffness: theme.motion.spring.snappy.stiffness,
|
|
64
71
|
mass: theme.motion.spring.snappy.mass,
|
|
65
72
|
useNativeDriver: true
|
|
66
|
-
})
|
|
73
|
+
});
|
|
74
|
+
anim.start();
|
|
75
|
+
return () => anim.stop();
|
|
67
76
|
}, [isActive, progress, theme.motion.spring.snappy]);
|
|
68
77
|
const scale = progress.interpolate({
|
|
69
78
|
inputRange: [0, 1],
|
|
@@ -72,7 +81,7 @@ const Checkbox = exports.Checkbox = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
72
81
|
const handlePress = event => {
|
|
73
82
|
if (disabled) return;
|
|
74
83
|
if (haptic !== false && theme.components.checkbox?.pressHaptic) (0, _hapticUtils.triggerHaptic)(haptic);
|
|
75
|
-
|
|
84
|
+
setCurrent(!current);
|
|
76
85
|
rest.onPressOut?.(event);
|
|
77
86
|
};
|
|
78
87
|
const accessibleLabel = accessibilityLabel ?? label;
|
|
@@ -89,7 +98,7 @@ const Checkbox = exports.Checkbox = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
89
98
|
accessibilityRole: "checkbox",
|
|
90
99
|
accessibilityLabel: accessibleLabel,
|
|
91
100
|
accessibilityState: {
|
|
92
|
-
checked: indeterminate ? 'mixed' :
|
|
101
|
+
checked: indeterminate ? 'mixed' : current,
|
|
93
102
|
disabled
|
|
94
103
|
},
|
|
95
104
|
testID: testID,
|