@webority-technologies/mobile 0.0.23 → 0.0.25
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 +5 -5
- 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/Autocomplete/Autocomplete.js +204 -0
- package/lib/commonjs/components/Autocomplete/index.js +13 -0
- package/lib/commonjs/components/Banner/Banner.js +12 -2
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/commonjs/components/Card/Card.js +3 -3
- package/lib/commonjs/components/Checkbox/Checkbox.js +3 -2
- package/lib/commonjs/components/Chip/Chip.js +4 -2
- package/lib/commonjs/components/Confetti/Confetti.js +170 -0
- package/lib/commonjs/components/Confetti/index.js +13 -0
- package/lib/commonjs/components/DatePicker/DatePicker.js +23 -18
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +11 -9
- package/lib/commonjs/components/Dialog/Dialog.js +4 -2
- package/lib/commonjs/components/Drawer/Drawer.js +4 -2
- package/lib/commonjs/components/FieldBase/FieldBase.js +0 -2
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +10 -8
- package/lib/commonjs/components/IconButton/IconButton.js +176 -0
- package/lib/commonjs/components/IconButton/index.js +13 -0
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +17 -15
- package/lib/commonjs/components/ListItem/ListItem.js +4 -3
- package/lib/commonjs/components/Modal/Modal.js +4 -4
- package/lib/commonjs/components/NumberInput/NumberInput.js +7 -5
- package/lib/commonjs/components/OTPInput/OTPInput.js +7 -7
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +32 -4
- package/lib/commonjs/components/Radio/Radio.js +2 -3
- package/lib/commonjs/components/Rating/Rating.js +4 -3
- package/lib/commonjs/components/SearchBar/SearchBar.js +7 -4
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +4 -3
- package/lib/commonjs/components/Select/Select.js +7 -4
- package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +224 -0
- package/lib/commonjs/components/SlideToConfirm/index.js +13 -0
- package/lib/commonjs/components/Slider/Slider.js +228 -228
- package/lib/commonjs/components/Stepper/Stepper.js +6 -5
- package/lib/commonjs/components/Swipeable/Swipeable.js +8 -9
- package/lib/commonjs/components/Tabs/Tabs.js +4 -3
- package/lib/commonjs/components/TimePicker/TimePicker.js +14 -9
- package/lib/commonjs/components/index.js +149 -114
- package/lib/commonjs/hooks/usePressAnimation.js +0 -1
- package/lib/commonjs/utils/hapticUtils.js +11 -1
- package/lib/commonjs/utils/index.js +6 -0
- package/lib/module/components/Accordion/Accordion.js +6 -6
- 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/Autocomplete/Autocomplete.js +199 -0
- package/lib/module/components/Autocomplete/index.js +4 -0
- package/lib/module/components/Banner/Banner.js +12 -2
- package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/module/components/Card/Card.js +4 -4
- package/lib/module/components/Checkbox/Checkbox.js +4 -3
- package/lib/module/components/Chip/Chip.js +5 -3
- package/lib/module/components/Confetti/Confetti.js +166 -0
- package/lib/module/components/Confetti/index.js +4 -0
- package/lib/module/components/DatePicker/DatePicker.js +24 -19
- package/lib/module/components/DateRangePicker/DateRangePicker.js +12 -10
- package/lib/module/components/Dialog/Dialog.js +5 -3
- package/lib/module/components/Drawer/Drawer.js +5 -3
- package/lib/module/components/FieldBase/FieldBase.js +0 -2
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +11 -9
- package/lib/module/components/IconButton/IconButton.js +172 -0
- package/lib/module/components/IconButton/index.js +4 -0
- package/lib/module/components/ImageGallery/ImageGallery.js +18 -16
- package/lib/module/components/ListItem/ListItem.js +5 -4
- package/lib/module/components/Modal/Modal.js +5 -5
- package/lib/module/components/NumberInput/NumberInput.js +8 -6
- package/lib/module/components/OTPInput/OTPInput.js +8 -8
- package/lib/module/components/ProgressBar/ProgressBar.js +33 -5
- package/lib/module/components/Radio/Radio.js +3 -4
- package/lib/module/components/Rating/Rating.js +5 -4
- package/lib/module/components/SearchBar/SearchBar.js +8 -5
- package/lib/module/components/SegmentedControl/SegmentedControl.js +5 -4
- package/lib/module/components/Select/Select.js +8 -5
- package/lib/module/components/SlideToConfirm/SlideToConfirm.js +220 -0
- package/lib/module/components/SlideToConfirm/index.js +4 -0
- package/lib/module/components/Slider/Slider.js +231 -231
- package/lib/module/components/Stepper/Stepper.js +7 -6
- package/lib/module/components/Swipeable/Swipeable.js +9 -10
- package/lib/module/components/Tabs/Tabs.js +5 -4
- package/lib/module/components/TimePicker/TimePicker.js +15 -10
- package/lib/module/components/index.js +5 -0
- package/lib/module/hooks/usePressAnimation.js +0 -1
- 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/Autocomplete/Autocomplete.d.ts +53 -0
- package/lib/typescript/commonjs/components/Autocomplete/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +3 -0
- package/lib/typescript/commonjs/components/Card/Card.d.ts +3 -0
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +1 -0
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +3 -0
- package/lib/typescript/commonjs/components/Confetti/Confetti.d.ts +41 -0
- package/lib/typescript/commonjs/components/Confetti/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +3 -0
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +6 -0
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +3 -0
- 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/IconButton/IconButton.d.ts +34 -0
- package/lib/typescript/commonjs/components/IconButton/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +6 -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 +3 -0
- package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +6 -0
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +12 -0
- package/lib/typescript/commonjs/components/ProgressBar/index.d.ts +1 -1
- 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 +3 -0
- package/lib/typescript/commonjs/components/Select/Select.d.ts +6 -0
- package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +34 -0
- package/lib/typescript/commonjs/components/SlideToConfirm/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +3 -0
- 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/Tabs/Tabs.d.ts +3 -0
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +3 -0
- package/lib/typescript/commonjs/components/index.d.ts +11 -1
- package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +1 -2
- package/lib/typescript/commonjs/theme/types.d.ts +2 -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/Autocomplete/Autocomplete.d.ts +53 -0
- package/lib/typescript/module/components/Autocomplete/index.d.ts +3 -0
- package/lib/typescript/module/components/Banner/Banner.d.ts +3 -0
- package/lib/typescript/module/components/Card/Card.d.ts +3 -0
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +1 -0
- package/lib/typescript/module/components/Chip/Chip.d.ts +3 -0
- package/lib/typescript/module/components/Confetti/Confetti.d.ts +41 -0
- package/lib/typescript/module/components/Confetti/index.d.ts +3 -0
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +3 -0
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +6 -0
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +3 -0
- 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/IconButton/IconButton.d.ts +34 -0
- package/lib/typescript/module/components/IconButton/index.d.ts +3 -0
- package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +6 -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 +3 -0
- package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +6 -0
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +12 -0
- package/lib/typescript/module/components/ProgressBar/index.d.ts +1 -1
- 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 +3 -0
- package/lib/typescript/module/components/Select/Select.d.ts +6 -0
- package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +34 -0
- package/lib/typescript/module/components/SlideToConfirm/index.d.ts +3 -0
- package/lib/typescript/module/components/Slider/Slider.d.ts +3 -0
- 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/Tabs/Tabs.d.ts +3 -0
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +3 -0
- package/lib/typescript/module/components/index.d.ts +11 -1
- package/lib/typescript/module/hooks/usePressAnimation.d.ts +1 -2
- package/lib/typescript/module/theme/types.d.ts +2 -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
|
@@ -96,7 +96,8 @@ const Accordion = props => {
|
|
|
96
96
|
contentWrapperStyle,
|
|
97
97
|
containerStyle,
|
|
98
98
|
testID,
|
|
99
|
-
loading = false
|
|
99
|
+
loading = false,
|
|
100
|
+
haptic
|
|
100
101
|
} = props;
|
|
101
102
|
const theme = (0, _index.useTheme)();
|
|
102
103
|
const styles = (0, _react.useMemo)(() => buildStyles(theme), [theme]);
|
|
@@ -143,9 +144,8 @@ const Accordion = props => {
|
|
|
143
144
|
}, [measuredHeight]);
|
|
144
145
|
const handlePress = (0, _react.useCallback)(() => {
|
|
145
146
|
if (disabled) return;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
147
|
+
const h = (0, _hapticUtils.resolveHaptic)(haptic, 'selection');
|
|
148
|
+
if (h) (0, _hapticUtils.triggerHaptic)(h);
|
|
149
149
|
if (group && id) {
|
|
150
150
|
group.toggle(id);
|
|
151
151
|
onChange?.(!expanded);
|
|
@@ -153,7 +153,7 @@ const Accordion = props => {
|
|
|
153
153
|
}
|
|
154
154
|
if (!isControlled) setInternalExpanded(!expanded);
|
|
155
155
|
onChange?.(!expanded);
|
|
156
|
-
}, [disabled, group, id, expanded, isControlled, onChange,
|
|
156
|
+
}, [disabled, group, id, expanded, isControlled, onChange, haptic]);
|
|
157
157
|
const rotate = rotateAnim.interpolate({
|
|
158
158
|
inputRange: [0, 1],
|
|
159
159
|
outputRange: ['0deg', '180deg']
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.AnimatePresence = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
9
|
+
var _index = require("../../theme/index.js");
|
|
10
|
+
var _index2 = require("../../hooks/index.js");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
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); }
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
/**
|
|
15
|
+
* Animates a single child in on mount and out on unmount. Thin, theme-aware
|
|
16
|
+
* wrapper over Reanimated's `entering`/`exiting` — Reanimated keeps the view
|
|
17
|
+
* alive to play the exit, so the parent only toggles a condition. Honors the OS
|
|
18
|
+
* Reduce Motion setting (renders instantly when reduced).
|
|
19
|
+
*
|
|
20
|
+
* For animating items inside a list, use Reanimated's `itemLayoutAnimation`
|
|
21
|
+
* on `Animated.FlatList` instead — this wrapper targets single conditional nodes.
|
|
22
|
+
*/
|
|
23
|
+
const AnimatePresence = ({
|
|
24
|
+
children,
|
|
25
|
+
preset = 'fade',
|
|
26
|
+
duration,
|
|
27
|
+
style,
|
|
28
|
+
testID
|
|
29
|
+
}) => {
|
|
30
|
+
const theme = (0, _index.useTheme)();
|
|
31
|
+
const reduceMotion = (0, _index2.useReducedMotion)();
|
|
32
|
+
const visible = children !== null && children !== undefined && children !== false;
|
|
33
|
+
if (!visible) return null;
|
|
34
|
+
const dur = duration ?? theme.motion.duration.normal;
|
|
35
|
+
let entering;
|
|
36
|
+
let exiting;
|
|
37
|
+
if (!reduceMotion) {
|
|
38
|
+
switch (preset) {
|
|
39
|
+
case 'scale':
|
|
40
|
+
entering = _reactNativeReanimated.ZoomIn.duration(dur);
|
|
41
|
+
exiting = _reactNativeReanimated.ZoomOut.duration(dur);
|
|
42
|
+
break;
|
|
43
|
+
case 'slide-up':
|
|
44
|
+
entering = _reactNativeReanimated.FadeInUp.duration(dur);
|
|
45
|
+
exiting = _reactNativeReanimated.FadeOutDown.duration(dur);
|
|
46
|
+
break;
|
|
47
|
+
case 'slide-down':
|
|
48
|
+
entering = _reactNativeReanimated.FadeInDown.duration(dur);
|
|
49
|
+
exiting = _reactNativeReanimated.FadeOutUp.duration(dur);
|
|
50
|
+
break;
|
|
51
|
+
case 'fade':
|
|
52
|
+
default:
|
|
53
|
+
entering = _reactNativeReanimated.FadeIn.duration(dur);
|
|
54
|
+
exiting = _reactNativeReanimated.FadeOut.duration(dur);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
59
|
+
entering: entering,
|
|
60
|
+
exiting: exiting,
|
|
61
|
+
style: style,
|
|
62
|
+
testID: testID,
|
|
63
|
+
children: children
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
exports.AnimatePresence = AnimatePresence;
|
|
67
|
+
AnimatePresence.displayName = 'AnimatePresence';
|
|
68
|
+
var _default = exports.default = AnimatePresence;
|
|
69
|
+
//# sourceMappingURL=AnimatePresence.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AnimatePresence", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _AnimatePresence.AnimatePresence;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _AnimatePresence = require("./AnimatePresence.js");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -41,7 +41,8 @@ const variantSize = (theme, variant) => {
|
|
|
41
41
|
const ActionButton = ({
|
|
42
42
|
action,
|
|
43
43
|
side,
|
|
44
|
-
badgeStyle
|
|
44
|
+
badgeStyle,
|
|
45
|
+
haptic
|
|
45
46
|
}) => {
|
|
46
47
|
const theme = (0, _index.useTheme)();
|
|
47
48
|
const {
|
|
@@ -53,9 +54,8 @@ const ActionButton = ({
|
|
|
53
54
|
});
|
|
54
55
|
const styles = (0, _react.useMemo)(() => buildActionStyles(theme), [theme]);
|
|
55
56
|
const onPress = () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
57
|
+
const h = (0, _hapticUtils.resolveHaptic)(haptic, 'selection');
|
|
58
|
+
if (h) (0, _hapticUtils.triggerHaptic)(h);
|
|
59
59
|
action.onPress();
|
|
60
60
|
};
|
|
61
61
|
const badgeValue = action.badge;
|
|
@@ -113,6 +113,7 @@ const AppBar = exports.AppBar = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
113
113
|
titleStyle,
|
|
114
114
|
subtitleStyle,
|
|
115
115
|
badgeStyle,
|
|
116
|
+
haptic,
|
|
116
117
|
testID
|
|
117
118
|
} = props;
|
|
118
119
|
const theme = (0, _index.useTheme)();
|
|
@@ -230,7 +231,8 @@ const AppBar = exports.AppBar = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
230
231
|
style: styles.sideSlot,
|
|
231
232
|
children: leftAction ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionButton, {
|
|
232
233
|
action: leftAction,
|
|
233
|
-
side: "left"
|
|
234
|
+
side: "left",
|
|
235
|
+
haptic: haptic
|
|
234
236
|
}) : null
|
|
235
237
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
236
238
|
style: [styles.center, titleAlignment === 'center' ? styles.centerAligned : styles.centerLeft],
|
|
@@ -240,7 +242,8 @@ const AppBar = exports.AppBar = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
240
242
|
children: rightActions?.map((action, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionButton, {
|
|
241
243
|
action: action,
|
|
242
244
|
side: "right",
|
|
243
|
-
badgeStyle: badgeStyle
|
|
245
|
+
badgeStyle: badgeStyle,
|
|
246
|
+
haptic: haptic
|
|
244
247
|
}, `appbar-right-${index}`))
|
|
245
248
|
})]
|
|
246
249
|
})]
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Autocomplete = Autocomplete;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _index = require("../../theme/index.js");
|
|
11
|
+
var _index2 = require("../../utils/index.js");
|
|
12
|
+
var _index3 = require("../../hooks/index.js");
|
|
13
|
+
var _index4 = require("../Input/index.js");
|
|
14
|
+
var _index5 = require("../Spinner/index.js");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
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); }
|
|
17
|
+
const defaultGetLabel = o => typeof o === 'string' ? o : String(o);
|
|
18
|
+
function Autocomplete(props) {
|
|
19
|
+
const {
|
|
20
|
+
options,
|
|
21
|
+
value,
|
|
22
|
+
defaultValue,
|
|
23
|
+
onChangeText,
|
|
24
|
+
onSelect,
|
|
25
|
+
getOptionLabel,
|
|
26
|
+
getOptionKey,
|
|
27
|
+
filter,
|
|
28
|
+
minChars = 1,
|
|
29
|
+
maxResults = 8,
|
|
30
|
+
emptyText = 'No matches',
|
|
31
|
+
loading = false,
|
|
32
|
+
filterMode = 'client',
|
|
33
|
+
loadingText = 'Searching…',
|
|
34
|
+
placeholder,
|
|
35
|
+
label,
|
|
36
|
+
error,
|
|
37
|
+
helperText,
|
|
38
|
+
disabled = false,
|
|
39
|
+
size = 'md',
|
|
40
|
+
variant,
|
|
41
|
+
haptic,
|
|
42
|
+
style,
|
|
43
|
+
listStyle,
|
|
44
|
+
optionTextStyle,
|
|
45
|
+
testID
|
|
46
|
+
} = props;
|
|
47
|
+
const theme = (0, _index.useTheme)();
|
|
48
|
+
const styles = (0, _react.useMemo)(() => buildStyles(theme), [theme]);
|
|
49
|
+
const [text, setText] = (0, _index3.useControllableState)({
|
|
50
|
+
value,
|
|
51
|
+
defaultValue: defaultValue ?? '',
|
|
52
|
+
onChange: onChangeText
|
|
53
|
+
});
|
|
54
|
+
const [focused, setFocused] = (0, _react.useState)(false);
|
|
55
|
+
const [fieldHeight, setFieldHeight] = (0, _react.useState)(0);
|
|
56
|
+
const blurTimer = (0, _react.useRef)(null);
|
|
57
|
+
const labelOf = (0, _react.useCallback)(o => getOptionLabel ? getOptionLabel(o) : defaultGetLabel(o), [getOptionLabel]);
|
|
58
|
+
const filtered = (0, _react.useMemo)(() => {
|
|
59
|
+
// Server-side search: trust the provided options, don't re-filter them away.
|
|
60
|
+
if (filterMode === 'none') return options.slice(0, maxResults);
|
|
61
|
+
const q = text.trim();
|
|
62
|
+
if (q.length < minChars) return [];
|
|
63
|
+
const lower = q.toLowerCase();
|
|
64
|
+
const match = filter ? o => filter(o, q) : o => labelOf(o).toLowerCase().includes(lower);
|
|
65
|
+
return options.filter(match).slice(0, maxResults);
|
|
66
|
+
}, [options, text, minChars, maxResults, filter, labelOf, filterMode]);
|
|
67
|
+
const showList = focused && (loading || text.trim().length >= minChars);
|
|
68
|
+
const handleSelect = (0, _react.useCallback)(o => {
|
|
69
|
+
const h = (0, _index2.resolveHaptic)(haptic, 'selection');
|
|
70
|
+
if (h) (0, _index2.triggerHaptic)(h);
|
|
71
|
+
if (blurTimer.current) clearTimeout(blurTimer.current);
|
|
72
|
+
setText(labelOf(o));
|
|
73
|
+
setFocused(false);
|
|
74
|
+
_reactNative.Keyboard.dismiss();
|
|
75
|
+
onSelect(o);
|
|
76
|
+
}, [haptic, setText, labelOf, onSelect]);
|
|
77
|
+
_react.default.useEffect(() => () => {
|
|
78
|
+
if (blurTimer.current) clearTimeout(blurTimer.current);
|
|
79
|
+
}, []);
|
|
80
|
+
const onFieldLayout = (0, _react.useCallback)(e => {
|
|
81
|
+
setFieldHeight(e.nativeEvent.layout.height);
|
|
82
|
+
}, []);
|
|
83
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
84
|
+
style: [styles.container, style],
|
|
85
|
+
testID: testID,
|
|
86
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
87
|
+
onLayout: onFieldLayout,
|
|
88
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index4.Input, {
|
|
89
|
+
value: text,
|
|
90
|
+
onChangeText: setText,
|
|
91
|
+
onFocus: () => {
|
|
92
|
+
if (blurTimer.current) clearTimeout(blurTimer.current);
|
|
93
|
+
setFocused(true);
|
|
94
|
+
},
|
|
95
|
+
onBlur: () => {
|
|
96
|
+
blurTimer.current = setTimeout(() => setFocused(false), 120);
|
|
97
|
+
},
|
|
98
|
+
placeholder: placeholder,
|
|
99
|
+
label: label,
|
|
100
|
+
error: error,
|
|
101
|
+
helperText: helperText,
|
|
102
|
+
editable: !disabled,
|
|
103
|
+
size: size,
|
|
104
|
+
variant: variant,
|
|
105
|
+
autoCorrect: false,
|
|
106
|
+
autoCapitalize: "none"
|
|
107
|
+
})
|
|
108
|
+
}), showList ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
109
|
+
style: [styles.list, {
|
|
110
|
+
top: fieldHeight,
|
|
111
|
+
backgroundColor: theme.colors.background.elevated,
|
|
112
|
+
borderColor: theme.colors.border.primary,
|
|
113
|
+
borderRadius: theme.radius.md,
|
|
114
|
+
...theme.shadows.lg
|
|
115
|
+
}, listStyle],
|
|
116
|
+
children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
117
|
+
style: styles.loadingRow,
|
|
118
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index5.Spinner, {
|
|
119
|
+
size: "sm"
|
|
120
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
121
|
+
style: [styles.loadingText, {
|
|
122
|
+
color: theme.colors.text.secondary,
|
|
123
|
+
fontSize: theme.typography.fontSize.sm
|
|
124
|
+
}],
|
|
125
|
+
children: loadingText
|
|
126
|
+
})]
|
|
127
|
+
}) : filtered.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
128
|
+
style: [styles.empty, {
|
|
129
|
+
color: theme.colors.text.tertiary,
|
|
130
|
+
fontSize: theme.typography.fontSize.sm
|
|
131
|
+
}],
|
|
132
|
+
children: emptyText
|
|
133
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
|
|
134
|
+
keyboardShouldPersistTaps: "handled",
|
|
135
|
+
style: styles.scroll,
|
|
136
|
+
children: filtered.map((o, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
137
|
+
onPress: () => handleSelect(o),
|
|
138
|
+
android_ripple: {
|
|
139
|
+
color: theme.colors.surface.pressed
|
|
140
|
+
},
|
|
141
|
+
style: ({
|
|
142
|
+
pressed
|
|
143
|
+
}) => [styles.option, {
|
|
144
|
+
paddingHorizontal: theme.spacing.md,
|
|
145
|
+
paddingVertical: theme.spacing.sm,
|
|
146
|
+
backgroundColor: pressed ? theme.colors.surface.pressed : 'transparent'
|
|
147
|
+
}],
|
|
148
|
+
accessibilityRole: "button",
|
|
149
|
+
accessibilityLabel: labelOf(o),
|
|
150
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
151
|
+
style: [styles.optionText, {
|
|
152
|
+
color: theme.colors.text.primary,
|
|
153
|
+
fontSize: theme.typography.fontSize.base
|
|
154
|
+
}, optionTextStyle],
|
|
155
|
+
numberOfLines: 1,
|
|
156
|
+
children: labelOf(o)
|
|
157
|
+
})
|
|
158
|
+
}, getOptionKey ? getOptionKey(o) : `${labelOf(o)}-${i}`))
|
|
159
|
+
})
|
|
160
|
+
}) : null]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
Autocomplete.displayName = 'Autocomplete';
|
|
164
|
+
const buildStyles = theme => _reactNative.StyleSheet.create({
|
|
165
|
+
container: {
|
|
166
|
+
width: '100%',
|
|
167
|
+
position: 'relative',
|
|
168
|
+
zIndex: 10
|
|
169
|
+
},
|
|
170
|
+
list: {
|
|
171
|
+
position: 'absolute',
|
|
172
|
+
left: 0,
|
|
173
|
+
right: 0,
|
|
174
|
+
borderWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
175
|
+
overflow: 'hidden',
|
|
176
|
+
zIndex: 20,
|
|
177
|
+
maxHeight: 240
|
|
178
|
+
},
|
|
179
|
+
scroll: {
|
|
180
|
+
maxHeight: 240
|
|
181
|
+
},
|
|
182
|
+
option: {
|
|
183
|
+
width: '100%'
|
|
184
|
+
},
|
|
185
|
+
optionText: {
|
|
186
|
+
includeFontPadding: false
|
|
187
|
+
},
|
|
188
|
+
empty: {
|
|
189
|
+
padding: theme.spacing.md,
|
|
190
|
+
textAlign: 'center',
|
|
191
|
+
includeFontPadding: false
|
|
192
|
+
},
|
|
193
|
+
loadingRow: {
|
|
194
|
+
flexDirection: 'row',
|
|
195
|
+
alignItems: 'center',
|
|
196
|
+
gap: theme.spacing.sm,
|
|
197
|
+
padding: theme.spacing.md
|
|
198
|
+
},
|
|
199
|
+
loadingText: {
|
|
200
|
+
includeFontPadding: false
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
var _default = exports.default = Autocomplete;
|
|
204
|
+
//# sourceMappingURL=Autocomplete.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Autocomplete", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Autocomplete.Autocomplete;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Autocomplete = require("./Autocomplete.js");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -7,6 +7,7 @@ exports.default = exports.Banner = 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 _hapticUtils = require("../../utils/hapticUtils.js");
|
|
10
11
|
var _index2 = require("../Skeleton/index.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); }
|
|
@@ -19,6 +20,7 @@ const Banner = exports.Banner = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
19
20
|
actions,
|
|
20
21
|
dismissible = false,
|
|
21
22
|
onDismiss,
|
|
23
|
+
haptic,
|
|
22
24
|
visible = true,
|
|
23
25
|
animateMount = true,
|
|
24
26
|
loading = false,
|
|
@@ -148,7 +150,11 @@ const Banner = exports.Banner = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
148
150
|
}), dismissible ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
149
151
|
accessibilityRole: "button",
|
|
150
152
|
accessibilityLabel: "Dismiss banner",
|
|
151
|
-
onPress:
|
|
153
|
+
onPress: () => {
|
|
154
|
+
const h = (0, _hapticUtils.resolveHaptic)(haptic, 'selection');
|
|
155
|
+
if (h) (0, _hapticUtils.triggerHaptic)(h);
|
|
156
|
+
onDismiss?.();
|
|
157
|
+
},
|
|
152
158
|
hitSlop: 8,
|
|
153
159
|
style: ({
|
|
154
160
|
pressed
|
|
@@ -173,7 +179,11 @@ const Banner = exports.Banner = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
173
179
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
174
180
|
accessibilityRole: "button",
|
|
175
181
|
accessibilityLabel: action.label,
|
|
176
|
-
onPress:
|
|
182
|
+
onPress: () => {
|
|
183
|
+
const h = (0, _hapticUtils.resolveHaptic)(haptic, 'selection');
|
|
184
|
+
if (h) (0, _hapticUtils.triggerHaptic)(h);
|
|
185
|
+
action.onPress();
|
|
186
|
+
},
|
|
177
187
|
style: ({
|
|
178
188
|
pressed
|
|
179
189
|
}) => [styles.actionBtn, {
|
|
@@ -159,7 +159,7 @@ const BottomNavigation = exports.BottomNavigation = /*#__PURE__*/(0, _react.forw
|
|
|
159
159
|
translateX: indicatorTranslateX
|
|
160
160
|
}]
|
|
161
161
|
}, indicatorStyle]
|
|
162
|
-
}) : null, tabs.map(
|
|
162
|
+
}) : null, tabs.map(tab => {
|
|
163
163
|
const isActive = tab.key === activeTab;
|
|
164
164
|
const color = isActive ? theme.colors.primary : theme.colors.text.tertiary;
|
|
165
165
|
const renderIcon = isActive && tab.activeIcon ? tab.activeIcon : tab.icon;
|
|
@@ -36,6 +36,7 @@ const Card = exports.Card = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
|
|
|
36
36
|
loading = false,
|
|
37
37
|
gradient,
|
|
38
38
|
onPress,
|
|
39
|
+
haptic,
|
|
39
40
|
accessibilityLabel,
|
|
40
41
|
accessibilityHint,
|
|
41
42
|
accessibilityRole,
|
|
@@ -155,9 +156,8 @@ const Card = exports.Card = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
|
|
|
155
156
|
let rendered;
|
|
156
157
|
if (isInteractive) {
|
|
157
158
|
const handlePress = event => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
159
|
+
const h = (0, _hapticUtils.resolveHaptic)(haptic, 'selection');
|
|
160
|
+
if (h) (0, _hapticUtils.triggerHaptic)(h);
|
|
161
161
|
onPress?.(event);
|
|
162
162
|
};
|
|
163
163
|
rendered = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
@@ -40,7 +40,7 @@ const Checkbox = exports.Checkbox = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
40
40
|
size = 'md',
|
|
41
41
|
tone = 'primary',
|
|
42
42
|
accessibilityLabel,
|
|
43
|
-
haptic
|
|
43
|
+
haptic,
|
|
44
44
|
style,
|
|
45
45
|
boxStyle,
|
|
46
46
|
checkIconStyle,
|
|
@@ -80,7 +80,8 @@ const Checkbox = exports.Checkbox = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
80
80
|
});
|
|
81
81
|
const handlePress = event => {
|
|
82
82
|
if (disabled) return;
|
|
83
|
-
|
|
83
|
+
const h = (0, _hapticUtils.resolveHaptic)(haptic, 'selection');
|
|
84
|
+
if (h) (0, _hapticUtils.triggerHaptic)(h);
|
|
84
85
|
setCurrent(!current);
|
|
85
86
|
rest.onPressOut?.(event);
|
|
86
87
|
};
|
|
@@ -104,6 +104,7 @@ const Chip = exports.Chip = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
|
|
|
104
104
|
disabled = false,
|
|
105
105
|
loading = false,
|
|
106
106
|
accessibilityLabel,
|
|
107
|
+
haptic,
|
|
107
108
|
style,
|
|
108
109
|
textStyle,
|
|
109
110
|
containerStyle,
|
|
@@ -150,12 +151,13 @@ const Chip = exports.Chip = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
|
|
|
150
151
|
const borderWidth = isFilled ? 0 : theme.colors.border.width;
|
|
151
152
|
const handlePress = () => {
|
|
152
153
|
if (!isPressable) return;
|
|
153
|
-
|
|
154
|
+
const h = (0, _hapticUtils.resolveHaptic)(haptic, 'selection');
|
|
155
|
+
if (h) (0, _hapticUtils.triggerHaptic)(h);
|
|
154
156
|
onPress?.();
|
|
155
157
|
};
|
|
156
158
|
const handleClose = () => {
|
|
157
159
|
if (disabled) return;
|
|
158
|
-
if (
|
|
160
|
+
if (haptic !== false) (0, _hapticUtils.triggerHaptic)('impactLight');
|
|
159
161
|
onClose?.();
|
|
160
162
|
};
|
|
161
163
|
const a11yLabel = accessibilityLabel ?? label;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Confetti = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
+
var _index = require("../../theme/index.js");
|
|
11
|
+
var _index2 = require("../../hooks/index.js");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
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); }
|
|
14
|
+
const TAU = Math.PI * 2;
|
|
15
|
+
const rand = (min, max) => min + Math.random() * (max - min);
|
|
16
|
+
const buildPieces = (count, colors, mode, baseSize) => Array.from({
|
|
17
|
+
length: count
|
|
18
|
+
}, (_, i) => {
|
|
19
|
+
const isCannon = mode === 'cannon';
|
|
20
|
+
return {
|
|
21
|
+
color: colors[i % colors.length] ?? colors[0],
|
|
22
|
+
size: baseSize * rand(0.6, 1.4),
|
|
23
|
+
isCircle: Math.random() < 0.35,
|
|
24
|
+
baseXFrac: isCannon ? 0.5 : Math.random(),
|
|
25
|
+
vxFrac: isCannon ? rand(-0.7, 0.7) : rand(-0.15, 0.15),
|
|
26
|
+
vy0Frac: isCannon ? rand(-1.5, -1.0) : rand(0, 0.15),
|
|
27
|
+
rotations: rand(1, 5),
|
|
28
|
+
rotateDir: Math.random() < 0.5 ? 1 : -1,
|
|
29
|
+
swayAmp: rand(8, 28),
|
|
30
|
+
swayFreq: rand(1, 3),
|
|
31
|
+
flutterFreq: rand(2, 5)
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
const ConfettiPiece = ({
|
|
35
|
+
piece,
|
|
36
|
+
progress,
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
originX,
|
|
40
|
+
originY,
|
|
41
|
+
mode,
|
|
42
|
+
fadeOut
|
|
43
|
+
}) => {
|
|
44
|
+
const animStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
45
|
+
const t = progress.value;
|
|
46
|
+
const startX = mode === 'cannon' ? originX : piece.baseXFrac * width;
|
|
47
|
+
const startY = mode === 'cannon' ? originY : -piece.size * 2;
|
|
48
|
+
const gravity = height * (mode === 'cannon' ? 1.8 : 1.5);
|
|
49
|
+
const x = startX + piece.vxFrac * width * t + Math.sin(t * piece.swayFreq * TAU) * piece.swayAmp;
|
|
50
|
+
const y = startY + piece.vy0Frac * height * t + gravity * t * t;
|
|
51
|
+
const rotate = piece.rotateDir * piece.rotations * 360 * t;
|
|
52
|
+
// Paper-flutter: oscillate scaleX so pieces read as thin spinning paper.
|
|
53
|
+
const flutter = 0.35 + 0.65 * Math.abs(Math.cos(t * piece.flutterFreq * TAU));
|
|
54
|
+
const opacity = fadeOut ? Math.max(0, 1 - Math.max(0, t - 0.8) / 0.2) : 1;
|
|
55
|
+
return {
|
|
56
|
+
opacity,
|
|
57
|
+
transform: [{
|
|
58
|
+
translateX: x
|
|
59
|
+
}, {
|
|
60
|
+
translateY: y
|
|
61
|
+
}, {
|
|
62
|
+
rotate: `${rotate}deg`
|
|
63
|
+
}, {
|
|
64
|
+
scaleX: flutter
|
|
65
|
+
}]
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
69
|
+
style: [{
|
|
70
|
+
position: 'absolute',
|
|
71
|
+
width: piece.size,
|
|
72
|
+
height: piece.isCircle ? piece.size : piece.size * 0.5,
|
|
73
|
+
borderRadius: piece.isCircle ? piece.size / 2 : 1,
|
|
74
|
+
backgroundColor: piece.color
|
|
75
|
+
}, animStyle]
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const Confetti = exports.Confetti = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
79
|
+
count = 80,
|
|
80
|
+
colors,
|
|
81
|
+
mode = 'rain',
|
|
82
|
+
origin,
|
|
83
|
+
duration = 2800,
|
|
84
|
+
fadeOut = true,
|
|
85
|
+
autoStart = false,
|
|
86
|
+
recycle = false,
|
|
87
|
+
size = 10,
|
|
88
|
+
onComplete,
|
|
89
|
+
style,
|
|
90
|
+
testID
|
|
91
|
+
}, ref) => {
|
|
92
|
+
const theme = (0, _index.useTheme)();
|
|
93
|
+
const reduceMotion = (0, _index2.useReducedMotion)();
|
|
94
|
+
const window = (0, _reactNative.useWindowDimensions)();
|
|
95
|
+
const [layout, setLayout] = (0, _react.useState)({
|
|
96
|
+
width: window.width,
|
|
97
|
+
height: window.height
|
|
98
|
+
});
|
|
99
|
+
const [active, setActive] = (0, _react.useState)(false);
|
|
100
|
+
const [pieces, setPieces] = (0, _react.useState)([]);
|
|
101
|
+
const palette = (0, _react.useMemo)(() => colors ?? [theme.colors.primary, theme.colors.secondary, theme.colors.success, theme.colors.warning, theme.colors.error, theme.colors.info], [colors, theme.colors]);
|
|
102
|
+
const progress = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
103
|
+
const finish = (0, _react.useCallback)(() => {
|
|
104
|
+
setActive(false);
|
|
105
|
+
onComplete?.();
|
|
106
|
+
}, [onComplete]);
|
|
107
|
+
const start = (0, _react.useCallback)(() => {
|
|
108
|
+
if (reduceMotion) {
|
|
109
|
+
onComplete?.();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
(0, _reactNativeReanimated.cancelAnimation)(progress);
|
|
113
|
+
progress.value = 0;
|
|
114
|
+
setPieces(buildPieces(count, palette, mode, size));
|
|
115
|
+
setActive(true);
|
|
116
|
+
const tween = (0, _reactNativeReanimated.withTiming)(1, {
|
|
117
|
+
duration,
|
|
118
|
+
easing: _reactNativeReanimated.Easing.linear
|
|
119
|
+
}, finished => {
|
|
120
|
+
'worklet';
|
|
121
|
+
|
|
122
|
+
if (finished && !recycle) (0, _reactNativeReanimated.runOnJS)(finish)();
|
|
123
|
+
});
|
|
124
|
+
progress.value = recycle ? (0, _reactNativeReanimated.withRepeat)(tween, -1, false) : tween;
|
|
125
|
+
}, [reduceMotion, progress, duration, recycle, finish, onComplete, count, palette, mode, size]);
|
|
126
|
+
const stop = (0, _react.useCallback)(() => {
|
|
127
|
+
(0, _reactNativeReanimated.cancelAnimation)(progress);
|
|
128
|
+
setActive(false);
|
|
129
|
+
}, [progress]);
|
|
130
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
131
|
+
start,
|
|
132
|
+
stop
|
|
133
|
+
}), [start, stop]);
|
|
134
|
+
(0, _react.useEffect)(() => {
|
|
135
|
+
if (autoStart) start();
|
|
136
|
+
return () => (0, _reactNativeReanimated.cancelAnimation)(progress);
|
|
137
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
138
|
+
}, []);
|
|
139
|
+
const onLayout = (0, _react.useCallback)(e => {
|
|
140
|
+
const {
|
|
141
|
+
width,
|
|
142
|
+
height
|
|
143
|
+
} = e.nativeEvent.layout;
|
|
144
|
+
if (width > 0 && height > 0) setLayout({
|
|
145
|
+
width,
|
|
146
|
+
height
|
|
147
|
+
});
|
|
148
|
+
}, []);
|
|
149
|
+
const originX = origin?.x ?? layout.width / 2;
|
|
150
|
+
const originY = origin?.y ?? layout.height;
|
|
151
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
152
|
+
style: [_reactNative.StyleSheet.absoluteFill, style],
|
|
153
|
+
pointerEvents: "none",
|
|
154
|
+
onLayout: onLayout,
|
|
155
|
+
testID: testID,
|
|
156
|
+
children: active ? pieces.map((piece, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(ConfettiPiece, {
|
|
157
|
+
piece: piece,
|
|
158
|
+
progress: progress,
|
|
159
|
+
width: layout.width,
|
|
160
|
+
height: layout.height,
|
|
161
|
+
originX: originX,
|
|
162
|
+
originY: originY,
|
|
163
|
+
mode: mode,
|
|
164
|
+
fadeOut: fadeOut
|
|
165
|
+
}, i)) : null
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
Confetti.displayName = 'Confetti';
|
|
169
|
+
var _default = exports.default = Confetti;
|
|
170
|
+
//# sourceMappingURL=Confetti.js.map
|