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