@afosto/checkout-ui 0.0.11 → 0.0.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 (51) hide show
  1. package/dist/CheckoutAddressFields/CheckoutAddressFields.d.ts +2 -0
  2. package/dist/CheckoutAddressFields/CheckoutAddressFields.d.ts.map +1 -1
  3. package/dist/CheckoutAddressFields/CheckoutAddressFields.js +155 -130
  4. package/dist/CheckoutAddressSection/CheckoutAddressSection.d.ts +6 -2
  5. package/dist/CheckoutAddressSection/CheckoutAddressSection.d.ts.map +1 -1
  6. package/dist/CheckoutAddressSection/CheckoutAddressSection.js +82 -71
  7. package/dist/CheckoutForm/CheckoutForm.d.ts.map +1 -1
  8. package/dist/CheckoutForm/CheckoutForm.js +146 -132
  9. package/dist/CheckoutInformationStep/CheckoutInformationStep.d.ts +0 -2
  10. package/dist/CheckoutInformationStep/CheckoutInformationStep.d.ts.map +1 -1
  11. package/dist/CheckoutInformationStep/CheckoutInformationStep.js +30 -37
  12. package/dist/constants/addressDefaultValues.d.ts +1 -0
  13. package/dist/constants/addressDefaultValues.d.ts.map +1 -1
  14. package/dist/constants/addressDefaultValues.js +1 -0
  15. package/dist/constants/addressFields.d.ts.map +1 -1
  16. package/dist/constants/addressFields.js +6 -5
  17. package/dist/constants/addressValidationSchema.d.ts +10 -2
  18. package/dist/constants/addressValidationSchema.d.ts.map +1 -1
  19. package/dist/constants/addressValidationSchema.js +58 -46
  20. package/dist/constants/analyticsEvents.d.ts +7 -0
  21. package/dist/constants/analyticsEvents.d.ts.map +1 -1
  22. package/dist/constants/index.js +8 -8
  23. package/dist/hooks/useCheckoutAddressOptions.d.ts +3 -1
  24. package/dist/hooks/useCheckoutAddressOptions.d.ts.map +1 -1
  25. package/dist/hooks/useCheckoutAddressOptions.js +64 -57
  26. package/dist/hooks/useCheckoutCart.d.ts.map +1 -1
  27. package/dist/hooks/useCheckoutForm.d.ts.map +1 -1
  28. package/dist/hooks/useCheckoutForm.js +45 -41
  29. package/dist/hooks/useCheckoutOrder.d.ts.map +1 -1
  30. package/dist/index.d.ts +0 -2
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +426 -428
  33. package/dist/operations/cartOperations.d.ts.map +1 -1
  34. package/dist/operations/cartOperations.js +120 -108
  35. package/dist/operations/orderOperations.d.ts.map +1 -1
  36. package/dist/operations/orderOperations.js +123 -111
  37. package/dist/steps/informationStep.d.ts +0 -1
  38. package/dist/steps/informationStep.d.ts.map +1 -1
  39. package/dist/steps/informationStep.js +234 -238
  40. package/dist/types.d.ts +1 -2
  41. package/dist/types.d.ts.map +1 -1
  42. package/dist/utils/createAddressValidationSchema.d.ts +4 -1
  43. package/dist/utils/createAddressValidationSchema.d.ts.map +1 -1
  44. package/dist/utils/createAddressValidationSchema.js +8 -8
  45. package/package.json +1 -1
  46. package/dist/CheckoutSalutationSection/CheckoutSalutationSection.d.ts +0 -13
  47. package/dist/CheckoutSalutationSection/CheckoutSalutationSection.d.ts.map +0 -1
  48. package/dist/CheckoutSalutationSection/CheckoutSalutationSection.js +0 -26
  49. package/dist/CheckoutSalutationSection/index.d.ts +0 -3
  50. package/dist/CheckoutSalutationSection/index.d.ts.map +0 -1
  51. package/dist/CheckoutSalutationSection/index.js +0 -4
