@xyo-network/react-form-credit-card 7.0.0 → 7.0.1
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/controls/Name.d.ts +1 -1
- package/dist/browser/controls/Name.d.ts.map +1 -1
- package/dist/browser/index.mjs +470 -422
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/stories/form.stories.d.ts +2 -2
- package/dist/browser/stories/form.stories.d.ts.map +1 -1
- package/package.json +29 -26
- package/src/controls/Name.ts +4 -1
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/assert";
|
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,18 +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
|
-
nameLabel;
|
347
309
|
required = true;
|
310
|
+
nameLabel;
|
348
311
|
constructor(nameLabel, autoCompleteLabel, placeHolder) {
|
349
|
-
super()
|
312
|
+
super();
|
313
|
+
this.nameLabel = nameLabel;
|
350
314
|
super.setName(nameLabel);
|
351
|
-
this.setSerializeSettings({
|
352
|
-
sensitive: false,
|
353
|
-
serializable: true
|
354
|
-
});
|
315
|
+
this.setSerializeSettings({ sensitive: false, serializable: true });
|
355
316
|
this.invalidMessage = `${nameLabel} name is missing.`;
|
356
317
|
this.props = {
|
357
318
|
autoComplete: autoCompleteLabel,
|
@@ -379,9 +340,6 @@ import { FormControlBase as FormControlBase6 } from "@xyo-network/react-form-gro
|
|
379
340
|
import valid4 from "card-validator";
|
380
341
|
var CONTROL_NAME5 = "Zip";
|
381
342
|
var CreditCardZipFormControl = class extends FormControlBase6 {
|
382
|
-
static {
|
383
|
-
__name(this, "CreditCardZipFormControl");
|
384
|
-
}
|
385
343
|
invalidMessage = "Your zip code is invalid.";
|
386
344
|
props = {
|
387
345
|
autoComplete: "postal-code",
|
@@ -396,10 +354,7 @@ var CreditCardZipFormControl = class extends FormControlBase6 {
|
|
396
354
|
constructor() {
|
397
355
|
super();
|
398
356
|
super.setName(CONTROL_NAME5);
|
399
|
-
this.setSerializeSettings({
|
400
|
-
sensitive: true,
|
401
|
-
serializable: true
|
402
|
-
});
|
357
|
+
this.setSerializeSettings({ sensitive: true, serializable: true });
|
403
358
|
}
|
404
359
|
blurError(value) {
|
405
360
|
const postalCodeValidation = valid4.postalCode(value);
|
@@ -428,43 +383,46 @@ var CreditCardZipFormControl = class extends FormControlBase6 {
|
|
428
383
|
// src/components/controls/card/FormControlTextField.tsx
|
429
384
|
import { FormControl as MuiFormControl, TextField } from "@mui/material";
|
430
385
|
import { LabeledTextFieldWrapper } from "@xyo-network/react-shared";
|
431
|
-
import
|
432
|
-
var FormControlTextField =
|
386
|
+
import { jsx } from "react/jsx-runtime";
|
387
|
+
var FormControlTextField = ({
|
388
|
+
ref,
|
389
|
+
formControl,
|
390
|
+
formControlError,
|
391
|
+
fieldLabel = "",
|
392
|
+
...props
|
393
|
+
}) => {
|
433
394
|
const { name } = formControl?.props ?? {};
|
434
|
-
const handleChange =
|
395
|
+
const handleChange = (event) => {
|
435
396
|
formControl?.setValue(event.target.value);
|
436
|
-
}
|
437
|
-
const handleBlur =
|
397
|
+
};
|
398
|
+
const handleBlur = (event) => {
|
438
399
|
formControl?.blurError?.(event.target.value);
|
439
400
|
formControl?.setTouched(true);
|
440
|
-
}
|
441
|
-
return /* @__PURE__ */
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
...props
|
466
|
-
}))));
|
467
|
-
}, "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.previous = selectionEnd;
|
416
|
+
}
|
417
|
+
},
|
418
|
+
ref,
|
419
|
+
required: formControl?.required,
|
420
|
+
size: "small",
|
421
|
+
variant: "filled",
|
422
|
+
...props
|
423
|
+
}
|
424
|
+
) }) }) });
|
425
|
+
};
|
468
426
|
FormControlTextField.displayName = "FormControlTextField";
|
469
427
|
|
470
428
|
// src/components/controls/card/cvv/use.ts
|
@@ -476,36 +434,42 @@ var FormGroupCreditCardContext = createContextEx();
|
|
476
434
|
|
477
435
|
// src/context/FormGroupCreditCardProvider.tsx
|
478
436
|
import { FormGroup } from "@xyo-network/react-form-group";
|
479
|
-
import
|
480
|
-
|
437
|
+
import { useMemo } from "react";
|
438
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
439
|
+
var FormGroupCreditCardProvider = ({
|
440
|
+
children,
|
441
|
+
params,
|
442
|
+
...props
|
443
|
+
}) => {
|
481
444
|
const formGroup = useMemo(() => {
|
482
445
|
const formGroup2 = new FormGroup(params);
|
483
446
|
return formGroup2;
|
484
|
-
}, [
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
...props
|
496
|
-
}, children);
|
497
|
-
}, "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
|
+
};
|
498
458
|
|
499
459
|
// src/context/useFormGroupWithCreditCard.tsx
|
500
460
|
import { useContextEx } from "@xylabs/react-shared";
|
501
|
-
var useFormGroupWithCreditCardInput =
|
461
|
+
var useFormGroupWithCreditCardInput = (required = false) => {
|
502
462
|
return useContextEx(FormGroupCreditCardContext, "FormGroupCreditCard", required);
|
503
|
-
}
|
463
|
+
};
|
504
464
|
|
505
465
|
// src/components/controls/card/useCreditCardFormControl.tsx
|
506
|
-
import {
|
466
|
+
import {
|
467
|
+
useMemo as useMemo2,
|
468
|
+
useRef,
|
469
|
+
useState
|
470
|
+
} from "react";
|
507
471
|
var STABLE_DEFAULT_ARGS = [];
|
508
|
-
var useCreditCardFormControl =
|
472
|
+
var useCreditCardFormControl = (formControlName, Control, args = STABLE_DEFAULT_ARGS) => {
|
509
473
|
const [error, setError] = useState("");
|
510
474
|
const [value, setValue] = useState("");
|
511
475
|
const inputRef = useRef(null);
|
@@ -518,23 +482,23 @@ var useCreditCardFormControl = /* @__PURE__ */ __name((formControlName, Control,
|
|
518
482
|
if (formControlName) formGroup?.registerControl(formControlName, control);
|
519
483
|
return control;
|
520
484
|
}
|
521
|
-
}, [
|
522
|
-
Control,
|
523
|
-
args,
|
524
|
-
formControlName,
|
525
|
-
formGroup
|
526
|
-
]);
|
485
|
+
}, [Control, args, formControlName, formGroup]);
|
527
486
|
return {
|
528
487
|
creditCardFormControl,
|
529
488
|
error,
|
530
489
|
inputRef,
|
531
490
|
value
|
532
491
|
};
|
533
|
-
}
|
492
|
+
};
|
534
493
|
|
535
494
|
// src/components/controls/card/cvv/use.ts
|
536
|
-
var useCreditCardCvvFormControl =
|
537
|
-
const {
|
495
|
+
var useCreditCardCvvFormControl = (formControlName, cardNumberControlName = "cardNumber", control) => {
|
496
|
+
const {
|
497
|
+
creditCardFormControl,
|
498
|
+
error,
|
499
|
+
value,
|
500
|
+
inputRef
|
501
|
+
} = useCreditCardFormControl(formControlName, control);
|
538
502
|
const { formGroup } = useFormGroupWithCreditCardInput(!!formControlName);
|
539
503
|
const creditCardNumberFormControl = formGroup?.getControl?.(cardNumberControlName);
|
540
504
|
useEffect(() => {
|
@@ -546,138 +510,211 @@ var useCreditCardCvvFormControl = /* @__PURE__ */ __name((formControlName, cardN
|
|
546
510
|
}
|
547
511
|
castControl.setCardNumberFormControl(creditCardNumberFormControl);
|
548
512
|
}
|
549
|
-
}, [
|
550
|
-
creditCardFormControl,
|
551
|
-
creditCardNumberFormControl
|
552
|
-
]);
|
513
|
+
}, [creditCardFormControl, creditCardNumberFormControl]);
|
553
514
|
return {
|
554
515
|
creditCardFormControl,
|
555
516
|
error,
|
556
517
|
inputRef,
|
557
518
|
value
|
558
519
|
};
|
559
|
-
}
|
520
|
+
};
|
560
521
|
|
561
522
|
// src/components/controls/card/cvv/Cvv.tsx
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
htmlInput: {
|
572
|
-
"aria-label": `${fieldLabel} number on the back of your card`,
|
573
|
-
autoComplete,
|
574
|
-
autoCorrect,
|
575
|
-
id,
|
576
|
-
name,
|
577
|
-
spellCheck
|
578
|
-
}
|
579
|
-
},
|
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,
|
580
532
|
inputRef,
|
581
|
-
value
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
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
|
+
};
|
586
568
|
|
587
569
|
// src/components/controls/card/Email.tsx
|
588
|
-
import
|
589
|
-
var CreditCardEmailWithFormControl =
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
slotProps: {
|
598
|
-
htmlInput: {
|
599
|
-
"aria-label": `${fieldLabel} for your purchase`,
|
600
|
-
autoComplete,
|
601
|
-
autoCorrect,
|
602
|
-
id,
|
603
|
-
name,
|
604
|
-
spellCheck
|
605
|
-
}
|
606
|
-
},
|
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,
|
607
579
|
inputRef,
|
608
|
-
value
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
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
|
+
};
|
613
615
|
|
614
616
|
// src/components/controls/card/Expiration.tsx
|
615
|
-
import
|
616
|
-
var CreditCardExpirationWithFormControl =
|
617
|
-
|
618
|
-
|
619
|
-
|
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,
|
620
626
|
inputRef,
|
621
|
-
|
622
|
-
|
623
|
-
|
627
|
+
value
|
628
|
+
} = useCreditCardFormControl(formControlName, CreditCardExpirationFormControl);
|
629
|
+
const {
|
630
|
+
autoComplete,
|
631
|
+
autoCorrect,
|
632
|
+
id,
|
624
633
|
inputMode,
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
}
|
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
|
+
};
|
640
662
|
|
641
663
|
// src/components/controls/card/Name.tsx
|
642
|
-
import
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
]);
|
653
|
-
const {
|
654
|
-
|
655
|
-
|
656
|
-
fieldLabel,
|
657
|
-
formControl: creditCardFormControl,
|
658
|
-
formControlError: error,
|
659
|
-
inputMode,
|
660
|
-
slotProps: {
|
661
|
-
htmlInput: {
|
662
|
-
"aria-label": `${fieldLabel} name on your card`,
|
663
|
-
autoComplete,
|
664
|
-
autoCorrect,
|
665
|
-
id,
|
666
|
-
name,
|
667
|
-
spellCheck,
|
668
|
-
tabIndex
|
669
|
-
}
|
670
|
-
},
|
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,
|
671
678
|
inputRef,
|
672
|
-
value
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
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
|
+
};
|
677
715
|
|
678
716
|
// src/components/controls/card/number/Number.tsx
|
679
717
|
import { InputAdornment } from "@mui/material";
|
680
|
-
import React7 from "react";
|
681
718
|
|
682
719
|
// src/components/img/american-express.svg
|
683
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>';
|
@@ -693,28 +730,21 @@ var visa_default = '<svg width="800px" height="800px" viewBox="0 -140 780 780" e
|
|
693
730
|
|
694
731
|
// src/components/controls/card/Options.ts
|
695
732
|
var CreditCardData = {
|
696
|
-
amex: {
|
697
|
-
|
698
|
-
|
699
|
-
}
|
700
|
-
discover: {
|
701
|
-
icon: discover_default,
|
702
|
-
name: "Discover"
|
703
|
-
},
|
704
|
-
mastercard: {
|
705
|
-
icon: mastercard_default,
|
706
|
-
name: "Mastercard"
|
707
|
-
},
|
708
|
-
visa: {
|
709
|
-
icon: visa_default,
|
710
|
-
name: "Visa"
|
711
|
-
}
|
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" }
|
712
737
|
};
|
713
738
|
|
714
739
|
// src/components/controls/card/number/use.ts
|
715
740
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
716
|
-
var useCreditCardNumberFormControl =
|
717
|
-
const {
|
741
|
+
var useCreditCardNumberFormControl = (formControlName, control) => {
|
742
|
+
const {
|
743
|
+
creditCardFormControl,
|
744
|
+
error,
|
745
|
+
inputRef,
|
746
|
+
value
|
747
|
+
} = useCreditCardFormControl(formControlName, control);
|
718
748
|
const [type, setType] = useState2("");
|
719
749
|
useEffect2(() => {
|
720
750
|
if (creditCardFormControl) {
|
@@ -730,10 +760,7 @@ var useCreditCardNumberFormControl = /* @__PURE__ */ __name((formControlName, co
|
|
730
760
|
}
|
731
761
|
};
|
732
762
|
}
|
733
|
-
}, [
|
734
|
-
creditCardFormControl,
|
735
|
-
inputRef
|
736
|
-
]);
|
763
|
+
}, [creditCardFormControl, inputRef]);
|
737
764
|
return {
|
738
765
|
creditCardFormControl,
|
739
766
|
error,
|
@@ -741,84 +768,114 @@ var useCreditCardNumberFormControl = /* @__PURE__ */ __name((formControlName, co
|
|
741
768
|
type,
|
742
769
|
value
|
743
770
|
};
|
744
|
-
}
|
771
|
+
};
|
745
772
|
|
746
773
|
// src/components/controls/card/number/Number.tsx
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
774
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
775
|
+
var CreditCardNumberWithFormControl = ({
|
776
|
+
fieldLabel = "Card Number",
|
777
|
+
formControlName = "cardNumber",
|
778
|
+
...props
|
779
|
+
}) => {
|
780
|
+
const {
|
781
|
+
creditCardFormControl,
|
782
|
+
error,
|
783
|
+
inputRef,
|
784
|
+
type,
|
785
|
+
value
|
786
|
+
} = useCreditCardNumberFormControl(formControlName, CreditCardNumberFormControl);
|
787
|
+
const {
|
788
|
+
autoComplete,
|
789
|
+
autoCorrect,
|
790
|
+
id,
|
791
|
+
inputMode,
|
792
|
+
name,
|
793
|
+
spellCheck,
|
794
|
+
...cardProps
|
795
|
+
} = creditCardFormControl?.props ?? {};
|
796
|
+
return /* @__PURE__ */ jsx7(
|
797
|
+
FormControlTextField,
|
798
|
+
{
|
799
|
+
fieldLabel,
|
800
|
+
formControl: creditCardFormControl,
|
801
|
+
formControlError: error,
|
802
|
+
inputRef,
|
803
|
+
inputMode,
|
804
|
+
slotProps: {
|
805
|
+
htmlInput: {
|
806
|
+
"aria-label": fieldLabel,
|
807
|
+
autoComplete,
|
808
|
+
autoCorrect,
|
809
|
+
id,
|
810
|
+
inputMode,
|
811
|
+
name,
|
812
|
+
spellCheck
|
813
|
+
},
|
814
|
+
input: {
|
815
|
+
startAdornment: type.length > 0 ? /* @__PURE__ */ jsx7(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx7("img", { height: "30px", width: "40px", src: CreditCardData[type].icon }) }) : null
|
816
|
+
}
|
817
|
+
},
|
818
|
+
value,
|
819
|
+
...cardProps,
|
820
|
+
...props
|
821
|
+
}
|
822
|
+
);
|
823
|
+
};
|
824
|
+
|
825
|
+
// src/components/controls/card/Zip.tsx
|
826
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
827
|
+
var CreditCardZipWithFormControl = ({
|
828
|
+
formControlName = "zip",
|
829
|
+
fieldLabel = "Zip",
|
830
|
+
...props
|
831
|
+
}) => {
|
832
|
+
const {
|
833
|
+
creditCardFormControl,
|
834
|
+
error,
|
754
835
|
inputRef,
|
836
|
+
value
|
837
|
+
} = useCreditCardFormControl(formControlName, CreditCardZipFormControl);
|
838
|
+
const {
|
839
|
+
autoComplete,
|
840
|
+
autoCorrect,
|
841
|
+
id,
|
755
842
|
inputMode,
|
756
|
-
|
757
|
-
|
758
|
-
|
843
|
+
name,
|
844
|
+
spellCheck,
|
845
|
+
...cvcProps
|
846
|
+
} = creditCardFormControl?.props ?? {};
|
847
|
+
return /* @__PURE__ */ jsx8(
|
848
|
+
FormControlTextField,
|
849
|
+
{
|
850
|
+
fieldLabel,
|
851
|
+
formControl: creditCardFormControl,
|
852
|
+
formControlError: error,
|
853
|
+
inputMode,
|
854
|
+
inputProps: {
|
855
|
+
"aria-label": `${fieldLabel} code for your card`,
|
759
856
|
autoComplete,
|
760
857
|
autoCorrect,
|
761
858
|
id,
|
762
|
-
inputMode,
|
763
859
|
name,
|
764
860
|
spellCheck
|
765
861
|
},
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
})) : null
|
774
|
-
}
|
775
|
-
},
|
776
|
-
value,
|
777
|
-
...cardProps,
|
778
|
-
...props
|
779
|
-
});
|
780
|
-
}, "CreditCardNumberWithFormControl");
|
781
|
-
|
782
|
-
// src/components/controls/card/Zip.tsx
|
783
|
-
import React8 from "react";
|
784
|
-
var CreditCardZipWithFormControl = /* @__PURE__ */ __name(({ formControlName = "zip", fieldLabel = "Zip", ...props }) => {
|
785
|
-
const { creditCardFormControl, error, inputRef, value } = useCreditCardFormControl(formControlName, CreditCardZipFormControl);
|
786
|
-
const { autoComplete, autoCorrect, id, inputMode, name, spellCheck, ...cvcProps } = creditCardFormControl?.props ?? {};
|
787
|
-
return /* @__PURE__ */ React8.createElement(FormControlTextField, {
|
788
|
-
fieldLabel,
|
789
|
-
formControl: creditCardFormControl,
|
790
|
-
formControlError: error,
|
791
|
-
inputMode,
|
792
|
-
inputProps: {
|
793
|
-
"aria-label": `${fieldLabel} code for your card`,
|
794
|
-
autoComplete,
|
795
|
-
autoCorrect,
|
796
|
-
id,
|
797
|
-
name,
|
798
|
-
spellCheck
|
799
|
-
},
|
800
|
-
inputRef,
|
801
|
-
value,
|
802
|
-
...cvcProps,
|
803
|
-
...props
|
804
|
-
});
|
805
|
-
}, "CreditCardZipWithFormControl");
|
862
|
+
inputRef,
|
863
|
+
value,
|
864
|
+
...cvcProps,
|
865
|
+
...props
|
866
|
+
}
|
867
|
+
);
|
868
|
+
};
|
806
869
|
|
807
870
|
// src/components/form/Form.tsx
|
808
871
|
import { Stack as Stack2 } from "@mui/material";
|
809
872
|
import { ErrorRender } from "@xylabs/react-error";
|
810
873
|
import { FlexCol } from "@xylabs/react-flexbox";
|
811
|
-
import
|
874
|
+
import { useState as useState3 } from "react";
|
812
875
|
|
813
876
|
// src/components/support/Fields.ts
|
814
|
-
var NameFields = [
|
815
|
-
|
816
|
-
"lastName"
|
817
|
-
];
|
818
|
-
var NameLabels = [
|
819
|
-
"First",
|
820
|
-
"Last"
|
821
|
-
];
|
877
|
+
var NameFields = ["firstName", "lastName"];
|
878
|
+
var NameLabels = ["First", "Last"];
|
822
879
|
|
823
880
|
// src/components/support/validateCreditCardInputs.ts
|
824
881
|
import { assertEx as assertEx3 } from "@xylabs/assert";
|
@@ -829,7 +886,7 @@ var CreditCardInputSchema = "network.xyo.credit.card.input";
|
|
829
886
|
var isCreditCardInput = isPayloadOfSchemaType(CreditCardInputSchema);
|
830
887
|
|
831
888
|
// src/components/support/validateCreditCardInputs.ts
|
832
|
-
var validateCreditCardInputs =
|
889
|
+
var validateCreditCardInputs = (values) => {
|
833
890
|
return {
|
834
891
|
cardNumber: assertEx3(values.cardNumber, () => "card number is not a string"),
|
835
892
|
cvc: assertEx3(values.cvc, () => "card cvc is not a string"),
|
@@ -841,92 +898,84 @@ var validateCreditCardInputs = /* @__PURE__ */ __name((values) => {
|
|
841
898
|
timestamp: values.timestamp,
|
842
899
|
zip: assertEx3(values.zip, () => "zip is not a string")
|
843
900
|
};
|
844
|
-
}
|
901
|
+
};
|
845
902
|
|
846
903
|
// src/components/form/InputFieldsStack.tsx
|
847
904
|
import { Stack } from "@mui/material";
|
848
|
-
import
|
849
|
-
var InputFieldsStack =
|
905
|
+
import { Fragment, jsx as jsx9, jsxs } from "react/jsx-runtime";
|
906
|
+
var InputFieldsStack = (props) => {
|
850
907
|
const { sx } = props;
|
851
|
-
return /* @__PURE__ */
|
852
|
-
|
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
|
-
}, /* @__PURE__ */ React9.createElement(CreditCardZipWithFormControl, null)), /* @__PURE__ */ React9.createElement(Stack, {
|
912
|
-
width: {
|
913
|
-
md: "75%",
|
914
|
-
xs: "100%"
|
915
|
-
}
|
916
|
-
}, /* @__PURE__ */ React9.createElement(CreditCardEmailWithFormControl, null))));
|
917
|
-
}, "InputFieldsStack");
|
908
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
909
|
+
/* @__PURE__ */ jsxs(
|
910
|
+
Stack,
|
911
|
+
{
|
912
|
+
gap: 2,
|
913
|
+
sx: {
|
914
|
+
flexDirection: { md: "row", xs: "column" },
|
915
|
+
...sx
|
916
|
+
},
|
917
|
+
...props,
|
918
|
+
children: [
|
919
|
+
/* @__PURE__ */ jsx9(NameWithFormControl, { autoCompleteLabel: "given-name", fieldLabel: "First", formControlName: "firstName", placeholder: "Jerry" }),
|
920
|
+
/* @__PURE__ */ jsx9(NameWithFormControl, { autoCompleteLabel: "family-name", fieldLabel: "Last", formControlName: "lastName", placeholder: "Smith" })
|
921
|
+
]
|
922
|
+
}
|
923
|
+
),
|
924
|
+
/* @__PURE__ */ jsxs(
|
925
|
+
Stack,
|
926
|
+
{
|
927
|
+
gap: 2,
|
928
|
+
sx: {
|
929
|
+
flexDirection: { lg: "row", xs: "column" },
|
930
|
+
...sx
|
931
|
+
},
|
932
|
+
...props,
|
933
|
+
children: [
|
934
|
+
/* @__PURE__ */ jsx9(Stack, { width: { lg: "50%", xs: "100%" }, children: /* @__PURE__ */ jsx9(CreditCardNumberWithFormControl, {}) }),
|
935
|
+
/* @__PURE__ */ jsxs(
|
936
|
+
Stack,
|
937
|
+
{
|
938
|
+
direction: { lg: "row", xs: "column" },
|
939
|
+
gap: 2,
|
940
|
+
width: { lg: "50%", xs: "100%" },
|
941
|
+
children: [
|
942
|
+
/* @__PURE__ */ jsx9(CreditCardCvvWithFormControl, {}),
|
943
|
+
/* @__PURE__ */ jsx9(CreditCardExpirationWithFormControl, {})
|
944
|
+
]
|
945
|
+
}
|
946
|
+
)
|
947
|
+
]
|
948
|
+
}
|
949
|
+
),
|
950
|
+
/* @__PURE__ */ jsxs(
|
951
|
+
Stack,
|
952
|
+
{
|
953
|
+
gap: 2,
|
954
|
+
sx: {
|
955
|
+
flexDirection: { md: "row", xs: "column" },
|
956
|
+
...sx
|
957
|
+
},
|
958
|
+
...props,
|
959
|
+
children: [
|
960
|
+
/* @__PURE__ */ jsx9(Stack, { width: { md: "25%", xs: "100%" }, children: /* @__PURE__ */ jsx9(CreditCardZipWithFormControl, {}) }),
|
961
|
+
/* @__PURE__ */ jsx9(Stack, { width: { md: "75%", xs: "100%" }, children: /* @__PURE__ */ jsx9(CreditCardEmailWithFormControl, {}) })
|
962
|
+
]
|
963
|
+
}
|
964
|
+
)
|
965
|
+
] });
|
966
|
+
};
|
918
967
|
|
919
968
|
// src/components/form/useFormStorage.tsx
|
920
969
|
import { usePromise } from "@xylabs/react-promise";
|
921
970
|
import { StorageArchivist, StorageArchivistConfigSchema } from "@xyo-network/archivist-storage";
|
922
971
|
import { ArchivistFormGroupStorage } from "@xyo-network/react-form-group";
|
923
972
|
var STORAGE_NAME_SPACE = "credit-card-fields";
|
924
|
-
var calculateTTL =
|
973
|
+
var calculateTTL = (months = 6) => {
|
925
974
|
const MS_PER_DAY = 24 * 60 * 60 * 1e3;
|
926
975
|
const DAYS_PER_MONTH = 30.44;
|
927
976
|
return months * DAYS_PER_MONTH * MS_PER_DAY;
|
928
|
-
}
|
929
|
-
var useFormStorage =
|
977
|
+
};
|
978
|
+
var useFormStorage = () => {
|
930
979
|
return usePromise(async () => {
|
931
980
|
const localStorageArchivist = await StorageArchivist.create({
|
932
981
|
account: "random",
|
@@ -954,13 +1003,22 @@ var useFormStorage = /* @__PURE__ */ __name(() => {
|
|
954
1003
|
ttlStorage: calculateTTL()
|
955
1004
|
};
|
956
1005
|
}, []);
|
957
|
-
}
|
1006
|
+
};
|
958
1007
|
|
959
1008
|
// src/components/form/Form.tsx
|
960
|
-
|
1009
|
+
import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
1010
|
+
var CreditCardFormFlexbox = ({
|
1011
|
+
ConfirmationButton,
|
1012
|
+
displayErrors,
|
1013
|
+
onErrorDuringSubmit,
|
1014
|
+
onInvalidSubmit,
|
1015
|
+
onSuccessfulSubmit,
|
1016
|
+
onValidSubmit,
|
1017
|
+
...props
|
1018
|
+
}) => {
|
961
1019
|
const { formGroup } = useFormGroupWithCreditCardInput(true);
|
962
1020
|
const [error, setError] = useState3();
|
963
|
-
const handleConfirmPayment =
|
1021
|
+
const handleConfirmPayment = async () => {
|
964
1022
|
try {
|
965
1023
|
if (!formGroup) {
|
966
1024
|
throw new Error("formGroup is not defined");
|
@@ -978,41 +1036,31 @@ var CreditCardFormFlexbox = /* @__PURE__ */ __name(({ ConfirmationButton, displa
|
|
978
1036
|
onErrorDuringSubmit?.(error2);
|
979
1037
|
if (displayErrors) setError(error2);
|
980
1038
|
}
|
981
|
-
}
|
982
|
-
return /* @__PURE__ */
|
983
|
-
error
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
md: "row",
|
988
|
-
|
1039
|
+
};
|
1040
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
1041
|
+
/* @__PURE__ */ jsx10(ErrorRender, { error }),
|
1042
|
+
/* @__PURE__ */ jsx10(
|
1043
|
+
FlexCol,
|
1044
|
+
{
|
1045
|
+
sx: { flexDirection: { md: "row", xs: "column" } },
|
1046
|
+
width: "100%",
|
1047
|
+
gap: 2,
|
1048
|
+
...props,
|
1049
|
+
children: /* @__PURE__ */ jsxs2(Stack2, { flexDirection: "column", sx: { width: "100%" }, gap: 2, children: [
|
1050
|
+
/* @__PURE__ */ jsx10(InputFieldsStack, {}),
|
1051
|
+
ConfirmationButton ? /* @__PURE__ */ jsx10(ConfirmationButton, { onClick: handleConfirmPayment, variant: "contained", sx: { alignSelf: "end" }, children: "Confirm Payment" }) : null
|
1052
|
+
] })
|
989
1053
|
}
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
}, /* @__PURE__ */ React10.createElement(Stack2, {
|
995
|
-
flexDirection: "column",
|
996
|
-
sx: {
|
997
|
-
width: "100%"
|
998
|
-
},
|
999
|
-
gap: 2
|
1000
|
-
}, /* @__PURE__ */ React10.createElement(InputFieldsStack, null), ConfirmationButton ? /* @__PURE__ */ React10.createElement(ConfirmationButton, {
|
1001
|
-
onClick: handleConfirmPayment,
|
1002
|
-
variant: "contained",
|
1003
|
-
sx: {
|
1004
|
-
alignSelf: "end"
|
1005
|
-
}
|
1006
|
-
}, "Confirm Payment") : null)));
|
1007
|
-
}, "CreditCardFormFlexbox");
|
1008
|
-
var CreditCardFormFlexboxWithFormGroupProvider = /* @__PURE__ */ __name((props) => {
|
1054
|
+
)
|
1055
|
+
] });
|
1056
|
+
};
|
1057
|
+
var CreditCardFormFlexboxWithFormGroupProvider = (props) => {
|
1009
1058
|
const [params, error] = useFormStorage();
|
1010
|
-
return /* @__PURE__ */
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
}, "CreditCardFormFlexboxWithFormGroupProvider");
|
1059
|
+
return /* @__PURE__ */ jsxs2(FormGroupCreditCardProvider, { params, children: [
|
1060
|
+
/* @__PURE__ */ jsx10(ErrorRender, { error }),
|
1061
|
+
/* @__PURE__ */ jsx10(CreditCardFormFlexbox, { ...props })
|
1062
|
+
] });
|
1063
|
+
};
|
1016
1064
|
export {
|
1017
1065
|
CreditCardCvvFormControl,
|
1018
1066
|
CreditCardCvvWithFormControl,
|