tonder-web-sdk 1.15.2 → 1.16.3
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/.husky/pre-commit +4 -0
- package/.prettierignore +8 -0
- package/.prettierrc +10 -0
- package/README.md +189 -35
- package/eslint.config.mjs +15 -0
- package/package.json +21 -4
- package/src/classes/3dsHandler.js +58 -62
- package/src/classes/BaseInlineCheckout.js +21 -36
- package/src/classes/LiteInlineCheckout.js +8 -8
- package/src/classes/checkout.js +75 -71
- package/src/classes/globalLoader.js +9 -7
- package/src/classes/inlineCheckout.js +528 -250
- package/src/data/apmApi.js +8 -14
- package/src/data/businessApi.js +5 -8
- package/src/data/cardApi.js +5 -14
- package/src/data/checkoutApi.js +54 -54
- package/src/data/customerApi.js +1 -6
- package/src/data/index.js +15 -15
- package/src/data/openPayApi.js +7 -7
- package/src/data/skyflowApi.js +14 -16
- package/src/helpers/skyflow.js +210 -119
- package/src/helpers/styles.js +56 -27
- package/src/helpers/template-skeleton.js +1 -1
- package/src/helpers/template.js +984 -541
- package/src/helpers/utils.js +152 -58
- package/src/helpers/validations.js +34 -35
- package/src/index-dev.js +38 -11
- package/src/index.html +20 -12
- package/src/index.js +19 -13
- package/src/shared/catalog/commonLogosCatalog.js +7 -0
- package/src/shared/catalog/paymentMethodsCatalog.js +242 -243
- package/src/shared/constants/colors.js +15 -0
- package/src/shared/constants/displayMode.js +4 -0
- package/src/shared/constants/fieldPathNames.js +4 -0
- package/src/shared/constants/htmlTonderIds.js +18 -0
- package/src/shared/constants/messages.js +10 -9
- package/types/card.d.ts +17 -17
- package/types/checkout.d.ts +85 -87
- package/types/common.d.ts +4 -1
- package/types/customer.d.ts +10 -10
- package/types/index.d.ts +9 -11
- package/types/inlineCheckout.d.ts +81 -61
- package/types/liteInlineCheckout.d.ts +78 -83
- package/types/paymentMethod.d.ts +17 -17
- package/types/transaction.d.ts +94 -94
- package/v1/bundle.min.js +3 -3
package/src/helpers/skyflow.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {getVaultToken} from "../data/skyflowApi";
|
|
3
|
-
import {buildErrorResponseFromCatch} from "./utils";
|
|
1
|
+
import { getDefaultStyles } from "./styles";
|
|
2
|
+
import { getVaultToken } from "../data/skyflowApi";
|
|
3
|
+
import { buildErrorResponseFromCatch, getCardFormLabels } from "./utils";
|
|
4
|
+
import { DISPLAY_MODE } from "../shared/constants/displayMode";
|
|
4
5
|
|
|
5
6
|
export async function initSkyflow(
|
|
6
7
|
vaultId,
|
|
@@ -10,30 +11,32 @@ export async function initSkyflow(
|
|
|
10
11
|
signal,
|
|
11
12
|
customStyles = {},
|
|
12
13
|
collectorIds,
|
|
14
|
+
displayMode,
|
|
13
15
|
) {
|
|
14
|
-
const skyflow = await
|
|
15
|
-
vaultID: vaultId,
|
|
16
|
-
vaultURL: vaultUrl,
|
|
17
|
-
getBearerToken: async () => {
|
|
18
|
-
// Pass the signal to the fetch call
|
|
19
|
-
return await getVaultToken(baseUrl, apiKey, signal)
|
|
20
|
-
},
|
|
21
|
-
options: {
|
|
22
|
-
logLevel: Skyflow.LogLevel.ERROR,
|
|
23
|
-
env: Skyflow.Env.DEV,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
16
|
+
const skyflow = await initializeSkyflow(vaultId, vaultUrl, baseUrl, apiKey, signal);
|
|
26
17
|
|
|
27
18
|
// Create collect Container.
|
|
28
|
-
const collectContainer = await skyflow.container(
|
|
29
|
-
Skyflow.ContainerType.COLLECT
|
|
30
|
-
);
|
|
31
|
-
|
|
19
|
+
const collectContainer = await skyflow.container(Skyflow.ContainerType.COLLECT);
|
|
32
20
|
// Custom styles for collect elements.
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
let collectStylesOptions = {
|
|
22
|
+
...getDefaultStyles(displayMode === DISPLAY_MODE.dark),
|
|
23
|
+
...(Object.keys(customStyles).length > 0 ? { ...customStyles } : {}),
|
|
24
|
+
...getCardFormLabels(customStyles),
|
|
25
|
+
};
|
|
35
26
|
const stylesForCardNumber = { ...collectStylesOptions.inputStyles.base };
|
|
36
|
-
stylesForCardNumber.textIndent =
|
|
27
|
+
stylesForCardNumber.textIndent = "44px";
|
|
28
|
+
|
|
29
|
+
const stylesForExpiryMonth = {
|
|
30
|
+
...collectStylesOptions.inputStyles.base,
|
|
31
|
+
borderBottomRightRadius: 0,
|
|
32
|
+
borderTopRightRadius: 0,
|
|
33
|
+
};
|
|
34
|
+
const stylesForExpiryYear = {
|
|
35
|
+
...collectStylesOptions.inputStyles.base,
|
|
36
|
+
borderBottomLeftRadius: 0,
|
|
37
|
+
borderTopLeftRadius: 0,
|
|
38
|
+
borderLeft: "1px solid #CED0D1",
|
|
39
|
+
};
|
|
37
40
|
|
|
38
41
|
const lengthMatchRule = {
|
|
39
42
|
type: Skyflow.ValidationRuleType.LENGTH_MATCH_RULE,
|
|
@@ -41,15 +44,6 @@ export async function initSkyflow(
|
|
|
41
44
|
max: 70,
|
|
42
45
|
},
|
|
43
46
|
};
|
|
44
|
-
const regexEmpty = RegExp("^(?!\s*$).+");
|
|
45
|
-
|
|
46
|
-
const regexMatchRule = {
|
|
47
|
-
type: Skyflow.ValidationRuleType.REGEX_MATCH_RULE,
|
|
48
|
-
params: {
|
|
49
|
-
regex: regexEmpty,
|
|
50
|
-
error: "El campo es requerido" // Optional, default error is 'VALIDATION FAILED'.
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
47
|
|
|
54
48
|
const cardHolderNameElement = await collectContainer.create({
|
|
55
49
|
table: "cards",
|
|
@@ -64,7 +58,7 @@ export async function initSkyflow(
|
|
|
64
58
|
handleSkyflowElementEvents(
|
|
65
59
|
cardHolderNameElement,
|
|
66
60
|
"titular de la tarjeta",
|
|
67
|
-
collectStylesOptions.errorTextStyles
|
|
61
|
+
collectStylesOptions.errorTextStyles,
|
|
68
62
|
);
|
|
69
63
|
|
|
70
64
|
// Create collect elements.
|
|
@@ -74,7 +68,7 @@ export async function initSkyflow(
|
|
|
74
68
|
...collectStylesOptions,
|
|
75
69
|
inputStyles: {
|
|
76
70
|
...collectStylesOptions.inputStyles,
|
|
77
|
-
base: stylesForCardNumber
|
|
71
|
+
base: stylesForCardNumber,
|
|
78
72
|
},
|
|
79
73
|
label: collectStylesOptions.labels?.cardLabel,
|
|
80
74
|
placeholder: collectStylesOptions.placeholders?.cardPlaceholder,
|
|
@@ -85,30 +79,18 @@ export async function initSkyflow(
|
|
|
85
79
|
handleSkyflowElementEvents(
|
|
86
80
|
cardNumberElement,
|
|
87
81
|
"número de tarjeta",
|
|
88
|
-
collectStylesOptions.errorTextStyles
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const cvvElement = await collectContainer.create({
|
|
92
|
-
table: "cards",
|
|
93
|
-
column: "cvv",
|
|
94
|
-
...collectStylesOptions,
|
|
95
|
-
label: collectStylesOptions.labels?.cvvLabel,
|
|
96
|
-
placeholder: collectStylesOptions.placeholders?.cvvPlaceholder,
|
|
97
|
-
type: Skyflow.ElementType.CVV,
|
|
98
|
-
validations: [regexMatchRule],
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
handleSkyflowElementEvents(
|
|
102
|
-
cvvElement,
|
|
103
|
-
"",
|
|
104
|
-
collectStylesOptions.errorTextStyles
|
|
82
|
+
collectStylesOptions.errorTextStyles,
|
|
105
83
|
);
|
|
106
84
|
|
|
107
85
|
const expiryMonthElement = await collectContainer.create({
|
|
108
86
|
table: "cards",
|
|
109
87
|
column: "expiration_month",
|
|
110
88
|
...collectStylesOptions,
|
|
111
|
-
|
|
89
|
+
inputStyles: {
|
|
90
|
+
...collectStylesOptions.inputStyles,
|
|
91
|
+
base: stylesForExpiryMonth,
|
|
92
|
+
},
|
|
93
|
+
label: "",
|
|
112
94
|
placeholder: collectStylesOptions.placeholders?.expiryMonthPlaceholder,
|
|
113
95
|
type: Skyflow.ElementType.EXPIRATION_MONTH,
|
|
114
96
|
validations: [regexMatchRule],
|
|
@@ -117,96 +99,200 @@ export async function initSkyflow(
|
|
|
117
99
|
handleSkyflowElementEvents(
|
|
118
100
|
expiryMonthElement,
|
|
119
101
|
"",
|
|
120
|
-
collectStylesOptions.errorTextStyles
|
|
102
|
+
collectStylesOptions.errorTextStyles,
|
|
103
|
+
true,
|
|
104
|
+
"Campo requerido",
|
|
121
105
|
);
|
|
122
106
|
|
|
123
107
|
const expiryYearElement = await collectContainer.create({
|
|
124
108
|
table: "cards",
|
|
125
109
|
column: "expiration_year",
|
|
126
110
|
...collectStylesOptions,
|
|
111
|
+
inputStyles: {
|
|
112
|
+
...collectStylesOptions.inputStyles,
|
|
113
|
+
base: stylesForExpiryYear,
|
|
114
|
+
},
|
|
127
115
|
label: "",
|
|
128
116
|
placeholder: collectStylesOptions.placeholders?.expiryYearPlaceholder,
|
|
129
117
|
type: Skyflow.ElementType.EXPIRATION_YEAR,
|
|
130
118
|
validations: [regexMatchRule],
|
|
131
119
|
});
|
|
132
120
|
|
|
133
|
-
handleSkyflowElementEvents(
|
|
134
|
-
expiryYearElement,
|
|
135
|
-
"",
|
|
136
|
-
collectStylesOptions.errorTextStyles
|
|
137
|
-
);
|
|
121
|
+
handleSkyflowElementEvents(expiryYearElement, "", collectStylesOptions.errorTextStyles);
|
|
138
122
|
|
|
139
|
-
await
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
123
|
+
const cvvElement = await collectContainer.create({
|
|
124
|
+
table: "cards",
|
|
125
|
+
column: "cvv",
|
|
126
|
+
...collectStylesOptions,
|
|
127
|
+
label: "",
|
|
128
|
+
placeholder: collectStylesOptions.placeholders?.cvvPlaceholder,
|
|
129
|
+
type: Skyflow.ElementType.CVV,
|
|
130
|
+
validations: [regexMatchRule],
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
handleSkyflowElementEvents(cvvElement, "", collectStylesOptions.errorTextStyles);
|
|
134
|
+
const elementsConfig = {
|
|
135
|
+
cardNumber: {
|
|
136
|
+
element: cardNumberElement,
|
|
137
|
+
container: "#collectCardNumber",
|
|
138
|
+
},
|
|
139
|
+
cvv: {
|
|
140
|
+
element: cvvElement,
|
|
141
|
+
container: "#collectCvv",
|
|
142
|
+
},
|
|
143
|
+
expiryMonth: {
|
|
144
|
+
element: expiryMonthElement,
|
|
145
|
+
container: "#collectExpirationMonth",
|
|
146
|
+
},
|
|
147
|
+
expiryYear: {
|
|
148
|
+
element: expiryYearElement,
|
|
149
|
+
container: "#collectExpirationYear",
|
|
150
|
+
},
|
|
151
|
+
cardHolderName: {
|
|
152
|
+
element: cardHolderNameElement,
|
|
153
|
+
container: "#collectCardholderName",
|
|
154
|
+
},
|
|
155
|
+
};
|
|
146
156
|
|
|
157
|
+
await mountElements(elementsConfig);
|
|
147
158
|
return {
|
|
148
159
|
container: collectContainer,
|
|
149
|
-
elements: {
|
|
150
|
-
cardHolderNameElement,
|
|
151
|
-
cardNumberElement,
|
|
152
|
-
cvvElement,
|
|
153
|
-
expiryMonthElement,
|
|
154
|
-
expiryYearElement
|
|
155
|
-
}
|
|
156
|
-
}
|
|
160
|
+
elements: {
|
|
161
|
+
cardHolderNameElement,
|
|
162
|
+
cardNumberElement,
|
|
163
|
+
cvvElement,
|
|
164
|
+
expiryMonthElement,
|
|
165
|
+
expiryYearElement,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
157
168
|
}
|
|
158
169
|
|
|
159
|
-
async function
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
170
|
+
export async function initUpdateSkyflow(
|
|
171
|
+
skyflowId,
|
|
172
|
+
vaultId,
|
|
173
|
+
vaultUrl,
|
|
174
|
+
baseUrl,
|
|
175
|
+
apiKey,
|
|
176
|
+
signal,
|
|
177
|
+
customStyles = {},
|
|
178
|
+
displayMode,
|
|
165
179
|
) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
180
|
+
const skyflow = await initializeSkyflow(vaultId, vaultUrl, baseUrl, apiKey, signal);
|
|
181
|
+
|
|
182
|
+
let collectStylesOptions = {
|
|
183
|
+
...getDefaultStyles(displayMode === DISPLAY_MODE.dark),
|
|
184
|
+
...(Object.keys(customStyles).length > 0 ? { ...customStyles } : {}),
|
|
185
|
+
...getCardFormLabels(customStyles),
|
|
186
|
+
};
|
|
187
|
+
// Create collect Container.
|
|
188
|
+
const collectContainer = await skyflow.container(Skyflow.ContainerType.COLLECT);
|
|
189
|
+
|
|
190
|
+
const cvvElement = await collectContainer.create({
|
|
191
|
+
table: "cards",
|
|
192
|
+
column: "cvv",
|
|
193
|
+
...collectStylesOptions,
|
|
194
|
+
label: "",
|
|
195
|
+
placeholder: collectStylesOptions.placeholders?.cvvPlaceholder,
|
|
196
|
+
type: Skyflow.ElementType.CVV,
|
|
197
|
+
validations: [regexMatchRule],
|
|
198
|
+
skyflowID: skyflowId,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
handleSkyflowElementEvents(cvvElement, "", collectStylesOptions.errorTextStyles);
|
|
202
|
+
|
|
203
|
+
const elementsConfig = {
|
|
204
|
+
cvv: {
|
|
205
|
+
element: cvvElement,
|
|
206
|
+
container: `#collectCvv${skyflowId}`,
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
await mountElements(elementsConfig);
|
|
210
|
+
|
|
211
|
+
return {
|
|
212
|
+
container: collectContainer,
|
|
213
|
+
elements: {
|
|
214
|
+
cvvElement,
|
|
215
|
+
},
|
|
216
|
+
};
|
|
171
217
|
}
|
|
172
218
|
|
|
219
|
+
async function initializeSkyflow(vaultId, vaultUrl, baseUrl, apiKey, signal) {
|
|
220
|
+
return await Skyflow.init({
|
|
221
|
+
vaultID: vaultId,
|
|
222
|
+
vaultURL: vaultUrl,
|
|
223
|
+
getBearerToken: async () => {
|
|
224
|
+
// Pass the signal to the fetch call
|
|
225
|
+
return await getVaultToken(baseUrl, apiKey, signal);
|
|
226
|
+
},
|
|
227
|
+
options: {
|
|
228
|
+
logLevel: Skyflow.LogLevel.ERROR,
|
|
229
|
+
env: Skyflow.Env.DEV,
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async function mountElements(elementsConfig) {
|
|
235
|
+
if (typeof elementsConfig !== "object" || elementsConfig === null) {
|
|
236
|
+
throw new Error("Invalid configuration object");
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for (const [elementKey, { element, container }] of Object.entries(elementsConfig)) {
|
|
240
|
+
if (element && container) {
|
|
241
|
+
element.mount(container);
|
|
242
|
+
} else {
|
|
243
|
+
console.warn(`Skipping mount for '${elementKey}' due to missing element or container.`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
173
247
|
|
|
174
|
-
function handleSkyflowElementEvents(
|
|
248
|
+
function handleSkyflowElementEvents(
|
|
249
|
+
element,
|
|
250
|
+
fieldMessage = "",
|
|
251
|
+
error_styles = {},
|
|
252
|
+
resetOnFocus = true,
|
|
253
|
+
requiredMessage = "Campo requerido",
|
|
254
|
+
invalidMessage = "Campo inválido",
|
|
255
|
+
focusNextElement = null,
|
|
256
|
+
) {
|
|
175
257
|
if ("on" in element) {
|
|
176
|
-
element.on(Skyflow.EventName.CHANGE,
|
|
177
|
-
updateErrorLabel(element, error_styles, "transparent")
|
|
258
|
+
element.on(Skyflow.EventName.CHANGE, state => {
|
|
259
|
+
updateErrorLabel(element, error_styles, "transparent");
|
|
178
260
|
});
|
|
179
261
|
|
|
180
|
-
element.on(Skyflow.EventName.BLUR,
|
|
262
|
+
element.on(Skyflow.EventName.BLUR, state => {
|
|
181
263
|
if (!state.isValid) {
|
|
182
|
-
const msj_error = state.isEmpty
|
|
264
|
+
const msj_error = state.isEmpty
|
|
265
|
+
? requiredMessage
|
|
266
|
+
: fieldMessage != ""
|
|
267
|
+
? `El campo ${fieldMessage} es inválido`
|
|
268
|
+
: invalidMessage;
|
|
183
269
|
element.setError(msj_error);
|
|
184
270
|
}
|
|
185
|
-
updateErrorLabel(element, error_styles)
|
|
271
|
+
updateErrorLabel(element, error_styles);
|
|
186
272
|
});
|
|
187
273
|
|
|
188
|
-
element.on(Skyflow.EventName.FOCUS,
|
|
189
|
-
updateErrorLabel(element, error_styles, "transparent")
|
|
274
|
+
element.on(Skyflow.EventName.FOCUS, state => {
|
|
275
|
+
updateErrorLabel(element, error_styles, "transparent");
|
|
190
276
|
element.resetError();
|
|
191
277
|
});
|
|
192
278
|
}
|
|
193
279
|
}
|
|
194
280
|
|
|
195
|
-
function updateErrorLabel(element, errorStyles, color = ""
|
|
196
|
-
if(Object.keys(errorStyles).length > 0){
|
|
281
|
+
function updateErrorLabel(element, errorStyles, color = "") {
|
|
282
|
+
if (Object.keys(errorStyles).length > 0) {
|
|
197
283
|
element.update({
|
|
198
284
|
errorTextStyles: {
|
|
199
285
|
...errorStyles,
|
|
200
286
|
base: {
|
|
201
|
-
...(errorStyles.base && {...errorStyles.base}),
|
|
202
|
-
...(color != "" && {color})
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
})
|
|
287
|
+
...(errorStyles.base && { ...errorStyles.base }),
|
|
288
|
+
...(color != "" && { color }),
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
});
|
|
206
292
|
}
|
|
207
293
|
}
|
|
208
294
|
|
|
209
|
-
export async
|
|
295
|
+
export async function getSkyflowTokens({ baseUrl, apiKey, vault_id, vault_url, data }) {
|
|
210
296
|
const skyflow = Skyflow.init({
|
|
211
297
|
vaultID: vault_id,
|
|
212
298
|
vaultURL: vault_url,
|
|
@@ -217,24 +303,21 @@ export async function getSkyflowTokens({baseUrl, apiKey, vault_id, vault_url, d
|
|
|
217
303
|
},
|
|
218
304
|
});
|
|
219
305
|
|
|
220
|
-
const collectContainer = skyflow.container(Skyflow.ContainerType.
|
|
306
|
+
const collectContainer = skyflow.container(Skyflow.ContainerType.COMPOSABLE);
|
|
221
307
|
|
|
222
308
|
const fieldPromises = await getFieldsPromise(data, collectContainer);
|
|
223
309
|
|
|
224
310
|
const result = await Promise.all(fieldPromises);
|
|
225
|
-
const mountFail = result.some(
|
|
311
|
+
const mountFail = result.some(item => !item);
|
|
226
312
|
|
|
227
313
|
if (mountFail) {
|
|
228
|
-
throw buildErrorResponseFromCatch(
|
|
229
|
-
Error("Ocurrió un error al montar los campos de la tarjeta"),
|
|
230
|
-
);
|
|
314
|
+
throw buildErrorResponseFromCatch(Error("Ocurrió un error al montar los campos de la tarjeta"));
|
|
231
315
|
} else {
|
|
232
316
|
try {
|
|
233
317
|
const collectResponseSkyflowTonder = await collectContainer.collect();
|
|
234
|
-
if (collectResponseSkyflowTonder)
|
|
235
|
-
return collectResponseSkyflowTonder["records"][0]["fields"];
|
|
318
|
+
if (collectResponseSkyflowTonder) return collectResponseSkyflowTonder["records"][0]["fields"];
|
|
236
319
|
throw buildErrorResponseFromCatch(
|
|
237
|
-
|
|
320
|
+
Error("Por favor, verifica todos los campos de tu tarjeta"),
|
|
238
321
|
);
|
|
239
322
|
} catch (error) {
|
|
240
323
|
throw buildErrorResponseFromCatch(error);
|
|
@@ -244,8 +327,8 @@ export async function getSkyflowTokens({baseUrl, apiKey, vault_id, vault_url, d
|
|
|
244
327
|
async function getFieldsPromise(data, collectContainer) {
|
|
245
328
|
const fields = await getFields(data, collectContainer);
|
|
246
329
|
if (!fields) return [];
|
|
247
|
-
return fields.map(
|
|
248
|
-
return new Promise(
|
|
330
|
+
return fields.map(field => {
|
|
331
|
+
return new Promise(resolve => {
|
|
249
332
|
const div = document.createElement("div");
|
|
250
333
|
div.hidden = true;
|
|
251
334
|
div.id = `id-${field.key}`;
|
|
@@ -261,19 +344,27 @@ async function getFieldsPromise(data, collectContainer) {
|
|
|
261
344
|
}, 120);
|
|
262
345
|
}, 120);
|
|
263
346
|
});
|
|
264
|
-
})
|
|
347
|
+
});
|
|
265
348
|
}
|
|
266
349
|
|
|
267
350
|
async function getFields(data, collectContainer) {
|
|
268
351
|
return await Promise.all(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
)
|
|
352
|
+
Object.keys(data).map(async key => {
|
|
353
|
+
const cardHolderNameElement = await collectContainer.create({
|
|
354
|
+
table: "cards",
|
|
355
|
+
column: key,
|
|
356
|
+
type: Skyflow.ElementType.INPUT_FIELD,
|
|
357
|
+
});
|
|
358
|
+
return { element: cardHolderNameElement, key: key };
|
|
359
|
+
}),
|
|
360
|
+
);
|
|
278
361
|
}
|
|
279
362
|
|
|
363
|
+
const regexEmpty = RegExp("^(?!\s*$).+");
|
|
364
|
+
const regexMatchRule = {
|
|
365
|
+
type: Skyflow.ValidationRuleType.REGEX_MATCH_RULE,
|
|
366
|
+
params: {
|
|
367
|
+
regex: regexEmpty,
|
|
368
|
+
error: "El campo es requerido", // Optional, default error is 'VALIDATION FAILED'.
|
|
369
|
+
},
|
|
370
|
+
};
|
package/src/helpers/styles.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
export const defaultStyles = {
|
|
2
2
|
inputStyles: {
|
|
3
3
|
base: {
|
|
4
|
-
border: "1px solid #e0e0e0",
|
|
5
4
|
padding: "10px 7px",
|
|
6
5
|
borderRadius: "5px",
|
|
7
|
-
color: "#
|
|
6
|
+
color: "#000000",
|
|
8
7
|
marginTop: "2px",
|
|
9
|
-
backgroundColor: "
|
|
8
|
+
backgroundColor: "#F5F5F5",
|
|
10
9
|
fontFamily: '"Inter", sans-serif',
|
|
11
|
-
fontSize:
|
|
12
|
-
|
|
10
|
+
fontSize: "14px",
|
|
11
|
+
"&::placeholder": {
|
|
13
12
|
color: "#ccc",
|
|
14
13
|
},
|
|
14
|
+
fontWeight: 400,
|
|
15
15
|
},
|
|
16
16
|
cardIcon: {
|
|
17
|
-
position:
|
|
18
|
-
left:
|
|
19
|
-
bottom:
|
|
17
|
+
position: "absolute",
|
|
18
|
+
left: "6px",
|
|
19
|
+
bottom: "calc(50% - 12px)",
|
|
20
20
|
},
|
|
21
21
|
complete: {
|
|
22
22
|
color: "#4caf50",
|
|
@@ -27,35 +27,64 @@ export const defaultStyles = {
|
|
|
27
27
|
border: "1px solid #f44336",
|
|
28
28
|
},
|
|
29
29
|
global: {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
"@import":
|
|
31
|
+
'url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")',
|
|
32
|
+
},
|
|
32
33
|
},
|
|
33
34
|
labelStyles: {
|
|
34
35
|
base: {
|
|
35
|
-
fontSize:
|
|
36
|
-
fontWeight:
|
|
37
|
-
fontFamily: '"Inter", sans-serif'
|
|
36
|
+
fontSize: "14px",
|
|
37
|
+
fontWeight: "600",
|
|
38
|
+
fontFamily: '"Inter", sans-serif',
|
|
39
|
+
color: "#333333",
|
|
40
|
+
textAlign: "start",
|
|
38
41
|
},
|
|
39
42
|
},
|
|
40
43
|
errorTextStyles: {
|
|
41
44
|
base: {
|
|
42
|
-
fontSize:
|
|
43
|
-
fontWeight:
|
|
45
|
+
fontSize: "14px",
|
|
46
|
+
fontWeight: "500",
|
|
44
47
|
color: "#f44336",
|
|
45
|
-
fontFamily: '"Inter", sans-serif'
|
|
48
|
+
fontFamily: '"Inter", sans-serif',
|
|
46
49
|
},
|
|
47
50
|
},
|
|
48
51
|
labels: {
|
|
49
|
-
nameLabel:
|
|
50
|
-
cardLabel:
|
|
51
|
-
cvvLabel:
|
|
52
|
-
expiryDateLabel:
|
|
52
|
+
nameLabel: "Nombre del titular de la tarjeta",
|
|
53
|
+
cardLabel: "Número de tarjeta",
|
|
54
|
+
cvvLabel: "CVC/CVV",
|
|
55
|
+
expiryDateLabel: "Fecha de expiración",
|
|
53
56
|
},
|
|
54
57
|
placeholders: {
|
|
55
|
-
namePlaceholder:
|
|
56
|
-
cardPlaceholder:
|
|
57
|
-
cvvPlaceholder:
|
|
58
|
-
expiryMonthPlaceholder:
|
|
59
|
-
expiryYearPlaceholder:
|
|
60
|
-
}
|
|
61
|
-
}
|
|
58
|
+
namePlaceholder: "Nombre del titular de la tarjeta",
|
|
59
|
+
cardPlaceholder: "1234 1234 1234 1234",
|
|
60
|
+
cvvPlaceholder: "CVV",
|
|
61
|
+
expiryMonthPlaceholder: "MM",
|
|
62
|
+
expiryYearPlaceholder: "AA",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const getDefaultStyles = isDark => {
|
|
67
|
+
const darkBaseInputStyles = {
|
|
68
|
+
backgroundColor: "#5C5C5C",
|
|
69
|
+
color: "#FFFFFF",
|
|
70
|
+
"&::placeholder": {
|
|
71
|
+
color: "#AAAAAA",
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const darkBaseLabelStyles = {
|
|
76
|
+
color: "#FFFFFF",
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
...defaultStyles,
|
|
81
|
+
inputStyles: {
|
|
82
|
+
...defaultStyles.inputStyles,
|
|
83
|
+
base: { ...defaultStyles.inputStyles.base, ...(isDark ? { ...darkBaseInputStyles } : {}) },
|
|
84
|
+
},
|
|
85
|
+
labelStyles: {
|
|
86
|
+
...defaultStyles.labelStyles,
|
|
87
|
+
base: { ...defaultStyles.labelStyles.base, ...(isDark ? { ...darkBaseLabelStyles } : {}) },
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
};
|