@afosto/checkout-ui 0.0.10 → 0.0.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutForm.d.ts","sourceRoot":"","sources":["../../src/CheckoutForm/CheckoutForm.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,OAAO,EACZ,KAAK,KAAK,EACX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,WAAW,EAEZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAC1D,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,OAAO,CAAC;AAYzD,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAcxB,CAAC;AAEF,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,YAAY,GAAG,OAAO,GAAG,aAAa,CAAC;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACjD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EACtC,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,SAAS,EACnB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E,gBAAgB,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACjD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,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,12 +4,14 @@ 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';
7
8
  export interface CheckoutInformationStepProps {
8
9
  translations?: {
9
10
  billingAddressSection?: CheckoutBillingAddressSectionProps['translations'];
10
11
  businessInformationSection?: CheckoutBusinessInformationSectionProps['translations'];
11
12
  contactInformationSection?: CheckoutContactInformationSectionProps['translations'];
12
13
  expressCheckoutSection?: CheckoutExpressCheckoutSectionProps['translations'];
14
+ salutationSection?: CheckoutSalutationSectionProps['translations'];
13
15
  shippingAddressSection?: CheckoutShippingAddressSectionProps['translations'];
14
16
  typeSection?: CheckoutTypeSectionProps['translations'];
15
17
  };
@@ -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;AAE1E,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,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,qDAmDpC,CAAC"}
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,qDAyDpC,CAAC"}
@@ -1,56 +1,63 @@
1
- import { jsxs as u, Fragment as g, jsx as o } from "react/jsx-runtime";
2
- import { useFormContext as f, Collapse as i } from "@afosto/components";
3
- import { CheckoutContactInformationSection as C } from "../CheckoutContactInformationSection/CheckoutContactInformationSection.js";
4
- import { CheckoutTypeSection as k } from "../CheckoutTypeSection/CheckoutTypeSection.js";
5
- import { useCheckout as x } from "../CheckoutStateProvider/CheckoutStateProvider.js";
6
- import { CheckoutBusinessInformationSection as A } from "../CheckoutBusinessInformationSection/CheckoutBusinessInformationSection.js";
7
- import { CheckoutShippingAddressSection as y } from "../CheckoutShippingAddressSection/CheckoutShippingAddressSection.js";
8
- import { CheckoutBillingAddressSection as B } from "../CheckoutBillingAddressSection/CheckoutBillingAddressSection.js";
9
- import { CheckoutExpressCheckoutSection as I } from "../CheckoutExpressCheckoutSection/CheckoutExpressCheckoutSection.js";
10
- const P = (e) => {
11
- const { translations: t = {} } = e || {}, { expressPaymentMethods: r, isSignedIn: a, settings: c } = x(), { isB2bExcluded: p, isB2cExcluded: m } = c || {}, { watch: d } = f(), [h, l, n] = d([
1
+ import { jsxs as C, Fragment as k, jsx as t } from "react/jsx-runtime";
2
+ import { useFormContext as x, Collapse as i } from "@afosto/components";
3
+ import { CheckoutContactInformationSection as A } from "../CheckoutContactInformationSection/CheckoutContactInformationSection.js";
4
+ import { CheckoutTypeSection as y } from "../CheckoutTypeSection/CheckoutTypeSection.js";
5
+ import { useCheckout as B } from "../CheckoutStateProvider/CheckoutStateProvider.js";
6
+ import { CheckoutBusinessInformationSection as I } from "../CheckoutBusinessInformationSection/CheckoutBusinessInformationSection.js";
7
+ import { CheckoutShippingAddressSection as b } from "../CheckoutShippingAddressSection/CheckoutShippingAddressSection.js";
8
+ import { CheckoutBillingAddressSection as w } from "../CheckoutBillingAddressSection/CheckoutBillingAddressSection.js";
9
+ import { CheckoutExpressCheckoutSection as E } from "../CheckoutExpressCheckoutSection/CheckoutExpressCheckoutSection.js";
10
+ import { CheckoutSalutationSection as F } from "../CheckoutSalutationSection/CheckoutSalutationSection.js";
11
+ const G = (e) => {
12
+ const { translations: o = {} } = e || {}, { expressPaymentMethods: r, isSignedIn: a, settings: c } = B(), { isB2bExcluded: m, isB2cExcluded: p, salutation: l } = c || {}, { watch: d } = x(), [h, u, n] = d([
12
13
  "organisation",
13
14
  "type",
14
15
  "sameBillingAsShippingAddress"
15
- ]), s = l === "business", S = !(h?.type?.toLowerCase() === "shared") && !p && !m;
16
- return /* @__PURE__ */ u(g, { children: [
17
- !a && r.length > 0 && /* @__PURE__ */ o(
18
- I,
16
+ ]), s = u === "business", S = h?.type?.toLowerCase() === "shared", g = !!l, f = !S && !m && !p;
17
+ return /* @__PURE__ */ C(k, { children: [
18
+ !a && r.length > 0 && /* @__PURE__ */ t(
19
+ E,
19
20
  {
20
- translations: t.expressCheckoutSection,
21
+ translations: o.expressCheckoutSection,
21
22
  sx: {
22
23
  mb: 3
23
24
  }
24
25
  }
25
26
  ),
26
- /* @__PURE__ */ o(
27
- C,
27
+ /* @__PURE__ */ t(
28
+ A,
28
29
  {
29
- translations: t.contactInformationSection
30
+ translations: o.contactInformationSection
30
31
  }
31
32
  ),
32
- S && /* @__PURE__ */ o(k, { translations: t.typeSection }),
33
- /* @__PURE__ */ o(i, { in: s, children: /* @__PURE__ */ o(
34
- A,
33
+ f && /* @__PURE__ */ t(y, { translations: o.typeSection }),
34
+ /* @__PURE__ */ t(i, { in: s, children: /* @__PURE__ */ t(
35
+ I,
35
36
  {
36
- translations: t.businessInformationSection
37
+ translations: o.businessInformationSection
37
38
  }
38
39
  ) }),
39
- /* @__PURE__ */ o(
40
- y,
40
+ g && /* @__PURE__ */ t(
41
+ F,
42
+ {
43
+ translations: o.salutationSection
44
+ }
45
+ ),
46
+ /* @__PURE__ */ t(
47
+ b,
41
48
  {
42
49
  showOrganisationField: !n && s,
43
- translations: t.shippingAddressSection
50
+ translations: o.shippingAddressSection
44
51
  }
45
52
  ),
46
- /* @__PURE__ */ o(i, { in: !n, children: /* @__PURE__ */ o(
47
- B,
53
+ /* @__PURE__ */ t(i, { in: !n, children: /* @__PURE__ */ t(
54
+ w,
48
55
  {
49
- translations: t.billingAddressSection
56
+ translations: o.billingAddressSection
50
57
  }
51
58
  ) })
52
59
  ] });
53
60
  };
54
61
  export {
55
- P as CheckoutInformationStep
62
+ G as CheckoutInformationStep
56
63
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutProvider.d.ts","sourceRoot":"","sources":["../../src/CheckoutProvider/CheckoutProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIpE,OAAO,EAAE,sBAAsB,EAAgB,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EACV,gBAAgB,EAChB,6CAA6C,EAC7C,aAAa,EACb,oBAAoB,EAEpB,WAAW,EACX,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAOzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EACP,WAAW,CAAC,sBAAsB,CAAC,GACnC,CAAC,WAAW,CAAC,sBAAsB,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB;AAED,MAAM,WAAW,8BAA8B;IAC7C,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,UAAU,CAAC,EACP,WAAW,CAAC,uBAAuB,CAAC,GACpC,CAAC,WAAW,CAAC,uBAAuB,CAAC,GACnC,MAAM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AW,CAAC;IAC1B,QAAQ,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IACtD,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACvB,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAED,MAAM,MAAM,qBAAqB,GAC7B,CAAC,6BAA6B,GAC5B,yBAAyB,GAAG;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC,GACJ,CAAC,8BAA8B,GAC7B,yBAAyB,GAAG;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC,CAAC;AAET,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,qDAkL5D,CAAC"}
@@ -4,7 +4,7 @@ import { CheckoutOrderProvider as O } from "../CheckoutOrderProvider/CheckoutOrd
4
4
  import { CheckoutCartProvider as A } from "../CheckoutCartProvider/CheckoutCartProvider.js";
5
5
  import { useGetLatest as V } from "@afosto/hooks";
6
6
  import "@afosto/storefront";
7
- import { camelize as j, isDefined as o } from "@afosto/utils";
7
+ import { camelize as j, isDefined as t } from "@afosto/utils";
8
8
  import { CheckoutPayPalExpressButton as z } from "../CheckoutPayPalExpressButton/CheckoutPayPalExpressButton.js";
9
9
  import { CheckoutExpressButton as D } from "../CheckoutExpressButton/CheckoutExpressButton.js";
10
10
  import { deepMerge as F } from "../utils/deepMerge.js";
@@ -14,8 +14,8 @@ import { shippingStep as _ } from "../steps/shippingStep.js";
14
14
  import { paymentStep as $ } from "../steps/paymentStep.js";
15
15
  import { reviewStep as H } from "../steps/reviewStep.js";
16
16
  import { createSummary as J } from "../utils/createSummary.js";
17
- const de = (t) => {
18
- if ("cartId" in t && "orderId" in t)
17
+ const de = (o) => {
18
+ if ("cartId" in o && "orderId" in o)
19
19
  throw new Error("Cannot provide both cartId and orderId");
20
20
  const {
21
21
  createSummary: h = J,
@@ -25,12 +25,12 @@ const de = (t) => {
25
25
  operations: b,
26
26
  queryClient: C,
27
27
  settings: e,
28
- steps: c,
29
- storefront: u,
28
+ steps: u,
29
+ storefront: c,
30
30
  theme: g,
31
31
  translations: y = {},
32
32
  ...R
33
- } = t, S = L(!1), [r, l] = v(null), [q, E] = v(!0), x = V(u), N = k || r?.locale?.replace("_", "-") || "en", P = {
33
+ } = o, S = L(!1), [r, l] = v(null), [q, E] = v(!0), x = V(c), N = k || r?.locale?.replace("_", "-") || "en", P = {
34
34
  ...M || {},
35
35
  default: D,
36
36
  paypalExpress: z
@@ -45,27 +45,29 @@ const de = (t) => {
45
45
  ),
46
46
  channelLinks: m,
47
47
  currency: e?.currency || r?.pricing?.currency,
48
- disableCouponModifications: o(
48
+ disableCouponModifications: t(
49
49
  e?.disableCouponModifications
50
50
  ) ? e?.disableCouponModifications : !1,
51
- isAccountEnabled: o(e?.isAccountEnabled) ? e?.isAccountEnabled : o(m?.myAccount),
52
- isB2bExcluded: o(e?.isB2bExcluded) ? e?.isB2bExcluded : r?.options?.isB2bExcluded ?? !1,
53
- isB2cExcluded: o(e?.isB2cExcluded) ? e?.isB2cExcluded : r?.options?.isB2cExcluded ?? !1,
54
- isPhoneNumberRequired: o(e?.isPhoneNumberRequired) ? e?.isPhoneNumberRequired : r?.options?.isPhoneNumberRequired ?? !1,
55
- isCocNumberRequired: o(e?.isCocNumberRequired) ? e?.isCocNumberRequired : r?.options?.isCocNumberRequired ?? !1,
56
- isSharedOrganisationRequired: o(
51
+ isAccountEnabled: t(e?.isAccountEnabled) ? e?.isAccountEnabled : t(m?.myAccount),
52
+ isB2bExcluded: t(e?.isB2bExcluded) ? e?.isB2bExcluded : r?.options?.isB2bExcluded ?? !1,
53
+ isB2cExcluded: t(e?.isB2cExcluded) ? e?.isB2cExcluded : r?.options?.isB2cExcluded ?? !1,
54
+ isPhoneNumberRequired: t(e?.isPhoneNumberRequired) ? e?.isPhoneNumberRequired : r?.options?.isPhoneNumberRequired ?? !1,
55
+ isCocNumberRequired: t(e?.isCocNumberRequired) ? e?.isCocNumberRequired : r?.options?.isCocNumberRequired ?? !1,
56
+ isSalutationRequired: t(e?.isSalutationRequired) ? e?.isSalutationRequired : !1,
57
+ isSharedOrganisationRequired: t(
57
58
  e?.isSharedOrganisationRequired
58
59
  ) ? e?.isSharedOrganisationRequired : r?.options?.isSharedOrganisationRequired ?? !1,
59
- isVatNumberRequired: o(e?.isVatNumberRequired) ? e?.isVatNumberRequired : r?.options?.isVatNumberRequired ?? !1,
60
+ isVatNumberRequired: t(e?.isVatNumberRequired) ? e?.isVatNumberRequired : r?.options?.isVatNumberRequired ?? !1,
60
61
  links: {
61
62
  ...m,
62
63
  ...e?.links || {}
63
64
  },
64
65
  logo: e?.logo || r?.logo,
66
+ salutation: t(e?.salutation) ? e?.salutation : !1,
65
67
  storeName: e?.storeName || r?.name
66
68
  };
67
69
  let p = [G, _, $, H];
68
- if (c && c.length > 0 && (p = c), w(() => {
70
+ if (u && u.length > 0 && (p = u), w(() => {
69
71
  const n = async () => {
70
72
  try {
71
73
  const i = x();
@@ -82,8 +84,8 @@ const de = (t) => {
82
84
  }
83
85
  };
84
86
  !s && !S.current && (S.current = !0, n());
85
- }, [x, s]), "orderId" in t) {
86
- const { orderId: n = "" } = t;
87
+ }, [x, s]), "orderId" in o) {
88
+ const { orderId: n = "" } = o;
87
89
  return /* @__PURE__ */ d(
88
90
  B,
89
91
  {
@@ -103,7 +105,7 @@ const de = (t) => {
103
105
  operations: b,
104
106
  settings: a,
105
107
  steps: p,
106
- storefront: u,
108
+ storefront: c,
107
109
  translations: y,
108
110
  ...R
109
111
  }
@@ -111,7 +113,7 @@ const de = (t) => {
111
113
  }
112
114
  );
113
115
  }
114
- const { cartId: I } = t;
116
+ const { cartId: I } = o;
115
117
  return /* @__PURE__ */ d(
116
118
  B,
117
119
  {
@@ -131,7 +133,7 @@ const de = (t) => {
131
133
  operations: b,
132
134
  settings: a,
133
135
  steps: p,
134
- storefront: u,
136
+ storefront: c,
135
137
  translations: y,
136
138
  ...R
137
139
  }
@@ -0,0 +1,13 @@
1
+ import { CheckoutSectionProps } from '../CheckoutSection/CheckoutSection';
2
+ import { DeepPartial } from '../types';
3
+ declare const defaultTranslations: {
4
+ title: string;
5
+ mr: string;
6
+ mrs: string;
7
+ };
8
+ export interface CheckoutSalutationSectionProps extends Omit<CheckoutSectionProps, 'children'> {
9
+ translations?: DeepPartial<typeof defaultTranslations>;
10
+ }
11
+ export declare const CheckoutSalutationSection: (props: CheckoutSalutationSectionProps) => import("@emotion/react/jsx-runtime").JSX.Element;
12
+ export {};
13
+ //# sourceMappingURL=CheckoutSalutationSection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckoutSalutationSection.d.ts","sourceRoot":"","sources":["../../src/CheckoutSalutationSection/CheckoutSalutationSection.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,oCAAoC,CAAC;AAG5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,QAAA,MAAM,mBAAmB;;;;CAIxB,CAAC;AAEF,MAAM,WAAW,8BACf,SAAQ,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC;IAC9C,YAAY,CAAC,EAAE,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;CACxD;AAED,eAAO,MAAM,yBAAyB,GACpC,OAAO,8BAA8B,qDAsBtC,CAAC"}