tonder-web-sdk 1.16.1 → 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 +113 -16
- package/eslint.config.mjs +15 -0
- package/package.json +20 -4
- package/src/classes/3dsHandler.js +58 -62
- package/src/classes/BaseInlineCheckout.js +12 -33
- package/src/classes/LiteInlineCheckout.js +5 -8
- package/src/classes/checkout.js +75 -71
- package/src/classes/globalLoader.js +9 -7
- package/src/classes/inlineCheckout.js +519 -321
- 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 +132 -123
- package/src/helpers/styles.js +56 -27
- package/src/helpers/template-skeleton.js +1 -1
- package/src/helpers/template.js +971 -610
- package/src/helpers/utils.js +152 -58
- package/src/helpers/validations.js +34 -35
- package/src/index-dev.js +33 -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 -2
- 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,19 +11,32 @@ export async function initSkyflow(
|
|
|
10
11
|
signal,
|
|
11
12
|
customStyles = {},
|
|
12
13
|
collectorIds,
|
|
14
|
+
displayMode,
|
|
13
15
|
) {
|
|
14
16
|
const skyflow = await initializeSkyflow(vaultId, vaultUrl, baseUrl, apiKey, signal);
|
|
15
17
|
|
|
16
18
|
// Create collect Container.
|
|
17
|
-
const collectContainer = await skyflow.container(
|
|
18
|
-
Skyflow.ContainerType.COLLECT
|
|
19
|
-
);
|
|
20
|
-
|
|
19
|
+
const collectContainer = await skyflow.container(Skyflow.ContainerType.COLLECT);
|
|
21
20
|
// Custom styles for collect elements.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
let collectStylesOptions = {
|
|
22
|
+
...getDefaultStyles(displayMode === DISPLAY_MODE.dark),
|
|
23
|
+
...(Object.keys(customStyles).length > 0 ? { ...customStyles } : {}),
|
|
24
|
+
...getCardFormLabels(customStyles),
|
|
25
|
+
};
|
|
24
26
|
const stylesForCardNumber = { ...collectStylesOptions.inputStyles.base };
|
|
25
|
-
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
|
+
};
|
|
26
40
|
|
|
27
41
|
const lengthMatchRule = {
|
|
28
42
|
type: Skyflow.ValidationRuleType.LENGTH_MATCH_RULE,
|
|
@@ -31,8 +45,6 @@ export async function initSkyflow(
|
|
|
31
45
|
},
|
|
32
46
|
};
|
|
33
47
|
|
|
34
|
-
|
|
35
|
-
|
|
36
48
|
const cardHolderNameElement = await collectContainer.create({
|
|
37
49
|
table: "cards",
|
|
38
50
|
column: "cardholder_name",
|
|
@@ -46,7 +58,7 @@ export async function initSkyflow(
|
|
|
46
58
|
handleSkyflowElementEvents(
|
|
47
59
|
cardHolderNameElement,
|
|
48
60
|
"titular de la tarjeta",
|
|
49
|
-
collectStylesOptions.errorTextStyles
|
|
61
|
+
collectStylesOptions.errorTextStyles,
|
|
50
62
|
);
|
|
51
63
|
|
|
52
64
|
// Create collect elements.
|
|
@@ -56,7 +68,7 @@ export async function initSkyflow(
|
|
|
56
68
|
...collectStylesOptions,
|
|
57
69
|
inputStyles: {
|
|
58
70
|
...collectStylesOptions.inputStyles,
|
|
59
|
-
base: stylesForCardNumber
|
|
71
|
+
base: stylesForCardNumber,
|
|
60
72
|
},
|
|
61
73
|
label: collectStylesOptions.labels?.cardLabel,
|
|
62
74
|
placeholder: collectStylesOptions.placeholders?.cardPlaceholder,
|
|
@@ -67,30 +79,18 @@ export async function initSkyflow(
|
|
|
67
79
|
handleSkyflowElementEvents(
|
|
68
80
|
cardNumberElement,
|
|
69
81
|
"número de tarjeta",
|
|
70
|
-
collectStylesOptions.errorTextStyles
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const cvvElement = await collectContainer.create({
|
|
74
|
-
table: "cards",
|
|
75
|
-
column: "cvv",
|
|
76
|
-
...collectStylesOptions,
|
|
77
|
-
label: collectStylesOptions.labels?.cvvLabel,
|
|
78
|
-
placeholder: collectStylesOptions.placeholders?.cvvPlaceholder,
|
|
79
|
-
type: Skyflow.ElementType.CVV,
|
|
80
|
-
validations: [regexMatchRule],
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
handleSkyflowElementEvents(
|
|
84
|
-
cvvElement,
|
|
85
|
-
"",
|
|
86
|
-
collectStylesOptions.errorTextStyles
|
|
82
|
+
collectStylesOptions.errorTextStyles,
|
|
87
83
|
);
|
|
88
84
|
|
|
89
85
|
const expiryMonthElement = await collectContainer.create({
|
|
90
86
|
table: "cards",
|
|
91
87
|
column: "expiration_month",
|
|
92
88
|
...collectStylesOptions,
|
|
93
|
-
|
|
89
|
+
inputStyles: {
|
|
90
|
+
...collectStylesOptions.inputStyles,
|
|
91
|
+
base: stylesForExpiryMonth,
|
|
92
|
+
},
|
|
93
|
+
label: "",
|
|
94
94
|
placeholder: collectStylesOptions.placeholders?.expiryMonthPlaceholder,
|
|
95
95
|
type: Skyflow.ElementType.EXPIRATION_MONTH,
|
|
96
96
|
validations: [regexMatchRule],
|
|
@@ -99,26 +99,38 @@ export async function initSkyflow(
|
|
|
99
99
|
handleSkyflowElementEvents(
|
|
100
100
|
expiryMonthElement,
|
|
101
101
|
"",
|
|
102
|
-
collectStylesOptions.errorTextStyles
|
|
102
|
+
collectStylesOptions.errorTextStyles,
|
|
103
|
+
true,
|
|
104
|
+
"Campo requerido",
|
|
103
105
|
);
|
|
104
106
|
|
|
105
107
|
const expiryYearElement = await collectContainer.create({
|
|
106
108
|
table: "cards",
|
|
107
109
|
column: "expiration_year",
|
|
108
110
|
...collectStylesOptions,
|
|
111
|
+
inputStyles: {
|
|
112
|
+
...collectStylesOptions.inputStyles,
|
|
113
|
+
base: stylesForExpiryYear,
|
|
114
|
+
},
|
|
109
115
|
label: "",
|
|
110
116
|
placeholder: collectStylesOptions.placeholders?.expiryYearPlaceholder,
|
|
111
117
|
type: Skyflow.ElementType.EXPIRATION_YEAR,
|
|
112
118
|
validations: [regexMatchRule],
|
|
113
119
|
});
|
|
114
120
|
|
|
115
|
-
handleSkyflowElementEvents(
|
|
116
|
-
expiryYearElement,
|
|
117
|
-
"",
|
|
118
|
-
collectStylesOptions.errorTextStyles
|
|
119
|
-
);
|
|
121
|
+
handleSkyflowElementEvents(expiryYearElement, "", collectStylesOptions.errorTextStyles);
|
|
120
122
|
|
|
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
|
+
});
|
|
121
132
|
|
|
133
|
+
handleSkyflowElementEvents(cvvElement, "", collectStylesOptions.errorTextStyles);
|
|
122
134
|
const elementsConfig = {
|
|
123
135
|
cardNumber: {
|
|
124
136
|
element: cardNumberElement,
|
|
@@ -142,82 +154,75 @@ export async function initSkyflow(
|
|
|
142
154
|
},
|
|
143
155
|
};
|
|
144
156
|
|
|
145
|
-
await mountElements(elementsConfig)
|
|
146
|
-
|
|
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
|
-
|
|
160
170
|
export async function initUpdateSkyflow(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
skyflowId,
|
|
172
|
+
vaultId,
|
|
173
|
+
vaultUrl,
|
|
174
|
+
baseUrl,
|
|
175
|
+
apiKey,
|
|
176
|
+
signal,
|
|
177
|
+
customStyles = {},
|
|
178
|
+
displayMode,
|
|
179
|
+
) {
|
|
171
180
|
const skyflow = await initializeSkyflow(vaultId, vaultUrl, baseUrl, apiKey, signal);
|
|
172
181
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
182
|
+
let collectStylesOptions = {
|
|
183
|
+
...getDefaultStyles(displayMode === DISPLAY_MODE.dark),
|
|
184
|
+
...(Object.keys(customStyles).length > 0 ? { ...customStyles } : {}),
|
|
185
|
+
...getCardFormLabels(customStyles),
|
|
186
|
+
};
|
|
176
187
|
// Create collect Container.
|
|
177
|
-
const collectContainer = await skyflow.container(
|
|
178
|
-
Skyflow.ContainerType.COLLECT
|
|
179
|
-
);
|
|
188
|
+
const collectContainer = await skyflow.container(Skyflow.ContainerType.COLLECT);
|
|
180
189
|
|
|
181
190
|
const cvvElement = await collectContainer.create({
|
|
182
191
|
table: "cards",
|
|
183
192
|
column: "cvv",
|
|
184
193
|
...collectStylesOptions,
|
|
185
|
-
label:
|
|
194
|
+
label: "",
|
|
186
195
|
placeholder: collectStylesOptions.placeholders?.cvvPlaceholder,
|
|
187
196
|
type: Skyflow.ElementType.CVV,
|
|
188
197
|
validations: [regexMatchRule],
|
|
189
|
-
skyflowID: skyflowId
|
|
198
|
+
skyflowID: skyflowId,
|
|
190
199
|
});
|
|
191
200
|
|
|
192
|
-
handleSkyflowElementEvents(
|
|
193
|
-
cvvElement,
|
|
194
|
-
"",
|
|
195
|
-
collectStylesOptions.errorTextStyles
|
|
196
|
-
);
|
|
201
|
+
handleSkyflowElementEvents(cvvElement, "", collectStylesOptions.errorTextStyles);
|
|
197
202
|
|
|
198
203
|
const elementsConfig = {
|
|
199
204
|
cvv: {
|
|
200
205
|
element: cvvElement,
|
|
201
206
|
container: `#collectCvv${skyflowId}`,
|
|
202
|
-
}
|
|
207
|
+
},
|
|
203
208
|
};
|
|
204
|
-
await mountElements(elementsConfig)
|
|
209
|
+
await mountElements(elementsConfig);
|
|
205
210
|
|
|
206
211
|
return {
|
|
207
212
|
container: collectContainer,
|
|
208
213
|
elements: {
|
|
209
214
|
cvvElement,
|
|
210
|
-
}
|
|
211
|
-
}
|
|
215
|
+
},
|
|
216
|
+
};
|
|
212
217
|
}
|
|
213
218
|
|
|
214
|
-
async function initializeSkyflow(vaultId, vaultUrl, baseUrl, apiKey, signal){
|
|
219
|
+
async function initializeSkyflow(vaultId, vaultUrl, baseUrl, apiKey, signal) {
|
|
215
220
|
return await Skyflow.init({
|
|
216
221
|
vaultID: vaultId,
|
|
217
222
|
vaultURL: vaultUrl,
|
|
218
223
|
getBearerToken: async () => {
|
|
219
224
|
// Pass the signal to the fetch call
|
|
220
|
-
return await getVaultToken(baseUrl, apiKey, signal)
|
|
225
|
+
return await getVaultToken(baseUrl, apiKey, signal);
|
|
221
226
|
},
|
|
222
227
|
options: {
|
|
223
228
|
logLevel: Skyflow.LogLevel.ERROR,
|
|
@@ -226,7 +231,6 @@ async function initializeSkyflow(vaultId, vaultUrl, baseUrl, apiKey, signal){
|
|
|
226
231
|
});
|
|
227
232
|
}
|
|
228
233
|
|
|
229
|
-
|
|
230
234
|
async function mountElements(elementsConfig) {
|
|
231
235
|
if (typeof elementsConfig !== "object" || elementsConfig === null) {
|
|
232
236
|
throw new Error("Invalid configuration object");
|
|
@@ -236,49 +240,59 @@ async function mountElements(elementsConfig) {
|
|
|
236
240
|
if (element && container) {
|
|
237
241
|
element.mount(container);
|
|
238
242
|
} else {
|
|
239
|
-
console.warn(
|
|
240
|
-
`Skipping mount for '${elementKey}' due to missing element or container.`
|
|
241
|
-
);
|
|
243
|
+
console.warn(`Skipping mount for '${elementKey}' due to missing element or container.`);
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
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
|
+
) {
|
|
247
257
|
if ("on" in element) {
|
|
248
|
-
element.on(Skyflow.EventName.CHANGE,
|
|
249
|
-
updateErrorLabel(element, error_styles, "transparent")
|
|
258
|
+
element.on(Skyflow.EventName.CHANGE, state => {
|
|
259
|
+
updateErrorLabel(element, error_styles, "transparent");
|
|
250
260
|
});
|
|
251
261
|
|
|
252
|
-
element.on(Skyflow.EventName.BLUR,
|
|
262
|
+
element.on(Skyflow.EventName.BLUR, state => {
|
|
253
263
|
if (!state.isValid) {
|
|
254
|
-
const msj_error = state.isEmpty
|
|
264
|
+
const msj_error = state.isEmpty
|
|
265
|
+
? requiredMessage
|
|
266
|
+
: fieldMessage != ""
|
|
267
|
+
? `El campo ${fieldMessage} es inválido`
|
|
268
|
+
: invalidMessage;
|
|
255
269
|
element.setError(msj_error);
|
|
256
270
|
}
|
|
257
|
-
updateErrorLabel(element, error_styles)
|
|
271
|
+
updateErrorLabel(element, error_styles);
|
|
258
272
|
});
|
|
259
273
|
|
|
260
|
-
element.on(Skyflow.EventName.FOCUS,
|
|
261
|
-
updateErrorLabel(element, error_styles, "transparent")
|
|
274
|
+
element.on(Skyflow.EventName.FOCUS, state => {
|
|
275
|
+
updateErrorLabel(element, error_styles, "transparent");
|
|
262
276
|
element.resetError();
|
|
263
277
|
});
|
|
264
278
|
}
|
|
265
279
|
}
|
|
266
280
|
|
|
267
|
-
function updateErrorLabel(element, errorStyles, color = ""
|
|
268
|
-
if(Object.keys(errorStyles).length > 0){
|
|
281
|
+
function updateErrorLabel(element, errorStyles, color = "") {
|
|
282
|
+
if (Object.keys(errorStyles).length > 0) {
|
|
269
283
|
element.update({
|
|
270
284
|
errorTextStyles: {
|
|
271
285
|
...errorStyles,
|
|
272
286
|
base: {
|
|
273
|
-
...(errorStyles.base && {...errorStyles.base}),
|
|
274
|
-
...(color != "" && {color})
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
})
|
|
287
|
+
...(errorStyles.base && { ...errorStyles.base }),
|
|
288
|
+
...(color != "" && { color }),
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
});
|
|
278
292
|
}
|
|
279
293
|
}
|
|
280
294
|
|
|
281
|
-
export async
|
|
295
|
+
export async function getSkyflowTokens({ baseUrl, apiKey, vault_id, vault_url, data }) {
|
|
282
296
|
const skyflow = Skyflow.init({
|
|
283
297
|
vaultID: vault_id,
|
|
284
298
|
vaultURL: vault_url,
|
|
@@ -289,24 +303,21 @@ export async function getSkyflowTokens({baseUrl, apiKey, vault_id, vault_url, d
|
|
|
289
303
|
},
|
|
290
304
|
});
|
|
291
305
|
|
|
292
|
-
const collectContainer = skyflow.container(Skyflow.ContainerType.
|
|
306
|
+
const collectContainer = skyflow.container(Skyflow.ContainerType.COMPOSABLE);
|
|
293
307
|
|
|
294
308
|
const fieldPromises = await getFieldsPromise(data, collectContainer);
|
|
295
309
|
|
|
296
310
|
const result = await Promise.all(fieldPromises);
|
|
297
|
-
const mountFail = result.some(
|
|
311
|
+
const mountFail = result.some(item => !item);
|
|
298
312
|
|
|
299
313
|
if (mountFail) {
|
|
300
|
-
throw buildErrorResponseFromCatch(
|
|
301
|
-
Error("Ocurrió un error al montar los campos de la tarjeta"),
|
|
302
|
-
);
|
|
314
|
+
throw buildErrorResponseFromCatch(Error("Ocurrió un error al montar los campos de la tarjeta"));
|
|
303
315
|
} else {
|
|
304
316
|
try {
|
|
305
317
|
const collectResponseSkyflowTonder = await collectContainer.collect();
|
|
306
|
-
if (collectResponseSkyflowTonder)
|
|
307
|
-
return collectResponseSkyflowTonder["records"][0]["fields"];
|
|
318
|
+
if (collectResponseSkyflowTonder) return collectResponseSkyflowTonder["records"][0]["fields"];
|
|
308
319
|
throw buildErrorResponseFromCatch(
|
|
309
|
-
|
|
320
|
+
Error("Por favor, verifica todos los campos de tu tarjeta"),
|
|
310
321
|
);
|
|
311
322
|
} catch (error) {
|
|
312
323
|
throw buildErrorResponseFromCatch(error);
|
|
@@ -316,8 +327,8 @@ export async function getSkyflowTokens({baseUrl, apiKey, vault_id, vault_url, d
|
|
|
316
327
|
async function getFieldsPromise(data, collectContainer) {
|
|
317
328
|
const fields = await getFields(data, collectContainer);
|
|
318
329
|
if (!fields) return [];
|
|
319
|
-
return fields.map(
|
|
320
|
-
return new Promise(
|
|
330
|
+
return fields.map(field => {
|
|
331
|
+
return new Promise(resolve => {
|
|
321
332
|
const div = document.createElement("div");
|
|
322
333
|
div.hidden = true;
|
|
323
334
|
div.id = `id-${field.key}`;
|
|
@@ -333,20 +344,20 @@ async function getFieldsPromise(data, collectContainer) {
|
|
|
333
344
|
}, 120);
|
|
334
345
|
}, 120);
|
|
335
346
|
});
|
|
336
|
-
})
|
|
347
|
+
});
|
|
337
348
|
}
|
|
338
349
|
|
|
339
350
|
async function getFields(data, collectContainer) {
|
|
340
351
|
return await Promise.all(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
)
|
|
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
|
+
);
|
|
350
361
|
}
|
|
351
362
|
|
|
352
363
|
const regexEmpty = RegExp("^(?!\s*$).+");
|
|
@@ -354,8 +365,6 @@ const regexMatchRule = {
|
|
|
354
365
|
type: Skyflow.ValidationRuleType.REGEX_MATCH_RULE,
|
|
355
366
|
params: {
|
|
356
367
|
regex: regexEmpty,
|
|
357
|
-
error: "El campo es requerido" // Optional, default error is 'VALIDATION FAILED'.
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
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
|
+
};
|