@tonder.io/ionic-full-sdk 0.0.20-beta → 0.0.22-beta

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonder.io/ionic-full-sdk",
3
- "version": "0.0.20-beta",
3
+ "version": "0.0.22-beta",
4
4
  "description": "Tonder ionic full SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.js",
@@ -77,16 +77,6 @@ export async function initSkyflow(
77
77
  }
78
78
  }
79
79
 
80
- const regexJustText = /^[A-Za-z\s]*$/;
81
-
82
- const regexJustTextRule = {
83
- type: Skyflow.ValidationRuleType.REGEX_MATCH_RULE,
84
- params: {
85
- regex: regexJustText,
86
- error: "Debe contener solo letras"
87
- }
88
- }
89
-
90
80
  const cardHolderNameElement: CollectElement | RevealElement | ComposableElement = await collectContainer.create({
91
81
  table: "cards",
92
82
  column: "cardholder_name",
@@ -94,9 +84,47 @@ export async function initSkyflow(
94
84
  label: "Titular de la tarjeta",
95
85
  placeholder: "Nombre como aparece en la tarjeta",
96
86
  type: Skyflow.ElementType.CARDHOLDER_NAME,
97
- validations: [regexMatchRule, lengthMatchRule, regexJustTextRule],
87
+ validations: [lengthMatchRule, regexMatchRule],
98
88
  });
99
89
 
90
+ if("on" in cardHolderNameElement) {
91
+
92
+ cardHolderNameElement.on(Skyflow.EventName.CHANGE, (state: any) => {
93
+
94
+ let element = document.getElementById(
95
+ "errorCardHolderIdTonder",
96
+ );
97
+
98
+ if (element && state.isValid && !state.isEmpty) {
99
+ element.remove();
100
+ }
101
+ });
102
+
103
+ cardHolderNameElement.on(Skyflow.EventName.BLUR, (state: any) => {
104
+ let tonderContainer = document.getElementById(
105
+ collectorIds.holderName
106
+ );
107
+
108
+ let element = document.getElementById(
109
+ "errorCardHolderIdTonder",
110
+ );
111
+
112
+ if (element) {
113
+ element.remove();
114
+ }
115
+
116
+ if (!state.isValid) {
117
+ let errorLabel = document.createElement("div");
118
+ errorLabel.classList.add("error-custom-inputs-tonder");
119
+ errorLabel.id = "errorCardHolderIdTonder";
120
+ errorLabel.textContent = state.isEmpty ? "El campo es requerido" : "El campo titular de la tarjeta es inválido";
121
+ tonderContainer?.appendChild(errorLabel);
122
+ }
123
+
124
+ });
125
+
126
+ }
127
+
100
128
  // Create collect elements.
101
129
  const cardNumberElement: CollectElement | RevealElement | ComposableElement = await collectContainer.create({
102
130
  table: "cards",
@@ -112,6 +140,45 @@ export async function initSkyflow(
112
140
  validations: [regexMatchRule],
113
141
  });
114
142
 
143
+ if("on" in cardNumberElement) {
144
+
145
+ cardNumberElement.on(Skyflow.EventName.CHANGE, (state: any) => {
146
+
147
+ let element = document.getElementById(
148
+ "errorCardNumberIdTonder",
149
+ );
150
+
151
+ if (element && state.isValid && !state.isEmpty) {
152
+ element.remove();
153
+ }
154
+
155
+ });
156
+
157
+ cardNumberElement.on(Skyflow.EventName.BLUR, (state: any) => {
158
+ let tonderContainer = document.getElementById(
159
+ collectorIds.cardNumber
160
+ );
161
+
162
+ let element = document.getElementById(
163
+ "errorCardNumberIdTonder",
164
+ );
165
+
166
+ if (element) {
167
+ element.remove();
168
+ }
169
+
170
+ if (!state.isValid) {
171
+ let errorLabel = document.createElement("div");
172
+ errorLabel.classList.add("error-custom-inputs-tonder");
173
+ errorLabel.id = "errorCardNumberIdTonder";
174
+ errorLabel.textContent = state.isEmpty ? "El campo es requerido" : "El campo número de tarjeta es inválido";
175
+ tonderContainer?.appendChild(errorLabel);
176
+ }
177
+
178
+ });
179
+
180
+ }
181
+
115
182
  const cvvElement: CollectElement | RevealElement | ComposableElement = await collectContainer.create({
116
183
  table: "cards",
117
184
  column: "cvv",
@@ -122,6 +189,44 @@ export async function initSkyflow(
122
189
  validations: [regexMatchRule],
123
190
  });
124
191
 
192
+ if("on" in cvvElement) {
193
+
194
+ cvvElement.on(Skyflow.EventName.CHANGE, (state: any) => {
195
+
196
+ let element = document.getElementById(
197
+ "errorCvvIdTonder",
198
+ );
199
+
200
+ if (element && state.isValid && !state.isEmpty) {
201
+ element.remove();
202
+ }
203
+ });
204
+
205
+ cvvElement.on(Skyflow.EventName.BLUR, (state: any) => {
206
+ let tonderContainer = document.getElementById(
207
+ collectorIds.cvv
208
+ );
209
+
210
+ let element = document.getElementById(
211
+ "errorCvvIdTonder",
212
+ );
213
+
214
+ if (element) {
215
+ element.remove();
216
+ }
217
+
218
+ if (!state.isValid) {
219
+ let errorLabel = document.createElement("div");
220
+ errorLabel.classList.add("error-custom-inputs-tonder");
221
+ errorLabel.id = "errorCvvIdTonder";
222
+ errorLabel.textContent = state.isEmpty ? "El campo es requerido" : "El campo es inválido";
223
+ tonderContainer?.appendChild(errorLabel);
224
+ }
225
+
226
+ });
227
+
228
+ }
229
+
125
230
  const expiryMonthElement: CollectElement | RevealElement | ComposableElement = await collectContainer.create({
126
231
  table: "cards",
127
232
  column: "expiration_month",
@@ -132,6 +237,44 @@ export async function initSkyflow(
132
237
  validations: [regexMatchRule],
133
238
  });
134
239
 
240
+ if("on" in expiryMonthElement) {
241
+
242
+ expiryMonthElement.on(Skyflow.EventName.CHANGE, (state: any) => {
243
+
244
+ let element = document.getElementById(
245
+ "errorExpiryMonthIdTonder",
246
+ );
247
+
248
+ if (element && state.isValid && !state.isEmpty) {
249
+ element.remove();
250
+ }
251
+ });
252
+
253
+ expiryMonthElement.on(Skyflow.EventName.BLUR, (state: any) => {
254
+ let tonderContainer = document.getElementById(
255
+ collectorIds.expirationMonth
256
+ );
257
+
258
+ let element = document.getElementById(
259
+ "errorExpiryMonthIdTonder",
260
+ );
261
+
262
+ if (element) {
263
+ element.remove();
264
+ }
265
+
266
+ if (!state.isValid) {
267
+ let errorLabel = document.createElement("div");
268
+ errorLabel.classList.add("error-custom-inputs-tonder");
269
+ errorLabel.id = "errorExpiryMonthIdTonder";
270
+ errorLabel.textContent = state.isEmpty ? "El campo es requerido" : "El campo es inválido";
271
+ tonderContainer?.appendChild(errorLabel);
272
+ }
273
+
274
+ });
275
+
276
+ }
277
+
135
278
  const expiryYearElement: CollectElement | RevealElement | ComposableElement = await collectContainer.create({
136
279
  table: "cards",
137
280
  column: "expiration_year",
@@ -142,6 +285,44 @@ export async function initSkyflow(
142
285
  validations: [regexMatchRule],
143
286
  });
144
287
 
288
+ if("on" in expiryYearElement) {
289
+
290
+ expiryYearElement.on(Skyflow.EventName.CHANGE, (state: any) => {
291
+
292
+ let element = document.getElementById(
293
+ "errorExpiryYearIdTonder",
294
+ );
295
+
296
+ if (element && state.isValid && !state.isEmpty) {
297
+ element.remove();
298
+ }
299
+ });
300
+
301
+ expiryYearElement.on(Skyflow.EventName.BLUR, (state: any) => {
302
+ let tonderContainer = document.getElementById(
303
+ collectorIds.expirationYear
304
+ );
305
+
306
+ let element = document.getElementById(
307
+ "errorExpiryYearIdTonder",
308
+ );
309
+
310
+ if (element) {
311
+ element.remove();
312
+ }
313
+
314
+ if (!state.isValid) {
315
+ let errorLabel = document.createElement("div");
316
+ errorLabel.classList.add("error-custom-inputs-tonder");
317
+ errorLabel.id = "errorExpiryYearIdTonder";
318
+ errorLabel.textContent = state.isEmpty ? "El campo es requerido" : "El campo es inválido";
319
+ tonderContainer?.appendChild(errorLabel);
320
+ }
321
+
322
+ });
323
+
324
+ }
325
+
145
326
  await mountElements(
146
327
  { id: collectorIds.cardNumber, element: cardNumberElement },
147
328
  { id: collectorIds.cvv, element: cvvElement },
@@ -55,6 +55,28 @@ ${external ? `` : `<style>
55
55
 
56
56
  @import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap");
57
57
 
58
+ .error-custom-inputs-tonder {
59
+ background-color: white;
60
+ position: absolute;
61
+ left: 0px;
62
+ bottom: -1px;
63
+ width: 100%;
64
+ font-size: 12px;
65
+ color: red;
66
+ font-family: "Inter", sans-serif !important;
67
+ }
68
+
69
+ .expiration-year .error-custom-inputs-tonder {
70
+ background-color: white;
71
+ position: absolute;
72
+ left: 0px;
73
+ bottom: 3px;
74
+ width: 100%;
75
+ font-size: 12px;
76
+ color: red;
77
+ font-family: "Inter", sans-serif !important;
78
+ }
79
+
58
80
  .container-tonder {
59
81
  background-color: #F9F9F9;
60
82
  margin: 0 auto !important;
@@ -76,10 +98,12 @@ ${external ? `` : `<style>
76
98
  }
77
99
 
78
100
  .expiration-year {
79
- padding-top: 25px !important;
101
+ position: relative !important;
102
+ padding-top: 24px !important;
80
103
  }
81
104
 
82
105
  .empty-div {
106
+ position: relative;
83
107
  height: 80px !important;
84
108
  margin-top: 2px;
85
109
  margin-bottom: 4px;