@tonder.io/rn-sdk 0.1.3 → 0.1.4

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 (75) hide show
  1. package/README.md +66 -24
  2. package/lib/commonjs/index.js +0 -15
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/types/base.js +8 -1
  5. package/lib/commonjs/types/base.js.map +1 -1
  6. package/lib/commonjs/ui/components/CardForm/index.js +3 -1
  7. package/lib/commonjs/ui/components/CardForm/index.js.map +1 -1
  8. package/lib/commonjs/ui/components/Checkbox/Checkbox.js +24 -6
  9. package/lib/commonjs/ui/components/Checkbox/Checkbox.js.map +1 -1
  10. package/lib/commonjs/ui/components/SavedCardsList/index.js +11 -4
  11. package/lib/commonjs/ui/components/SavedCardsList/index.js.map +1 -1
  12. package/lib/commonjs/ui/components/Skeleton/CardFormSkeleton.js +51 -23
  13. package/lib/commonjs/ui/components/Skeleton/CardFormSkeleton.js.map +1 -1
  14. package/lib/commonjs/ui/features/TonderEnrollment/index.js +1 -0
  15. package/lib/commonjs/ui/features/TonderEnrollment/index.js.map +1 -1
  16. package/lib/commonjs/ui/features/TonderPayment/index.js +6 -2
  17. package/lib/commonjs/ui/features/TonderPayment/index.js.map +1 -1
  18. package/lib/module/index.js +0 -13
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/module/types/base.js +7 -0
  21. package/lib/module/types/base.js.map +1 -1
  22. package/lib/module/ui/components/CardForm/index.js +3 -1
  23. package/lib/module/ui/components/CardForm/index.js.map +1 -1
  24. package/lib/module/ui/components/Checkbox/Checkbox.js +24 -6
  25. package/lib/module/ui/components/Checkbox/Checkbox.js.map +1 -1
  26. package/lib/module/ui/components/SavedCardsList/index.js +11 -4
  27. package/lib/module/ui/components/SavedCardsList/index.js.map +1 -1
  28. package/lib/module/ui/components/Skeleton/CardFormSkeleton.js +51 -23
  29. package/lib/module/ui/components/Skeleton/CardFormSkeleton.js.map +1 -1
  30. package/lib/module/ui/features/TonderEnrollment/index.js +1 -0
  31. package/lib/module/ui/features/TonderEnrollment/index.js.map +1 -1
  32. package/lib/module/ui/features/TonderPayment/index.js +6 -2
  33. package/lib/module/ui/features/TonderPayment/index.js.map +1 -1
  34. package/lib/typescript/commonjs/src/index.d.ts +0 -1
  35. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/src/types/base.d.ts +6 -5
  37. package/lib/typescript/commonjs/src/types/base.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/src/types/common.d.ts +22 -1
  39. package/lib/typescript/commonjs/src/types/common.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/src/ui/components/CardForm/index.d.ts +2 -2
  41. package/lib/typescript/commonjs/src/ui/components/CardForm/index.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/src/ui/components/Checkbox/Checkbox.d.ts +3 -0
  43. package/lib/typescript/commonjs/src/ui/components/Checkbox/Checkbox.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/src/ui/components/SavedCardsList/index.d.ts +1 -0
  45. package/lib/typescript/commonjs/src/ui/components/SavedCardsList/index.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/src/ui/components/Skeleton/CardFormSkeleton.d.ts +4 -1
  47. package/lib/typescript/commonjs/src/ui/components/Skeleton/CardFormSkeleton.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/src/ui/features/TonderEnrollment/index.d.ts.map +1 -1
  49. package/lib/typescript/commonjs/src/ui/features/TonderPayment/index.d.ts.map +1 -1
  50. package/lib/typescript/module/src/index.d.ts +0 -1
  51. package/lib/typescript/module/src/index.d.ts.map +1 -1
  52. package/lib/typescript/module/src/types/base.d.ts +6 -5
  53. package/lib/typescript/module/src/types/base.d.ts.map +1 -1
  54. package/lib/typescript/module/src/types/common.d.ts +22 -1
  55. package/lib/typescript/module/src/types/common.d.ts.map +1 -1
  56. package/lib/typescript/module/src/ui/components/CardForm/index.d.ts +2 -2
  57. package/lib/typescript/module/src/ui/components/CardForm/index.d.ts.map +1 -1
  58. package/lib/typescript/module/src/ui/components/Checkbox/Checkbox.d.ts +3 -0
  59. package/lib/typescript/module/src/ui/components/Checkbox/Checkbox.d.ts.map +1 -1
  60. package/lib/typescript/module/src/ui/components/SavedCardsList/index.d.ts +1 -0
  61. package/lib/typescript/module/src/ui/components/SavedCardsList/index.d.ts.map +1 -1
  62. package/lib/typescript/module/src/ui/components/Skeleton/CardFormSkeleton.d.ts +4 -1
  63. package/lib/typescript/module/src/ui/components/Skeleton/CardFormSkeleton.d.ts.map +1 -1
  64. package/lib/typescript/module/src/ui/features/TonderEnrollment/index.d.ts.map +1 -1
  65. package/lib/typescript/module/src/ui/features/TonderPayment/index.d.ts.map +1 -1
  66. package/package.json +1 -1
  67. package/src/index.tsx +0 -23
  68. package/src/types/base.ts +6 -8
  69. package/src/types/common.ts +25 -1
  70. package/src/ui/components/CardForm/index.tsx +8 -4
  71. package/src/ui/components/Checkbox/Checkbox.tsx +29 -4
  72. package/src/ui/components/SavedCardsList/index.tsx +15 -3
  73. package/src/ui/components/Skeleton/CardFormSkeleton.tsx +78 -20
  74. package/src/ui/features/TonderEnrollment/index.tsx +6 -1
  75. package/src/ui/features/TonderPayment/index.tsx +10 -2
