udp-react-enterprise-component-library 26.5.0-beta.12 → 26.5.0-beta.13

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.
Files changed (100) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/utilities/form/paymentForm/BankAccountForm.d.ts +12 -29
  3. package/dist/utilities/form/paymentForm/BankAccountForm.d.ts.map +1 -1
  4. package/dist/utilities/form/paymentForm/BankAccountForm.js +64 -78
  5. package/dist/utilities/form/paymentForm/BankAccountForm.js.map +1 -1
  6. package/dist/utilities/form/paymentForm/BankAccountForm.mjs +77 -196
  7. package/dist/utilities/form/paymentForm/BankAccountForm.mjs.map +1 -1
  8. package/dist/utilities/form/paymentForm/CashForm.d.ts +1 -1
  9. package/dist/utilities/form/paymentForm/CashForm.d.ts.map +1 -1
  10. package/dist/utilities/form/paymentForm/CashForm.js +19 -51
  11. package/dist/utilities/form/paymentForm/CashForm.js.map +1 -1
  12. package/dist/utilities/form/paymentForm/CashForm.mjs +80 -119
  13. package/dist/utilities/form/paymentForm/CashForm.mjs.map +1 -1
  14. package/dist/utilities/form/paymentForm/CreditCardForm.d.ts +10 -21
  15. package/dist/utilities/form/paymentForm/CreditCardForm.d.ts.map +1 -1
  16. package/dist/utilities/form/paymentForm/CreditCardForm.js +81 -87
  17. package/dist/utilities/form/paymentForm/CreditCardForm.js.map +1 -1
  18. package/dist/utilities/form/paymentForm/CreditCardForm.mjs +84 -195
  19. package/dist/utilities/form/paymentForm/CreditCardForm.mjs.map +1 -1
  20. package/dist/utilities/form/paymentForm/CreditCardUtils.d.ts.map +1 -1
  21. package/dist/utilities/form/paymentForm/CreditCardUtils.js +5 -0
  22. package/dist/utilities/form/paymentForm/CreditCardUtils.js.map +1 -1
  23. package/dist/utilities/form/paymentForm/CreditCardUtils.mjs +1 -0
  24. package/dist/utilities/form/paymentForm/CreditCardUtils.mjs.map +1 -1
  25. package/dist/utilities/form/paymentForm/HostedPaymentError.d.ts +5 -16
  26. package/dist/utilities/form/paymentForm/HostedPaymentError.d.ts.map +1 -1
  27. package/dist/utilities/form/paymentForm/HostedPaymentError.js +6 -18
  28. package/dist/utilities/form/paymentForm/HostedPaymentError.js.map +1 -1
  29. package/dist/utilities/form/paymentForm/HostedPaymentError.mjs +18 -55
  30. package/dist/utilities/form/paymentForm/HostedPaymentError.mjs.map +1 -1
  31. package/dist/utilities/form/paymentForm/NewCreditCardForm.d.ts +12 -14
  32. package/dist/utilities/form/paymentForm/NewCreditCardForm.d.ts.map +1 -1
  33. package/dist/utilities/form/paymentForm/NewCreditCardForm.js +45 -58
  34. package/dist/utilities/form/paymentForm/NewCreditCardForm.js.map +1 -1
  35. package/dist/utilities/form/paymentForm/NewCreditCardForm.mjs +185 -262
  36. package/dist/utilities/form/paymentForm/NewCreditCardForm.mjs.map +1 -1
  37. package/dist/utilities/form/paymentForm/NewECheckForm.d.ts +9 -14
  38. package/dist/utilities/form/paymentForm/NewECheckForm.d.ts.map +1 -1
  39. package/dist/utilities/form/paymentForm/NewECheckForm.js +28 -68
  40. package/dist/utilities/form/paymentForm/NewECheckForm.js.map +1 -1
  41. package/dist/utilities/form/paymentForm/NewECheckForm.mjs +184 -227
  42. package/dist/utilities/form/paymentForm/NewECheckForm.mjs.map +1 -1
  43. package/dist/utilities/form/paymentForm/PaymentBankDetails.d.ts.map +1 -1
  44. package/dist/utilities/form/paymentForm/PaymentBankDetails.js +4 -2
  45. package/dist/utilities/form/paymentForm/PaymentBankDetails.js.map +1 -1
  46. package/dist/utilities/form/paymentForm/PaymentCardDetail.d.ts.map +1 -1
  47. package/dist/utilities/form/paymentForm/PaymentCardDetail.js +4 -2
  48. package/dist/utilities/form/paymentForm/PaymentCardDetail.js.map +1 -1
  49. package/dist/utilities/form/paymentForm/PaymentForm.d.ts +67 -3
  50. package/dist/utilities/form/paymentForm/PaymentForm.d.ts.map +1 -1
  51. package/dist/utilities/form/paymentForm/PaymentForm.js +265 -246
  52. package/dist/utilities/form/paymentForm/PaymentForm.js.map +1 -1
  53. package/dist/utilities/form/paymentForm/PaymentForm.mjs +275 -296
  54. package/dist/utilities/form/paymentForm/PaymentForm.mjs.map +1 -1
  55. package/dist/utilities/form/paymentForm/usePaymentContext.d.ts +22 -0
  56. package/dist/utilities/form/paymentForm/usePaymentContext.d.ts.map +1 -0
  57. package/dist/utilities/form/paymentForm/usePaymentContext.js +117 -0
  58. package/dist/utilities/form/paymentForm/usePaymentContext.js.map +1 -0
  59. package/dist/utilities/form/paymentForm/usePaymentContext.mjs +119 -0
  60. package/dist/utilities/form/paymentForm/usePaymentContext.mjs.map +1 -0
  61. package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.d.ts.map +1 -1
  62. package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.js +22 -28
  63. package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.js.map +1 -1
  64. package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.mjs +37 -32
  65. package/dist/utilities/form/paymentForm/vendorsForms/FiservForm.mjs.map +1 -1
  66. package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.d.ts.map +1 -1
  67. package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.js +25 -27
  68. package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.js.map +1 -1
  69. package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.mjs +40 -38
  70. package/dist/utilities/form/paymentForm/vendorsForms/ICheckForm.mjs.map +1 -1
  71. package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.d.ts.map +1 -1
  72. package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.js +25 -32
  73. package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.js.map +1 -1
  74. package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.mjs +38 -43
  75. package/dist/utilities/form/paymentForm/vendorsForms/PaymentusForm.mjs.map +1 -1
  76. package/package.json +6 -42
  77. package/dist/utilities/form/paymentForm/BankIcon.mjs +0 -56
  78. package/dist/utilities/form/paymentForm/BankIcon.mjs.map +0 -1
  79. package/dist/utilities/form/paymentForm/CashIcon.mjs +0 -55
  80. package/dist/utilities/form/paymentForm/CashIcon.mjs.map +0 -1
  81. package/dist/utilities/form/paymentForm/CheckIcon.mjs +0 -62
  82. package/dist/utilities/form/paymentForm/CheckIcon.mjs.map +0 -1
  83. package/dist/utilities/form/paymentForm/CreditCardIcon.mjs +0 -85
  84. package/dist/utilities/form/paymentForm/CreditCardIcon.mjs.map +0 -1
  85. package/dist/utilities/form/paymentForm/DisableOverlay.mjs +0 -44
  86. package/dist/utilities/form/paymentForm/DisableOverlay.mjs.map +0 -1
  87. package/dist/utilities/form/paymentForm/PaymentBankDetails.mjs +0 -161
  88. package/dist/utilities/form/paymentForm/PaymentBankDetails.mjs.map +0 -1
  89. package/dist/utilities/form/paymentForm/PaymentCard.d.ts +0 -13
  90. package/dist/utilities/form/paymentForm/PaymentCard.d.ts.map +0 -1
  91. package/dist/utilities/form/paymentForm/PaymentCard.js +0 -54
  92. package/dist/utilities/form/paymentForm/PaymentCard.js.map +0 -1
  93. package/dist/utilities/form/paymentForm/PaymentCard.mjs +0 -96
  94. package/dist/utilities/form/paymentForm/PaymentCard.mjs.map +0 -1
  95. package/dist/utilities/form/paymentForm/PaymentCardDetail.mjs +0 -284
  96. package/dist/utilities/form/paymentForm/PaymentCardDetail.mjs.map +0 -1
  97. package/dist/utilities/form/paymentForm/PaymentDropdown.mjs +0 -142
  98. package/dist/utilities/form/paymentForm/PaymentDropdown.mjs.map +0 -1
  99. package/dist/utilities/form/paymentForm/TabPanel.mjs +0 -74
  100. package/dist/utilities/form/paymentForm/TabPanel.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CashForm.d.ts","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/CashForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAcxD,UAAU,aAAa;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,cAAc,CAAC,EAAE,CAAC,iBAAiB,EAAE,OAAO,KAAK,IAAI,CAAC;CACvD;AAED,eAAO,MAAM,QAAQ,uGA+DpB,CAAA"}
