@xyo-network/react-form-credit-card 7.5.8 → 7.5.11
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/dist/browser/components/controls/card/FormControlTextField.d.ts.map +1 -1
- package/dist/browser/components/controls/card/number/use.d.ts.map +1 -1
- package/dist/browser/components/support/InputError.d.ts +2 -2
- package/dist/browser/components/support/InputError.d.ts.map +1 -1
- package/dist/browser/controls/CreditCardNumber.d.ts.map +1 -1
- package/dist/browser/index.mjs +474 -425
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/models/CreditCardInput.d.ts +2 -2
- package/dist/browser/models/CreditCardInput.d.ts.map +1 -1
- package/package.json +120 -34
- package/src/components/controls/WithFormControlProps.ts +0 -6
- package/src/components/controls/card/Email.tsx +0 -37
- package/src/components/controls/card/Expiration.tsx +0 -37
- package/src/components/controls/card/FormControlTextField.tsx +0 -63
- package/src/components/controls/card/Name.tsx +0 -44
- package/src/components/controls/card/Options.ts +0 -22
- package/src/components/controls/card/Zip.tsx +0 -33
- package/src/components/controls/card/cvv/Cvv.tsx +0 -35
- package/src/components/controls/card/cvv/index.ts +0 -2
- package/src/components/controls/card/cvv/use.ts +0 -37
- package/src/components/controls/card/index.ts +0 -9
- package/src/components/controls/card/number/Number.tsx +0 -49
- package/src/components/controls/card/number/index.ts +0 -2
- package/src/components/controls/card/number/use.ts +0 -34
- package/src/components/controls/card/useCreditCardFormControl.tsx +0 -40
- package/src/components/controls/index.ts +0 -2
- package/src/components/form/Form.tsx +0 -83
- package/src/components/form/InputFieldsStack.tsx +0 -69
- package/src/components/form/Props.ts +0 -15
- package/src/components/form/index.ts +0 -4
- package/src/components/form/useFormStorage.tsx +0 -40
- package/src/components/img/american-express.svg +0 -69
- package/src/components/img/discover.svg +0 -13
- package/src/components/img/index.ts +0 -4
- package/src/components/img/mastercard.svg +0 -16
- package/src/components/img/visa.svg +0 -1
- package/src/components/index.ts +0 -3
- package/src/components/support/Fields.ts +0 -3
- package/src/components/support/InputError.ts +0 -4
- package/src/components/support/index.ts +0 -3
- package/src/components/support/validateCreditCardInputs.ts +0 -18
- package/src/context/FormGroupCreditCardContext.ts +0 -6
- package/src/context/FormGroupCreditCardProvider.tsx +0 -33
- package/src/context/index.ts +0 -3
- package/src/context/useFormGroupWithCreditCard.tsx +0 -7
- package/src/controls/CreditCardCvv.ts +0 -85
- package/src/controls/CreditCardExpiry.ts +0 -94
- package/src/controls/CreditCardNumber.ts +0 -138
- package/src/controls/Email.ts +0 -47
- package/src/controls/Name.ts +0 -40
- package/src/controls/Zip.ts +0 -54
- package/src/controls/index.ts +0 -6
- package/src/index.ts +0 -5
- package/src/models/CreditCardInput.ts +0 -20
- package/src/models/index.ts +0 -1
- package/src/stories/form.stories.tsx +0 -26
- package/src/types/images.d.ts +0 -29
- package/src/utils/index.ts +0 -1
- package/src/utils/umask.ts +0 -3
package/dist/browser/index.mjs
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/components/controls/card/cvv/Cvv.tsx
|
|
5
|
-
import React3 from "react";
|
|
6
|
-
|
|
7
1
|
// src/controls/CreditCardCvv.ts
|
|
8
2
|
import { assertEx } from "@xylabs/sdk-js";
|
|
9
3
|
import { FormControlBase } from "@xyo-network/react-form-group";
|
|
@@ -13,14 +7,10 @@ import valid from "card-validator";
|
|
|
13
7
|
function unmask(value) {
|
|
14
8
|
return value.replaceAll(/\D/g, "");
|
|
15
9
|
}
|
|
16
|
-
__name(unmask, "unmask");
|
|
17
10
|
|
|
18
11
|
// src/controls/CreditCardCvv.ts
|
|
19
12
|
var CONTROL_NAME = "cvv";
|
|
20
13
|
var CreditCardCvvFormControl = class extends FormControlBase {
|
|
21
|
-
static {
|
|
22
|
-
__name(this, "CreditCardCvvFormControl");
|
|
23
|
-
}
|
|
24
14
|
invalidMessage = "Your card cvc is invalid.";
|
|
25
15
|
pattern = /^\d{0,4}$/;
|
|
26
16
|
patternStrict = /^\d{1,4}$/;
|
|
@@ -39,10 +29,7 @@ var CreditCardCvvFormControl = class extends FormControlBase {
|
|
|
39
29
|
constructor() {
|
|
40
30
|
super();
|
|
41
31
|
super.setName(CONTROL_NAME);
|
|
42
|
-
this.setSerializeSettings({
|
|
43
|
-
sensitive: true,
|
|
44
|
-
serializable: true
|
|
45
|
-
});
|
|
32
|
+
this.setSerializeSettings({ sensitive: true, serializable: true });
|
|
46
33
|
}
|
|
47
34
|
get cardNumberFormControl() {
|
|
48
35
|
return assertEx(this._cardNumberFormControl, () => "Card number form control is not set");
|
|
@@ -94,9 +81,6 @@ import { FormControlBase as FormControlBase2 } from "@xyo-network/react-form-gro
|
|
|
94
81
|
import valid2 from "card-validator";
|
|
95
82
|
var CONTROL_NAME2 = "expiration";
|
|
96
83
|
var CreditCardExpirationFormControl = class extends FormControlBase2 {
|
|
97
|
-
static {
|
|
98
|
-
__name(this, "CreditCardExpirationFormControl");
|
|
99
|
-
}
|
|
100
84
|
invalidMessage = "Card Expiration is invalid";
|
|
101
85
|
pattern = /^\d{0,4}$/;
|
|
102
86
|
patternStrict = /^\d{1,4}$/;
|
|
@@ -115,10 +99,7 @@ var CreditCardExpirationFormControl = class extends FormControlBase2 {
|
|
|
115
99
|
constructor() {
|
|
116
100
|
super();
|
|
117
101
|
super.setName(CONTROL_NAME2);
|
|
118
|
-
this.setSerializeSettings({
|
|
119
|
-
sensitive: true,
|
|
120
|
-
serializable: true
|
|
121
|
-
});
|
|
102
|
+
this.setSerializeSettings({ sensitive: true, serializable: true });
|
|
122
103
|
}
|
|
123
104
|
get cardNumberFormControl() {
|
|
124
105
|
return assertEx2(this._cardNumberFormControl, () => "Card number form control is not set");
|
|
@@ -174,9 +155,6 @@ import { FormControlBase as FormControlBase3 } from "@xyo-network/react-form-gro
|
|
|
174
155
|
import valid3 from "card-validator";
|
|
175
156
|
var CONTROL_NAME3 = "cardNumber2";
|
|
176
157
|
var CreditCardNumberFormControl = class extends FormControlBase3 {
|
|
177
|
-
static {
|
|
178
|
-
__name(this, "CreditCardNumberFormControl");
|
|
179
|
-
}
|
|
180
158
|
creditCardType = "";
|
|
181
159
|
invalidMessage = "Card Number is invalid";
|
|
182
160
|
pattern = /^(\d+)?$/;
|
|
@@ -195,10 +173,7 @@ var CreditCardNumberFormControl = class extends FormControlBase3 {
|
|
|
195
173
|
constructor() {
|
|
196
174
|
super();
|
|
197
175
|
super.setName(CONTROL_NAME3);
|
|
198
|
-
this.setSerializeSettings({
|
|
199
|
-
sensitive: true,
|
|
200
|
-
serializable: true
|
|
201
|
-
});
|
|
176
|
+
this.setSerializeSettings({ sensitive: true, serializable: true });
|
|
202
177
|
}
|
|
203
178
|
blurError(value) {
|
|
204
179
|
const unmasked = unmask(value);
|
|
@@ -270,17 +245,14 @@ var CreditCardNumberFormControl = class extends FormControlBase3 {
|
|
|
270
245
|
const card = numberValidation.card;
|
|
271
246
|
if (card) {
|
|
272
247
|
const max = card.lengths.includes(16) ? 16 : card.lengths[0];
|
|
273
|
-
const gaps = [
|
|
274
|
-
...card.gaps,
|
|
275
|
-
max
|
|
276
|
-
];
|
|
248
|
+
const gaps = [...card.gaps, max];
|
|
277
249
|
const newVal = gaps.map((gap, i) => unmasked.slice(gaps[i - 1] || 0, gap)).filter(Boolean).join(" ");
|
|
278
250
|
return newVal;
|
|
279
251
|
}
|
|
280
252
|
return value;
|
|
281
253
|
}
|
|
282
|
-
onCreditCardTypeChange =
|
|
283
|
-
}
|
|
254
|
+
onCreditCardTypeChange = () => {
|
|
255
|
+
};
|
|
284
256
|
setCreditCardType(type) {
|
|
285
257
|
this.creditCardType = type;
|
|
286
258
|
this.onCreditCardTypeChange(type);
|
|
@@ -296,9 +268,6 @@ var CreditCardNumberFormControl = class extends FormControlBase3 {
|
|
|
296
268
|
import { FormControlBase as FormControlBase4 } from "@xyo-network/react-form-group";
|
|
297
269
|
var CONTROL_NAME4 = "Email";
|
|
298
270
|
var CreditCardEmailFormControl = class extends FormControlBase4 {
|
|
299
|
-
static {
|
|
300
|
-
__name(this, "CreditCardEmailFormControl");
|
|
301
|
-
}
|
|
302
271
|
invalidMessage = "Your email is invalid.";
|
|
303
272
|
pattern = /^.*$/;
|
|
304
273
|
patternStrict = /^([\w+.\-])+@(([\dA-Za-z-])+\.)+([\dA-Za-z]{2,4})+$/;
|
|
@@ -314,10 +283,7 @@ var CreditCardEmailFormControl = class extends FormControlBase4 {
|
|
|
314
283
|
constructor() {
|
|
315
284
|
super();
|
|
316
285
|
super.setName(CONTROL_NAME4);
|
|
317
|
-
this.setSerializeSettings({
|
|
318
|
-
sensitive: false,
|
|
319
|
-
serializable: true
|
|
320
|
-
});
|
|
286
|
+
this.setSerializeSettings({ sensitive: false, serializable: true });
|
|
321
287
|
}
|
|
322
288
|
blurError(value) {
|
|
323
289
|
const match = RegExp(this.patternStrict).exec(value);
|
|
@@ -340,19 +306,13 @@ var CreditCardEmailFormControl = class extends FormControlBase4 {
|
|
|
340
306
|
// src/controls/Name.ts
|
|
341
307
|
import { FormControlBase as FormControlBase5 } from "@xyo-network/react-form-group";
|
|
342
308
|
var NameFormControl = class extends FormControlBase5 {
|
|
343
|
-
static {
|
|
344
|
-
__name(this, "NameFormControl");
|
|
345
|
-
}
|
|
346
309
|
required = true;
|
|
347
310
|
nameLabel;
|
|
348
311
|
constructor(nameLabel, autoCompleteLabel, placeHolder) {
|
|
349
312
|
super();
|
|
350
313
|
this.nameLabel = nameLabel;
|
|
351
314
|
super.setName(nameLabel);
|
|
352
|
-
this.setSerializeSettings({
|
|
353
|
-
sensitive: false,
|
|
354
|
-
serializable: true
|
|
355
|
-
});
|
|
315
|
+
this.setSerializeSettings({ sensitive: false, serializable: true });
|
|
356
316
|
this.invalidMessage = `${nameLabel} name is missing.`;
|
|
357
317
|
this.props = {
|
|
358
318
|
autoComplete: autoCompleteLabel,
|
|
@@ -380,9 +340,6 @@ import { FormControlBase as FormControlBase6 } from "@xyo-network/react-form-gro
|
|
|
380
340
|
import valid4 from "card-validator";
|
|
381
341
|
var CONTROL_NAME5 = "Zip";
|
|
382
342
|
var CreditCardZipFormControl = class extends FormControlBase6 {
|
|
383
|
-
static {
|
|
384
|
-
__name(this, "CreditCardZipFormControl");
|
|
385
|
-
}
|
|
386
343
|
invalidMessage = "Your zip code is invalid.";
|
|
387
344
|
props = {
|
|
388
345
|
autoComplete: "postal-code",
|
|
@@ -397,10 +354,7 @@ var CreditCardZipFormControl = class extends FormControlBase6 {
|
|
|
397
354
|
constructor() {
|
|
398
355
|
super();
|
|
399
356
|
super.setName(CONTROL_NAME5);
|
|
400
|
-
this.setSerializeSettings({
|
|
401
|
-
sensitive: true,
|
|
402
|
-
serializable: true
|
|
403
|
-
});
|
|
357
|
+
this.setSerializeSettings({ sensitive: true, serializable: true });
|
|
404
358
|
}
|
|
405
359
|
blurError(value) {
|
|
406
360
|
const postalCodeValidation = valid4.postalCode(value);
|
|
@@ -429,43 +383,46 @@ var CreditCardZipFormControl = class extends FormControlBase6 {
|
|
|
429
383
|
// src/components/controls/card/FormControlTextField.tsx
|
|
430
384
|
import { FormControl as MuiFormControl, TextField } from "@mui/material";
|
|
431
385
|
import { LabeledTextFieldWrapper } from "@xyo-network/react-shared";
|
|
432
|
-
import
|
|
433
|
-
var FormControlTextField =
|
|
386
|
+
import { jsx } from "react/jsx-runtime";
|
|
387
|
+
var FormControlTextField = ({
|
|
388
|
+
ref,
|
|
389
|
+
formControl,
|
|
390
|
+
formControlError,
|
|
391
|
+
fieldLabel = "",
|
|
392
|
+
...props
|
|
393
|
+
}) => {
|
|
434
394
|
const { name } = formControl?.props ?? {};
|
|
435
|
-
const handleChange =
|
|
395
|
+
const handleChange = (event) => {
|
|
436
396
|
formControl?.setValue(event.target.value);
|
|
437
|
-
}
|
|
438
|
-
const handleBlur =
|
|
397
|
+
};
|
|
398
|
+
const handleBlur = (event) => {
|
|
439
399
|
formControl?.blurError?.(event.target.value);
|
|
440
400
|
formControl?.setTouched(true);
|
|
441
|
-
}
|
|
442
|
-
return /* @__PURE__ */
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
...props
|
|
467
|
-
}))));
|
|
468
|
-
}, "FormControlTextField");
|
|
401
|
+
};
|
|
402
|
+
return /* @__PURE__ */ jsx(MuiFormControl, { fullWidth: true, children: /* @__PURE__ */ jsx(LabeledTextFieldWrapper, { label: fieldLabel, children: /* @__PURE__ */ jsx("label", { htmlFor: name, children: /* @__PURE__ */ jsx(
|
|
403
|
+
TextField,
|
|
404
|
+
{
|
|
405
|
+
error: !!formControlError,
|
|
406
|
+
helperText: formControlError || " ",
|
|
407
|
+
fullWidth: true,
|
|
408
|
+
hiddenLabel: true,
|
|
409
|
+
name,
|
|
410
|
+
onBlur: handleBlur,
|
|
411
|
+
onChange: handleChange,
|
|
412
|
+
onKeyDown: (event) => {
|
|
413
|
+
const selectionEnd = event.target.selectionEnd;
|
|
414
|
+
if (selectionEnd && formControl) {
|
|
415
|
+
formControl.cursorPosition = { ...formControl.cursorPosition, previous: selectionEnd };
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
ref,
|
|
419
|
+
required: formControl?.required,
|
|
420
|
+
size: "small",
|
|
421
|
+
variant: "filled",
|
|
422
|
+
...props
|
|
423
|
+
}
|
|
424
|
+
) }) }) });
|
|
425
|
+
};
|
|
469
426
|
FormControlTextField.displayName = "FormControlTextField";
|
|
470
427
|
|
|
471
428
|
// src/components/controls/card/cvv/use.ts
|
|
@@ -477,36 +434,42 @@ var FormGroupCreditCardContext = createContextEx();
|
|
|
477
434
|
|
|
478
435
|
// src/context/FormGroupCreditCardProvider.tsx
|
|
479
436
|
import { FormGroup } from "@xyo-network/react-form-group";
|
|
480
|
-
import
|
|
481
|
-
|
|
437
|
+
import { useMemo } from "react";
|
|
438
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
439
|
+
var FormGroupCreditCardProvider = ({
|
|
440
|
+
children,
|
|
441
|
+
params,
|
|
442
|
+
...props
|
|
443
|
+
}) => {
|
|
482
444
|
const formGroup = useMemo(() => {
|
|
483
445
|
const formGroup2 = new FormGroup(params);
|
|
484
446
|
return formGroup2;
|
|
485
|
-
}, [
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
...props
|
|
497
|
-
}, children);
|
|
498
|
-
}, "FormGroupCreditCardProvider");
|
|
447
|
+
}, [params]);
|
|
448
|
+
const value = useMemo(() => ({ formGroup, provided: true }), [formGroup]);
|
|
449
|
+
return /* @__PURE__ */ jsx2(
|
|
450
|
+
FormGroupCreditCardContext,
|
|
451
|
+
{
|
|
452
|
+
value,
|
|
453
|
+
...props,
|
|
454
|
+
children
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
};
|
|
499
458
|
|
|
500
459
|
// src/context/useFormGroupWithCreditCard.tsx
|
|
501
460
|
import { useContextEx } from "@xylabs/react-shared";
|
|
502
|
-
var useFormGroupWithCreditCardInput =
|
|
461
|
+
var useFormGroupWithCreditCardInput = (required = false) => {
|
|
503
462
|
return useContextEx(FormGroupCreditCardContext, "FormGroupCreditCard", required);
|
|
504
|
-
}
|
|
463
|
+
};
|
|
505
464
|
|
|
506
465
|
// src/components/controls/card/useCreditCardFormControl.tsx
|
|
507
|
-
import {
|
|
466
|
+
import {
|
|
467
|
+
useMemo as useMemo2,
|
|
468
|
+
useRef,
|
|
469
|
+
useState
|
|
470
|
+
} from "react";
|
|
508
471
|
var STABLE_DEFAULT_ARGS = [];
|
|
509
|
-
var useCreditCardFormControl =
|
|
472
|
+
var useCreditCardFormControl = (formControlName, Control, args = STABLE_DEFAULT_ARGS) => {
|
|
510
473
|
const [error, setError] = useState("");
|
|
511
474
|
const [value, setValue] = useState("");
|
|
512
475
|
const inputRef = useRef(null);
|
|
@@ -519,23 +482,23 @@ var useCreditCardFormControl = /* @__PURE__ */ __name((formControlName, Control,
|
|
|
519
482
|
if (formControlName) formGroup?.registerControl(formControlName, control);
|
|
520
483
|
return control;
|
|
521
484
|
}
|
|
522
|
-
}, [
|
|
523
|
-
Control,
|
|
524
|
-
args,
|
|
525
|
-
formControlName,
|
|
526
|
-
formGroup
|
|
527
|
-
]);
|
|
485
|
+
}, [Control, args, formControlName, formGroup]);
|
|
528
486
|
return {
|
|
529
487
|
creditCardFormControl,
|
|
530
488
|
error,
|
|
531
489
|
inputRef,
|
|
532
490
|
value
|
|
533
491
|
};
|
|
534
|
-
}
|
|
492
|
+
};
|
|
535
493
|
|
|
536
494
|
// src/components/controls/card/cvv/use.ts
|
|
537
|
-
var useCreditCardCvvFormControl =
|
|
538
|
-
const {
|
|
495
|
+
var useCreditCardCvvFormControl = (formControlName, cardNumberControlName = "cardNumber", control) => {
|
|
496
|
+
const {
|
|
497
|
+
creditCardFormControl,
|
|
498
|
+
error,
|
|
499
|
+
value,
|
|
500
|
+
inputRef
|
|
501
|
+
} = useCreditCardFormControl(formControlName, control);
|
|
539
502
|
const { formGroup } = useFormGroupWithCreditCardInput(!!formControlName);
|
|
540
503
|
const creditCardNumberFormControl = formGroup?.getControl?.(cardNumberControlName);
|
|
541
504
|
useEffect(() => {
|
|
@@ -547,138 +510,211 @@ var useCreditCardCvvFormControl = /* @__PURE__ */ __name((formControlName, cardN
|
|
|
547
510
|
}
|
|
548
511
|
castControl.setCardNumberFormControl(creditCardNumberFormControl);
|
|
549
512
|
}
|
|
550
|
-
}, [
|
|
551
|
-
creditCardFormControl,
|
|
552
|
-
creditCardNumberFormControl
|
|
553
|
-
]);
|
|
513
|
+
}, [creditCardFormControl, creditCardNumberFormControl]);
|
|
554
514
|
return {
|
|
555
515
|
creditCardFormControl,
|
|
556
516
|
error,
|
|
557
517
|
inputRef,
|
|
558
518
|
value
|
|
559
519
|
};
|
|
560
|
-
}
|
|
520
|
+
};
|
|
561
521
|
|
|
562
522
|
// src/components/controls/card/cvv/Cvv.tsx
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
htmlInput: {
|
|
573
|
-
"aria-label": `${fieldLabel} number on the back of your card`,
|
|
574
|
-
autoComplete,
|
|
575
|
-
autoCorrect,
|
|
576
|
-
id,
|
|
577
|
-
name,
|
|
578
|
-
spellCheck
|
|
579
|
-
}
|
|
580
|
-
},
|
|
523
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
524
|
+
var CreditCardCvvWithFormControl = ({
|
|
525
|
+
formControlName = "cvc",
|
|
526
|
+
fieldLabel = "CVC",
|
|
527
|
+
...props
|
|
528
|
+
}) => {
|
|
529
|
+
const {
|
|
530
|
+
creditCardFormControl,
|
|
531
|
+
error,
|
|
581
532
|
inputRef,
|
|
582
|
-
value
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
533
|
+
value
|
|
534
|
+
} = useCreditCardCvvFormControl(formControlName, void 0, CreditCardCvvFormControl);
|
|
535
|
+
const {
|
|
536
|
+
autoComplete,
|
|
537
|
+
autoCorrect,
|
|
538
|
+
id,
|
|
539
|
+
inputMode,
|
|
540
|
+
name,
|
|
541
|
+
spellCheck,
|
|
542
|
+
...cvcProps
|
|
543
|
+
} = creditCardFormControl?.props ?? {};
|
|
544
|
+
return /* @__PURE__ */ jsx3(
|
|
545
|
+
FormControlTextField,
|
|
546
|
+
{
|
|
547
|
+
fieldLabel,
|
|
548
|
+
formControl: creditCardFormControl,
|
|
549
|
+
formControlError: error,
|
|
550
|
+
inputMode,
|
|
551
|
+
slotProps: {
|
|
552
|
+
htmlInput: {
|
|
553
|
+
"aria-label": `${fieldLabel} number on the back of your card`,
|
|
554
|
+
autoComplete,
|
|
555
|
+
autoCorrect,
|
|
556
|
+
id,
|
|
557
|
+
name,
|
|
558
|
+
spellCheck
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
inputRef,
|
|
562
|
+
value,
|
|
563
|
+
...cvcProps,
|
|
564
|
+
...props
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
};
|
|
587
568
|
|
|
588
569
|
// src/components/controls/card/Email.tsx
|
|
589
|
-
import
|
|
590
|
-
var CreditCardEmailWithFormControl =
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
slotProps: {
|
|
599
|
-
htmlInput: {
|
|
600
|
-
"aria-label": `${fieldLabel} for your purchase`,
|
|
601
|
-
autoComplete,
|
|
602
|
-
autoCorrect,
|
|
603
|
-
id,
|
|
604
|
-
name,
|
|
605
|
-
spellCheck
|
|
606
|
-
}
|
|
607
|
-
},
|
|
570
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
571
|
+
var CreditCardEmailWithFormControl = ({
|
|
572
|
+
formControlName = "emailAddress",
|
|
573
|
+
fieldLabel = "Email",
|
|
574
|
+
...props
|
|
575
|
+
}) => {
|
|
576
|
+
const {
|
|
577
|
+
creditCardFormControl,
|
|
578
|
+
error,
|
|
608
579
|
inputRef,
|
|
609
|
-
value
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
580
|
+
value
|
|
581
|
+
} = useCreditCardFormControl(formControlName, CreditCardEmailFormControl);
|
|
582
|
+
const {
|
|
583
|
+
autoComplete,
|
|
584
|
+
autoCorrect,
|
|
585
|
+
id,
|
|
586
|
+
inputMode,
|
|
587
|
+
name,
|
|
588
|
+
spellCheck,
|
|
589
|
+
...cvcProps
|
|
590
|
+
} = creditCardFormControl?.props ?? {};
|
|
591
|
+
return /* @__PURE__ */ jsx4(
|
|
592
|
+
FormControlTextField,
|
|
593
|
+
{
|
|
594
|
+
fieldLabel,
|
|
595
|
+
formControl: creditCardFormControl,
|
|
596
|
+
formControlError: error,
|
|
597
|
+
inputMode,
|
|
598
|
+
slotProps: {
|
|
599
|
+
htmlInput: {
|
|
600
|
+
"aria-label": `${fieldLabel} for your purchase`,
|
|
601
|
+
autoComplete,
|
|
602
|
+
autoCorrect,
|
|
603
|
+
id,
|
|
604
|
+
name,
|
|
605
|
+
spellCheck
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
inputRef,
|
|
609
|
+
value,
|
|
610
|
+
...cvcProps,
|
|
611
|
+
...props
|
|
612
|
+
}
|
|
613
|
+
);
|
|
614
|
+
};
|
|
614
615
|
|
|
615
616
|
// src/components/controls/card/Expiration.tsx
|
|
616
|
-
import
|
|
617
|
-
var CreditCardExpirationWithFormControl =
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
617
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
618
|
+
var CreditCardExpirationWithFormControl = ({
|
|
619
|
+
formControlName = "expiration",
|
|
620
|
+
fieldLabel = "Expiration",
|
|
621
|
+
...props
|
|
622
|
+
}) => {
|
|
623
|
+
const {
|
|
624
|
+
creditCardFormControl,
|
|
625
|
+
error,
|
|
621
626
|
inputRef,
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
627
|
+
value
|
|
628
|
+
} = useCreditCardFormControl(formControlName, CreditCardExpirationFormControl);
|
|
629
|
+
const {
|
|
630
|
+
autoComplete,
|
|
631
|
+
autoCorrect,
|
|
632
|
+
id,
|
|
625
633
|
inputMode,
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
634
|
+
name,
|
|
635
|
+
spellCheck,
|
|
636
|
+
...expirationProps
|
|
637
|
+
} = creditCardFormControl?.props ?? {};
|
|
638
|
+
return /* @__PURE__ */ jsx5(
|
|
639
|
+
FormControlTextField,
|
|
640
|
+
{
|
|
641
|
+
inputRef,
|
|
642
|
+
formControl: creditCardFormControl,
|
|
643
|
+
fieldLabel,
|
|
644
|
+
formControlError: error,
|
|
645
|
+
inputMode,
|
|
646
|
+
slotProps: {
|
|
647
|
+
htmlInput: {
|
|
648
|
+
"aria-label": `${fieldLabel} of the card`,
|
|
649
|
+
autoComplete,
|
|
650
|
+
autoCorrect,
|
|
651
|
+
id,
|
|
652
|
+
name,
|
|
653
|
+
spellCheck
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
value,
|
|
657
|
+
...expirationProps,
|
|
658
|
+
...props
|
|
659
|
+
}
|
|
660
|
+
);
|
|
661
|
+
};
|
|
641
662
|
|
|
642
663
|
// src/components/controls/card/Name.tsx
|
|
643
|
-
import
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
]);
|
|
654
|
-
const {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
fieldLabel,
|
|
658
|
-
formControl: creditCardFormControl,
|
|
659
|
-
formControlError: error,
|
|
660
|
-
inputMode,
|
|
661
|
-
slotProps: {
|
|
662
|
-
htmlInput: {
|
|
663
|
-
"aria-label": `${fieldLabel} name on your card`,
|
|
664
|
-
autoComplete,
|
|
665
|
-
autoCorrect,
|
|
666
|
-
id,
|
|
667
|
-
name,
|
|
668
|
-
spellCheck,
|
|
669
|
-
tabIndex
|
|
670
|
-
}
|
|
671
|
-
},
|
|
664
|
+
import { useMemo as useMemo3 } from "react";
|
|
665
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
666
|
+
var NameWithFormControl = ({
|
|
667
|
+
autoCompleteLabel,
|
|
668
|
+
fieldLabel = "Name",
|
|
669
|
+
formControlName,
|
|
670
|
+
placeholder,
|
|
671
|
+
tabIndex,
|
|
672
|
+
...props
|
|
673
|
+
}) => {
|
|
674
|
+
const args = useMemo3(() => [fieldLabel, autoCompleteLabel, placeholder ?? ""], [autoCompleteLabel, fieldLabel, placeholder]);
|
|
675
|
+
const {
|
|
676
|
+
creditCardFormControl,
|
|
677
|
+
error,
|
|
672
678
|
inputRef,
|
|
673
|
-
value
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
679
|
+
value
|
|
680
|
+
} = useCreditCardFormControl(formControlName, NameFormControl, args);
|
|
681
|
+
const {
|
|
682
|
+
autoComplete,
|
|
683
|
+
autoCorrect,
|
|
684
|
+
id,
|
|
685
|
+
inputMode,
|
|
686
|
+
name,
|
|
687
|
+
spellCheck,
|
|
688
|
+
...cvcProps
|
|
689
|
+
} = creditCardFormControl?.props ?? {};
|
|
690
|
+
return /* @__PURE__ */ jsx6(
|
|
691
|
+
FormControlTextField,
|
|
692
|
+
{
|
|
693
|
+
fieldLabel,
|
|
694
|
+
formControl: creditCardFormControl,
|
|
695
|
+
formControlError: error,
|
|
696
|
+
inputMode,
|
|
697
|
+
slotProps: {
|
|
698
|
+
htmlInput: {
|
|
699
|
+
"aria-label": `${fieldLabel} name on your card`,
|
|
700
|
+
autoComplete,
|
|
701
|
+
autoCorrect,
|
|
702
|
+
id,
|
|
703
|
+
name,
|
|
704
|
+
spellCheck,
|
|
705
|
+
tabIndex
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
inputRef,
|
|
709
|
+
value,
|
|
710
|
+
...cvcProps,
|
|
711
|
+
...props
|
|
712
|
+
}
|
|
713
|
+
);
|
|
714
|
+
};
|
|
678
715
|
|
|
679
716
|
// src/components/controls/card/number/Number.tsx
|
|
680
717
|
import { InputAdornment } from "@mui/material";
|
|
681
|
-
import React7 from "react";
|
|
682
718
|
|
|
683
719
|
// src/components/img/american-express.svg
|
|
684
720
|
var american_express_default = '<svg height="800px" width="800px" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" \n viewBox="0 0 512 512" xml:space="preserve">\n<path style="fill:#306FC5;" d="M512,402.281c0,16.716-13.55,30.267-30.265,30.267H30.265C13.55,432.549,0,418.997,0,402.281V109.717\n c0-16.715,13.55-30.266,30.265-30.266h451.47c16.716,0,30.265,13.551,30.265,30.266V402.281L512,402.281z"/>\n<path style="opacity:0.15;fill:#202121;enable-background:new ;" d="M21.517,402.281V109.717\n c0-16.715,13.552-30.266,30.267-30.266h-21.52C13.55,79.451,0,93.001,0,109.717v292.565c0,16.716,13.55,30.267,30.265,30.267h21.52\n C35.07,432.549,21.517,418.997,21.517,402.281z"/>\n<g>\n <polygon style="fill:#FFFFFF;" points="74.59,220.748 89.888,220.748 82.241,201.278 "/>\n <polygon style="fill:#FFFFFF;" points="155.946,286.107 155.946,295.148 181.675,295.148 181.675,304.885 155.946,304.885 \n 155.946,315.318 184.455,315.318 197.666,300.712 185.151,286.107 "/>\n <polygon style="fill:#FFFFFF;" points="356.898,201.278 348.553,220.748 364.548,220.748 "/>\n <polygon style="fill:#FFFFFF;" points="230.348,320.875 230.348,281.241 212.268,300.712 "/>\n <path style="fill:#FFFFFF;" d="M264.42,292.368c-0.696-4.172-3.48-6.261-7.654-6.261h-14.599v12.516h15.299\n C261.637,298.624,264.42,296.539,264.42,292.368z"/>\n <path style="fill:#FFFFFF;" d="M313.09,297.236c1.391-0.697,2.089-2.785,2.089-4.867c0.696-2.779-0.698-4.172-2.089-4.868\n c-1.387-0.696-3.476-0.696-5.559-0.696h-13.91v11.127h13.909C309.613,297.932,311.702,297.932,313.09,297.236z"/>\n <path style="fill:#FFFFFF;" d="M413.217,183.198v8.344l-4.169-8.344H376.37v8.344l-4.174-8.344h-44.502\n c-7.648,0-13.909,1.392-19.469,4.173v-4.173h-31.289v0.696v3.477c-3.476-2.78-7.648-4.173-13.211-4.173h-111.95l-7.652,17.384\n l-7.647-17.384h-25.031h-10.431v8.344l-3.477-8.344h-0.696H66.942l-13.909,32.68L37.042,251.34l-0.294,0.697h0.294h35.463h0.444\n l0.252-0.697l4.174-10.428h9.039l4.172,11.125h40.326v-0.697v-7.647l3.479,8.343h20.163l3.475-8.343v7.647v0.697h15.993h79.965\n h0.696v-18.08h1.394c1.389,0,1.389,0,1.389,2.087v15.297h50.065v-4.172c4.172,2.089,10.426,4.172,18.771,4.172h20.863l4.172-11.123\n h9.732l4.172,11.123h40.328v-6.952v-3.476l6.261,10.428h1.387h0.698h30.595v-68.143h-31.291l0,0H413.217z M177.501,241.609h-6.955\n h-4.171v-4.169v-34.076l-0.696,1.595v-0.019l-16.176,36.669h-0.512h-3.719h-6.017l-16.687-38.245v38.245h-23.64l-4.867-10.43\n H70.417l-4.868,10.43H53.326l20.57-48.675h17.382l19.469,46.587v-46.587h4.171h14.251l0.328,0.697h0.024l8.773,19.094l6.3,14.306\n l0.223-0.721l13.906-33.375H177.5v48.674H177.501L177.501,241.609z M225.481,203.364h-27.119v9.039h26.423v9.734h-26.423v9.738\n h27.119v10.427h-38.939v-49.367h38.939V203.364L225.481,203.364z M275.076,221.294c0.018,0.016,0.041,0.027,0.063,0.042\n c0.263,0.278,0.488,0.557,0.68,0.824c1.332,1.746,2.409,4.343,2.463,8.151c0.004,0.066,0.007,0.131,0.011,0.197\n c0,0.038,0.007,0.071,0.007,0.11c0,0.022-0.002,0.039-0.002,0.06c0.016,0.383,0.026,0.774,0.026,1.197v9.735h-10.428v-5.565\n c0-2.781,0-6.954-2.089-9.735c-0.657-0.657-1.322-1.09-2.046-1.398c-1.042-0.675-3.017-0.686-6.295-0.686h-12.52v17.384h-11.818\n v-48.675h26.425c6.254,0,10.428,0,13.906,2.086c3.407,2.046,5.465,5.439,5.543,10.812c-0.161,7.4-4.911,11.46-8.326,12.829\n C270.676,218.662,272.996,219.129,275.076,221.294z M298.491,241.609h-11.822v-48.675h11.822V241.609z M434.083,241.609h-15.3\n l-22.25-36.855v30.595l-0.073-0.072v6.362h-11.747v-0.029h-11.822l-4.172-10.43H344.38l-4.172,11.123h-13.211\n c-5.559,0-12.517-1.389-16.687-5.561c-4.172-4.172-6.256-9.735-6.256-18.773c0-6.953,1.389-13.911,6.256-19.472\n c3.474-4.175,9.735-5.562,17.382-5.562h11.128v10.429h-11.128c-4.172,0-6.254,0.693-9.041,2.783\n c-2.082,2.085-3.474,6.256-3.474,11.123c0,5.564,0.696,9.04,3.474,11.821c2.091,2.089,4.87,2.785,8.346,2.785h4.867l15.991-38.243\n h6.957h10.428l19.472,46.587v-2.376v-15.705v-1.389v-27.116h17.382l20.161,34.07v-34.07h11.826v47.977h0.002L434.083,241.609\n L434.083,241.609z"/>\n <path style="fill:#FFFFFF;" d="M265.161,213.207c0.203-0.217,0.387-0.463,0.543-0.745c0.63-0.997,1.352-2.793,0.963-5.244\n c-0.016-0.225-0.057-0.433-0.105-0.634c-0.013-0.056-0.011-0.105-0.026-0.161l-0.007,0.001c-0.346-1.191-1.229-1.923-2.11-2.367\n c-1.394-0.693-3.48-0.693-5.565-0.693h-13.909v11.127h13.909c2.085,0,4.172,0,5.565-0.697c0.209-0.106,0.395-0.25,0.574-0.413\n l0.002,0.009C264.996,213.389,265.067,213.315,265.161,213.207z"/>\n <path style="fill:#FFFFFF;" d="M475.105,311.144c0-4.867-1.389-9.736-3.474-13.212v-31.289h-0.032v-2.089c0,0-29.145,0-33.483,0\n c-4.336,0-9.598,4.171-9.598,4.171v-4.171h-31.984c-4.87,0-11.124,1.392-13.909,4.171v-4.171h-57.016v2.089v2.081\n c-4.169-3.474-11.824-4.171-15.298-4.171h-37.549v2.089v2.081c-3.476-3.474-11.824-4.171-15.998-4.171H215.05l-9.737,10.431\n l-9.04-10.431h-2.911h-4.737h-54.93v2.089v5.493v62.651h61.19l10.054-10.057l8.715,10.057h0.698h35.258h1.598h0.696h0.692v-6.953\n v-9.039h3.479c4.863,0,11.124,0,15.991-2.089v17.382v1.394h31.291v-1.394V317.4h1.387c2.089,0,2.089,0,2.089,2.086v14.6v1.394\n h94.563c6.263,0,12.517-1.394,15.993-4.175v2.781v1.394h29.902c6.254,0,12.517-0.695,16.689-3.478\n c6.402-3.841,10.437-10.64,11.037-18.749c0.028-0.24,0.063-0.48,0.085-0.721l-0.041-0.039\n C475.087,312.043,475.105,311.598,475.105,311.144z M256.076,306.973h-13.91v2.081v4.174v4.173v7.649h-22.855l-13.302-15.299\n l-0.046,0.051l-0.65-0.748l-15.297,15.996h-44.501v-48.673h45.197l12.348,13.525l2.596,2.832l0.352-0.365l14.604-15.991h36.852\n c7.152,0,15.161,1.765,18.196,9.042c0.365,1.441,0.577,3.043,0.577,4.863C276.237,304.189,266.502,306.973,256.076,306.973z\n M325.609,306.276c1.389,2.081,2.085,4.867,2.085,9.041v9.732h-11.819v-6.256c0-2.786,0-7.65-2.089-9.739\n c-1.387-2.081-4.172-2.081-8.341-2.081H292.93v18.077h-11.82v-49.369h26.421c5.559,0,10.426,0,13.909,2.084\n c3.474,2.088,6.254,5.565,6.254,11.128c0,7.647-4.865,11.819-8.343,13.212C322.829,303.49,324.914,304.885,325.609,306.276z\n M373.589,286.107h-27.122v9.04h26.424v9.737h-26.424v9.736h27.122v10.429H334.65V275.68h38.939V286.107z M402.791,325.05h-22.252\n v-10.429h22.252c2.082,0,3.476,0,4.87-1.392c0.696-0.697,1.387-2.085,1.387-3.477c0-1.394-0.691-2.778-1.387-3.475\n c-0.698-0.695-2.091-1.391-4.176-1.391c-11.126-0.696-24.337,0-24.337-15.296c0-6.954,4.172-14.604,16.689-14.604h22.945v11.819\n h-21.554c-2.085,0-3.478,0-4.87,0.696c-1.387,0.697-1.387,2.089-1.387,3.478c0,2.087,1.387,2.783,2.778,3.473\n c1.394,0.697,2.783,0.697,4.172,0.697h6.259c6.259,0,10.43,1.391,13.211,4.173c2.087,2.087,3.478,5.564,3.478,10.43\n C420.869,320.179,414.611,325.05,402.791,325.05z M462.59,320.179c-2.778,2.785-7.648,4.871-14.604,4.871H425.74v-10.429h22.245\n c2.087,0,3.481,0,4.87-1.392c0.693-0.697,1.391-2.085,1.391-3.477c0-1.394-0.698-2.778-1.391-3.475\n c-0.696-0.695-2.085-1.391-4.172-1.391c-11.122-0.696-24.337,0-24.337-15.295c0-6.609,3.781-12.579,13.106-14.352\n c1.115-0.154,2.293-0.253,3.583-0.253h22.948v11.819h-15.3h-5.561h-0.696c-2.087,0-3.476,0-4.865,0.696\n c-0.7,0.697-1.396,2.089-1.396,3.478c0,2.087,0.696,2.783,2.785,3.473c1.389,0.697,2.78,0.697,4.172,0.697h0.691h5.565\n c3.039,0,5.337,0.375,7.44,1.114c1.926,0.697,8.302,3.549,9.728,10.994c0.124,0.78,0.215,1.594,0.215,2.495\n C466.761,313.925,465.37,317.401,462.59,320.179z"/>\n</g>\n</svg>';
|
|
@@ -694,28 +730,21 @@ var visa_default = '<svg width="800px" height="800px" viewBox="0 -140 780 780" e
|
|
|
694
730
|
|
|
695
731
|
// src/components/controls/card/Options.ts
|
|
696
732
|
var CreditCardData = {
|
|
697
|
-
amex: {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
}
|
|
701
|
-
discover: {
|
|
702
|
-
icon: discover_default,
|
|
703
|
-
name: "Discover"
|
|
704
|
-
},
|
|
705
|
-
mastercard: {
|
|
706
|
-
icon: mastercard_default,
|
|
707
|
-
name: "Mastercard"
|
|
708
|
-
},
|
|
709
|
-
visa: {
|
|
710
|
-
icon: visa_default,
|
|
711
|
-
name: "Visa"
|
|
712
|
-
}
|
|
733
|
+
amex: { icon: american_express_default, name: "American Express" },
|
|
734
|
+
discover: { icon: discover_default, name: "Discover" },
|
|
735
|
+
mastercard: { icon: mastercard_default, name: "Mastercard" },
|
|
736
|
+
visa: { icon: visa_default, name: "Visa" }
|
|
713
737
|
};
|
|
714
738
|
|
|
715
739
|
// src/components/controls/card/number/use.ts
|
|
716
740
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
717
|
-
var useCreditCardNumberFormControl =
|
|
718
|
-
const {
|
|
741
|
+
var useCreditCardNumberFormControl = (formControlName, control) => {
|
|
742
|
+
const {
|
|
743
|
+
creditCardFormControl,
|
|
744
|
+
error,
|
|
745
|
+
inputRef,
|
|
746
|
+
value
|
|
747
|
+
} = useCreditCardFormControl(formControlName, control);
|
|
719
748
|
const [type, setType] = useState2("");
|
|
720
749
|
useEffect2(() => {
|
|
721
750
|
if (creditCardFormControl) {
|
|
@@ -724,17 +753,16 @@ var useCreditCardNumberFormControl = /* @__PURE__ */ __name((formControlName, co
|
|
|
724
753
|
console.error("cannot set onCreditCardTypeChange on control because it is not a CreditCardNumberFormControl");
|
|
725
754
|
return;
|
|
726
755
|
}
|
|
727
|
-
castControl
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
inputRef.current
|
|
756
|
+
Object.assign(castControl, { onCreditCardTypeChange: (type2) => setType(type2) });
|
|
757
|
+
Object.assign(castControl, {
|
|
758
|
+
onCursorChange: (cursor) => {
|
|
759
|
+
if (inputRef.current && cursor) {
|
|
760
|
+
inputRef.current.setSelectionRange(cursor, cursor);
|
|
761
|
+
}
|
|
731
762
|
}
|
|
732
|
-
};
|
|
763
|
+
});
|
|
733
764
|
}
|
|
734
|
-
}, [
|
|
735
|
-
creditCardFormControl,
|
|
736
|
-
inputRef
|
|
737
|
-
]);
|
|
765
|
+
}, [creditCardFormControl, inputRef]);
|
|
738
766
|
return {
|
|
739
767
|
creditCardFormControl,
|
|
740
768
|
error,
|
|
@@ -742,84 +770,114 @@ var useCreditCardNumberFormControl = /* @__PURE__ */ __name((formControlName, co
|
|
|
742
770
|
type,
|
|
743
771
|
value
|
|
744
772
|
};
|
|
745
|
-
}
|
|
773
|
+
};
|
|
746
774
|
|
|
747
775
|
// src/components/controls/card/number/Number.tsx
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
776
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
777
|
+
var CreditCardNumberWithFormControl = ({
|
|
778
|
+
fieldLabel = "Card Number",
|
|
779
|
+
formControlName = "cardNumber",
|
|
780
|
+
...props
|
|
781
|
+
}) => {
|
|
782
|
+
const {
|
|
783
|
+
creditCardFormControl,
|
|
784
|
+
error,
|
|
755
785
|
inputRef,
|
|
786
|
+
type,
|
|
787
|
+
value
|
|
788
|
+
} = useCreditCardNumberFormControl(formControlName, CreditCardNumberFormControl);
|
|
789
|
+
const {
|
|
790
|
+
autoComplete,
|
|
791
|
+
autoCorrect,
|
|
792
|
+
id,
|
|
756
793
|
inputMode,
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
794
|
+
name,
|
|
795
|
+
spellCheck,
|
|
796
|
+
...cardProps
|
|
797
|
+
} = creditCardFormControl?.props ?? {};
|
|
798
|
+
return /* @__PURE__ */ jsx7(
|
|
799
|
+
FormControlTextField,
|
|
800
|
+
{
|
|
801
|
+
fieldLabel,
|
|
802
|
+
formControl: creditCardFormControl,
|
|
803
|
+
formControlError: error,
|
|
804
|
+
inputRef,
|
|
805
|
+
inputMode,
|
|
806
|
+
slotProps: {
|
|
807
|
+
htmlInput: {
|
|
808
|
+
"aria-label": fieldLabel,
|
|
809
|
+
autoComplete,
|
|
810
|
+
autoCorrect,
|
|
811
|
+
id,
|
|
812
|
+
inputMode,
|
|
813
|
+
name,
|
|
814
|
+
spellCheck
|
|
815
|
+
},
|
|
816
|
+
input: {
|
|
817
|
+
startAdornment: type.length > 0 ? /* @__PURE__ */ jsx7(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx7("img", { height: "30px", width: "40px", src: CreditCardData[type].icon }) }) : null
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
value,
|
|
821
|
+
...cardProps,
|
|
822
|
+
...props
|
|
823
|
+
}
|
|
824
|
+
);
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
// src/components/controls/card/Zip.tsx
|
|
828
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
829
|
+
var CreditCardZipWithFormControl = ({
|
|
830
|
+
formControlName = "zip",
|
|
831
|
+
fieldLabel = "Zip",
|
|
832
|
+
...props
|
|
833
|
+
}) => {
|
|
834
|
+
const {
|
|
835
|
+
creditCardFormControl,
|
|
836
|
+
error,
|
|
837
|
+
inputRef,
|
|
838
|
+
value
|
|
839
|
+
} = useCreditCardFormControl(formControlName, CreditCardZipFormControl);
|
|
840
|
+
const {
|
|
841
|
+
autoComplete,
|
|
842
|
+
autoCorrect,
|
|
843
|
+
id,
|
|
844
|
+
inputMode,
|
|
845
|
+
name,
|
|
846
|
+
spellCheck,
|
|
847
|
+
...cvcProps
|
|
848
|
+
} = creditCardFormControl?.props ?? {};
|
|
849
|
+
return /* @__PURE__ */ jsx8(
|
|
850
|
+
FormControlTextField,
|
|
851
|
+
{
|
|
852
|
+
fieldLabel,
|
|
853
|
+
formControl: creditCardFormControl,
|
|
854
|
+
formControlError: error,
|
|
855
|
+
inputMode,
|
|
856
|
+
inputProps: {
|
|
857
|
+
"aria-label": `${fieldLabel} code for your card`,
|
|
760
858
|
autoComplete,
|
|
761
859
|
autoCorrect,
|
|
762
860
|
id,
|
|
763
|
-
inputMode,
|
|
764
861
|
name,
|
|
765
862
|
spellCheck
|
|
766
863
|
},
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
})) : null
|
|
775
|
-
}
|
|
776
|
-
},
|
|
777
|
-
value,
|
|
778
|
-
...cardProps,
|
|
779
|
-
...props
|
|
780
|
-
});
|
|
781
|
-
}, "CreditCardNumberWithFormControl");
|
|
782
|
-
|
|
783
|
-
// src/components/controls/card/Zip.tsx
|
|
784
|
-
import React8 from "react";
|
|
785
|
-
var CreditCardZipWithFormControl = /* @__PURE__ */ __name(({ formControlName = "zip", fieldLabel = "Zip", ...props }) => {
|
|
786
|
-
const { creditCardFormControl, error, inputRef, value } = useCreditCardFormControl(formControlName, CreditCardZipFormControl);
|
|
787
|
-
const { autoComplete, autoCorrect, id, inputMode, name, spellCheck, ...cvcProps } = creditCardFormControl?.props ?? {};
|
|
788
|
-
return /* @__PURE__ */ React8.createElement(FormControlTextField, {
|
|
789
|
-
fieldLabel,
|
|
790
|
-
formControl: creditCardFormControl,
|
|
791
|
-
formControlError: error,
|
|
792
|
-
inputMode,
|
|
793
|
-
inputProps: {
|
|
794
|
-
"aria-label": `${fieldLabel} code for your card`,
|
|
795
|
-
autoComplete,
|
|
796
|
-
autoCorrect,
|
|
797
|
-
id,
|
|
798
|
-
name,
|
|
799
|
-
spellCheck
|
|
800
|
-
},
|
|
801
|
-
inputRef,
|
|
802
|
-
value,
|
|
803
|
-
...cvcProps,
|
|
804
|
-
...props
|
|
805
|
-
});
|
|
806
|
-
}, "CreditCardZipWithFormControl");
|
|
864
|
+
inputRef,
|
|
865
|
+
value,
|
|
866
|
+
...cvcProps,
|
|
867
|
+
...props
|
|
868
|
+
}
|
|
869
|
+
);
|
|
870
|
+
};
|
|
807
871
|
|
|
808
872
|
// src/components/form/Form.tsx
|
|
809
873
|
import { Stack as Stack2 } from "@mui/material";
|
|
810
874
|
import { ErrorRender } from "@xylabs/react-error";
|
|
811
875
|
import { FlexCol } from "@xylabs/react-flexbox";
|
|
812
|
-
import
|
|
876
|
+
import { useState as useState3 } from "react";
|
|
813
877
|
|
|
814
878
|
// src/components/support/Fields.ts
|
|
815
|
-
var NameFields = [
|
|
816
|
-
|
|
817
|
-
"lastName"
|
|
818
|
-
];
|
|
819
|
-
var NameLabels = [
|
|
820
|
-
"First",
|
|
821
|
-
"Last"
|
|
822
|
-
];
|
|
879
|
+
var NameFields = ["firstName", "lastName"];
|
|
880
|
+
var NameLabels = ["First", "Last"];
|
|
823
881
|
|
|
824
882
|
// src/components/support/validateCreditCardInputs.ts
|
|
825
883
|
import { assertEx as assertEx3 } from "@xylabs/sdk-js";
|
|
@@ -830,7 +888,7 @@ var CreditCardInputSchema = asSchema("network.xyo.credit.card.input", true);
|
|
|
830
888
|
var isCreditCardInput = isPayloadOfSchemaType(CreditCardInputSchema);
|
|
831
889
|
|
|
832
890
|
// src/components/support/validateCreditCardInputs.ts
|
|
833
|
-
var validateCreditCardInputs =
|
|
891
|
+
var validateCreditCardInputs = (values) => {
|
|
834
892
|
return {
|
|
835
893
|
cardNumber: assertEx3(values.cardNumber, () => "card number is not a string"),
|
|
836
894
|
cvc: assertEx3(values.cvc, () => "card cvc is not a string"),
|
|
@@ -842,92 +900,84 @@ var validateCreditCardInputs = /* @__PURE__ */ __name((values) => {
|
|
|
842
900
|
timestamp: values.timestamp,
|
|
843
901
|
zip: assertEx3(values.zip, () => "zip is not a string")
|
|
844
902
|
};
|
|
845
|
-
}
|
|
903
|
+
};
|
|
846
904
|
|
|
847
905
|
// src/components/form/InputFieldsStack.tsx
|
|
848
906
|
import { Stack } from "@mui/material";
|
|
849
|
-
import
|
|
850
|
-
var InputFieldsStack =
|
|
907
|
+
import { Fragment, jsx as jsx9, jsxs } from "react/jsx-runtime";
|
|
908
|
+
var InputFieldsStack = (props) => {
|
|
851
909
|
const { sx } = props;
|
|
852
|
-
return /* @__PURE__ */
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
}, /* @__PURE__ */ React9.createElement(CreditCardZipWithFormControl, null)), /* @__PURE__ */ React9.createElement(Stack, {
|
|
913
|
-
width: {
|
|
914
|
-
md: "75%",
|
|
915
|
-
xs: "100%"
|
|
916
|
-
}
|
|
917
|
-
}, /* @__PURE__ */ React9.createElement(CreditCardEmailWithFormControl, null))));
|
|
918
|
-
}, "InputFieldsStack");
|
|
910
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
911
|
+
/* @__PURE__ */ jsxs(
|
|
912
|
+
Stack,
|
|
913
|
+
{
|
|
914
|
+
gap: 2,
|
|
915
|
+
sx: {
|
|
916
|
+
flexDirection: { md: "row", xs: "column" },
|
|
917
|
+
...sx
|
|
918
|
+
},
|
|
919
|
+
...props,
|
|
920
|
+
children: [
|
|
921
|
+
/* @__PURE__ */ jsx9(NameWithFormControl, { autoCompleteLabel: "given-name", fieldLabel: "First", formControlName: "firstName", placeholder: "Jerry" }),
|
|
922
|
+
/* @__PURE__ */ jsx9(NameWithFormControl, { autoCompleteLabel: "family-name", fieldLabel: "Last", formControlName: "lastName", placeholder: "Smith" })
|
|
923
|
+
]
|
|
924
|
+
}
|
|
925
|
+
),
|
|
926
|
+
/* @__PURE__ */ jsxs(
|
|
927
|
+
Stack,
|
|
928
|
+
{
|
|
929
|
+
gap: 2,
|
|
930
|
+
sx: {
|
|
931
|
+
flexDirection: { lg: "row", xs: "column" },
|
|
932
|
+
...sx
|
|
933
|
+
},
|
|
934
|
+
...props,
|
|
935
|
+
children: [
|
|
936
|
+
/* @__PURE__ */ jsx9(Stack, { width: { lg: "50%", xs: "100%" }, children: /* @__PURE__ */ jsx9(CreditCardNumberWithFormControl, {}) }),
|
|
937
|
+
/* @__PURE__ */ jsxs(
|
|
938
|
+
Stack,
|
|
939
|
+
{
|
|
940
|
+
direction: { lg: "row", xs: "column" },
|
|
941
|
+
gap: 2,
|
|
942
|
+
width: { lg: "50%", xs: "100%" },
|
|
943
|
+
children: [
|
|
944
|
+
/* @__PURE__ */ jsx9(CreditCardCvvWithFormControl, {}),
|
|
945
|
+
/* @__PURE__ */ jsx9(CreditCardExpirationWithFormControl, {})
|
|
946
|
+
]
|
|
947
|
+
}
|
|
948
|
+
)
|
|
949
|
+
]
|
|
950
|
+
}
|
|
951
|
+
),
|
|
952
|
+
/* @__PURE__ */ jsxs(
|
|
953
|
+
Stack,
|
|
954
|
+
{
|
|
955
|
+
gap: 2,
|
|
956
|
+
sx: {
|
|
957
|
+
flexDirection: { md: "row", xs: "column" },
|
|
958
|
+
...sx
|
|
959
|
+
},
|
|
960
|
+
...props,
|
|
961
|
+
children: [
|
|
962
|
+
/* @__PURE__ */ jsx9(Stack, { width: { md: "25%", xs: "100%" }, children: /* @__PURE__ */ jsx9(CreditCardZipWithFormControl, {}) }),
|
|
963
|
+
/* @__PURE__ */ jsx9(Stack, { width: { md: "75%", xs: "100%" }, children: /* @__PURE__ */ jsx9(CreditCardEmailWithFormControl, {}) })
|
|
964
|
+
]
|
|
965
|
+
}
|
|
966
|
+
)
|
|
967
|
+
] });
|
|
968
|
+
};
|
|
919
969
|
|
|
920
970
|
// src/components/form/useFormStorage.tsx
|
|
921
971
|
import { usePromise } from "@xylabs/react-promise";
|
|
922
972
|
import { StorageArchivist, StorageArchivistConfigSchema } from "@xyo-network/archivist-storage";
|
|
923
973
|
import { ArchivistFormGroupStorage } from "@xyo-network/react-form-group";
|
|
924
974
|
var STORAGE_NAME_SPACE = "credit-card-fields";
|
|
925
|
-
var calculateTTL =
|
|
975
|
+
var calculateTTL = (months = 6) => {
|
|
926
976
|
const MS_PER_DAY = 24 * 60 * 60 * 1e3;
|
|
927
977
|
const DAYS_PER_MONTH = 30.44;
|
|
928
978
|
return months * DAYS_PER_MONTH * MS_PER_DAY;
|
|
929
|
-
}
|
|
930
|
-
var useFormStorage =
|
|
979
|
+
};
|
|
980
|
+
var useFormStorage = () => {
|
|
931
981
|
return usePromise(async () => {
|
|
932
982
|
const localStorageArchivist = await StorageArchivist.create({
|
|
933
983
|
account: "random",
|
|
@@ -955,13 +1005,22 @@ var useFormStorage = /* @__PURE__ */ __name(() => {
|
|
|
955
1005
|
ttlStorage: calculateTTL()
|
|
956
1006
|
};
|
|
957
1007
|
}, []);
|
|
958
|
-
}
|
|
1008
|
+
};
|
|
959
1009
|
|
|
960
1010
|
// src/components/form/Form.tsx
|
|
961
|
-
|
|
1011
|
+
import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1012
|
+
var CreditCardFormFlexbox = ({
|
|
1013
|
+
ConfirmationButton,
|
|
1014
|
+
displayErrors,
|
|
1015
|
+
onErrorDuringSubmit,
|
|
1016
|
+
onInvalidSubmit,
|
|
1017
|
+
onSuccessfulSubmit,
|
|
1018
|
+
onValidSubmit,
|
|
1019
|
+
...props
|
|
1020
|
+
}) => {
|
|
962
1021
|
const { formGroup } = useFormGroupWithCreditCardInput(true);
|
|
963
1022
|
const [error, setError] = useState3();
|
|
964
|
-
const handleConfirmPayment =
|
|
1023
|
+
const handleConfirmPayment = async () => {
|
|
965
1024
|
try {
|
|
966
1025
|
if (!formGroup) {
|
|
967
1026
|
throw new Error("formGroup is not defined");
|
|
@@ -979,41 +1038,31 @@ var CreditCardFormFlexbox = /* @__PURE__ */ __name(({ ConfirmationButton, displa
|
|
|
979
1038
|
onErrorDuringSubmit?.(error2);
|
|
980
1039
|
if (displayErrors) setError(error2);
|
|
981
1040
|
}
|
|
982
|
-
}
|
|
983
|
-
return /* @__PURE__ */
|
|
984
|
-
error
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
md: "row",
|
|
989
|
-
|
|
1041
|
+
};
|
|
1042
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
1043
|
+
/* @__PURE__ */ jsx10(ErrorRender, { error }),
|
|
1044
|
+
/* @__PURE__ */ jsx10(
|
|
1045
|
+
FlexCol,
|
|
1046
|
+
{
|
|
1047
|
+
sx: { flexDirection: { md: "row", xs: "column" } },
|
|
1048
|
+
width: "100%",
|
|
1049
|
+
gap: 2,
|
|
1050
|
+
...props,
|
|
1051
|
+
children: /* @__PURE__ */ jsxs2(Stack2, { flexDirection: "column", sx: { width: "100%" }, gap: 2, children: [
|
|
1052
|
+
/* @__PURE__ */ jsx10(InputFieldsStack, {}),
|
|
1053
|
+
ConfirmationButton ? /* @__PURE__ */ jsx10(ConfirmationButton, { onClick: handleConfirmPayment, variant: "contained", sx: { alignSelf: "end" }, children: "Confirm Payment" }) : null
|
|
1054
|
+
] })
|
|
990
1055
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
}, /* @__PURE__ */ React10.createElement(Stack2, {
|
|
996
|
-
flexDirection: "column",
|
|
997
|
-
sx: {
|
|
998
|
-
width: "100%"
|
|
999
|
-
},
|
|
1000
|
-
gap: 2
|
|
1001
|
-
}, /* @__PURE__ */ React10.createElement(InputFieldsStack, null), ConfirmationButton ? /* @__PURE__ */ React10.createElement(ConfirmationButton, {
|
|
1002
|
-
onClick: handleConfirmPayment,
|
|
1003
|
-
variant: "contained",
|
|
1004
|
-
sx: {
|
|
1005
|
-
alignSelf: "end"
|
|
1006
|
-
}
|
|
1007
|
-
}, "Confirm Payment") : null)));
|
|
1008
|
-
}, "CreditCardFormFlexbox");
|
|
1009
|
-
var CreditCardFormFlexboxWithFormGroupProvider = /* @__PURE__ */ __name((props) => {
|
|
1056
|
+
)
|
|
1057
|
+
] });
|
|
1058
|
+
};
|
|
1059
|
+
var CreditCardFormFlexboxWithFormGroupProvider = (props) => {
|
|
1010
1060
|
const [params, error] = useFormStorage();
|
|
1011
|
-
return /* @__PURE__ */
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
}, "CreditCardFormFlexboxWithFormGroupProvider");
|
|
1061
|
+
return /* @__PURE__ */ jsxs2(FormGroupCreditCardProvider, { params, children: [
|
|
1062
|
+
/* @__PURE__ */ jsx10(ErrorRender, { error }),
|
|
1063
|
+
/* @__PURE__ */ jsx10(CreditCardFormFlexbox, { ...props })
|
|
1064
|
+
] });
|
|
1065
|
+
};
|
|
1017
1066
|
export {
|
|
1018
1067
|
CreditCardCvvFormControl,
|
|
1019
1068
|
CreditCardCvvWithFormControl,
|