@@ -22,6 +22,7 @@ interface SavedCardsListProps {
22
22
  deletingCards?: string[];
23
23
  style?: StylesSavedCardsVariant;
24
24
  showDeleteButton?: boolean;
25
+ expirationLabel?: string;
25
26
  }
26
27
 
27
28
  const SavedCardsList: React.FC<SavedCardsListProps> = ({
@@ -32,6 +33,7 @@ const SavedCardsList: React.FC<SavedCardsListProps> = ({
32
33
  deletingCards,
33
34
  showDeleteButton = true,
34
35
  style,
36
+ expirationLabel = 'Exp.',
35
37
  }) => {
36
38
  if (!cards.length) return null;
37
39
 
@@ -42,8 +44,17 @@ const SavedCardsList: React.FC<SavedCardsListProps> = ({
42
44
  };
43
45
  return (
44
46
  <View style={{ ...styles.container, ...(style?.base || {}) }}>
45
- {cards.map((card) => (
46
- <View key={card.fields.skyflow_id} style={styles.cardItem}>
47
+ {cards.map((card, index) => (
48
+ <View
49
+ key={card.fields.skyflow_id}
50
+ style={[
51
+ styles.cardItem,
52
+ { ...{ ...(style?.cardItem?.base || {}) } },
53
+ index === cards.length - 1 && {
54
+ borderBottomWidth: 0,
55
+ },
56
+ ]}
57
+ >
47
58
  <RadioButton
48
59
  style={{
49
60
  base: style?.radioBase,
@@ -73,7 +84,8 @@ const SavedCardsList: React.FC<SavedCardsListProps> = ({
73
84
  ...buildBaseStyleText(style),
74
85
  }}
75
86
  >
76
- Exp. {card.fields.expiration_month}/{card.fields.expiration_year}
87
+ {expirationLabel} {card.fields.expiration_month}/
88
+ {card.fields.expiration_year}
77
89
  </Text>
78
90
  </View>
79
91
  {(deletingCards || []).includes(card.fields.skyflow_id) && (
@@ -1,8 +1,34 @@
1
1
  import React from 'react';
2
2
  import { View, StyleSheet, Animated, Easing, Text } from 'react-native';
3
+ import type { ISkeletonCardStyles, StylesBaseVariant } from '@tonder.io/rn-sdk';
4
+ import { buildBaseStyleText } from '../../../shared/utils/styleUtils';
3
5
 
4
- const CardFormSkeleton = ({ message }: { message?: string }) => {
5
- const animatedValue = new Animated.Value(0);
6
+ const SkeletonItem = ({
7
+ styleItem,
8
+ interpolatedColor,
9
+ }: {
10
+ styleItem?: StylesBaseVariant;
11
+ interpolatedColor: Animated.AnimatedInterpolation<string | number>;
12
+ }) => (
13
+ <Animated.View
14
+ style={[
15
+ styles.skeletonLoader,
16
+ ...(styleItem?.base ? [styleItem.base] : []),
17
+ { backgroundColor: interpolatedColor },
18
+ ]}
19
+ />
20
+ );
21
+
22
+ const CardFormSkeleton = ({
23
+ message,
24
+ style,
25
+ errorMessageStyle,
26
+ }: {
27
+ message?: string;
28
+ style?: ISkeletonCardStyles;
29
+ errorMessageStyle?: StylesBaseVariant;
30
+ }) => {
31
+ const animatedValue = React.useRef(new Animated.Value(0)).current;
6
32
 
7
33
  React.useEffect(() => {
8
34
  Animated.loop(
@@ -25,42 +51,71 @@ const CardFormSkeleton = ({ message }: { message?: string }) => {
25
51
 
26
52
  const interpolatedColor = animatedValue.interpolate({
27
53
  inputRange: [0, 1],
28
- outputRange: ['#e0e0e0', '#f0f0f0'],
54
+ outputRange: style?.animatedBGColors || ['#e0e0e0', '#dddddd'],
29
55
  });
30
56
 
31
- const SkeletonItem = () => (
32
- <Animated.View
33
- style={[styles.skeletonLoader, { backgroundColor: interpolatedColor }]}
34
- />
35
- );
36
-
37
57
  return (
38
- <View style={styles.container}>
39
- <SkeletonItem />
40
- <SkeletonItem />
41
- <View style={styles.collectRow}>
58
+ <View
59
+ style={{
60
+ ...styles.container,
61
+ ...(style?.base || {}),
62
+ ...styles.containerBase,
63
+ }}
64
+ >
65
+ <SkeletonItem
66
+ styleItem={style?.fullField}
67
+ interpolatedColor={interpolatedColor}
68
+ />
69
+ <SkeletonItem
70
+ styleItem={style?.fullField}
71
+ interpolatedColor={interpolatedColor}
72
+ />
73
+ <View
74
+ style={{
75
+ ...styles.collectRow,
76
+ ...(style?.compactRow?.base || {}),
77
+ }}
78
+ >
42
79
  <Animated.View
43
80
  style={[
81
+ styles.skeletonLoader,
82
+ ...(style?.compactField?.base ? [style?.compactField?.base] : []),
44
83
  styles.skeletonLoaderItem,
45
84
  { backgroundColor: interpolatedColor },
46
85
  ]}
47
86
  />
48
87
  <Animated.View
49
88
  style={[
89
+ styles.skeletonLoader,
90
+ ...(style?.compactField?.base ? [style?.compactField?.base] : []),
50
91
  styles.skeletonLoaderItem,
51
92
  { backgroundColor: interpolatedColor },
52
93
  ]}
53
94
  />
54
95
  <Animated.View
55
96
  style={[
97
+ styles.skeletonLoader,
98
+ ...(style?.compactField?.base ? [style?.compactField?.base] : []),
56
99
  styles.skeletonLoaderItem,
57
100
  { backgroundColor: interpolatedColor },
58
101
  ]}
59
102
  />
60
103
  </View>
61
104
  {!!message && (
62
- <View style={styles.errorContainer}>
63
- <Text style={styles.errorText}>{message}</Text>
105
+ <View
106
+ style={{
107
+ ...styles.errorContainer,
108
+ ...(errorMessageStyle?.base || {}),
109
+ }}
110
+ >
111
+ <Text
112
+ style={{
113
+ ...styles.errorText,
114
+ ...buildBaseStyleText(errorMessageStyle),
115
+ }}
116
+ >
117
+ {message}
118
+ </Text>
64
119
  </View>
65
120
  )}
66
121
  </View>
@@ -68,17 +123,19 @@ const CardFormSkeleton = ({ message }: { message?: string }) => {
68
123
  };
69
124
 
70
125
  const styles = StyleSheet.create({
71
- container: {
126
+ containerBase: {
72
127
  position: 'absolute',
73
128
  top: 0,
74
129
  left: 0,
75
130
  width: '100%',
76
131
  height: '100%',
132
+ zIndex: 1,
133
+ },
134
+ container: {
77
135
  backgroundColor: '#F9F9F9',
78
136
  padding: 20,
79
137
  flex: 1,
80
138
  gap: 20,
81
- zIndex: 1,
82
139
  },
83
140
  collectRow: {
84
141
  flexDirection: 'row',
@@ -93,12 +150,13 @@ const styles = StyleSheet.create({
93
150
  marginHorizontal: 10,
94
151
  },
95
152
  skeletonLoaderItem: {
96
- height: 35,
97
- borderRadius: 8,
98
153
  flex: 1,
154
+ marginVertical: 0,
155
+ marginHorizontal: 0,
99
156
  },
100
157
  errorContainer: {
101
- paddingHorizontal: 11,
158
+ paddingHorizontal: 20,
159
+ marginVertical: 5,
102
160
  },
103
161
  errorText: {
104
162
  color: 'red',
@@ -26,7 +26,12 @@ const TonderEnrollment: React.FC<ITonderEnrollmentProps> = () => {
26
26
 
27
27
  return (
28
28
  <View style={styles.container}>
29
- {state?.isCreating && <CardFormSkeleton message={state?.message} />}
29
+ {state?.isCreating && (
30
+ <CardFormSkeleton
31
+ style={state?.customization?.styles?.skeletonCard}
32
+ message={state?.message}
33
+ />
34
+ )}
30
35
  <View
31
36
  style={{
32
37
  ...DEFAULT_PAYMENT_CONTAINER.base,
@@ -55,7 +55,12 @@ const TonderPayment: React.FC<ITonderPaymentProps> = () => {
55
55
 
56
56
  return (
57
57
  <View style={styles.container}>
58
- {state?.isCreating && <CardFormSkeleton message={state?.message} />}
58
+ {state?.isCreating && (
59
+ <CardFormSkeleton
60
+ style={state?.customization?.styles?.skeletonCard}
61
+ message={state?.message}
62
+ />
63
+ )}
59
64
  <View
60
65
  style={{
61
66
  ...DEFAULT_PAYMENT_CONTAINER.base,
@@ -66,6 +71,7 @@ const TonderPayment: React.FC<ITonderPaymentProps> = () => {
66
71
  {state?.customization?.saveCards?.showSaved && (
67
72
  <SavedCardsList
68
73
  style={state?.customization?.styles?.savedCards}
74
+ expirationLabel={state?.customization?.labels?.expirationCard}
69
75
  cards={state.uiData?.cards}
70
76
  selectedMethod={state?.uiData?.card || ''}
71
77
  onMethodSelect={(methodId) => {
@@ -110,7 +116,7 @@ const TonderPayment: React.FC<ITonderPaymentProps> = () => {
110
116
  ),
111
117
  }}
112
118
  >
113
- Pagar con tarjeta
119
+ {state?.customization?.labels?.payWithCard || 'Pagar con tarjeta'}
114
120
  </Text>
115
121
  </View>
116
122
  )}
@@ -210,6 +216,8 @@ const styles = StyleSheet.create({
210
216
  paddingHorizontal: 20,
211
217
  borderBottomWidth: 1,
212
218
  borderBottomColor: '#e2e8f0',
219
+ borderTopWidth: 1,
220
+ borderTopColor: '#e2e8f0',
213
221
  },
214
222
  cardImage: {
215
223
  width: 32,