@@ -1,27 +1,33 @@
1
- import { jsxs as V, jsx as r } from "react/jsx-runtime";
2
- import { useFormContext as j, Collapse as f } from "@afosto/components";
3
- import { CheckoutAddressCard as q } from "../CheckoutAddressCard/CheckoutAddressCard.js";
4
- import { CheckoutSection as D } from "../CheckoutSection/CheckoutSection.js";
5
- import { CheckoutSectionHeader as H } from "../CheckoutSectionHeader/CheckoutSectionHeader.js";
6
- import { CheckoutAddressFields as O } from "../CheckoutAddressFields/CheckoutAddressFields.js";
7
- import { string as e, object as p } from "yup";
8
- import { useState as $, useEffect as z } from "react";
9
- import { isDefined as B } from "@afosto/utils";
10
- import { useCheckout as I } from "../CheckoutStateProvider/CheckoutStateProvider.js";
11
- const Z = {
12
- givenName: e().required(),
13
- additionalName: e().nullable(),
14
- familyName: e().required(),
15
- country: p().nullable().required(),
16
- postalCode: e(),
17
- premiseNumber: e().numbersOnly(),
18
- premiseNumberSuffix: e().maxLength(15),
19
- addressLine1: e(),
20
- addressLine2: e(),
21
- administrativeArea: p().nullable(),
22
- thoroughfare: e(),
23
- locality: e()
24
- }, G = {
1
+ import { jsxs as B, jsx as t } from "react/jsx-runtime";
2
+ import { useFormContext as H, Collapse as b } from "@afosto/components";
3
+ import { CheckoutAddressCard as O } from "../CheckoutAddressCard/CheckoutAddressCard.js";
4
+ import { CheckoutSection as R } from "../CheckoutSection/CheckoutSection.js";
5
+ import { CheckoutSectionHeader as $ } from "../CheckoutSectionHeader/CheckoutSectionHeader.js";
6
+ import { CheckoutAddressFields as z } from "../CheckoutAddressFields/CheckoutAddressFields.js";
7
+ import { string as e, object as y } from "yup";
8
+ import { useState as I, useEffect as Z } from "react";
9
+ import { isDefined as G } from "@afosto/utils";
10
+ import { useCheckout as J } from "../CheckoutStateProvider/CheckoutStateProvider.js";
11
+ const K = (r) => {
12
+ const { isSalutationRequired: o = !1, salutation: i = !1 } = r || {};
13
+ return {
14
+ ...i ? {
15
+ salutation: o ? e().required() : e().nullable()
16
+ } : {},
17
+ givenName: e().required(),
18
+ additionalName: e().nullable(),
19
+ familyName: e().required(),
20
+ country: y().nullable().required(),
21
+ postalCode: e(),
22
+ premiseNumber: e().numbersOnly(),
23
+ premiseNumberSuffix: e().maxLength(15),
24
+ addressLine1: e(),
25
+ addressLine2: e(),
26
+ administrativeArea: y().nullable(),
27
+ thoroughfare: e(),
28
+ locality: e()
29
+ };
30
+ }, Q = {
25
31
  addressFields: {
26
32
  additionalName: "Prefix",
27
33
  addressLine2: "Address line 2",
@@ -36,83 +42,88 @@ const Z = {
36
42
  premiseNumber: "House number",
37
43
  premiseNumberSuffix: "Suffix",
38
44
  province: "Province",
45
+ salutation: "Salutation",
46
+ salutationMr: "Mr.",
47
+ salutationMrs: "Ms.",
39
48
  state: "State",
40
49
  suburb: "Suburb",
41
50
  thoroughfare: "Street",
42
51
  zip: "ZIP code"
43
52
  }
44
- }, re = (C) => {
53
+ }, de = (r) => {
45
54
  const {
46
- address: S,
47
- addressCardProps: b = {},
48
- availableCountryCodes: y = [],
49
- canEdit: F = !0,
50
- checkFieldsState: g = !1,
51
- children: k,
55
+ address: o,
56
+ addressCardProps: i = {},
57
+ availableCountryCodes: F = [],
58
+ canEdit: g = !0,
59
+ checkFieldsState: k = !1,
60
+ children: v,
52
61
  name: s,
53
62
  onChangeCountry: A,
54
- onChangeValidationSchema: v,
55
- showAddressCard: o,
63
+ onChangeValidationSchema: w,
64
+ showAddressCard: n,
56
65
  showOrganisationField: N = !1,
57
- title: d,
58
- translations: i = {},
59
- validationSchema: w = Z,
60
- ...x
61
- } = C, [n, t] = $(
62
- o ?? !1
63
- ), { translations: l } = I(), { clearErrors: c, setValue: a, trigger: m, watch: P } = j(), [E] = P([s]), L = S ?? E, u = g && !B(o);
64
- z(() => {
65
- u ? (async () => {
66
+ title: l,
67
+ translations: c = {},
68
+ validationSchema: x,
69
+ ...P
70
+ } = r, [u, a] = I(
71
+ n ?? !1
72
+ ), { settings: m, translations: h } = J(), { isSalutationRequired: q = !1, salutation: E = !1 } = m || {}, { clearErrors: f, setValue: d, trigger: p, watch: L } = H(), [T] = L([s]), V = o ?? T, C = k && !G(n), M = !!E, j = x ?? K(m);
73
+ Z(() => {
74
+ C ? (async () => {
66
75
  try {
67
- const h = await m(s);
68
- c(s), h || a(`${s}.isDirty`, !0), t(h);
76
+ const S = await p(s);
77
+ f(s), S || d(`${s}.isDirty`, !0), a(S);
69
78
  } catch {
70
- t(!1);
79
+ a(!1);
71
80
  }
72
- })() : t(!1);
73
- }, [c, s, a, u, m]);
74
- const T = {
75
- ...l?.addressSection || {},
76
- ...i || {},
81
+ })() : a(!1);
82
+ }, [f, s, d, C, p]);
83
+ const D = {
84
+ ...h?.addressSection || {},
85
+ ...c || {},
77
86
  addressFields: {
78
- ...G.addressFields || {},
79
- ...l?.addressFields || {},
80
- ...i?.addressFields || {}
87
+ ...Q.addressFields || {},
88
+ ...h?.addressFields || {},
89
+ ...c?.addressFields || {}
81
90
  }
82
91
  };
83
- return /* @__PURE__ */ V(D, { ...x, children: [
84
- /* @__PURE__ */ r(H, { title: d }),
85
- /* @__PURE__ */ r(f, { in: n, children: /* @__PURE__ */ r(
86
- q,
92
+ return /* @__PURE__ */ B(R, { ...P, children: [
93
+ /* @__PURE__ */ t($, { title: l }),
94
+ /* @__PURE__ */ t(b, { in: u, children: /* @__PURE__ */ t(
95
+ O,
87
96
  {
88
- address: L,
89
- canEdit: F,
97
+ address: V,
98
+ canEdit: g,
90
99
  onEdit: () => {
91
- t(!1), a(`${s}.isDirty`, !0);
100
+ a(!1), d(`${s}.isDirty`, !0);
92
101
  }
93
102
  }
94
103
  ) }),
95
- /* @__PURE__ */ r(f, { in: !n, children: /* @__PURE__ */ r(
96
- O,
104
+ /* @__PURE__ */ t(b, { in: !u, children: /* @__PURE__ */ t(
105
+ z,
97
106
  {
98
107
  addressCardProps: {
99
108
  editComponentType: "link",
100
- ...b
109
+ ...i
101
110
  },
102
111
  name: s,
103
- title: d,
104
- availableCountryCodes: y,
105
- fieldLabels: T.addressFields,
112
+ title: l,
113
+ availableCountryCodes: F,
114
+ fieldLabels: D.addressFields,
115
+ isSalutationRequired: q,
106
116
  onChangeCountry: A,
107
- onChangeValidationSchema: v,
117
+ onChangeValidationSchema: w,
108
118
  showOrganisationField: N,
109
- validationSchema: w
119
+ showSalutationField: M,
120
+ validationSchema: j
110
121
  }
111
122
  ) }),
112
- k
123
+ v
113
124
  ] });
114
125
  };
115
126
  export {
116
- re as CheckoutAddressSection,
117
- Z as baseAddressValidationSchema
127
+ de as CheckoutAddressSection,
128
+ K as getBaseAddressValidationSchema
118
129
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutForm.d.ts","sourceRoot":"","sources":["../../src/CheckoutForm/Checko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I,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EACtC,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,QAAQ,KACd,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC,CAAC;IAC9D,YAAY,CAAC,EAAE,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;IACvD,gBAAgB,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;CACrD;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,qDAyTpD,CAAC"}
@@ -1,18 +1,18 @@
1
- import { jsxs as u, jsx as c, Fragment as M } from "react/jsx-runtime";
2
- import { Box as be, MultiStepForm as fe } from "@afosto/components";
3
- import { useCheckout as Se } from "../CheckoutStateProvider/CheckoutStateProvider.js";
4
- import { useEffect as he } from "react";
5
- import { createPortal as ke } from "react-dom";
6
- import { isDefined as ve, camelize as Le, wait as ge } from "@afosto/utils";
7
- import { CheckoutFormSkeleton as xe } from "../CheckoutFormSkeleton/CheckoutFormSkeleton.js";
8
- import { CheckoutSubmitButton as ye } from "../CheckoutSubmitButton/CheckoutSubmitButton.js";
9
- import { CheckoutTermsAndPrivacyMessage as T } from "../CheckoutTermsAndPrivacyMessage/CheckoutTermsAndPrivacyMessage.js";
10
- import { getErrorMessage as Pe } from "../utils/getErrorMessage.js";
11
- import { getValidationErrorMessage as Ce } from "../utils/getValidationErrorMessage.js";
12
- import { validationTranslations as we } from "../constants/validationTranslations.js";
13
- import { CheckoutErrorMessageAlert as Fe } from "../CheckoutErrorMessageAlert/CheckoutErrorMessageAlert.js";
14
- import { useGetLatest as Me } from "@afosto/hooks";
15
- const h = {
1
+ import { jsxs as p, jsx as u, Fragment as B } from "react/jsx-runtime";
2
+ import { Box as fe, MultiStepForm as he } from "@afosto/components";
3
+ import { useCheckout as ke } from "../CheckoutStateProvider/CheckoutStateProvider.js";
4
+ import { useEffect as ve } from "react";
5
+ import { createPortal as Le } from "react-dom";
6
+ import { isDefined as ge, camelize as xe, wait as ye } from "@afosto/utils";
7
+ import { CheckoutFormSkeleton as Pe } from "../CheckoutFormSkeleton/CheckoutFormSkeleton.js";
8
+ import { CheckoutSubmitButton as Ce } from "../CheckoutSubmitButton/CheckoutSubmitButton.js";
9
+ import { CheckoutTermsAndPrivacyMessage as E } from "../CheckoutTermsAndPrivacyMessage/CheckoutTermsAndPrivacyMessage.js";
10
+ import { getErrorMessage as we } from "../utils/getErrorMessage.js";
11
+ import { getValidationErrorMessage as Fe } from "../utils/getValidationErrorMessage.js";
12
+ import { validationTranslations as Me } from "../constants/validationTranslations.js";
13
+ import { CheckoutErrorMessageAlert as Te } from "../CheckoutErrorMessageAlert/CheckoutErrorMessageAlert.js";
14
+ import { useGetLatest as Be } from "@afosto/hooks";
15
+ const v = {
16
16
  cancelLabel: "Back to webshop",
17
17
  downPaymentSubmitLabel: "Pay deposit & order",
18
18
  nextStepLabel: "To {stepLabel}",
@@ -24,74 +24,74 @@ const h = {
24
24
  checkoutFailedTitle: "Could not proceed to payment",
25
25
  checkoutFailedDescription: "Something went wrong while proceeding to the payment. Please try again."
26
26
  },
27
- validation: we
28
- }, Je = (B) => {
27
+ validation: Me
28
+ }, Qe = (I) => {
29
29
  const {
30
- activeStep: E,
31
- autoComplete: D = "on",
32
- defaultValues: N,
33
- errorMessage: V,
34
- formRef: k,
35
- hideErrorMessage: A = !1,
36
- hideForm: v = !1,
37
- isLoading: R,
38
- onNextStep: O,
39
- onPreviousStep: I,
40
- onCancel: p,
41
- onSubmit: m,
42
- steps: j,
43
- submitLabel: d,
44
- validationSchema: z,
45
- translations: b = {},
46
- sx: G = {},
47
- ...q
48
- } = B, r = Se(), {
49
- activeStep: H = 0,
50
- defaultValues: J = [],
51
- checkout: K,
52
- errorMessage: Q,
53
- formRef: U,
54
- getNextStepLabel: W,
55
- getPreviousStepLabel: X,
56
- isLoading: Y,
57
- isProcessing: L,
58
- nextStep: Z,
59
- previousStep: _,
60
- setErrorMessage: g,
61
- settings: $,
62
- steps: ee = [],
63
- subStep: te,
64
- submitButtonDisabled: oe,
65
- submitButtonPortalRef: x,
66
- summary: ae,
67
- validationSchema: ne,
30
+ activeStep: N,
31
+ autoComplete: A = "on",
32
+ defaultValues: R,
33
+ errorMessage: D,
34
+ formRef: L,
35
+ hideErrorMessage: V = !1,
36
+ hideForm: g = !1,
37
+ isLoading: O,
38
+ onNextStep: j,
39
+ onPreviousStep: z,
40
+ onCancel: m,
41
+ onSubmit: d,
42
+ steps: G,
43
+ submitLabel: b,
44
+ validationSchema: q,
45
+ translations: S = {},
46
+ sx: H = {},
47
+ ...J
48
+ } = I, s = ke(), {
49
+ activeStep: K = 0,
50
+ defaultValues: Q = [],
51
+ checkout: U,
52
+ errorMessage: W,
53
+ formRef: X,
54
+ getNextStepLabel: Y,
55
+ getPreviousStepLabel: Z,
56
+ isLoading: _,
57
+ isProcessing: x,
58
+ nextStep: $,
59
+ previousStep: ee,
60
+ setErrorMessage: y,
61
+ settings: te,
62
+ steps: oe = [],
63
+ subStep: ne,
64
+ submitButtonDisabled: ae,
65
+ submitButtonPortalRef: P,
66
+ summary: re,
67
+ validationSchema: se,
68
68
  translations: f = {},
69
- track: re
70
- } = r, { vendor: y } = $?.links ?? {}, t = {
71
- ...h,
69
+ track: h
70
+ } = s, { vendor: C } = te?.links ?? {}, t = {
71
+ ...v,
72
72
  ...f?.checkoutForm || {},
73
- ...b || {},
73
+ ...S || {},
74
74
  feedback: {
75
- ...h.feedback,
75
+ ...v.feedback,
76
76
  ...f?.checkoutForm?.feedback || {},
77
- ...b?.feedback || {}
77
+ ...S?.feedback || {}
78
78
  },
79
79
  validation: {
80
- ...h.validation,
80
+ ...v.validation,
81
81
  ...f?.validation || {},
82
- ...b?.validation || {}
82
+ ...S?.validation || {}
83
83
  }
84
- }, s = R ?? Y, i = E ?? H, ie = N ?? J, P = V ?? Q, se = O ?? Z, ce = I ?? _, le = z ?? ne, l = (j ?? ee ?? []).map((e) => {
85
- let o = typeof e.nextLabel == "function" ? e.nextLabel({ ...r, translations: t }) : e.nextLabel, a = typeof e.previousLabel == "function" ? e.previousLabel({ ...r, translations: t }) : e.previousLabel;
84
+ }, i = O ?? _, r = N ?? K, ie = R ?? Q, w = D ?? W, ce = j ?? $, ue = z ?? ee, le = q ?? se, c = (G ?? oe ?? []).map((e) => {
85
+ let o = typeof e.nextLabel == "function" ? e.nextLabel({ ...s, translations: t }) : e.nextLabel, a = typeof e.previousLabel == "function" ? e.previousLabel({ ...s, translations: t }) : e.previousLabel;
86
86
  if (!o) {
87
- const n = W();
87
+ const n = Y();
88
88
  n && (o = t.nextStepLabel.replace(
89
89
  "{stepLabel}",
90
90
  n
91
91
  ));
92
92
  }
93
93
  if (!a) {
94
- const n = X();
94
+ const n = Z();
95
95
  n && (a = t.previousStepLabel.replace(
96
96
  "{stepLabel}",
97
97
  n
@@ -102,57 +102,71 @@ const h = {
102
102
  nextLabel: o,
103
103
  previousLabel: a
104
104
  };
105
- }), C = i === l.length - 1, w = l[i]?.component, F = Me({
106
- summary: ae,
107
- steps: l,
108
- track: re
105
+ }), F = r === c.length - 1, M = c[r]?.component, T = Be({
106
+ summary: re,
107
+ steps: c,
108
+ track: h
109
109
  });
110
- he(() => {
111
- s || (() => {
110
+ ve(() => {
111
+ i || (() => {
112
112
  const {
113
113
  steps: o,
114
114
  summary: a,
115
115
  track: n
116
- } = F();
116
+ } = T();
117
117
  !n && typeof n != "function" || n("checkoutStep", {
118
- step: o[i],
119
- stepIndex: i + 1,
118
+ step: o[r],
119
+ stepIndex: r + 1,
120
120
  summary: a
121
121
  });
122
122
  })();
123
- }, [i, s, F]);
124
- const ue = async (e, o) => se(e, o, {
125
- ...r,
126
- translations: t
127
- }), pe = async (e) => ce(e, { ...r, translations: t }), me = () => {
128
- if (p && typeof p == "function")
129
- return p();
130
- }, de = async (e, o) => {
123
+ }, [r, i, T]);
124
+ const pe = async (e, o) => {
125
+ const a = c[r], n = r + 1, l = await ce(e, o, {
126
+ ...s,
127
+ translations: t
128
+ });
129
+ return h("stepSubmitted", {
130
+ step: a,
131
+ stepIndex: n,
132
+ stepValues: e,
133
+ formData: o
134
+ }), l;
135
+ }, me = async (e) => ue(e, { ...s, translations: t }), de = () => {
131
136
  if (m && typeof m == "function")
132
- return m(e, o, {
133
- ...r,
137
+ return m();
138
+ }, be = async (e, o) => {
139
+ const a = c[r], n = r + 1;
140
+ if (h("stepSubmitted", {
141
+ step: a,
142
+ stepIndex: n,
143
+ stepValues: e,
144
+ formData: o
145
+ }), d && typeof d == "function")
146
+ return d(e, o, {
147
+ ...s,
134
148
  translations: t
135
149
  });
136
150
  try {
137
- await K(), g(null), await ge(5e3);
138
- } catch (a) {
139
- const n = Pe(a);
140
- return g({
151
+ await U(), y(null), await ye(5e3);
152
+ } catch (l) {
153
+ const Se = we(l);
154
+ return y({
141
155
  title: t.feedback?.checkoutFailedTitle,
142
- description: n || t.feedback?.checkoutFailedDescription
143
- }), Promise.reject(a);
156
+ description: Se || t.feedback?.checkoutFailedDescription
157
+ }), Promise.reject(l);
144
158
  }
145
- }, S = typeof d == "function" ? d({ ...r, translations: t }) : d ?? (() => {
146
- const { summary: e } = r, { agreementTemplate: o } = e || {}, a = Le(
159
+ }, k = typeof b == "function" ? b({ ...s, translations: t }) : b ?? (() => {
160
+ const { summary: e } = s, { agreementTemplate: o } = e || {}, a = xe(
147
161
  o?.type?.toLowerCase() || ""
148
162
  );
149
163
  return a === "downPayment" ? t.downPaymentSubmitLabel : ["cod", "postPaid"].includes(a) ? t.postPaidSubmitLabel : t.submitLabel;
150
164
  })();
151
- return /* @__PURE__ */ u(be, { sx: v ? { display: "none" } : G, children: [
152
- /* @__PURE__ */ u(
153
- fe,
165
+ return /* @__PURE__ */ p(fe, { sx: g ? { display: "none" } : H, children: [
166
+ /* @__PURE__ */ p(
167
+ he,
154
168
  {
155
- ...q,
169
+ ...J,
156
170
  actionsAlignment: "space-between",
157
171
  actionsContainerProps: {
158
172
  sx: {
@@ -161,71 +175,71 @@ const h = {
161
175
  mt: 1
162
176
  }
163
177
  },
164
- activeStep: i,
165
- autoComplete: D,
178
+ activeStep: r,
179
+ autoComplete: A,
166
180
  cancelLabel: t.cancelLabel,
167
181
  defaultValues: ie,
168
182
  formRef: [
169
- U,
170
- ...k ? [k] : []
183
+ X,
184
+ ...L ? [L] : []
171
185
  ],
172
- getErrorMessage: Ce(t.validation),
173
- hideActions: s,
174
- onNextStep: ue,
175
- onPreviousStep: pe,
176
- onCancel: me,
177
- onSubmit: de,
178
- subStep: te,
179
- steps: l,
186
+ getErrorMessage: Fe(t.validation),
187
+ hideActions: i,
188
+ onNextStep: pe,
189
+ onPreviousStep: me,
190
+ onCancel: de,
191
+ onSubmit: be,
192
+ subStep: ne,
193
+ steps: c,
180
194
  cancelButtonProps: {
181
- ...i === 0 && ve(y) ? { href: y } : {},
182
- disabled: L,
195
+ ...r === 0 && ge(C) ? { href: C } : {},
196
+ disabled: x,
183
197
  size: "large"
184
198
  },
185
199
  submitButtonProps: {
186
- disabled: oe,
187
- loading: L,
200
+ disabled: ae,
201
+ loading: x,
188
202
  size: "large"
189
203
  },
190
- submitLabel: S,
204
+ submitLabel: k,
191
205
  validationSchema: le,
192
206
  children: [
193
- !s && P && !A && /* @__PURE__ */ c(
194
- Fe,
207
+ !i && w && !V && /* @__PURE__ */ u(
208
+ Te,
195
209
  {
196
- errorMessage: P,
210
+ errorMessage: w,
197
211
  sx: { mt: 1.5, mb: 3 }
198
212
  }
199
213
  ),
200
- !s && w && /* @__PURE__ */ u(M, { children: [
201
- /* @__PURE__ */ c(w, {}),
202
- !v && x.current && ke(
203
- /* @__PURE__ */ u(M, { children: [
204
- /* @__PURE__ */ c(ye, { sx: { mt: 0.5 } }),
205
- C && /* @__PURE__ */ c(
206
- T,
214
+ !i && M && /* @__PURE__ */ p(B, { children: [
215
+ /* @__PURE__ */ u(M, {}),
216
+ !g && P.current && Le(
217
+ /* @__PURE__ */ p(B, { children: [
218
+ /* @__PURE__ */ u(Ce, { sx: { mt: 0.5 } }),
219
+ F && /* @__PURE__ */ u(
220
+ E,
207
221
  {
208
- submitLabel: S,
222
+ submitLabel: k,
209
223
  sx: { mt: 3 }
210
224
  }
211
225
  )
212
226
  ] }),
213
- x.current
227
+ P.current
214
228
  )
215
229
  ] }),
216
- s && /* @__PURE__ */ c(xe, {})
230
+ i && /* @__PURE__ */ u(Pe, {})
217
231
  ]
218
232
  }
219
233
  ),
220
- C && /* @__PURE__ */ c(
221
- T,
234
+ F && /* @__PURE__ */ u(
235
+ E,
222
236
  {
223
- submitLabel: S,
237
+ submitLabel: k,
224
238
  sx: { display: { md: "none" }, mt: 3, textAlign: "center" }
225
239
  }
226
240
  )
227
241
  ] });
228
242
  };
229
243
  export {
230
- Je as CheckoutForm
244
+ Qe as CheckoutForm
231
245
  };
@@ -4,14 +4,12 @@ import { CheckoutBusinessInformationSectionProps } from '../CheckoutBusinessInfo
4
4
  import { CheckoutShippingAddressSectionProps } from '../CheckoutShippingAddressSection/CheckoutShippingAddressSection';
5
5
  import { CheckoutBillingAddressSectionProps } from '../CheckoutBillingAddressSection/CheckoutBillingAddressSection';
6
6
  import { CheckoutExpressCheckoutSectionProps } from '../CheckoutExpressCheckoutSection/CheckoutExpressCheckoutSection';
7
- import { CheckoutSalutationSectionProps } from '../CheckoutSalutationSection/CheckoutSalutationSection';
8
7
  export interface CheckoutInformationStepProps {
9
8
  translations?: {
10
9
  billingAddressSection?: CheckoutBillingAddressSectionProps['translations'];
11
10
  businessInformationSection?: CheckoutBusinessInformationSectionProps['translations'];
12
11
  contactInformationSection?: CheckoutContactInformationSectionProps['translations'];
13
12
  expressCheckoutSection?: CheckoutExpressCheckoutSectionProps['translations'];
14
- salutationSection?: CheckoutSalutationSectionProps['translations'];
15
13
  shippingAddressSection?: CheckoutShippingAddressSectionProps['translations'];
16
14
  typeSection?: CheckoutTypeSectionProps['translations'];
17
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutInformationStep.d.ts","sourceRoot":"","sources":["../../src/CheckoutInformationStep/CheckoutInformationStep.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,sCAAsC,EAC5C,MAAM,wEAAwE,CAAC;AAChF,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAEL,KAAK,uCAAuC,EAC7C,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,KAAK,mCAAmC,EACzC,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EAEL,KAAK,kCAAkC,EACxC,MAAM,gEAAgE,CAAC;AACxE,OAAO,EAEL,KAAK,mCAAmC,EACzC,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,wDAAwD,CAAC;AAEhE,MAAM,WAAW,4BAA4B;IAC3C,YAAY,CAAC,EAAE;QACb,qBAAqB,CAAC,EAAE,kCAAkC,CAAC,cAAc,CAAC,CAAC;QAC3E,0BAA0B,CAAC,EAAE,uCAAuC,CAAC,cAAc,CAAC,CAAC;QACrF,yBAAyB,CAAC,EAAE,sCAAsC,CAAC,cAAc,CAAC,CAAC;QACnF,sBAAsB,CAAC,EAAE,mCAAmC,CAAC,cAAc,CAAC,CAAC;QAC7E,iBAAiB,CAAC,EAAE,8BAA8B,CAAC,cAAc,CAAC,CAAC;QACnE,sBAAsB,CAAC,EAAE,mCAAmC,CAAC,cAAc,CAAC,CAAC;QAC7E,WAAW,CAAC,EAAE,wBAAwB,CAAC,cAAc,CAAC,CAAC;KACxD,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB,GAClC,OAAO,4BAA4B,qDAyD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