expo-openpay 0.1.0
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/.eslintrc.js +5 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/android/build.gradle +76 -0
- package/android/gradle.properties +2 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/openpay/ExpoOpenpayModule.kt +127 -0
- package/android/src/main/java/expo/modules/openpay/ExpoOpenpayView.kt +30 -0
- package/android/src/main/java/mx/openpay/android/BuildConfig.java +8 -0
- package/android/src/main/java/mx/openpay/android/DeviceCollectorDefaultImpl.java +70 -0
- package/android/src/main/java/mx/openpay/android/JavaScriptInterface.java +19 -0
- package/android/src/main/java/mx/openpay/android/OpCountry.java +24 -0
- package/android/src/main/java/mx/openpay/android/OpenPayResult.java +35 -0
- package/android/src/main/java/mx/openpay/android/Openpay.java +98 -0
- package/android/src/main/java/mx/openpay/android/OpenpayUrls.java +11 -0
- package/android/src/main/java/mx/openpay/android/OperationCallBack.java +13 -0
- package/android/src/main/java/mx/openpay/android/OperationResult.java +14 -0
- package/android/src/main/java/mx/openpay/android/exceptions/OpenpayServiceException.java +93 -0
- package/android/src/main/java/mx/openpay/android/exceptions/ServiceUnavailableException.java +23 -0
- package/android/src/main/java/mx/openpay/android/model/Address.java +123 -0
- package/android/src/main/java/mx/openpay/android/model/Card.java +219 -0
- package/android/src/main/java/mx/openpay/android/model/Token.java +43 -0
- package/android/src/main/java/mx/openpay/android/services/BaseService.java +93 -0
- package/android/src/main/java/mx/openpay/android/services/ServicesFactory.java +47 -0
- package/android/src/main/java/mx/openpay/android/services/TokenService.java +19 -0
- package/android/src/main/java/mx/openpay/android/validation/CardType.java +9 -0
- package/android/src/main/java/mx/openpay/android/validation/CardValidator.java +105 -0
- package/android/src/main/java/mx/openpay/android/validation/LuhnValidator.java +34 -0
- package/build/ExpoOpenpay.types.d.ts +42 -0
- package/build/ExpoOpenpay.types.d.ts.map +1 -0
- package/build/ExpoOpenpay.types.js +2 -0
- package/build/ExpoOpenpay.types.js.map +1 -0
- package/build/ExpoOpenpayModule.d.ts +10 -0
- package/build/ExpoOpenpayModule.d.ts.map +1 -0
- package/build/ExpoOpenpayModule.js +6 -0
- package/build/ExpoOpenpayModule.js.map +1 -0
- package/build/ExpoOpenpayModule.web.d.ts +10 -0
- package/build/ExpoOpenpayModule.web.d.ts.map +1 -0
- package/build/ExpoOpenpayModule.web.js +12 -0
- package/build/ExpoOpenpayModule.web.js.map +1 -0
- package/build/ExpoOpenpayView.d.ts +4 -0
- package/build/ExpoOpenpayView.d.ts.map +1 -0
- package/build/ExpoOpenpayView.js +7 -0
- package/build/ExpoOpenpayView.js.map +1 -0
- package/build/ExpoOpenpayView.web.d.ts +3 -0
- package/build/ExpoOpenpayView.web.d.ts.map +1 -0
- package/build/ExpoOpenpayView.web.js +5 -0
- package/build/ExpoOpenpayView.web.js.map +1 -0
- package/build/assets/AmexLogo.d.ts +4 -0
- package/build/assets/AmexLogo.d.ts.map +1 -0
- package/build/assets/AmexLogo.js +9 -0
- package/build/assets/AmexLogo.js.map +1 -0
- package/build/assets/MCLogo.d.ts +4 -0
- package/build/assets/MCLogo.d.ts.map +1 -0
- package/build/assets/MCLogo.js +9 -0
- package/build/assets/MCLogo.js.map +1 -0
- package/build/assets/VisaLogo.d.ts +4 -0
- package/build/assets/VisaLogo.d.ts.map +1 -0
- package/build/assets/VisaLogo.js +6 -0
- package/build/assets/VisaLogo.js.map +1 -0
- package/build/assets/index.d.ts +4 -0
- package/build/assets/index.d.ts.map +1 -0
- package/build/assets/index.js +4 -0
- package/build/assets/index.js.map +1 -0
- package/build/components/OPCardForm.d.ts +33 -0
- package/build/components/OPCardForm.d.ts.map +1 -0
- package/build/components/OPCardForm.js +120 -0
- package/build/components/OPCardForm.js.map +1 -0
- package/build/components/OPCardNumberInput.d.ts +17 -0
- package/build/components/OPCardNumberInput.d.ts.map +1 -0
- package/build/components/OPCardNumberInput.js +60 -0
- package/build/components/OPCardNumberInput.js.map +1 -0
- package/build/components/OPCvv2Input.d.ts +17 -0
- package/build/components/OPCvv2Input.d.ts.map +1 -0
- package/build/components/OPCvv2Input.js +13 -0
- package/build/components/OPCvv2Input.js.map +1 -0
- package/build/components/OPExpInput.d.ts +17 -0
- package/build/components/OPExpInput.d.ts.map +1 -0
- package/build/components/OPExpInput.js +22 -0
- package/build/components/OPExpInput.js.map +1 -0
- package/build/components/OPExpMonthInput.d.ts +17 -0
- package/build/components/OPExpMonthInput.d.ts.map +1 -0
- package/build/components/OPExpMonthInput.js +6 -0
- package/build/components/OPExpMonthInput.js.map +1 -0
- package/build/components/OPExpYearInput.d.ts +17 -0
- package/build/components/OPExpYearInput.d.ts.map +1 -0
- package/build/components/OPExpYearInput.js +6 -0
- package/build/components/OPExpYearInput.js.map +1 -0
- package/build/components/OPHolderNameInput.d.ts +17 -0
- package/build/components/OPHolderNameInput.d.ts.map +1 -0
- package/build/components/OPHolderNameInput.js +6 -0
- package/build/components/OPHolderNameInput.js.map +1 -0
- package/build/components/forms/ErrorMessage.d.ts +7 -0
- package/build/components/forms/ErrorMessage.d.ts.map +1 -0
- package/build/components/forms/ErrorMessage.js +12 -0
- package/build/components/forms/ErrorMessage.js.map +1 -0
- package/build/components/forms/FormField.d.ts +34 -0
- package/build/components/forms/FormField.d.ts.map +1 -0
- package/build/components/forms/FormField.js +33 -0
- package/build/components/forms/FormField.js.map +1 -0
- package/build/components/forms/SubmitButton.d.ts +11 -0
- package/build/components/forms/SubmitButton.d.ts.map +1 -0
- package/build/components/forms/SubmitButton.js +45 -0
- package/build/components/forms/SubmitButton.js.map +1 -0
- package/build/components/forms/Text.d.ts +7 -0
- package/build/components/forms/Text.d.ts.map +1 -0
- package/build/components/forms/Text.js +12 -0
- package/build/components/forms/Text.js.map +1 -0
- package/build/components/forms/TextInput.d.ts +30 -0
- package/build/components/forms/TextInput.d.ts.map +1 -0
- package/build/components/forms/TextInput.js +195 -0
- package/build/components/forms/TextInput.js.map +1 -0
- package/build/components/forms/index.d.ts +4 -0
- package/build/components/forms/index.d.ts.map +1 -0
- package/build/components/forms/index.js +5 -0
- package/build/components/forms/index.js.map +1 -0
- package/build/components/index.d.ts +8 -0
- package/build/components/index.d.ts.map +1 -0
- package/build/components/index.js +8 -0
- package/build/components/index.js.map +1 -0
- package/build/constants/Colors.d.ts +27 -0
- package/build/constants/Colors.d.ts.map +1 -0
- package/build/constants/Colors.js +27 -0
- package/build/constants/Colors.js.map +1 -0
- package/build/constants/Styles.d.ts +9 -0
- package/build/constants/Styles.d.ts.map +1 -0
- package/build/constants/Styles.js +9 -0
- package/build/constants/Styles.js.map +1 -0
- package/build/context/FormContext.d.ts +22 -0
- package/build/context/FormContext.d.ts.map +1 -0
- package/build/context/FormContext.js +63 -0
- package/build/context/FormContext.js.map +1 -0
- package/build/context/FormThemeContext.d.ts +20 -0
- package/build/context/FormThemeContext.d.ts.map +1 -0
- package/build/context/FormThemeContext.js +21 -0
- package/build/context/FormThemeContext.js.map +1 -0
- package/build/context/index.d.ts +4 -0
- package/build/context/index.d.ts.map +1 -0
- package/build/context/index.js +3 -0
- package/build/context/index.js.map +1 -0
- package/build/index.d.ts +6 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +18 -0
- package/build/index.js.map +1 -0
- package/build/utility/cardBranding.d.ts +2 -0
- package/build/utility/cardBranding.d.ts.map +1 -0
- package/build/utility/cardBranding.js +2 -0
- package/build/utility/cardBranding.js.map +1 -0
- package/build/utility/formatting.d.ts +4 -0
- package/build/utility/formatting.d.ts.map +1 -0
- package/build/utility/formatting.js +20 -0
- package/build/utility/formatting.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/ExpoOpenpay.podspec +30 -0
- package/ios/Frameworks/OpenpayKit.xcframework/Info.plist +40 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Headers/OpenpayKit-Swift.h +274 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Info.plist +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios.abi.json +5179 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios.private.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/module.modulemap +4 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/OpenpayKit +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/_CodeSignature/CodeResources +287 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/en.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/en.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/es-MX.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/es-MX.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/es.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/es.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Headers/OpenpayKit-Swift.h +544 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Info.plist +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios-simulator.abi.json +5179 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +5179 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/module.modulemap +4 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/OpenpayKit +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/_CodeSignature/CodeResources +342 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/en.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/en.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/es-MX.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/es-MX.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/es.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/es.lproj/Localizable.strings +0 -0
- package/ios/src/ExpoOpenpayModule.swift +105 -0
- package/ios/src/ExpoOpenpayView.swift +38 -0
- package/package.json +46 -0
- package/src/ExpoOpenpay.types.ts +47 -0
- package/src/ExpoOpenpayModule.ts +29 -0
- package/src/ExpoOpenpayModule.web.ts +15 -0
- package/src/ExpoOpenpayView.tsx +11 -0
- package/src/ExpoOpenpayView.web.tsx +5 -0
- package/src/assets/AmexLogo.tsx +24 -0
- package/src/assets/MCLogo.tsx +19 -0
- package/src/assets/VisaLogo.tsx +11 -0
- package/src/assets/index.ts +3 -0
- package/src/assets/photos/discover_logo.png +0 -0
- package/src/components/OPCardForm.tsx +303 -0
- package/src/components/OPCardNumberInput.tsx +126 -0
- package/src/components/OPCvv2Input.tsx +62 -0
- package/src/components/OPExpInput.tsx +74 -0
- package/src/components/OPExpMonthInput.tsx +55 -0
- package/src/components/OPExpYearInput.tsx +55 -0
- package/src/components/OPHolderNameInput.tsx +53 -0
- package/src/components/forms/ErrorMessage.tsx +19 -0
- package/src/components/forms/FormField.tsx +96 -0
- package/src/components/forms/SubmitButton.tsx +81 -0
- package/src/components/forms/Text.tsx +20 -0
- package/src/components/forms/TextInput.tsx +329 -0
- package/src/components/forms/index.ts +4 -0
- package/src/components/index.ts +7 -0
- package/src/constants/Colors.ts +26 -0
- package/src/constants/Styles.ts +9 -0
- package/src/context/FormContext.tsx +109 -0
- package/src/context/FormThemeContext.tsx +55 -0
- package/src/context/index.ts +3 -0
- package/src/index.ts +19 -0
- package/src/utility/cardBranding.ts +0 -0
- package/src/utility/formatting.ts +23 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Animated, Image, StyleSheet, TextInput, View, } from "react-native";
|
|
3
|
+
import { FontAwesome6, MaterialCommunityIcons } from "@expo/vector-icons";
|
|
4
|
+
import Styles from "../../constants/Styles";
|
|
5
|
+
import { useFormThemeContext } from "../../context/FormThemeContext";
|
|
6
|
+
import { AmexLogo, MCLogo, VisaLogo } from "../../assets";
|
|
7
|
+
const cardIcons = {
|
|
8
|
+
amex: AmexLogo,
|
|
9
|
+
discover: require("../../assets/photos/discover_logo.png"),
|
|
10
|
+
mc: MCLogo,
|
|
11
|
+
visa: VisaLogo,
|
|
12
|
+
};
|
|
13
|
+
export default function AppTextInput({ defaultStyling, fieldName, icon, onBlur, onChangeText, placeholder, hasError = false, errorText = "", styling: { formFieldStyle = {}, inputStyle = {}, textInputStyle = {} } = {}, value, withAnimatedText, withIcon, withPlaceholder, ...otherProps }) {
|
|
14
|
+
const { formFieldBackground, formFieldErrorBorder, iconColor, iconError, placeholderColor, placeholderError, textInput, textInputCarot, } = useFormThemeContext();
|
|
15
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
16
|
+
const [renderedIcon, setRenderedIcon] = useState(icon);
|
|
17
|
+
const activeAnim = useRef(null);
|
|
18
|
+
const animatedIsFlipped = useRef(new Animated.Value(icon?.type === "png" ? 1 : 0)).current;
|
|
19
|
+
const animatedIsFocused = useRef(new Animated.Value(value ? 1 : 0)).current;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
Animated.timing(animatedIsFocused, {
|
|
22
|
+
toValue: isFocused || !!value ? 1 : 0,
|
|
23
|
+
duration: 200,
|
|
24
|
+
useNativeDriver: false,
|
|
25
|
+
}).start();
|
|
26
|
+
}, [isFocused, value, animatedIsFocused]);
|
|
27
|
+
const placeholderStyle = {
|
|
28
|
+
position: "absolute",
|
|
29
|
+
left: animatedIsFocused.interpolate({
|
|
30
|
+
inputRange: [0, 1],
|
|
31
|
+
outputRange: [withIcon ? 40 : 15, withIcon ? 40 : 15],
|
|
32
|
+
}),
|
|
33
|
+
top: animatedIsFocused.interpolate({
|
|
34
|
+
inputRange: [0, 1],
|
|
35
|
+
outputRange: [30, 5],
|
|
36
|
+
}),
|
|
37
|
+
fontSize: animatedIsFocused.interpolate({
|
|
38
|
+
inputRange: [0, 1],
|
|
39
|
+
outputRange: [18, 12],
|
|
40
|
+
}),
|
|
41
|
+
color: animatedIsFocused.interpolate({
|
|
42
|
+
inputRange: [0, 1],
|
|
43
|
+
outputRange: [placeholderColor, placeholderColor],
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (icon === renderedIcon)
|
|
48
|
+
return;
|
|
49
|
+
const hasBrandIcon = icon?.type === "png";
|
|
50
|
+
if (activeAnim.current) {
|
|
51
|
+
try {
|
|
52
|
+
activeAnim.current.stop();
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
// ignore
|
|
56
|
+
}
|
|
57
|
+
activeAnim.current = null;
|
|
58
|
+
}
|
|
59
|
+
const anim = Animated.timing(animatedIsFlipped, {
|
|
60
|
+
toValue: hasBrandIcon ? 1 : 0,
|
|
61
|
+
duration: 500,
|
|
62
|
+
useNativeDriver: true,
|
|
63
|
+
});
|
|
64
|
+
activeAnim.current = anim;
|
|
65
|
+
anim.start(({ finished }) => {
|
|
66
|
+
activeAnim.current = null;
|
|
67
|
+
if (finished) {
|
|
68
|
+
setRenderedIcon(icon);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
setRenderedIcon(icon);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}, [icon]);
|
|
75
|
+
const rotateY = animatedIsFlipped.interpolate({
|
|
76
|
+
inputRange: [0, 1],
|
|
77
|
+
outputRange: ["0deg", "180deg"],
|
|
78
|
+
});
|
|
79
|
+
const rotateYBack = animatedIsFlipped.interpolate({
|
|
80
|
+
inputRange: [0, 1],
|
|
81
|
+
outputRange: ["180deg", "360deg"],
|
|
82
|
+
});
|
|
83
|
+
const backImageSource = icon?.type === "png"
|
|
84
|
+
? cardIcons[icon.name]
|
|
85
|
+
: renderedIcon?.type === "png"
|
|
86
|
+
? cardIcons[renderedIcon.name]
|
|
87
|
+
: null;
|
|
88
|
+
const Icon = backImageSource;
|
|
89
|
+
console.log(Icon);
|
|
90
|
+
return (<View style={defaultStyling && [
|
|
91
|
+
styles.formFieldContainer,
|
|
92
|
+
{ backgroundColor: formFieldBackground },
|
|
93
|
+
formFieldStyle,
|
|
94
|
+
hasError && { borderColor: formFieldErrorBorder },
|
|
95
|
+
]}>
|
|
96
|
+
{defaultStyling && withIcon && (<View style={styles.iconContainer}>
|
|
97
|
+
<View style={styles.flipContainer}>
|
|
98
|
+
{/* Front side: generic card icon or previously rendered icon.
|
|
99
|
+
We use renderedIcon so the old front stays visible until animation completes */}
|
|
100
|
+
<Animated.View style={[
|
|
101
|
+
styles.face,
|
|
102
|
+
styles.front,
|
|
103
|
+
{
|
|
104
|
+
transform: [{ rotateY }],
|
|
105
|
+
},
|
|
106
|
+
]}>
|
|
107
|
+
{/* If previously renderedIcon was a material/fa6 show it; otherwise show generic credit-card */}
|
|
108
|
+
{renderedIcon?.type === "material" && renderedIcon?.name ? (<MaterialCommunityIcons name={renderedIcon.name} size={25} color={hasError ? iconError : iconColor}/>) : renderedIcon?.type === "fa6" && renderedIcon?.name ? (<FontAwesome6 name={renderedIcon.name} size={21} color={hasError ? iconError : iconColor}/>) : (<MaterialCommunityIcons name="credit-card" size={25} color={hasError ? iconError : iconColor}/>)}
|
|
109
|
+
</Animated.View>
|
|
110
|
+
<Animated.View style={[
|
|
111
|
+
styles.face,
|
|
112
|
+
{
|
|
113
|
+
transform: [
|
|
114
|
+
{
|
|
115
|
+
rotateY: rotateYBack,
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
]}>
|
|
120
|
+
{Icon ? (typeof Icon === "function" ? (<Icon width="100%" height="100%"/>) : (<Image source={Icon} style={[
|
|
121
|
+
styles.logo,
|
|
122
|
+
(icon?.name === "visa" ||
|
|
123
|
+
icon?.name === "discover" ||
|
|
124
|
+
renderedIcon?.name === "visa" ||
|
|
125
|
+
renderedIcon?.name === "discover") && {
|
|
126
|
+
width: "70%",
|
|
127
|
+
height: "70%",
|
|
128
|
+
},
|
|
129
|
+
]}/>)) : (<View style={styles.logo}/>)}
|
|
130
|
+
</Animated.View>
|
|
131
|
+
</View>
|
|
132
|
+
</View>)}
|
|
133
|
+
{withPlaceholder && withAnimatedText && (<Animated.Text pointerEvents="none" style={defaultStyling && [
|
|
134
|
+
placeholderStyle,
|
|
135
|
+
hasError && { color: placeholderError },
|
|
136
|
+
]}>
|
|
137
|
+
{hasError ? errorText : placeholder}
|
|
138
|
+
</Animated.Text>)}
|
|
139
|
+
<TextInput onBlur={(e) => {
|
|
140
|
+
setIsFocused(false);
|
|
141
|
+
onBlur?.(e);
|
|
142
|
+
}} onChangeText={onChangeText} onFocus={() => setIsFocused(true)} placeholder={withPlaceholder && !withAnimatedText ? placeholder : undefined} placeholderTextColor={!withAnimatedText ? placeholderColor : undefined} selectionColor={textInputCarot} style={defaultStyling
|
|
143
|
+
? [
|
|
144
|
+
styles.textInput,
|
|
145
|
+
{ color: textInput },
|
|
146
|
+
!withIcon && { marginLeft: 15 },
|
|
147
|
+
textInputStyle,
|
|
148
|
+
]
|
|
149
|
+
: textInputStyle} value={value} {...otherProps}/>
|
|
150
|
+
</View>);
|
|
151
|
+
}
|
|
152
|
+
const styles = StyleSheet.create({
|
|
153
|
+
formFieldContainer: {
|
|
154
|
+
borderColor: "#3c3c3c",
|
|
155
|
+
borderRadius: 25,
|
|
156
|
+
borderWidth: 1,
|
|
157
|
+
flexDirection: "row",
|
|
158
|
+
paddingVertical: 20,
|
|
159
|
+
marginTop: 12,
|
|
160
|
+
},
|
|
161
|
+
iconContainer: {
|
|
162
|
+
marginTop: 8,
|
|
163
|
+
width: 40,
|
|
164
|
+
height: 25,
|
|
165
|
+
justifyContent: "center",
|
|
166
|
+
alignItems: "center",
|
|
167
|
+
padding: 1,
|
|
168
|
+
},
|
|
169
|
+
textInput: { height: 40, ...Styles.text },
|
|
170
|
+
// Flip animation styles
|
|
171
|
+
flipContainer: {
|
|
172
|
+
width: "100%",
|
|
173
|
+
height: "100%",
|
|
174
|
+
...{ transform: [{ perspective: 1000 }] },
|
|
175
|
+
},
|
|
176
|
+
flipCard: {
|
|
177
|
+
width: "100%",
|
|
178
|
+
height: "100%",
|
|
179
|
+
},
|
|
180
|
+
face: {
|
|
181
|
+
position: "absolute",
|
|
182
|
+
width: "100%",
|
|
183
|
+
height: "100%",
|
|
184
|
+
justifyContent: "center",
|
|
185
|
+
alignItems: "center",
|
|
186
|
+
backfaceVisibility: "hidden",
|
|
187
|
+
},
|
|
188
|
+
front: { zIndex: 2 },
|
|
189
|
+
logo: {
|
|
190
|
+
width: "100%",
|
|
191
|
+
height: "100%",
|
|
192
|
+
resizeMode: "contain",
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
//# sourceMappingURL=TextInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../src/components/forms/TextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,KAAK,EAEL,UAAU,EACV,SAAS,EAGT,IAAI,GAEL,MAAM,cAAc,CAAC;AAC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CAAC,CAAC","sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport {\n Animated,\n Image,\n StyleProp,\n StyleSheet,\n TextInput,\n TextInputProps,\n TextStyle,\n View,\n ViewStyle,\n} from \"react-native\";\nimport { FontAwesome6, MaterialCommunityIcons } from \"@expo/vector-icons\";\n\nimport Styles from \"../../constants/Styles\";\nimport { useFormThemeContext } from \"../../context/FormThemeContext\";\nimport { AmexLogo, MCLogo, VisaLogo } from \"../../assets\";\n\ntype StylingProps = {\n formFieldStyle?: StyleProp<ViewStyle>;\n inputStyle?: StyleProp<ViewStyle>;\n textInputStyle?: StyleProp<TextStyle>;\n};\n\ntype AppTextInputProps = TextInputProps & {\n defaultStyling?: boolean;\n fieldName?: string;\n icon?:\n | { type: \"material\"; name: keyof typeof MaterialCommunityIcons.glyphMap }\n | { type: \"fa6\"; name: keyof typeof FontAwesome6.glyphMap }\n | { type: \"png\"; name: \"amex\" | \"discover\" | \"mc\" | \"visa\" };\n hasError?: boolean;\n errorText?: string;\n styling?: StylingProps;\n withAnimatedText?: boolean;\n withIcon?: boolean;\n withPlaceholder?: boolean;\n};\n\nconst cardIcons: Record<string, any> = {\n amex: AmexLogo,\n discover: require(\"../../assets/photos/discover_logo.png\"),\n mc: MCLogo,\n visa: VisaLogo,\n};\n\nexport default function AppTextInput({\n defaultStyling,\n fieldName,\n icon,\n onBlur,\n onChangeText,\n placeholder,\n hasError = false,\n errorText = \"\",\n styling: { formFieldStyle = {}, inputStyle = {}, textInputStyle = {} } = {},\n value,\n withAnimatedText,\n withIcon,\n withPlaceholder,\n ...otherProps\n}: AppTextInputProps) {\n const {\n formFieldBackground,\n formFieldErrorBorder,\n iconColor,\n iconError,\n placeholderColor,\n placeholderError,\n textInput,\n textInputCarot,\n } = useFormThemeContext();\n\n const [isFocused, setIsFocused] = useState<boolean>(false);\n const [renderedIcon, setRenderedIcon] = useState(icon);\n\n const activeAnim = useRef<Animated.CompositeAnimation | null>(null);\n const animatedIsFlipped = useRef(\n new Animated.Value(icon?.type === \"png\" ? 1 : 0)\n ).current;\n const animatedIsFocused = useRef(new Animated.Value(value ? 1 : 0)).current;\n\n useEffect(() => {\n Animated.timing(animatedIsFocused, {\n toValue: isFocused || !!value ? 1 : 0,\n duration: 200,\n useNativeDriver: false,\n }).start();\n }, [isFocused, value, animatedIsFocused]);\n\n const placeholderStyle: Animated.WithAnimatedObject<StyleProp<TextStyle>> = {\n position: \"absolute\",\n left: animatedIsFocused.interpolate({\n inputRange: [0, 1],\n outputRange: [withIcon ? 40 : 15, withIcon ? 40 : 15],\n }),\n top: animatedIsFocused.interpolate({\n inputRange: [0, 1],\n outputRange: [30, 5],\n }),\n fontSize: animatedIsFocused.interpolate({\n inputRange: [0, 1],\n outputRange: [18, 12],\n }),\n color: animatedIsFocused.interpolate({\n inputRange: [0, 1],\n outputRange: [placeholderColor, placeholderColor],\n }),\n };\n\n useEffect(() => {\n if (icon === renderedIcon) return;\n\n const hasBrandIcon = icon?.type === \"png\";\n\n if (activeAnim.current) {\n try {\n activeAnim.current.stop();\n } catch (e) {\n // ignore\n }\n activeAnim.current = null;\n }\n\n const anim = Animated.timing(animatedIsFlipped, {\n toValue: hasBrandIcon ? 1 : 0,\n duration: 500,\n useNativeDriver: true,\n });\n\n activeAnim.current = anim;\n anim.start(({ finished }) => {\n activeAnim.current = null;\n if (finished) {\n setRenderedIcon(icon);\n } else {\n setRenderedIcon(icon);\n }\n });\n }, [icon]);\n\n const rotateY = animatedIsFlipped.interpolate({\n inputRange: [0, 1],\n outputRange: [\"0deg\", \"180deg\"],\n });\n\n const rotateYBack = animatedIsFlipped.interpolate({\n inputRange: [0, 1],\n outputRange: [\"180deg\", \"360deg\"],\n });\n\n const backImageSource =\n icon?.type === \"png\"\n ? cardIcons[icon.name]\n : renderedIcon?.type === \"png\"\n ? cardIcons[renderedIcon.name]\n : null;\n\n const Icon = backImageSource;\n console.log(Icon);\n return (\n <View\n style={\n defaultStyling && [\n styles.formFieldContainer,\n { backgroundColor: formFieldBackground },\n formFieldStyle,\n hasError && { borderColor: formFieldErrorBorder },\n ]\n }\n >\n {defaultStyling && withIcon && (\n <View style={styles.iconContainer}>\n <View style={styles.flipContainer}>\n {/* Front side: generic card icon or previously rendered icon.\n We use renderedIcon so the old front stays visible until animation completes */}\n <Animated.View\n style={[\n styles.face,\n styles.front,\n {\n transform: [{ rotateY }],\n },\n ]}\n >\n {/* If previously renderedIcon was a material/fa6 show it; otherwise show generic credit-card */}\n {renderedIcon?.type === \"material\" && renderedIcon?.name ? (\n <MaterialCommunityIcons\n name={renderedIcon.name}\n size={25}\n color={hasError ? iconError : iconColor}\n />\n ) : renderedIcon?.type === \"fa6\" && renderedIcon?.name ? (\n <FontAwesome6\n name={renderedIcon.name}\n size={21}\n color={hasError ? iconError : iconColor}\n />\n ) : (\n <MaterialCommunityIcons\n name=\"credit-card\"\n size={25}\n color={hasError ? iconError : iconColor}\n />\n )}\n </Animated.View>\n <Animated.View\n style={[\n styles.face,\n {\n transform: [\n {\n rotateY: rotateYBack,\n },\n ],\n },\n ]}\n >\n {Icon ? (\n typeof Icon === \"function\" ? (\n <Icon width=\"100%\" height=\"100%\" />\n ) : (\n <Image\n source={Icon}\n style={[\n styles.logo,\n (icon?.name === \"visa\" ||\n icon?.name === \"discover\" ||\n renderedIcon?.name === \"visa\" ||\n renderedIcon?.name === \"discover\") && {\n width: \"70%\",\n height: \"70%\",\n },\n ]}\n />\n )\n ) : (\n <View style={styles.logo} />\n )}\n </Animated.View>\n </View>\n </View>\n )}\n {withPlaceholder && withAnimatedText && (\n <Animated.Text\n pointerEvents=\"none\"\n style={\n defaultStyling && [\n placeholderStyle,\n hasError && { color: placeholderError },\n ]\n }\n >\n {hasError ? errorText : placeholder}\n </Animated.Text>\n )}\n <TextInput\n onBlur={(e) => {\n setIsFocused(false);\n onBlur?.(e);\n }}\n onChangeText={onChangeText}\n onFocus={() => setIsFocused(true)}\n placeholder={\n withPlaceholder && !withAnimatedText ? placeholder : undefined\n }\n placeholderTextColor={!withAnimatedText ? placeholderColor : undefined}\n selectionColor={textInputCarot}\n style={\n defaultStyling\n ? [\n styles.textInput,\n { color: textInput },\n !withIcon && { marginLeft: 15 },\n textInputStyle,\n ]\n : textInputStyle\n }\n value={value}\n {...otherProps}\n />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n formFieldContainer: {\n borderColor: \"#3c3c3c\",\n borderRadius: 25,\n borderWidth: 1,\n flexDirection: \"row\",\n paddingVertical: 20,\n marginTop: 12,\n },\n iconContainer: {\n marginTop: 8,\n width: 40,\n height: 25,\n justifyContent: \"center\",\n alignItems: \"center\",\n padding: 1,\n },\n textInput: { height: 40, ...Styles.text },\n\n // Flip animation styles\n flipContainer: {\n width: \"100%\",\n height: \"100%\",\n ...({ transform: [{ perspective: 1000 }] } as any),\n },\n flipCard: {\n width: \"100%\",\n height: \"100%\",\n },\n face: {\n position: \"absolute\",\n width: \"100%\",\n height: \"100%\",\n justifyContent: \"center\",\n alignItems: \"center\",\n backfaceVisibility: \"hidden\",\n },\n front: { zIndex: 2 },\n logo: {\n width: \"100%\",\n height: \"100%\",\n resizeMode: \"contain\",\n },\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/forms/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/forms/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["// export { default as ErrorMessage } from \"./ErrorMessage\";\nexport { default as FormField } from \"./FormField\";\nexport { default as SubmitButton } from \"./SubmitButton\";\nexport { default as TextInput } from \"./TextInput\";\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as OPCardForm } from "./OPCardForm";
|
|
2
|
+
export { default as OPCardNumberInput } from "./OPCardNumberInput";
|
|
3
|
+
export { default as OPCvv2Input } from "./OPCvv2Input";
|
|
4
|
+
export { default as OPExpInput } from "./OPExpInput";
|
|
5
|
+
export { default as OPExpMonthInput } from "./OPExpMonthInput";
|
|
6
|
+
export { default as OPExpYearInput } from "./OPExpYearInput";
|
|
7
|
+
export { default as OPHolderNameInput } from "./OPHolderNameInput";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as OPCardForm } from "./OPCardForm";
|
|
2
|
+
export { default as OPCardNumberInput } from "./OPCardNumberInput";
|
|
3
|
+
export { default as OPCvv2Input } from "./OPCvv2Input";
|
|
4
|
+
export { default as OPExpInput } from "./OPExpInput";
|
|
5
|
+
export { default as OPExpMonthInput } from "./OPExpMonthInput";
|
|
6
|
+
export { default as OPExpYearInput } from "./OPExpYearInput";
|
|
7
|
+
export { default as OPHolderNameInput } from "./OPHolderNameInput";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export { default as OPCardForm } from \"./OPCardForm\";\nexport { default as OPCardNumberInput } from \"./OPCardNumberInput\";\nexport { default as OPCvv2Input } from \"./OPCvv2Input\";\nexport { default as OPExpInput } from \"./OPExpInput\";\nexport { default as OPExpMonthInput } from \"./OPExpMonthInput\";\nexport { default as OPExpYearInput } from \"./OPExpYearInput\";\nexport { default as OPHolderNameInput } from \"./OPHolderNameInput\";\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const Colors: {
|
|
2
|
+
light: {
|
|
3
|
+
button: string;
|
|
4
|
+
buttonText: string;
|
|
5
|
+
formFieldBackground: string;
|
|
6
|
+
formFieldErrorBorder: string;
|
|
7
|
+
iconColor: string;
|
|
8
|
+
iconError: string;
|
|
9
|
+
placeholderColor: string;
|
|
10
|
+
placeholderError: string;
|
|
11
|
+
textInput: string;
|
|
12
|
+
textInputCarot: string;
|
|
13
|
+
};
|
|
14
|
+
dark: {
|
|
15
|
+
button: string;
|
|
16
|
+
buttonText: string;
|
|
17
|
+
formFieldBackground: string;
|
|
18
|
+
formFieldErrorBorder: string;
|
|
19
|
+
iconColor: string;
|
|
20
|
+
iconError: string;
|
|
21
|
+
placeholderColor: string;
|
|
22
|
+
placeholderError: string;
|
|
23
|
+
textInput: string;
|
|
24
|
+
textInputCarot: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=Colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Colors.d.ts","sourceRoot":"","sources":["../../src/constants/Colors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const Colors = {
|
|
2
|
+
light: {
|
|
3
|
+
button: "#16c8bf",
|
|
4
|
+
buttonText: "#014481",
|
|
5
|
+
formFieldBackground: "#f8f4f4",
|
|
6
|
+
formFieldErrorBorder: "#fc5c65",
|
|
7
|
+
iconColor: "#6e6969",
|
|
8
|
+
iconError: "#fc5c65",
|
|
9
|
+
placeholderColor: "#6e6969",
|
|
10
|
+
placeholderError: "#fc5c65",
|
|
11
|
+
textInput: "#6e6969",
|
|
12
|
+
textInputCarot: "#014481",
|
|
13
|
+
},
|
|
14
|
+
dark: {
|
|
15
|
+
button: "#16c8bf",
|
|
16
|
+
buttonText: "#014481",
|
|
17
|
+
formFieldBackground: "#242526",
|
|
18
|
+
formFieldErrorBorder: "#fc5c65",
|
|
19
|
+
iconColor: "#e5e5e5",
|
|
20
|
+
iconError: "#fc5c65",
|
|
21
|
+
placeholderColor: "#6e6969",
|
|
22
|
+
placeholderError: "#fc5c65",
|
|
23
|
+
textInput: "#e5e5e5",
|
|
24
|
+
textInputCarot: "#014481",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=Colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Colors.js","sourceRoot":"","sources":["../../src/constants/Colors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE;QACL,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,SAAS;QACrB,mBAAmB,EAAE,SAAS;QAC9B,oBAAoB,EAAE,SAAS;QAC/B,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,gBAAgB,EAAE,SAAS;QAC3B,gBAAgB,EAAE,SAAS;QAC3B,SAAS,EAAE,SAAS;QACpB,cAAc,EAAE,SAAS;KAC1B;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,SAAS;QACrB,mBAAmB,EAAE,SAAS;QAC9B,oBAAoB,EAAE,SAAS;QAC/B,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,gBAAgB,EAAE,SAAS;QAC3B,gBAAgB,EAAE,SAAS;QAC3B,SAAS,EAAE,SAAS;QACpB,cAAc,EAAE,SAAS;KAC1B;CACF,CAAC","sourcesContent":["export const Colors = {\n light: {\n button: \"#16c8bf\",\n buttonText: \"#014481\",\n formFieldBackground: \"#f8f4f4\",\n formFieldErrorBorder: \"#fc5c65\",\n iconColor: \"#6e6969\",\n iconError: \"#fc5c65\",\n placeholderColor: \"#6e6969\",\n placeholderError: \"#fc5c65\",\n textInput: \"#6e6969\",\n textInputCarot: \"#014481\",\n },\n dark: {\n button: \"#16c8bf\",\n buttonText: \"#014481\",\n formFieldBackground: \"#242526\",\n formFieldErrorBorder: \"#fc5c65\",\n iconColor: \"#e5e5e5\",\n iconError: \"#fc5c65\",\n placeholderColor: \"#6e6969\",\n placeholderError: \"#fc5c65\",\n textInput: \"#e5e5e5\",\n textInputCarot: \"#014481\",\n },\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../src/constants/Styles.ts"],"names":[],"mappings":";;;;;;;AAEA,wBAME"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.js","sourceRoot":"","sources":["../../src/constants/Styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,eAAe;IACb,IAAI,EAAE;QACJ,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;KAC5D;CACF,CAAC","sourcesContent":["import { Platform } from \"react-native\";\n\nexport default {\n text: {\n flex: 1,\n fontSize: 18,\n fontFamily: Platform.OS === \"android\" ? \"Roboto\" : \"Avenir\",\n },\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type FormValues = Record<string, any>;
|
|
2
|
+
type FormErrors = Record<string, string | undefined>;
|
|
3
|
+
type FormTouched = Record<string, boolean>;
|
|
4
|
+
interface FormContextType {
|
|
5
|
+
errors: FormErrors;
|
|
6
|
+
isSubmitting: boolean;
|
|
7
|
+
touched: FormTouched;
|
|
8
|
+
values: FormValues;
|
|
9
|
+
handleSubmit: () => Promise<any>;
|
|
10
|
+
resetForm: () => void;
|
|
11
|
+
setFieldValue: (field: string, value: any) => void;
|
|
12
|
+
setFieldTouched: (field: string, touched?: boolean) => void;
|
|
13
|
+
setFieldError: (field: string, error: string | undefined) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const useFormContext: () => FormContextType;
|
|
16
|
+
export default function FormProvider({ children, initialValues, onSubmit, }: {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
initialValues?: FormValues;
|
|
19
|
+
onSubmit?: () => any;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=FormContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormContext.d.ts","sourceRoot":"","sources":["../../src/context/FormContext.tsx"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACtC,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AACrD,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3C,UAAU,eAAe;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACnD,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5D,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CACnE;AAID,eAAO,MAAM,cAAc,uBAM1B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,QAAQ,EACR,aAAkB,EAClB,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC;CACtB,+BAqEA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createContext, useContext, useState } from "react";
|
|
2
|
+
import { tokenizeCard } from "../ExpoOpenpayModule";
|
|
3
|
+
import { unformat } from "../utility/formatting";
|
|
4
|
+
const FormContext = createContext(undefined);
|
|
5
|
+
export const useFormContext = () => {
|
|
6
|
+
const context = useContext(FormContext);
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error("useFormContext must be used within a FormProvider");
|
|
9
|
+
}
|
|
10
|
+
return context;
|
|
11
|
+
};
|
|
12
|
+
export default function FormProvider({ children, initialValues = {}, onSubmit, }) {
|
|
13
|
+
const [values, setValues] = useState(initialValues);
|
|
14
|
+
const [errors, setErrors] = useState({});
|
|
15
|
+
const [touched, setTouched] = useState({});
|
|
16
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
17
|
+
const handleSubmit = async () => {
|
|
18
|
+
try {
|
|
19
|
+
setIsSubmitting(true);
|
|
20
|
+
if (onSubmit)
|
|
21
|
+
onSubmit();
|
|
22
|
+
if (values["exp"]) {
|
|
23
|
+
values["expMonth"] = values["exp"].slice(0, 2);
|
|
24
|
+
values["expYear"] = values["exp"].slice(3);
|
|
25
|
+
}
|
|
26
|
+
await tokenizeCard(unformat(values["cardNumber"]), values["cardHolderName"], values["expYear"], values["expMonth"], values["cvc"]);
|
|
27
|
+
resetForm();
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
if (e instanceof Error) {
|
|
31
|
+
console.error("Error during submission:", e.message);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.error("Unknown error during submission", e);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
setIsSubmitting(false);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const resetForm = () => {
|
|
42
|
+
setValues({});
|
|
43
|
+
setErrors({});
|
|
44
|
+
setTouched({});
|
|
45
|
+
};
|
|
46
|
+
const setFieldValue = (field, value) => setValues((prev) => ({ ...prev, [field]: value }));
|
|
47
|
+
const setFieldTouched = (field, isTouched = true) => setTouched((prev) => ({ ...prev, [field]: isTouched }));
|
|
48
|
+
const setFieldError = (field, error) => setErrors((prev) => ({ ...prev, [field]: error }));
|
|
49
|
+
return (<FormContext.Provider value={{
|
|
50
|
+
errors,
|
|
51
|
+
isSubmitting,
|
|
52
|
+
touched,
|
|
53
|
+
values,
|
|
54
|
+
handleSubmit,
|
|
55
|
+
resetForm,
|
|
56
|
+
setFieldValue,
|
|
57
|
+
setFieldTouched,
|
|
58
|
+
setFieldError,
|
|
59
|
+
}}>
|
|
60
|
+
{children}
|
|
61
|
+
</FormContext.Provider>);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=FormContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormContext.js","sourceRoot":"","sources":["../../src/context/FormContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAkBjD,MAAM,WAAW,GAAG,aAAa,CAA8B,SAAS,CAAC,CAAC;AAE1E,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,QAAQ,EACR,aAAa,GAAG,EAAE,EAClB,QAAQ,GAKT;IACC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAa,aAAa,CAAC,CAAC;IAChE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAA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CAAC;QACd,SAAS,CAAC,EAAE,CAAC,CAAC;QACd,UAAU,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,KAAU,EAAE,EAAE,CAClD,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAErD,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,YAAqB,IAAI,EAAE,EAAE,CACnE,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAE1D,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,KAAyB,EAAE,EAAE,CACjE,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAErD,OAAO,CACL,CAAC,WAAW,CAAC,QAAQ,CACnB,KAAK,CAAC,CAAC;YACL,MAAM;YACN,YAAY;YACZ,OAAO;YACP,MAAM;YACN,YAAY;YACZ,SAAS;YACT,aAAa;YACb,eAAe;YACf,aAAa;SACd,CAAC,CAEF;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,WAAW,CAAC,QAAQ,CAAC,CACxB,CAAC;AACJ,CAAC","sourcesContent":["import { createContext, useContext, useState } from \"react\";\n\nimport { tokenizeCard } from \"../ExpoOpenpayModule\";\nimport { unformat } from \"../utility/formatting\";\n\ntype FormValues = Record<string, any>;\ntype FormErrors = Record<string, string | undefined>;\ntype FormTouched = Record<string, boolean>;\n\ninterface FormContextType {\n errors: FormErrors;\n isSubmitting: boolean;\n touched: FormTouched;\n values: FormValues;\n handleSubmit: () => Promise<any>;\n resetForm: () => void;\n setFieldValue: (field: string, value: any) => void;\n setFieldTouched: (field: string, touched?: boolean) => void;\n setFieldError: (field: string, error: string | undefined) => void;\n}\n\nconst FormContext = createContext<FormContextType | undefined>(undefined);\n\nexport const useFormContext = () => {\n const context = useContext(FormContext);\n if (!context) {\n throw new Error(\"useFormContext must be used within a FormProvider\");\n }\n return context;\n};\n\nexport default function FormProvider({\n children,\n initialValues = {},\n onSubmit,\n}: {\n children: React.ReactNode;\n initialValues?: FormValues;\n onSubmit?: () => any;\n}) {\n const [values, setValues] = useState<FormValues>(initialValues);\n const [errors, setErrors] = useState<FormErrors>({});\n const [touched, setTouched] = useState<FormTouched>({});\n const [isSubmitting, setIsSubmitting] = useState<boolean>(false);\n\n const handleSubmit = async (): Promise<any> => {\n try {\n setIsSubmitting(true);\n\n if (onSubmit) onSubmit();\n\n if (values[\"exp\"]) {\n values[\"expMonth\"] = values[\"exp\"].slice(0, 2);\n values[\"expYear\"] = values[\"exp\"].slice(3);\n }\n\n await tokenizeCard(\n unformat(values[\"cardNumber\"]),\n values[\"cardHolderName\"],\n values[\"expYear\"],\n values[\"expMonth\"],\n values[\"cvc\"]\n );\n\n resetForm();\n } catch (e) {\n if (e instanceof Error) {\n console.error(\"Error during submission:\", e.message);\n } else {\n console.error(\"Unknown error during submission\", e);\n }\n } finally {\n setIsSubmitting(false);\n }\n };\n\n const resetForm = () => {\n setValues({});\n setErrors({});\n setTouched({});\n };\n\n const setFieldValue = (field: string, value: any) =>\n setValues((prev) => ({ ...prev, [field]: value }));\n\n const setFieldTouched = (field: string, isTouched: boolean = true) =>\n setTouched((prev) => ({ ...prev, [field]: isTouched }));\n\n const setFieldError = (field: string, error: string | undefined) =>\n setErrors((prev) => ({ ...prev, [field]: error }));\n\n return (\n <FormContext.Provider\n value={{\n errors,\n isSubmitting,\n touched,\n values,\n handleSubmit,\n resetForm,\n setFieldValue,\n setFieldTouched,\n setFieldError,\n }}\n >\n {children}\n </FormContext.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface FormThemeColors {
|
|
2
|
+
button: string;
|
|
3
|
+
buttonText: string;
|
|
4
|
+
formFieldBackground: string;
|
|
5
|
+
formFieldErrorBorder: string;
|
|
6
|
+
iconColor: string;
|
|
7
|
+
iconError: string;
|
|
8
|
+
placeholderColor: string;
|
|
9
|
+
placeholderError: string;
|
|
10
|
+
textInput: string;
|
|
11
|
+
textInputCarot: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const useFormThemeContext: () => FormThemeColors;
|
|
14
|
+
export default function FormThemeProvider({ children, dark, light, }: {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
colorScheme: "light" | "dark";
|
|
17
|
+
dark?: FormThemeColors;
|
|
18
|
+
light?: FormThemeColors;
|
|
19
|
+
}): import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=FormThemeContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormThemeContext.d.ts","sourceRoot":"","sources":["../../src/context/FormThemeContext.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAID,eAAO,MAAM,mBAAmB,uBAQ/B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,QAAQ,EACR,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB,+BAeA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext, useContext, useMemo } from "react";
|
|
2
|
+
import { useColorScheme } from "react-native";
|
|
3
|
+
import { Colors } from "../constants/Colors";
|
|
4
|
+
const FormThemeContext = createContext(undefined);
|
|
5
|
+
export const useFormThemeContext = () => {
|
|
6
|
+
const context = useContext(FormThemeContext);
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error("useFormThemeContext must be used within a FormThemeProvider");
|
|
9
|
+
}
|
|
10
|
+
return context;
|
|
11
|
+
};
|
|
12
|
+
export default function FormThemeProvider({ children, dark, light, }) {
|
|
13
|
+
const mergedDark = useMemo(() => ({ ...Colors.dark, ...dark }), [dark]);
|
|
14
|
+
const mergedLight = useMemo(() => ({ ...Colors.light, ...light }), [light]);
|
|
15
|
+
const colorScheme = useColorScheme();
|
|
16
|
+
const colorTheme = useMemo(() => (colorScheme === "dark" ? mergedDark : mergedLight), [colorScheme, mergedDark, mergedLight]);
|
|
17
|
+
return (<FormThemeContext.Provider value={colorTheme}>
|
|
18
|
+
{children}
|
|
19
|
+
</FormThemeContext.Provider>);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=FormThemeContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormThemeContext.js","sourceRoot":"","sources":["../../src/context/FormThemeContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAe7C,MAAM,gBAAgB,GAAG,aAAa,CAA8B,SAAS,CAAC,CAAC;AAE/E,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,QAAQ,EACR,IAAI,EACJ,KAAK,GAMN;IACC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAE5E,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,UAAU,GAAG,OAAO,CACxB,GAAG,EAAE,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,EACzD,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,CAAC,CACvC,CAAC;IAEF,OAAO,CACL,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAC3C;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\nimport { useColorScheme } from \"react-native\";\n\nimport { Colors } from \"../constants/Colors\";\n\nexport interface FormThemeColors {\n button: string;\n buttonText: string;\n formFieldBackground: string;\n formFieldErrorBorder: string;\n iconColor: string;\n iconError: string;\n placeholderColor: string;\n placeholderError: string;\n textInput: string;\n textInputCarot: string;\n}\n\nconst FormThemeContext = createContext<FormThemeColors | undefined>(undefined);\n\nexport const useFormThemeContext = () => {\n const context = useContext(FormThemeContext);\n if (!context) {\n throw new Error(\n \"useFormThemeContext must be used within a FormThemeProvider\"\n );\n }\n return context;\n};\n\nexport default function FormThemeProvider({\n children,\n dark,\n light,\n}: {\n children: React.ReactNode;\n colorScheme: \"light\" | \"dark\";\n dark?: FormThemeColors;\n light?: FormThemeColors;\n}) {\n const mergedDark = useMemo(() => ({ ...Colors.dark, ...dark }), [dark]);\n const mergedLight = useMemo(() => ({ ...Colors.light, ...light }), [light]);\n\n const colorScheme = useColorScheme();\n const colorTheme = useMemo(\n () => (colorScheme === \"dark\" ? mergedDark : mergedLight),\n [colorScheme, mergedDark, mergedLight]\n );\n\n return (\n <FormThemeContext.Provider value={colorTheme}>\n {children}\n </FormThemeContext.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { default as FormProvider } from \"./FormContext\";\nexport { default as FormThemeProvider } from \"./FormThemeContext\";\nexport { FormThemeColors } from \"./FormThemeContext\";\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Runtime check for react-native-svg
|
|
2
|
+
try {
|
|
3
|
+
require("react-native-svg");
|
|
4
|
+
}
|
|
5
|
+
catch (e) {
|
|
6
|
+
throw new Error("expo-openpay requires react-native-svg. Please install it:\n" +
|
|
7
|
+
" yarn add react-native-svg\n" +
|
|
8
|
+
"or\n" +
|
|
9
|
+
" npm install react-native-svg");
|
|
10
|
+
}
|
|
11
|
+
// Reexport the native module. On web, it will be resolved to ExpoOpenpayModule.web.ts
|
|
12
|
+
// and on native platforms to ExpoOpenpayModule.ts
|
|
13
|
+
export { default } from "./ExpoOpenpayModule";
|
|
14
|
+
export { default as ExpoOpenpayView } from "./ExpoOpenpayView";
|
|
15
|
+
export * from "./ExpoOpenpayModule";
|
|
16
|
+
export * from "./components";
|
|
17
|
+
export * from "./ExpoOpenpay.types";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,IAAI,CAAC;IACH,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC9B,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC;IACX,MAAM,IAAI,KAAK,CACb,8DAA8D;QAC5D,+BAA+B;QAC/B,MAAM;QACN,gCAAgC,CACnC,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,kDAAkD;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC","sourcesContent":["// Runtime check for react-native-svg\ntry {\n require(\"react-native-svg\");\n} catch (e) {\n throw new Error(\n \"expo-openpay requires react-native-svg. Please install it:\\n\" +\n \" yarn add react-native-svg\\n\" +\n \"or\\n\" +\n \" npm install react-native-svg\"\n );\n}\n\n// Reexport the native module. On web, it will be resolved to ExpoOpenpayModule.web.ts\n// and on native platforms to ExpoOpenpayModule.ts\nexport { default } from \"./ExpoOpenpayModule\";\nexport { default as ExpoOpenpayView } from \"./ExpoOpenpayView\";\nexport * from \"./ExpoOpenpayModule\";\nexport * from \"./components\";\nexport * from \"./ExpoOpenpay.types\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardBranding.d.ts","sourceRoot":"","sources":["../../src/utility/cardBranding.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardBranding.js","sourceRoot":"","sources":["../../src/utility/cardBranding.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utility/formatting.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,KAAG,MAQtD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAQzC,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,eAAe,MAAM,KAAG,MAEhD,CAAC"}
|