1
+ {"version":3,"file":"CashForm.d.ts","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/CashForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,UAAU,aAAa;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,cAAc,CAAC,EAAE,CAAC,iBAAiB,EAAE,OAAO,KAAK,IAAI,CAAC;CACvD;AAED,eAAO,MAAM,QAAQ,wEA6CpB,CAAC"}
@@ -1,56 +1,24 @@
1
1
  import React from 'react';
2
- import { FormControl, makeStyles, InputAdornment } from '@material-ui/core';
3
- import { Field } from '../Field';
4
- import { FluentTextField } from '../../../UI/inputs/textField/FluentTextField';
5
2
  import { useTranslation } from 'react-i18next';
6
- import { PaymentCard } from './PaymentCard';
7
- const useStyles = makeStyles(theme => ({
8
- formControl: {
9
- width: '100%',
10
- marginBottom: '10px',
11
- },
12
- formControlCheck: {
13
- width: '100%',
14
- marginTop: '5px',
15
- marginLeft: '3px',
16
- },
17
- }));
18
- export const CashForm = ({ isFormDisabled = false, paymentDetails, amountValue = null, onStatusChange }) => {
3
+ import { Field as FinalField } from 'react-final-form';
4
+ import { Field } from '../Field';
5
+ import { UdpFlexbox } from '../../../UI/fluent-web-components/UdpFlexbox';
6
+ import { UdpTextInput } from '../../../UI/fluent-web-components/UdpTextInput';
7
+ import { UdpTextarea } from '../../../UI/fluent-web-components/UdpTextarea';
8
+ export const CashForm = ({ isFormDisabled = false, amountValue = null, }) => {
19
9
  const { t } = useTranslation();
20
- const classes = useStyles();
21
- return (React.createElement(PaymentCard, null, React.createElement(FormControl, { className: classes.formControl }, React.createElement(Field
22
- // @ts-ignore
23
- , {
24
- // @ts-ignore
25
- component: FluentTextField, ComponentProps: {
26
- // @ts-ignore
27
- label: t("Amount"),
28
- variant: "outlined",
29
- margin: "none",
30
- size: "small",
31
- disabled: isFormDisabled || amountValue || false,
32
- fullWidth: true,
33
- InputProps: {
34
- startAdornment: (React.createElement(InputAdornment, { position: "start" }, "$")),
35
- },
36
- }, name: "cashAmount", initialValue: amountValue, required: !isFormDisabled })), React.createElement(FormControl, { className: classes.formControl }, React.createElement(Field
37
- // @ts-ignore
38
- , {
39
- // @ts-ignore
40
- component: FluentTextField, ComponentProps: {
41
- label: t("Description"),
42
- variant: 'outlined',
43
- margin: 'normal',
44
- size: 'small',
45
- disabled: false,
46
- fullWidth: true,
47
- autoComplete: 'off',
48
- multiline: true,
49
- rows: 4,
50
- inputProps: {
51
- maxLength: 256,
52
- autocomplete: 'off',
53
- },
54
- }, name: "cashDescription", initialValue: "", required: !isFormDisabled }))));
10
+ const amountLocked = isFormDisabled || amountValue != null;
11
+ return (React.createElement(UdpFlexbox, { direction: "column", gap: "sm", wrap: "nowrap" }, React.createElement(FinalField, { name: "cashAmount", initialValue: String(amountValue !== null && amountValue !== void 0 ? amountValue : ''),
12
+ // Raw FinalField, so the Field wrapper's required validation is
13
+ // replicated here (skipped when the amount is preset/locked).
14
+ validate: (value) => (!amountLocked && !value ? 'Required' : undefined) }, ({ input, meta }) => {
15
+ var _a;
16
+ return (React.createElement(UdpTextInput, { label: t('Amount'), value: String((_a = input.value) !== null && _a !== void 0 ? _a : ''), error: meta.touched && meta.error ? meta.error : undefined, onChange: input.onChange, disabled: amountLocked, required: !isFormDisabled }, React.createElement("span", { slot: "start" }, "$")));
17
+ }), React.createElement(Field, { component: UdpTextarea, ComponentProps: {
18
+ label: t('Description'),
19
+ maxLength: 256,
20
+ autoResize: true,
21
+ disabled: isFormDisabled,
22
+ }, name: "cashDescription", initialValue: "", required: !isFormDisabled, onChange: () => { } })));
55
23
  };
56
24
  //# sourceMappingURL=CashForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CashForm.js","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/CashForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAA;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrC,WAAW,EAAE;QACX,KAAK,EAAE,MAAM;QACb,YAAY,EAAE,MAAM;KACrB;IACD,gBAAgB,EAAE;QAChB,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,KAAK;KAClB;CACF,CAAC,CAAC,CAAC;AASJ,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,cAAc,GAAG,KAAK,EACtB,cAAc,EACd,WAAW,GAAG,IAAI,EAClB,cAAc,EACA,EAAE,EAAE,CAAC;IACnB,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;IAE5B,OAAO,CACL,oBAAC,WAAW,QACV,oBAAC,WAAW,IAAC,SAAS,EAAE,OAAO,CAAC,WAAW,IACzC,oBAAC,KAAK;IACJ,aAAa;;QAAb,aAAa;QACb,SAAS,EAAE,eAAe,EAC1B,cAAc,EAAE;YACd,aAAa;YACb,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC;YAClB,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,cAAc,IAAI,WAAW,IAAI,KAAK;YAChD,SAAS,EAAE,IAAI;YACf,UAAU,EAAE;gBACV,cAAc,EAAE,CACd,oBAAC,cAAc,IAAC,QAAQ,EAAC,OAAO,QAAmB,CACpD;aACF;SACF,EACD,IAAI,EAAC,YAAY,EACjB,YAAY,EAAE,WAAW,EACzB,QAAQ,EAAE,CAAC,cAAc,GACzB,CACU,EAEd,oBAAC,WAAW,IAAC,SAAS,EAAE,OAAO,CAAC,WAAW,IACzC,oBAAC,KAAK;IACJ,aAAa;;QAAb,aAAa;QACb,SAAS,EAAE,eAAe,EAC1B,cAAc,EACZ;YACE,KAAK,EAAE,CAAC,CAAC,aAAa,CAAC;YACvB,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,KAAK;YACnB,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,CAAC;YACP,UAAU,EAAE;gBACV,SAAS,EAAE,GAAG;gBACd,YAAY,EAAE,KAAK;aACpB;SACK,EAEV,IAAI,EAAC,iBAAiB,EACtB,YAAY,EAAC,EAAE,EACf,QAAQ,EAAE,CAAC,cAAc,GACzB,CACU,CACF,CACf,CAAC;AAAA,CACH,CAAA"}
1
+ {"version":3,"file":"CashForm.js","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/CashForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KA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AQ,EAAE,YAAY,EACtB,QAAQ,EAAE,CAAC,cAAc,IAEzB,8BAAM,IAAI,EAAC,OAAO,QAAS,CACd,CAChB;KAAA,CACU,EAEb,oBAAC,KAAK,IACJ,SAAS,EAAE,WAAuC,EAClD,cAAc,EAAE;YACd,KAAK,EAAE,CAAC,CAAC,aAAa,CAAC;YACvB,SAAS,EAAE,GAAG;YACd,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,cAAc;SACzB,EACD,IAAI,EAAC,iBAAiB,EACtB,YAAY,EAAC,EAAE,EACf,QAAQ,EAAE,CAAC,cAAc,EACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAC,CAAC,GAClB,CACS,CACd,CAAC;AAAA,CACH,CAAC"}
@@ -1,142 +1,103 @@
1
1
  import { c } from "../../../reactCompilerRuntime.mjs";
2
- import { Field } from "../Field.mjs";
3
- import { FluentTextField } from "../../../UI/inputs/textField/FluentTextField.mjs";
4
- import { PaymentCard } from "./PaymentCard.mjs";
2
+ import { Field as Field$1 } from "../Field.mjs";
3
+ import { UdpFlexbox } from "../../../UI/fluent-web-components/UdpFlexbox.mjs";
4
+ import { UdpTextInput } from "../../../UI/fluent-web-components/UdpTextInput.mjs";
5
+ import { UdpTextarea } from "../../../UI/fluent-web-components/UdpTextarea.mjs";
5
6
  import React from "react";
6
- import { FormControl, InputAdornment, makeStyles } from "@material-ui/core";
7
+ import { Field } from "react-final-form";
7
8
  import { useTranslation } from "react-i18next";
8
9
  //#region src/utilities/form/paymentForm/CashForm.tsx
9
- const useStyles = makeStyles((theme) => ({
10
- formControl: {
11
- width: "100%",
12
- marginBottom: "10px"
13
- },
14
- formControlCheck: {
15
- width: "100%",
16
- marginTop: "5px",
17
- marginLeft: "3px"
18
- }
19
- }));
20
10
  const CashForm = (t0) => {
21
- const $ = c(27);
11
+ const $ = c(21);
22
12
  const { isFormDisabled: t1, amountValue: t2 } = t0;
23
13
  const isFormDisabled = t1 === void 0 ? false : t1;
24
14
  const amountValue = t2 === void 0 ? null : t2;
25
15
  const { t } = useTranslation();
26
- const classes = useStyles();
27
- const t3 = classes.formControl;
16
+ const amountLocked = isFormDisabled || amountValue != null;
17
+ const t3 = String(amountValue ?? "");
28
18
  let t4;
29
- if ($[0] !== t) {
30
- t4 = t("Amount");
31
- $[0] = t;
19
+ if ($[0] !== amountLocked) {
20
+ t4 = (value) => !amountLocked && !value ? "Required" : void 0;
21
+ $[0] = amountLocked;
32
22
  $[1] = t4;
33
23
  } else t4 = $[1];
34
- const t5 = isFormDisabled || amountValue || false;
35
- let t6;
36
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
37
- t6 = { startAdornment: /* @__PURE__ */ React.createElement(InputAdornment, { position: "start" }, "$") };
38
- $[2] = t6;
39
- } else t6 = $[2];
40
- let t7;
41
- if ($[3] !== t4 || $[4] !== t5) {
42
- t7 = {
43
- label: t4,
44
- variant: "outlined",
45
- margin: "none",
46
- size: "small",
47
- disabled: t5,
48
- fullWidth: true,
49
- InputProps: t6
24
+ let t5;
25
+ if ($[2] !== amountLocked || $[3] !== isFormDisabled || $[4] !== t) {
26
+ t5 = (t6) => {
27
+ const { input, meta } = t6;
28
+ return /* @__PURE__ */ React.createElement(UdpTextInput, {
29
+ label: t("Amount"),
30
+ value: String(input.value ?? ""),
31
+ error: meta.touched && meta.error ? meta.error : void 0,
32
+ onChange: input.onChange,
33
+ disabled: amountLocked,
34
+ required: !isFormDisabled
35
+ }, /* @__PURE__ */ React.createElement("span", { slot: "start" }, "$"));
50
36
  };
51
- $[3] = t4;
52
- $[4] = t5;
53
- $[5] = t7;
54
- } else t7 = $[5];
55
- const t8 = !isFormDisabled;
56
- let t9;
57
- if ($[6] !== amountValue || $[7] !== t7 || $[8] !== t8) {
58
- t9 = /* @__PURE__ */ React.createElement(Field, {
59
- component: FluentTextField,
60
- ComponentProps: t7,
37
+ $[2] = amountLocked;
38
+ $[3] = isFormDisabled;
39
+ $[4] = t;
40
+ $[5] = t5;
41
+ } else t5 = $[5];
42
+ let t6;
43
+ if ($[6] !== t3 || $[7] !== t4 || $[8] !== t5) {
44
+ t6 = /* @__PURE__ */ React.createElement(Field, {
61
45
  name: "cashAmount",
62
- initialValue: amountValue,
63
- required: t8
64
- });
65
- $[6] = amountValue;
66
- $[7] = t7;
67
- $[8] = t8;
68
- $[9] = t9;
69
- } else t9 = $[9];
70
- let t10;
71
- if ($[10] !== classes.formControl || $[11] !== t9) {
72
- t10 = /* @__PURE__ */ React.createElement(FormControl, { className: t3 }, t9);
73
- $[10] = classes.formControl;
74
- $[11] = t9;
75
- $[12] = t10;
76
- } else t10 = $[12];
77
- const t11 = classes.formControl;
78
- let t12;
79
- if ($[13] !== t) {
80
- t12 = t("Description");
81
- $[13] = t;
82
- $[14] = t12;
83
- } else t12 = $[14];
84
- let t13;
85
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
86
- t13 = {
46
+ initialValue: t3,
47
+ validate: t4
48
+ }, t5);
49
+ $[6] = t3;
50
+ $[7] = t4;
51
+ $[8] = t5;
52
+ $[9] = t6;
53
+ } else t6 = $[9];
54
+ let t7;
55
+ if ($[10] !== t) {
56
+ t7 = t("Description");
57
+ $[10] = t;
58
+ $[11] = t7;
59
+ } else t7 = $[11];
60
+ let t8;
61
+ if ($[12] !== isFormDisabled || $[13] !== t7) {
62
+ t8 = {
63
+ label: t7,
87
64
  maxLength: 256,
88
- autocomplete: "off"
65
+ autoResize: true,
66
+ disabled: isFormDisabled
89
67
  };
90
- $[15] = t13;
91
- } else t13 = $[15];
92
- let t14;
93
- if ($[16] !== t12) {
94
- t14 = {
95
- label: t12,
96
- variant: "outlined",
97
- margin: "normal",
98
- size: "small",
99
- disabled: false,
100
- fullWidth: true,
101
- autoComplete: "off",
102
- multiline: true,
103
- rows: 4,
104
- inputProps: t13
105
- };
106
- $[16] = t12;
107
- $[17] = t14;
108
- } else t14 = $[17];
109
- const t15 = t14;
110
- const t16 = !isFormDisabled;
111
- let t17;
112
- if ($[18] !== t15 || $[19] !== t16) {
113
- t17 = /* @__PURE__ */ React.createElement(Field, {
114
- component: FluentTextField,
115
- ComponentProps: t15,
68
+ $[12] = isFormDisabled;
69
+ $[13] = t7;
70
+ $[14] = t8;
71
+ } else t8 = $[14];
72
+ const t9 = !isFormDisabled;
73
+ let t10;
74
+ if ($[15] !== t8 || $[16] !== t9) {
75
+ t10 = /* @__PURE__ */ React.createElement(Field$1, {
76
+ component: UdpTextarea,
77
+ ComponentProps: t8,
116
78
  name: "cashDescription",
117
79
  initialValue: "",
118
- required: t16
80
+ required: t9,
81
+ onChange: _temp
119
82
  });
120
- $[18] = t15;
121
- $[19] = t16;
122
- $[20] = t17;
123
- } else t17 = $[20];
124
- let t18;
125
- if ($[21] !== classes.formControl || $[22] !== t17) {
126
- t18 = /* @__PURE__ */ React.createElement(FormControl, { className: t11 }, t17);
127
- $[21] = classes.formControl;
128
- $[22] = t17;
129
- $[23] = t18;
130
- } else t18 = $[23];
131
- let t19;
132
- if ($[24] !== t10 || $[25] !== t18) {
133
- t19 = /* @__PURE__ */ React.createElement(PaymentCard, null, t10, t18);
134
- $[24] = t10;
135
- $[25] = t18;
136
- $[26] = t19;
137
- } else t19 = $[26];
138
- return t19;
83
+ $[15] = t8;
84
+ $[16] = t9;
85
+ $[17] = t10;
86
+ } else t10 = $[17];
87
+ let t11;
88
+ if ($[18] !== t10 || $[19] !== t6) {
89
+ t11 = /* @__PURE__ */ React.createElement(UdpFlexbox, {
90
+ direction: "column",
91
+ gap: "sm",
92
+ wrap: "nowrap"
93
+ }, t6, t10);
94
+ $[18] = t10;
95
+ $[19] = t6;
96
+ $[20] = t11;
97
+ } else t11 = $[20];
98
+ return t11;
139
99
  };
100
+ function _temp() {}
140
101
  //#endregion
141
102
  export { CashForm };
142
103
 
@@ -1 +1 @@
1
- {"version":3,"file":"CashForm.mjs","names":["React","FormControl","makeStyles","InputAdornment","Field","FluentTextField","useTranslation","PaymentCard","PaymentDetails","useStyles","theme","formControl","width","marginBottom","formControlCheck","marginTop","marginLeft","CashFormProps","isFormDisabled","paymentDetails","amountValue","onStatusChange","paymentFormResult","CashForm","t0","$","_c","t1","t2","undefined","t","classes","t3","t4","t5","t6","Symbol","for","startAdornment","t7","label","variant","margin","size","disabled","fullWidth","InputProps","t8","t9","t10","t11","t12","t13","maxLength","autocomplete","t14","autoComplete","multiline","rows","inputProps","t15","t16","t17","t18","t19"],"sources":["../../../../src/utilities/form/paymentForm/CashForm.tsx"],"sourcesContent":["import React from 'react';\nimport {\n FormControl,\n makeStyles,\n InputAdornment\n} from '@material-ui/core';\nimport { Field } from '../Field';\nimport { FluentTextField } from '../../../UI/inputs/textField/FluentTextField'\nimport { useTranslation } from 'react-i18next';\nimport { PaymentCard } from './PaymentCard';\nimport { PaymentDetails } from './AccountPayment.model';\n\nconst useStyles = makeStyles(theme => ({\n formControl: {\n width: '100%',\n marginBottom: '10px',\n },\n formControlCheck: {\n width: '100%',\n marginTop: '5px',\n marginLeft: '3px',\n },\n}));\n\ninterface CashFormProps {\n isFormDisabled?: boolean;\n paymentDetails: PaymentDetails;\n amountValue?: string | number | null | undefined;\n onStatusChange?: (paymentFormResult: boolean) => void;\n}\n\nexport const CashForm = ({\n isFormDisabled = false,\n paymentDetails,\n amountValue = null,\n onStatusChange\n}: CashFormProps) => {\n const { t } = useTranslation();\n const classes = useStyles();\n\n return (\n <PaymentCard>\n <FormControl className={classes.formControl}>\n <Field\n // @ts-ignore\n component={FluentTextField}\n ComponentProps={{\n // @ts-ignore\n label: t(\"Amount\"),\n variant: \"outlined\",\n margin: \"none\",\n size: \"small\",\n disabled: isFormDisabled || amountValue || false,\n fullWidth: true,\n InputProps: {\n startAdornment: (\n <InputAdornment position=\"start\">$</InputAdornment>\n ),\n },\n }}\n name=\"cashAmount\"\n initialValue={amountValue}\n required={!isFormDisabled}\n />\n </FormControl>\n\n <FormControl className={classes.formControl}>\n <Field\n // @ts-ignore\n component={FluentTextField}\n ComponentProps={\n {\n label: t(\"Description\"),\n variant: 'outlined',\n margin: 'normal',\n size: 'small',\n disabled: false,\n fullWidth: true,\n autoComplete: 'off',\n multiline: true,\n rows: 4,\n inputProps: {\n maxLength: 256,\n autocomplete: 'off',\n },\n } as any\n }\n name=\"cashDescription\"\n initialValue=\"\"\n required={!isFormDisabled}\n />\n </FormControl>\n </PaymentCard>\n );\n}\n"],"mappings":";;;;;;;;AAYA,MAAMS,YAAYP,YAAWQ,WAAU;CACrCC,aAAa;EACXC,OAAO;EACPC,cAAc;EACf;CACDC,kBAAkB;EAChBF,OAAO;EACPG,WAAW;EACXC,YAAY;EACd;CACD,EAAE;AASH,MAAaO,YAAWC,OAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAC,MAAA,EAAAR,gBAAAS,IAAAP,aAAAQ,OAAAJ;CACvB,MAAAN,iBAAAS,OAAAE,KAAAA,IAAA,QAAAF;CAEA,MAAAP,cAAAQ,OAAAC,KAAAA,IAAA,OAAAD;CAGA,MAAA,EAAAE,MAAcxB,gBAAgB;CAC9B,MAAAyB,UAAgBtB,WAAW;CAIC,MAAAuB,KAAAD,QAAOpB;CAAY,IAAAsB;AAAA,KAAAR,EAAA,OAAAK,GAAA;AAM9BG,OAAAH,EAAE,SAAS;AAAAL,IAAA,KAAAK;AAAAL,IAAA,KAAAQ;OAAAA,MAAAR,EAAA;CAIR,MAAAS,KAAAhB,kBAAAE,eAAA;CAAsC,IAAAe;AAAA,KAAAV,EAAA,OAAAW,OAAAC,IAAA,4BAAA,EAAA;AAEpCF,OAAA,EAAAG,gBAER,sBAAA,cAAC,gBAAD,EAAyB,UAAA,SAAV,EAAkB,IAAlB,EAElB;AAAAb,IAAA,KAAAU;OAAAA,MAAAV,EAAA;CAAA,IAAAc;AAAA,KAAAd,EAAA,OAAAQ,MAAAR,EAAA,OAAAS,IAAA;AAZaK,OAAA;GAAAC,OAEPP;GAAWQ,SACT;GAAUC,QACX;GAAMC,MACR;GAAOC,UACHV;GAAsCW,WACrC;GAAIC,YACHX;GAKb;AAAAV,IAAA,KAA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,EAAA;CAdD,MAAAmC,MAAAL;CAkBQ,MAAAM,MAAA,CAAC3C;CAAc,IAAA4C;AAAA,KAAArC,EAAA,QAAAmC,OAAAnC,EAAA,QAAAoC,KAAA;AAtB3BC,QAAA,sBAAA,cAAC,OAAD;GAEazD,WAAAA;GAET,gBAAAuD;GAgBG,MAAA;GACQ,cAAA;GACH,UAAAC;GACV,CAAA;AAAApC,IAAA,MAAAmC;AAAAnC,IAAA,MAAAoC;AAAApC,IAAA,MAAAqC;OAAAA,OAAArC,EAAA;CAAA,IAAAsC;AAAA,KAAAtC,EAAA,QAAAM,QAAApB,eAAAc,EAAA,QAAAqC,KAAA;AAxBJC,QAAA,sBAAA,cAAC,aAAD,EAAwB,WAAAb,KAyBV,EAxBZY,IAwBY;AAAArC,IAAA,MAAAM,QAAApB;AAAAc,IAAA,MAAAqC;AAAArC,IAAA,MAAAsC;OAAAA,OAAAtC,EAAA;CAAA,IAAAuC;AAAA,KAAAvC,EAAA,QAAAwB,OAAAxB,EAAA,QAAAsC,KAAA;AAlDhBC,QAAA,sBAAA,cAAC,aAAA,MACCf,KAwBAc,IA0BY;AAAAtC,IAAA,MAAAwB;AAAAxB,IAAA,MAAAsC;AAAAtC,IAAA,MAAAuC;OAAAA,OAAAvC,EAAA;AAAA,QAnDduC"}
1
+ {"version":3,"file":"CashForm.mjs","names":["React","useTranslation","Field","FinalField","UdpFlexbox","UdpTextInput","UdpTextarea","PaymentDetails","CashFormProps","isFormDisabled","paymentDetails","amountValue","onStatusChange","paymentFormResult","CashForm","t0","$","_c","t1","t2","undefined","t","amountLocked","t3","String","t4","value","t5","t6","input","meta","touched","error","onChange","t7","t8","label","maxLength","autoResize","disabled","t9","t10","ComponentType","_temp","t11"],"sources":["../../../../src/utilities/form/paymentForm/CashForm.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Field as FinalField } from 'react-final-form';\nimport { Field } from '../Field';\nimport { UdpFlexbox } from '../../../UI/fluent-web-components/UdpFlexbox';\nimport { UdpTextInput } from '../../../UI/fluent-web-components/UdpTextInput';\nimport { UdpTextarea } from '../../../UI/fluent-web-components/UdpTextarea';\nimport { PaymentDetails } from './AccountPayment.model';\n\ninterface CashFormProps {\n isFormDisabled?: boolean;\n paymentDetails: PaymentDetails;\n amountValue?: string | number | null | undefined;\n onStatusChange?: (paymentFormResult: boolean) => void;\n}\n\nexport const CashForm = ({\n isFormDisabled = false,\n amountValue = null,\n}: CashFormProps) => {\n const { t } = useTranslation();\n const amountLocked = isFormDisabled || amountValue != null;\n\n return (\n <UdpFlexbox direction=\"column\" gap=\"sm\" wrap=\"nowrap\">\n <FinalField\n name=\"cashAmount\"\n initialValue={String(amountValue ?? '')}\n // Raw FinalField, so the Field wrapper's required validation is\n // replicated here (skipped when the amount is preset/locked).\n validate={(value) => (!amountLocked && !value ? 'Required' : undefined)}\n >\n {({ input, meta }) => (\n <UdpTextInput\n label={t('Amount')}\n value={String(input.value ?? '')}\n error={meta.touched && meta.error ? meta.error : undefined}\n onChange={input.onChange}\n disabled={amountLocked}\n required={!isFormDisabled}\n >\n <span slot=\"start\">$</span>\n </UdpTextInput>\n )}\n </FinalField>\n\n <Field\n component={UdpTextarea as React.ComponentType<any>}\n ComponentProps={{\n label: t('Description'),\n maxLength: 256,\n autoResize: true,\n disabled: isFormDisabled,\n }}\n name=\"cashDescription\"\n initialValue=\"\"\n required={!isFormDisabled}\n onChange={() => {}}\n />\n </UdpFlexbox>\n );\n};\n"],"mappings":";;;;;;;;;AAgBA,MAAac,YAAWC,OAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAC,MAAA,EAAAR,gBAAAS,IAAAP,aAAAQ,OAAAJ;CACvB,MAAAN,iBAAAS,OAAAE,KAAAA,IAAA,QAAAF;CACA,MAAAP,cAAAQ,OAAAC,KAAAA,IAAA,OAAAD;CAEA,MAAA,EAAAE,MAAcpB,gBAAgB;CAC9B,MAAAqB,eAAqBb,kBAAkBE,eAAe;CAMlC,MAAA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AAAC,OACPF;GAAgBG,WACZ;GAAGC,YACF;GAAIC,UACN9B;GACX;AAAAO,IAAA,MAAAP;AAAAO,IAAA,MAAAkB;AAAAlB,IAAA,MAAAmB;OAAAA,MAAAnB,EAAA;CAGS,MAAAwB,KAAA,CAAC/B;CAAc,IAAAgC;AAAA,KAAAzB,EAAA,QAAAmB,MAAAnB,EAAA,QAAAwB,IAAA;AAV3BC,QAAA,sBAAA,cAAC,SAAD;GACa,WAAAnC;GACK,gBAAA6B;GAMX,MAAA;GACQ,cAAA;GACH,UAAAK;GACA,UAAAG;GACV,CAAA;AAAA3B,IAAA,MAAAmB;AAAAnB,IAAA,MAAAwB;AAAAxB,IAAA,MAAAyB;OAAAA,OAAAzB,EAAA;CAAA,IAAA4B;AAAA,KAAA5B,EAAA,QAAAyB,OAAAzB,EAAA,QAAAY,IAAA;AAlCJgB,QAAA,sBAAA,cAAC,YAAD;GAAsB,WAAA;GAAa,KAAA;GAAU,MAAA;GAmChC,EAlCXhB,IAqBAa,IAaW;AAAAzB,IAAA,MAAAyB;AAAAzB,IAAA,MAAAY;AAAAZ,IAAA,MAAA4B;OAAAA,OAAA5B,EAAA;AAAA,QAnCb4B;;AARoB,SAAAD,QAAA"}
@@ -1,10 +1,11 @@
1
+ import React from 'react';
1
2
  import { PaymentDetails, PaymentMethodData } from './AccountPayment.model';
2
3
  import { PaymentVendorFactoryEnum } from '../../../enums/paymentVendorFactoryEnum';
3
4
  interface CreditCardFormProps {
4
5
  isFormDisabled?: boolean;
5
6
  paymentDetails: PaymentDetails;
6
7
  externalId?: string;
7
- tenantId: string;
8
+ tenantId?: string;
8
9
  providerType?: PaymentVendorFactoryEnum | null;
9
10
  providerProps?: any;
10
11
  isHostedPaymentPage?: boolean | null;
@@ -13,30 +14,18 @@ interface CreditCardFormProps {
13
14
  enabled?: boolean | null;
14
15
  data?: PaymentMethodData;
15
16
  actionLabel?: string;
17
+ /** When false, the manual card form hides its "save this card" checkbox. */
18
+ allowSaveMethod?: boolean;
16
19
  setSelectedPaymentAccount?: (paymentAccount: any) => void;
17
20
  onStatusChange?: (paymentFormResult: any) => void;
18
21
  }
19
22
  /**
20
- * CreditCardForm component handles the rendering of a credit card payment form.
21
- * It supports both hosted payment pages and direct credit card input forms.
22
- *
23
- * @param {boolean} isFormDisabled - Flag to disable the form.
24
- * @param {object} data - Data related to the payment form.
25
- * @param {string} externalId - External identifier for the payment form.
26
- * @param {object} paymentDetails - Details of the payment.
27
- * @param {string|null} providerType - Type of the payment provider.
28
- * @param {object|null} providerProps - Properties for the payment provider.
29
- * @param {boolean} isHostedPaymentPage - Flag to indicate if it is a hosted payment page.
30
- * @param {boolean} hasReadPropertiesError - Flag to indicate if there was an error reading properties.
31
- * @param {string} readPropertiesMessageError - Error message for reading properties.
32
- * @param {boolean} enabled - Flag to indicate if the form is enabled.
33
- * @param {function} onStatusChange - Callback function to handle status changes.
34
- * @param {function} setSelectedPaymentAccount - Callback function to set the selected payment account.
35
- * @param {string} actionLabel - Label for the action button.
36
- * @param {object} restProps - Additional properties.
37
- *
38
- * @returns {JSX.Element} The rendered CreditCardForm component.
23
+ * Credit-card branch of the payment form. Shows:
24
+ * - A radio list of saved cards (when any exist) + an "Other / new card"
25
+ * option, per D3 of REFACTOR_PLAN.md
26
+ * - Either the hosted-payment iframe (when `isHostedPaymentPage`) or the
27
+ * manual `NewCreditCardForm` once the user picks "Other".
39
28
  */
40
- export declare const CreditCardForm: ({ isFormDisabled, data, externalId, paymentDetails, providerType, providerProps, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, enabled, actionLabel, onStatusChange, setSelectedPaymentAccount, ...restProps }: CreditCardFormProps) => any;
29
+ export declare const CreditCardForm: ({ isFormDisabled, data, externalId, paymentDetails, providerType, providerProps, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, actionLabel, allowSaveMethod, onStatusChange, setSelectedPaymentAccount, }: CreditCardFormProps) => React.JSX.Element;
41
30
  export {};
42
31
  //# sourceMappingURL=CreditCardForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CreditCardForm.d.ts","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/CreditCardForm.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AA+BnF,UAAU,mBAAmB;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC,0BAA0B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1D,cAAc,CAAC,EAAE,CAAC,iBAAiB,EAAE,GAAG,KAAK,IAAI,CAAC;CACnD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,yQA0G1B,CAAC"}
1
+ {"version":3,"file":"CreditCardForm.d.ts","sourceRoot":"","sources":["../../../../src/utilities/form/paymentForm/CreditCardForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAM5D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAQnF,UAAU,mBAAmB;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC,0BAA0B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yBAAyB,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1D,cAAc,CAAC,EAAE,CAAC,iBAAiB,EAAE,GAAG,KAAK,IAAI,CAAC;CACnD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,kRA8I1B,CAAC"}
@@ -1,103 +1,97 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import React, { useState, useEffect } from 'react';
13
- import { Box, makeStyles } from '@material-ui/core';
14
- import { UnityFluentIcon } from '../../iconLibrary/UnityFluentIcon';
15
- import { getIconFromName } from '../../tree/TreeUtilities';
1
+ import React, { useEffect, useMemo, useState } from 'react';
16
2
  import { useTranslation } from 'react-i18next';
3
+ import { UdpFlexbox } from '../../../UI/fluent-web-components/UdpFlexbox';
4
+ import { UdpRadioGroup } from '../../../UI/fluent-web-components/UdpRadioGroup';
5
+ import { UdpSpinner } from '../../../UI/fluent-web-components/UdpSpinner';
17
6
  import { usePaymentProviderForm } from './usePaymentProviderForm';
18
7
  import { PaymentTenderTypeEnum } from '../../../enums/paymentTenderTypeEnum';
19
- import { LinearProgress } from '../../../UI/loading/LinearProgress';
20
- import { useUser } from '../../auth/useUser';
21
- import { useAxiosGet } from '../../useAxiosGet';
22
- import PaymentDropdown from './PaymentDropdown';
23
- import { FluentButton } from '../../../UI/inputs/buttons/FluentButton';
8
+ import { useApiQuery } from '../../useApiQuery';
24
9
  import { HostedPaymentError } from './HostedPaymentError';
25
10
  import { NewCreditCardForm } from './NewCreditCardForm';
26
11
  import { ConfigService } from '../../../configService';
27
- const useStyles = makeStyles(theme => ({
28
- cardNumber: {
29
- width: '100%',
30
- marginBottom: '10px'
31
- },
32
- formControl: {
33
- width: '100%',
34
- '&.cardNumber': {
35
- marginBottom: '10px',
36
- },
37
- '&.submitControl': {
38
- marginTop: '35px',
39
- },
40
- },
41
- formControlCheck: {
42
- width: '100%',
43
- marginTop: '5px',
44
- marginLeft: '3px',
45
- },
46
- }));
12
+ const OTHER_RADIO_VALUE = '__other__';
47
13
  /**
48
- * CreditCardForm component handles the rendering of a credit card payment form.
49
- * It supports both hosted payment pages and direct credit card input forms.
50
- *
51
- * @param {boolean} isFormDisabled - Flag to disable the form.
52
- * @param {object} data - Data related to the payment form.
53
- * @param {string} externalId - External identifier for the payment form.
54
- * @param {object} paymentDetails - Details of the payment.
55
- * @param {string|null} providerType - Type of the payment provider.
56
- * @param {object|null} providerProps - Properties for the payment provider.
57
- * @param {boolean} isHostedPaymentPage - Flag to indicate if it is a hosted payment page.
58
- * @param {boolean} hasReadPropertiesError - Flag to indicate if there was an error reading properties.
59
- * @param {string} readPropertiesMessageError - Error message for reading properties.
60
- * @param {boolean} enabled - Flag to indicate if the form is enabled.
61
- * @param {function} onStatusChange - Callback function to handle status changes.
62
- * @param {function} setSelectedPaymentAccount - Callback function to set the selected payment account.
63
- * @param {string} actionLabel - Label for the action button.
64
- * @param {object} restProps - Additional properties.
65
- *
66
- * @returns {JSX.Element} The rendered CreditCardForm component.
14
+ * Credit-card branch of the payment form. Shows:
15
+ * - A radio list of saved cards (when any exist) + an "Other / new card"
16
+ * option, per D3 of REFACTOR_PLAN.md
17
+ * - Either the hosted-payment iframe (when `isHostedPaymentPage`) or the
18
+ * manual `NewCreditCardForm` once the user picks "Other".
67
19
  */
68
- export const CreditCardForm = (_a) => {
69
- var { isFormDisabled = false, data, externalId, paymentDetails, providerType = null, providerProps = null, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, enabled, actionLabel, onStatusChange, setSelectedPaymentAccount } = _a, restProps = __rest(_a, ["isFormDisabled", "data", "externalId", "paymentDetails", "providerType", "providerProps", "isHostedPaymentPage", "hasReadPropertiesError", "readPropertiesMessageError", "enabled", "actionLabel", "onStatusChange", "setSelectedPaymentAccount"]);
20
+ export const CreditCardForm = ({ isFormDisabled = false, data, externalId, paymentDetails, providerType = null, providerProps = null, isHostedPaymentPage, hasReadPropertiesError, readPropertiesMessageError, actionLabel, allowSaveMethod = true, onStatusChange, setSelectedPaymentAccount, }) => {
70
21
  const { t } = useTranslation();
71
- const classes = useStyles();
72
- const user = useUser();
73
- const paymentProviderForm = usePaymentProviderForm(PaymentTenderTypeEnum.CreditCard, providerType, providerProps, onStatusChange, paymentDetails, data);
74
- const [showHostedPaymentPage, setShowHostedPaymentPage] = useState(false);
75
- const [creditCardNumberInput, setCreditCardNumberInput] = useState('');
76
- // @ts-ignore
77
- const [{ data: paymentAccounts, loading: loadingPaymentAccounts }] = useAxiosGet(ConfigService.pgV1ApiUrl, `PaymentTokenCreditCard/${externalId}`, {}, false);
78
- const handleShowHostedPaymentPage = () => {
79
- setShowHostedPaymentPage(true);
80
- onStatusChange && onStatusChange({ isValid: false });
81
- };
22
+ const { data: paymentAccounts, isLoading: loadingPaymentAccounts } = useApiQuery(ConfigService.pgV1ApiUrl, `PaymentTokenCreditCard/${externalId}`, {}, { enabled: Boolean(externalId) });
23
+ const savedMethods = paymentAccounts !== null && paymentAccounts !== void 0 ? paymentAccounts : [];
24
+ const hasSavedMethods = savedMethods.length > 0;
25
+ const [selected, setSelected] = useState(OTHER_RADIO_VALUE);
26
+ // Default to the first saved method, or "Other" if none on file.
27
+ useEffect(() => {
28
+ var _a;
29
+ setSelected(((_a = savedMethods[0]) === null || _a === void 0 ? void 0 : _a.paymentTokenID) || OTHER_RADIO_VALUE);
30
+ }, [savedMethods]);
31
+ // Push the selected saved token up so the submit flow can include it.
32
+ useEffect(() => {
33
+ if (selected && selected !== OTHER_RADIO_VALUE) {
34
+ const sel = savedMethods.find((s) => (s === null || s === void 0 ? void 0 : s.paymentTokenID) === selected);
35
+ setSelectedPaymentAccount === null || setSelectedPaymentAccount === void 0 ? void 0 : setSelectedPaymentAccount(sel || null);
36
+ }
37
+ else {
38
+ setSelectedPaymentAccount === null || setSelectedPaymentAccount === void 0 ? void 0 : setSelectedPaymentAccount(null);
39
+ }
40
+ }, [selected, savedMethods, setSelectedPaymentAccount]);
41
+ const showOtherForm = selected === OTHER_RADIO_VALUE;
42
+ // Report validity to the parent picker so submit can be enabled. The hosted
43
+ // iframe component reports its own granular status; we only set a coarse
44
+ // "ready to submit" signal here.
82
45
  useEffect(() => {
83
- const showHostedPaymentPageByDefault = (isHostedPaymentPage && (paymentAccounts === null || paymentAccounts === void 0 ? void 0 : paymentAccounts.length) > 0);
84
- const enableSubmitForm = (isHostedPaymentPage === false || (paymentAccounts === null || paymentAccounts === void 0 ? void 0 : paymentAccounts.length) > 0);
85
- setShowHostedPaymentPage(!showHostedPaymentPageByDefault);
86
- onStatusChange && onStatusChange({ isValid: enableSubmitForm });
87
- }, [isHostedPaymentPage, paymentAccounts]);
46
+ if (!showOtherForm) {
47
+ onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange({ isValid: true });
48
+ return;
49
+ }
50
+ if (isHostedPaymentPage === false) {
51
+ // Manual entry — RFF blocks invalid submits at submit time.
52
+ onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange({ isValid: true });
53
+ }
54
+ else {
55
+ // Hosted iframe — wait for the iframe to report a token.
56
+ onStatusChange === null || onStatusChange === void 0 ? void 0 : onStatusChange({ isValid: false });
57
+ }
58
+ // onStatusChange is intentionally omitted from deps; consumers may pass
59
+ // unstable references and we only want to fire when the selection / mode
60
+ // changes.
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
62
+ }, [showOtherForm, isHostedPaymentPage]);
63
+ const paymentProviderForm = usePaymentProviderForm(PaymentTenderTypeEnum.CreditCard, providerType, providerProps, onStatusChange, paymentDetails, data);
64
+ const items = useMemo(() => {
65
+ const savedItems = savedMethods.map((m) => {
66
+ var _a;
67
+ var _b, _c;
68
+ const nickname = (_b = (_a = m === null || m === void 0 ? void 0 : m.paymentToken) === null || _a === void 0 ? void 0 : _a.nickname) !== null && _b !== void 0 ? _b : t('Saved card');
69
+ const exp = (m === null || m === void 0 ? void 0 : m.expirationDate)
70
+ ? new Date(m.expirationDate).toLocaleDateString('en-US', {
71
+ month: '2-digit',
72
+ year: '2-digit',
73
+ })
74
+ : null;
75
+ return {
76
+ label: exp ? `${nickname} (${exp})` : nickname,
77
+ value: String((_c = m === null || m === void 0 ? void 0 : m.paymentTokenID) !== null && _c !== void 0 ? _c : ''),
78
+ };
79
+ });
80
+ return [
81
+ ...savedItems,
82
+ {
83
+ label: actionLabel || t('Use a different card'),
84
+ value: OTHER_RADIO_VALUE,
85
+ },
86
+ ];
87
+ }, [savedMethods, actionLabel, t]);
88
88
  if (loadingPaymentAccounts) {
89
- return (
90
- // @ts-ignore
91
- React.createElement(Box, { sx: { width: '100%' } }, React.createElement(LinearProgress, null)));
92
- }
93
- if (!showHostedPaymentPage && (paymentAccounts === null || paymentAccounts === void 0 ? void 0 : paymentAccounts.length) > 0) {
94
- return (React.createElement(React.Fragment, null, React.createElement(PaymentDropdown, { paymentAccounts: paymentAccounts, setSelectedPaymentAccount: setSelectedPaymentAccount, paymentType: PaymentTenderTypeEnum.CreditCard }), React.createElement(Box, { textAlign: "center", mt: 3 }, React.createElement(FluentButton, { variant: "outlined", color: "primary", onClick: handleShowHostedPaymentPage, size: "small", startIcon: React.createElement(UnityFluentIcon, { icon: getIconFromName('PaymentCardIcon') }), style: { padding: "18px 20px" } }, actionLabel || t('Enter Card Details')))));
89
+ return (React.createElement(UdpFlexbox, { direction: "row", justify: "center", align: "center" }, React.createElement(UdpSpinner, { size: "medium" })));
95
90
  }
96
91
  if (hasReadPropertiesError) {
97
- return (React.createElement(HostedPaymentError, { error: "Error", message: readPropertiesMessageError || t('Unknown error') }));
92
+ return (React.createElement(HostedPaymentError, { error: t('Configuration error'), message: readPropertiesMessageError || t('Unknown error') }));
98
93
  }
99
- return showHostedPaymentPage &&
100
- isHostedPaymentPage ?
101
- paymentProviderForm : (React.createElement(NewCreditCardForm, { isFormDisabled: isFormDisabled, classes: classes, paymentDetails: paymentDetails, creditCardNumberInput: creditCardNumberInput, setCreditCardNumberInput: setCreditCardNumberInput }));
94
+ return (React.createElement(UdpFlexbox, { direction: "column", gap: "sm", wrap: "nowrap" }, hasSavedMethods && (React.createElement(UdpRadioGroup, { label: t('Saved cards'), name: "savedCreditCard", orientation: "vertical", disabled: isFormDisabled, value: selected, items: items, onChange: (e) => setSelected(String(e.target.value)) })), showOtherForm &&
95
+ (isHostedPaymentPage ? (paymentProviderForm) : (React.createElement(NewCreditCardForm, { isFormDisabled: isFormDisabled, paymentDetails: paymentDetails, allowSaveMethod: allowSaveMethod })))));
102
96
  };
103
97
  //# sourceMappingURL=CreditCardForm.js.map