@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.
Files changed (171) hide show
  1. package/lib/commonjs/components/Accordion/Accordion.js +5 -5
  2. package/lib/commonjs/components/AnimatePresence/AnimatePresence.js +69 -0
  3. package/lib/commonjs/components/AnimatePresence/index.js +13 -0
  4. package/lib/commonjs/components/AppBar/AppBar.js +9 -6
  5. package/lib/commonjs/components/Autocomplete/Autocomplete.js +204 -0
  6. package/lib/commonjs/components/Autocomplete/index.js +13 -0
  7. package/lib/commonjs/components/Banner/Banner.js +12 -2
  8. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  9. package/lib/commonjs/components/Card/Card.js +3 -3
  10. package/lib/commonjs/components/Checkbox/Checkbox.js +3 -2
  11. package/lib/commonjs/components/Chip/Chip.js +4 -2
  12. package/lib/commonjs/components/Confetti/Confetti.js +170 -0
  13. package/lib/commonjs/components/Confetti/index.js +13 -0
  14. package/lib/commonjs/components/DatePicker/DatePicker.js +23 -18
  15. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +11 -9
  16. package/lib/commonjs/components/Dialog/Dialog.js +4 -2
  17. package/lib/commonjs/components/Drawer/Drawer.js +4 -2
  18. package/lib/commonjs/components/FieldBase/FieldBase.js +0 -2
  19. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +10 -8
  20. package/lib/commonjs/components/IconButton/IconButton.js +176 -0
  21. package/lib/commonjs/components/IconButton/index.js +13 -0
  22. package/lib/commonjs/components/ImageGallery/ImageGallery.js +17 -15
  23. package/lib/commonjs/components/ListItem/ListItem.js +4 -3
  24. package/lib/commonjs/components/Modal/Modal.js +4 -4
  25. package/lib/commonjs/components/NumberInput/NumberInput.js +7 -5
  26. package/lib/commonjs/components/OTPInput/OTPInput.js +7 -7
  27. package/lib/commonjs/components/ProgressBar/ProgressBar.js +32 -4
  28. package/lib/commonjs/components/Radio/Radio.js +2 -3
  29. package/lib/commonjs/components/Rating/Rating.js +4 -3
  30. package/lib/commonjs/components/SearchBar/SearchBar.js +7 -4
  31. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +4 -3
  32. package/lib/commonjs/components/Select/Select.js +7 -4
  33. package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +224 -0
  34. package/lib/commonjs/components/SlideToConfirm/index.js +13 -0
  35. package/lib/commonjs/components/Slider/Slider.js +228 -228
  36. package/lib/commonjs/components/Stepper/Stepper.js +6 -5
  37. package/lib/commonjs/components/Swipeable/Swipeable.js +8 -9
  38. package/lib/commonjs/components/Tabs/Tabs.js +4 -3
  39. package/lib/commonjs/components/TimePicker/TimePicker.js +14 -9
  40. package/lib/commonjs/components/index.js +149 -114
  41. package/lib/commonjs/hooks/usePressAnimation.js +0 -1
  42. package/lib/commonjs/utils/hapticUtils.js +11 -1
  43. package/lib/commonjs/utils/index.js +6 -0
  44. package/lib/module/components/Accordion/Accordion.js +6 -6
  45. package/lib/module/components/AnimatePresence/AnimatePresence.js +63 -0
  46. package/lib/module/components/AnimatePresence/index.js +4 -0
  47. package/lib/module/components/AppBar/AppBar.js +10 -7
  48. package/lib/module/components/Autocomplete/Autocomplete.js +199 -0
  49. package/lib/module/components/Autocomplete/index.js +4 -0
  50. package/lib/module/components/Banner/Banner.js +12 -2
  51. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  52. package/lib/module/components/Card/Card.js +4 -4
  53. package/lib/module/components/Checkbox/Checkbox.js +4 -3
  54. package/lib/module/components/Chip/Chip.js +5 -3
  55. package/lib/module/components/Confetti/Confetti.js +166 -0
  56. package/lib/module/components/Confetti/index.js +4 -0
  57. package/lib/module/components/DatePicker/DatePicker.js +24 -19
  58. package/lib/module/components/DateRangePicker/DateRangePicker.js +12 -10
  59. package/lib/module/components/Dialog/Dialog.js +5 -3
  60. package/lib/module/components/Drawer/Drawer.js +5 -3
  61. package/lib/module/components/FieldBase/FieldBase.js +0 -2
  62. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +11 -9
  63. package/lib/module/components/IconButton/IconButton.js +172 -0
  64. package/lib/module/components/IconButton/index.js +4 -0
  65. package/lib/module/components/ImageGallery/ImageGallery.js +18 -16
  66. package/lib/module/components/ListItem/ListItem.js +5 -4
  67. package/lib/module/components/Modal/Modal.js +5 -5
  68. package/lib/module/components/NumberInput/NumberInput.js +8 -6
  69. package/lib/module/components/OTPInput/OTPInput.js +8 -8
  70. package/lib/module/components/ProgressBar/ProgressBar.js +33 -5
  71. package/lib/module/components/Radio/Radio.js +3 -4
  72. package/lib/module/components/Rating/Rating.js +5 -4
  73. package/lib/module/components/SearchBar/SearchBar.js +8 -5
  74. package/lib/module/components/SegmentedControl/SegmentedControl.js +5 -4
  75. package/lib/module/components/Select/Select.js +8 -5
  76. package/lib/module/components/SlideToConfirm/SlideToConfirm.js +220 -0
  77. package/lib/module/components/SlideToConfirm/index.js +4 -0
  78. package/lib/module/components/Slider/Slider.js +231 -231
  79. package/lib/module/components/Stepper/Stepper.js +7 -6
  80. package/lib/module/components/Swipeable/Swipeable.js +9 -10
  81. package/lib/module/components/Tabs/Tabs.js +5 -4
  82. package/lib/module/components/TimePicker/TimePicker.js +15 -10
  83. package/lib/module/components/index.js +5 -0
  84. package/lib/module/hooks/usePressAnimation.js +0 -1
  85. package/lib/module/utils/hapticUtils.js +9 -0
  86. package/lib/module/utils/index.js +1 -1
  87. package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +3 -0
  88. package/lib/typescript/commonjs/components/AnimatePresence/AnimatePresence.d.ts +30 -0
  89. package/lib/typescript/commonjs/components/AnimatePresence/index.d.ts +3 -0
  90. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +6 -0
  91. package/lib/typescript/commonjs/components/Autocomplete/Autocomplete.d.ts +53 -0
  92. package/lib/typescript/commonjs/components/Autocomplete/index.d.ts +3 -0
  93. package/lib/typescript/commonjs/components/Banner/Banner.d.ts +3 -0
  94. package/lib/typescript/commonjs/components/Card/Card.d.ts +3 -0
  95. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +1 -0
  96. package/lib/typescript/commonjs/components/Chip/Chip.d.ts +3 -0
  97. package/lib/typescript/commonjs/components/Confetti/Confetti.d.ts +41 -0
  98. package/lib/typescript/commonjs/components/Confetti/index.d.ts +3 -0
  99. package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +3 -0
  100. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +6 -0
  101. package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +3 -0
  102. package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +3 -0
  103. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +5 -0
  104. package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +34 -0
  105. package/lib/typescript/commonjs/components/IconButton/index.d.ts +3 -0
  106. package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +6 -0
  107. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +3 -0
  108. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +6 -0
  109. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +3 -0
  110. package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +6 -0
  111. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +12 -0
  112. package/lib/typescript/commonjs/components/ProgressBar/index.d.ts +1 -1
  113. package/lib/typescript/commonjs/components/Rating/Rating.d.ts +6 -0
  114. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +3 -0
  115. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -0
  116. package/lib/typescript/commonjs/components/Select/Select.d.ts +6 -0
  117. package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +34 -0
  118. package/lib/typescript/commonjs/components/SlideToConfirm/index.d.ts +3 -0
  119. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +3 -0
  120. package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +6 -0
  121. package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +3 -0
  122. package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +3 -0
  123. package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +3 -0
  124. package/lib/typescript/commonjs/components/index.d.ts +11 -1
  125. package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +1 -2
  126. package/lib/typescript/commonjs/theme/types.d.ts +2 -67
  127. package/lib/typescript/commonjs/utils/hapticUtils.d.ts +8 -0
  128. package/lib/typescript/commonjs/utils/index.d.ts +1 -1
  129. package/lib/typescript/module/components/Accordion/Accordion.d.ts +3 -0
  130. package/lib/typescript/module/components/AnimatePresence/AnimatePresence.d.ts +30 -0
  131. package/lib/typescript/module/components/AnimatePresence/index.d.ts +3 -0
  132. package/lib/typescript/module/components/AppBar/AppBar.d.ts +6 -0
  133. package/lib/typescript/module/components/Autocomplete/Autocomplete.d.ts +53 -0
  134. package/lib/typescript/module/components/Autocomplete/index.d.ts +3 -0
  135. package/lib/typescript/module/components/Banner/Banner.d.ts +3 -0
  136. package/lib/typescript/module/components/Card/Card.d.ts +3 -0
  137. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +1 -0
  138. package/lib/typescript/module/components/Chip/Chip.d.ts +3 -0
  139. package/lib/typescript/module/components/Confetti/Confetti.d.ts +41 -0
  140. package/lib/typescript/module/components/Confetti/index.d.ts +3 -0
  141. package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +3 -0
  142. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +6 -0
  143. package/lib/typescript/module/components/Dialog/Dialog.d.ts +3 -0
  144. package/lib/typescript/module/components/Drawer/Drawer.d.ts +3 -0
  145. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +5 -0
  146. package/lib/typescript/module/components/IconButton/IconButton.d.ts +34 -0
  147. package/lib/typescript/module/components/IconButton/index.d.ts +3 -0
  148. package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +6 -0
  149. package/lib/typescript/module/components/ListItem/ListItem.d.ts +3 -0
  150. package/lib/typescript/module/components/Modal/Modal.d.ts +6 -0
  151. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +3 -0
  152. package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +6 -0
  153. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +12 -0
  154. package/lib/typescript/module/components/ProgressBar/index.d.ts +1 -1
  155. package/lib/typescript/module/components/Rating/Rating.d.ts +6 -0
  156. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +3 -0
  157. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -0
  158. package/lib/typescript/module/components/Select/Select.d.ts +6 -0
  159. package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +34 -0
  160. package/lib/typescript/module/components/SlideToConfirm/index.d.ts +3 -0
  161. package/lib/typescript/module/components/Slider/Slider.d.ts +3 -0
  162. package/lib/typescript/module/components/Stepper/Stepper.d.ts +6 -0
  163. package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +3 -0
  164. package/lib/typescript/module/components/Tabs/Tabs.d.ts +3 -0
  165. package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +3 -0
  166. package/lib/typescript/module/components/index.d.ts +11 -1
  167. package/lib/typescript/module/hooks/usePressAnimation.d.ts +1 -2
  168. package/lib/typescript/module/theme/types.d.ts +2 -67
  169. package/lib/typescript/module/utils/hapticUtils.d.ts +8 -0
  170. package/lib/typescript/module/utils/index.d.ts +1 -1
  171. package/package.json +1 -1
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+
3
+ import React, { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
4
+ import { StyleSheet, Text, View } from 'react-native';
5
+ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
6
+ import Animated, { Easing, cancelAnimation, runOnJS, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
7
+ import { useTheme } from "../../theme/index.js";
8
+ import { resolveHaptic, triggerHaptic } from "../../utils/index.js";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ const SIZE_MAP = {
11
+ sm: {
12
+ height: 44,
13
+ pad: 4
14
+ },
15
+ md: {
16
+ height: 56,
17
+ pad: 5
18
+ },
19
+ lg: {
20
+ height: 64,
21
+ pad: 6
22
+ }
23
+ };
24
+ const Chevron = ({
25
+ color,
26
+ size
27
+ }) => /*#__PURE__*/_jsx(View, {
28
+ style: {
29
+ width: 0,
30
+ height: 0,
31
+ borderTopWidth: size * 0.4,
32
+ borderBottomWidth: size * 0.4,
33
+ borderLeftWidth: size * 0.55,
34
+ borderTopColor: 'transparent',
35
+ borderBottomColor: 'transparent',
36
+ borderLeftColor: color,
37
+ marginLeft: size * 0.2
38
+ }
39
+ });
40
+ const SlideToConfirm = /*#__PURE__*/forwardRef((props, ref) => {
41
+ const {
42
+ onConfirm,
43
+ label = 'Slide to confirm',
44
+ confirmedLabel = 'Confirmed',
45
+ tone = 'primary',
46
+ size = 'md',
47
+ disabled = false,
48
+ threshold = 0.9,
49
+ resetAfter = false,
50
+ haptic,
51
+ icon,
52
+ style,
53
+ trackStyle,
54
+ handleStyle,
55
+ labelStyle,
56
+ testID
57
+ } = props;
58
+ const theme = useTheme();
59
+ const sizeCfg = SIZE_MAP[size];
60
+ const handleSize = sizeCfg.height - sizeCfg.pad * 2;
61
+ const styles = useMemo(() => buildStyles(theme, sizeCfg), [theme, sizeCfg]);
62
+ const toneColor = theme.colors[tone];
63
+ const [confirmed, setConfirmed] = useState(false);
64
+ const x = useSharedValue(0);
65
+ const maxX = useSharedValue(0);
66
+ const dragStart = useSharedValue(0);
67
+ const resetTimer = useRef(null);
68
+ const fireHaptic = useCallback(() => {
69
+ const h = resolveHaptic(haptic, 'notificationSuccess');
70
+ if (h) triggerHaptic(h);
71
+ }, [haptic]);
72
+ const reset = useCallback(() => {
73
+ setConfirmed(false);
74
+ x.value = withSpring(0, {
75
+ damping: 18,
76
+ stiffness: 160,
77
+ mass: 1
78
+ });
79
+ }, [x]);
80
+ const handleConfirm = useCallback(() => {
81
+ setConfirmed(true);
82
+ fireHaptic();
83
+ onConfirm();
84
+ if (resetAfter !== false) {
85
+ if (resetTimer.current) clearTimeout(resetTimer.current);
86
+ resetTimer.current = setTimeout(reset, resetAfter);
87
+ }
88
+ }, [fireHaptic, onConfirm, resetAfter, reset]);
89
+ React.useEffect(() => () => {
90
+ cancelAnimation(x);
91
+ if (resetTimer.current) clearTimeout(resetTimer.current);
92
+ }, [x]);
93
+ const onLayout = useCallback(e => {
94
+ maxX.value = Math.max(0, e.nativeEvent.layout.width - handleSize - sizeCfg.pad * 2);
95
+ }, [maxX, handleSize, sizeCfg.pad]);
96
+ const pan = useMemo(() => {
97
+ const thresholdFrac = threshold;
98
+ const springCfg = {
99
+ damping: 18,
100
+ stiffness: 160,
101
+ mass: 1
102
+ };
103
+ const timingCfg = {
104
+ duration: theme.motion.duration.fast,
105
+ easing: Easing.out(Easing.cubic)
106
+ };
107
+ return Gesture.Pan().enabled(!disabled && !confirmed).minDistance(0).onStart(() => {
108
+ 'worklet';
109
+
110
+ dragStart.value = x.value;
111
+ }).onUpdate(event => {
112
+ 'worklet';
113
+
114
+ x.value = Math.min(Math.max(dragStart.value + event.translationX, 0), maxX.value);
115
+ }).onEnd(() => {
116
+ 'worklet';
117
+
118
+ if (maxX.value > 0 && x.value >= maxX.value * thresholdFrac) {
119
+ x.value = withTiming(maxX.value, timingCfg);
120
+ runOnJS(handleConfirm)();
121
+ } else {
122
+ x.value = withSpring(0, springCfg);
123
+ }
124
+ });
125
+ }, [disabled, confirmed, threshold, x, maxX, dragStart, handleConfirm, theme.motion.duration.fast]);
126
+ const handleAnim = useAnimatedStyle(() => ({
127
+ transform: [{
128
+ translateX: x.value
129
+ }]
130
+ }));
131
+ const fillAnim = useAnimatedStyle(() => ({
132
+ width: x.value + handleSize + sizeCfg.pad
133
+ }));
134
+ const labelAnim = useAnimatedStyle(() => {
135
+ const max = maxX.value > 0 ? maxX.value : 1;
136
+ return {
137
+ opacity: Math.max(0, 1 - x.value / (max * 0.6))
138
+ };
139
+ });
140
+ return /*#__PURE__*/_jsxs(View, {
141
+ ref: ref,
142
+ style: [styles.track, {
143
+ backgroundColor: theme.colors.background.secondary
144
+ }, trackStyle, style],
145
+ onLayout: onLayout,
146
+ testID: testID,
147
+ accessibilityRole: "adjustable",
148
+ accessibilityLabel: confirmed ? confirmedLabel : label,
149
+ accessibilityState: {
150
+ disabled
151
+ },
152
+ children: [/*#__PURE__*/_jsx(Animated.View, {
153
+ style: [styles.fill, {
154
+ backgroundColor: toneColor,
155
+ opacity: disabled ? 0.5 : 1
156
+ }, fillAnim],
157
+ pointerEvents: "none"
158
+ }), /*#__PURE__*/_jsx(Animated.View, {
159
+ style: [styles.labelWrap, labelAnim],
160
+ pointerEvents: "none",
161
+ children: /*#__PURE__*/_jsx(Text, {
162
+ style: [styles.label, {
163
+ color: theme.colors.text.secondary,
164
+ fontSize: theme.typography.fontSize.base
165
+ }, labelStyle],
166
+ numberOfLines: 1,
167
+ children: confirmed ? confirmedLabel : label
168
+ })
169
+ }), /*#__PURE__*/_jsx(GestureDetector, {
170
+ gesture: pan,
171
+ children: /*#__PURE__*/_jsx(Animated.View, {
172
+ style: [styles.handle, {
173
+ width: handleSize,
174
+ height: handleSize,
175
+ borderRadius: handleSize / 2,
176
+ backgroundColor: theme.colors.background.elevated,
177
+ opacity: disabled ? 0.5 : 1,
178
+ ...theme.shadows.sm
179
+ }, handleStyle, handleAnim],
180
+ children: icon ?? /*#__PURE__*/_jsx(Chevron, {
181
+ color: toneColor,
182
+ size: handleSize * 0.5
183
+ })
184
+ })
185
+ })]
186
+ });
187
+ });
188
+ SlideToConfirm.displayName = 'SlideToConfirm';
189
+ const buildStyles = (theme, sizeCfg) => StyleSheet.create({
190
+ track: {
191
+ height: sizeCfg.height,
192
+ borderRadius: sizeCfg.height / 2,
193
+ justifyContent: 'center',
194
+ overflow: 'hidden',
195
+ padding: sizeCfg.pad
196
+ },
197
+ fill: {
198
+ position: 'absolute',
199
+ left: 0,
200
+ top: 0,
201
+ bottom: 0,
202
+ borderRadius: sizeCfg.height / 2
203
+ },
204
+ labelWrap: {
205
+ position: 'absolute',
206
+ left: sizeCfg.height,
207
+ right: sizeCfg.height
208
+ },
209
+ label: {
210
+ textAlign: 'center',
211
+ includeFontPadding: false
212
+ },
213
+ handle: {
214
+ alignItems: 'center',
215
+ justifyContent: 'center'
216
+ }
217
+ });
218
+ export { SlideToConfirm };
219
+ export default SlideToConfirm;
220
+ //# sourceMappingURL=SlideToConfirm.js.map
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { SlideToConfirm } from "./SlideToConfirm.js";
4
+ //# sourceMappingURL=index.js.map