@afosto/checkout-ui 0.0.12 → 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 (47) 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/CheckoutInformationStep/CheckoutInformationStep.d.ts +0 -2
  8. package/dist/CheckoutInformationStep/CheckoutInformationStep.d.ts.map +1 -1
  9. package/dist/CheckoutInformationStep/CheckoutInformationStep.js +30 -37
  10. package/dist/constants/addressDefaultValues.d.ts +1 -0
  11. package/dist/constants/addressDefaultValues.d.ts.map +1 -1
  12. package/dist/constants/addressDefaultValues.js +1 -0
  13. package/dist/constants/addressFields.d.ts.map +1 -1
  14. package/dist/constants/addressFields.js +6 -5
  15. package/dist/constants/addressValidationSchema.d.ts +10 -2
  16. package/dist/constants/addressValidationSchema.d.ts.map +1 -1
  17. package/dist/constants/addressValidationSchema.js +58 -46
  18. package/dist/constants/index.js +8 -8
  19. package/dist/hooks/useCheckoutAddressOptions.d.ts +3 -1
  20. package/dist/hooks/useCheckoutAddressOptions.d.ts.map +1 -1
  21. package/dist/hooks/useCheckoutAddressOptions.js +64 -57
  22. package/dist/hooks/useCheckoutCart.d.ts.map +1 -1
  23. package/dist/hooks/useCheckoutForm.d.ts.map +1 -1
  24. package/dist/hooks/useCheckoutForm.js +45 -41
  25. package/dist/hooks/useCheckoutOrder.d.ts.map +1 -1
  26. package/dist/index.d.ts +0 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +426 -428
  29. package/dist/operations/cartOperations.d.ts.map +1 -1
  30. package/dist/operations/cartOperations.js +120 -108
  31. package/dist/operations/orderOperations.d.ts.map +1 -1
  32. package/dist/operations/orderOperations.js +123 -111
  33. package/dist/steps/informationStep.d.ts +0 -1
  34. package/dist/steps/informationStep.d.ts.map +1 -1
  35. package/dist/steps/informationStep.js +234 -238
  36. package/dist/types.d.ts +1 -2
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/utils/createAddressValidationSchema.d.ts +4 -1
  39. package/dist/utils/createAddressValidationSchema.d.ts.map +1 -1
  40. package/dist/utils/createAddressValidationSchema.js +8 -8
  41. package/package.json +1 -1
  42. package/dist/CheckoutSalutationSection/CheckoutSalutationSection.d.ts +0 -13
  43. package/dist/CheckoutSalutationSection/CheckoutSalutationSection.d.ts.map +0 -1
  44. package/dist/CheckoutSalutationSection/CheckoutSalutationSection.js +0 -26
  45. package/dist/CheckoutSalutationSection/index.d.ts +0 -3
  46. package/dist/CheckoutSalutationSection/index.d.ts.map +0 -1
  47. 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
  };
@@ -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,qDAyDpC,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;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,63 +1,56 @@
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([
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([
13
12
  "organisation",
14
13
  "type",
15
14
  "sameBillingAsShippingAddress"
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,
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,
20
19
  {
21
- translations: o.expressCheckoutSection,
20
+ translations: t.expressCheckoutSection,
22
21
  sx: {
23
22
  mb: 3
24
23
  }
25
24
  }
26
25
  ),
27
- /* @__PURE__ */ t(
28
- A,
26
+ /* @__PURE__ */ o(
27
+ C,
29
28
  {
30
- translations: o.contactInformationSection
29
+ translations: t.contactInformationSection
31
30
  }
32
31
  ),
33
- f && /* @__PURE__ */ t(y, { translations: o.typeSection }),
34
- /* @__PURE__ */ t(i, { in: s, children: /* @__PURE__ */ t(
35
- I,
32
+ S && /* @__PURE__ */ o(k, { translations: t.typeSection }),
33
+ /* @__PURE__ */ o(i, { in: s, children: /* @__PURE__ */ o(
34
+ A,
36
35
  {
37
- translations: o.businessInformationSection
36
+ translations: t.businessInformationSection
38
37
  }
39
38
  ) }),
40
- g && /* @__PURE__ */ t(
41
- F,
42
- {
43
- translations: o.salutationSection
44
- }
45
- ),
46
- /* @__PURE__ */ t(
47
- b,
39
+ /* @__PURE__ */ o(
40
+ y,
48
41
  {
49
42
  showOrganisationField: !n && s,
50
- translations: o.shippingAddressSection
43
+ translations: t.shippingAddressSection
51
44
  }
52
45
  ),
53
- /* @__PURE__ */ t(i, { in: !n, children: /* @__PURE__ */ t(
54
- w,
46
+ /* @__PURE__ */ o(i, { in: !n, children: /* @__PURE__ */ o(
47
+ B,
55
48
  {
56
- translations: o.billingAddressSection
49
+ translations: t.billingAddressSection
57
50
  }
58
51
  ) })
59
52
  ] });
60
53
  };
61
54
  export {
62
- G as CheckoutInformationStep
55
+ P as CheckoutInformationStep
63
56
  };
@@ -17,6 +17,7 @@ export declare const addressDefaultValues: {
17
17
  thoroughfare: string;
18
18
  locality: string;
19
19
  dependentLocality: string;
20
+ salutation: string;
20
21
  sortingCode: string;
21
22
  administrativeArea: null;
22
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"addressDefaultValues.d.ts","sourceRoot":"","sources":["../../src/constants/addressDefaultValues.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;CAqBhC,CAAC"}
1
+ {"version":3,"file":"addressDefaultValues.d.ts","sourceRoot":"","sources":["../../src/constants/addressDefaultValues.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;CAsBhC,CAAC"}
@@ -17,6 +17,7 @@ const e = {
17
17
  thoroughfare: "",
18
18
  locality: "",
19
19
  dependentLocality: "",
20
+ salutation: "",
20
21
  sortingCode: "",
21
22
  administrativeArea: null
22
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"addressFields.d.ts","sourceRoot":"","sources":["../../src/constants/addressFields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,UAU1C,CAAC;AAEF,eAAO,MAAM,+BAA+B,UAQ3C,CAAC;AAEF,eAAO,MAAM,0BAA0B;;CAEtC,CAAC;AAEF,eAAO,MAAM,6BAA6B,YAOzC,CAAC;AAEF,eAAO,MAAM,iCAAiC,YAK7C,CAAC;AAEF,eAAO,MAAM,+BAA+B,YAM3C,CAAC;AAEF,eAAO,MAAM,2BAA2B,YAMvC,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAAiB,CAAC;AAE1D,eAAO,MAAM,4BAA4B,UAKxC,CAAC;AAEF,eAAO,MAAM,sBAAsB,oJACgH,CAAC"}
1
+ {"version":3,"file":"addressFields.d.ts","sourceRoot":"","sources":["../../src/constants/addressFields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,UAU1C,CAAC;AAEF,eAAO,MAAM,+BAA+B,UAQ3C,CAAC;AAEF,eAAO,MAAM,0BAA0B;;CAEtC,CAAC;AAEF,eAAO,MAAM,6BAA6B,YAOzC,CAAC;AAEF,eAAO,MAAM,iCAAiC,YAK7C,CAAC;AAEF,eAAO,MAAM,+BAA+B,YAM3C,CAAC;AAEF,eAAO,MAAM,2BAA2B,YAMvC,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAAiB,CAAC;AAE1D,eAAO,MAAM,4BAA4B,UAMxC,CAAC;AAEF,eAAO,MAAM,sBAAsB,oJACgH,CAAC"}
@@ -18,14 +18,14 @@ const e = [
18
18
  "locality"
19
19
  ], i = {
20
20
  city: "locality"
21
- }, _ = [
21
+ }, n = [
22
22
  ["organisation"],
23
23
  ["given_name", "additional_name", "family_name"],
24
24
  ["thoroughfare", "premise_number", "premise_number_suffix"],
25
25
  ["address_line_2"],
26
26
  ["postal_code", "locality"],
27
27
  ["administrative_area"]
28
- ], n = [
28
+ ], _ = [
29
29
  ["organisation"],
30
30
  ["given_name", "additional_name", "family_name"],
31
31
  ["address_line_2"],
@@ -46,7 +46,8 @@ const e = [
46
46
  "givenName",
47
47
  "familyName",
48
48
  "organisation",
49
- "country"
49
+ "country",
50
+ "salutation"
50
51
  ], t = `{organisation}
51
52
  {given_name} {family_name}
52
53
  {thoroughfare} {premise_number} {premise_number_suffix}
@@ -55,9 +56,9 @@ const e = [
55
56
  export {
56
57
  e as ADDRESS_DEFAULT_ALLOWED_FIELDS,
57
58
  a as ADDRESS_DEFAULT_REQUIRED_FIELDS,
58
- _ as ADDRESS_FIELDS_DEFAULT_FORMAT,
59
+ n as ADDRESS_FIELDS_DEFAULT_FORMAT,
59
60
  m as ADDRESS_FIELDS_FORMAT_MACAO,
60
- n as ADDRESS_FIELDS_FORMAT_NETHERLANDS,
61
+ _ as ADDRESS_FIELDS_FORMAT_NETHERLANDS,
61
62
  o as ADDRESS_FIELDS_FORMAT_SINGAPORE,
62
63
  r as ADDRESS_FIELDS_REGEX_FORMAT,
63
64
  i as ADDRESS_FIELD_TYPE_MAPPING,
@@ -1,5 +1,8 @@
1
1
  import * as yup from 'yup';
2
- export declare const baseAddressSchema: {
2
+ export declare const getBaseAddressSchema: (options?: {
3
+ isSalutationRequired?: boolean;
4
+ salutation?: boolean;
5
+ }) => {
3
6
  givenName: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
4
7
  additionalName: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
5
8
  familyName: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
@@ -13,8 +16,12 @@ export declare const baseAddressSchema: {
13
16
  administrativeArea: yup.ObjectSchema<{} | null, yup.AnyObject, {}, "">;
14
17
  thoroughfare: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
15
18
  locality: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
19
+ salutation?: yup.StringSchema<string | null | undefined, yup.AnyObject, undefined, ""> | undefined;
16
20
  };
17
- export declare const addressValidationSchema: {
21
+ export declare const getAddressValidationSchema: (options?: {
22
+ isSalutationRequired?: boolean;
23
+ salutation?: boolean;
24
+ }) => {
18
25
  givenName: yup.StringSchema<string, yup.AnyObject, undefined, "">;
19
26
  additionalName: yup.StringSchema<string | null | undefined, yup.AnyObject, undefined, "">;
20
27
  familyName: yup.StringSchema<string, yup.AnyObject, undefined, "">;
@@ -28,5 +35,6 @@ export declare const addressValidationSchema: {
28
35
  administrativeArea: yup.ObjectSchema<{} | null, yup.AnyObject, {}, "">;
29
36
  thoroughfare: yup.StringSchema<string, yup.AnyObject, undefined, "">;
30
37
  locality: yup.StringSchema<string, yup.AnyObject, undefined, "">;
38
+ salutation?: yup.StringSchema<string | null | undefined, yup.AnyObject, undefined, ""> | undefined;
31
39
  };
32
40
  //# sourceMappingURL=addressValidationSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"addressValidationSchema.d.ts","sourceRoot":"","sources":["../../src/constants/addressValidationSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAM3B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;CA0D7B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;CAcnC,CAAC"}
1
+ {"version":3,"file":"addressValidationSchema.d.ts","sourceRoot":"","sources":["../../src/constants/addressValidationSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAM3B,eAAO,MAAM,oBAAoB,GAAI,UAAU;IAC7C,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;;;;;;;;;;;;;;;CAqEA,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,UAAU;IACnD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;;;;;;;;;;;;;;;CAyBA,CAAC"}
@@ -1,51 +1,63 @@
1
1
  import * as e from "yup";
2
- import { setupCustomValidationRules as d } from "../utils/setupCustomValidationRules.js";
2
+ import { setupCustomValidationRules as g } from "../utils/setupCustomValidationRules.js";
3
3
  import { isDefined as r } from "@afosto/utils";
4
- d();
5
- const g = {
6
- givenName: e.string().test({
7
- name: "required",
8
- test: (t, i) => {
9
- const a = i.resolve(e.ref("additionalName")), s = i.resolve(e.ref("familyName")), l = i.resolve(e.ref("organisation")), o = r(t);
10
- let n = !0;
11
- return !o && (r(a) || r(s) || !r(a) && !r(s) && !r(l)) && (n = !1), n;
12
- }
13
- }),
14
- additionalName: e.string(),
15
- familyName: e.string().test({
16
- name: "required",
17
- test: (t, i) => {
18
- const a = i.resolve(e.ref("additionalName")), s = i.resolve(e.ref("givenName")), l = i.resolve(e.ref("organisation")), o = r(t);
19
- let n = !0;
20
- return !o && (r(a) || r(s) || !r(a) && !r(s) && !r(l)) && (n = !1), n;
21
- }
22
- }),
23
- organisation: e.string(),
24
- country: e.object().nullable().required(),
25
- postalCode: e.string(),
26
- premiseNumber: e.string().numbersOnly(),
27
- premiseNumberSuffix: e.string().maxLength(15),
28
- addressLine1: e.string(),
29
- addressLine2: e.string(),
30
- administrativeArea: e.object().nullable(),
31
- thoroughfare: e.string(),
32
- locality: e.string()
33
- }, f = {
34
- givenName: e.string().required(),
35
- additionalName: e.string().nullable(),
36
- familyName: e.string().required(),
37
- country: e.object().nullable().required(),
38
- countryCode: e.string().required(),
39
- postalCode: e.string().required(),
40
- premiseNumber: e.string().numbersOnly().required(),
41
- premiseNumberSuffix: e.string().maxLength(15).nullable(),
42
- addressLine1: e.string().required(),
43
- addressLine2: e.string().nullable(),
44
- administrativeArea: e.object().nullable(),
45
- thoroughfare: e.string().required(),
46
- locality: e.string().required()
4
+ g();
5
+ const c = (n) => {
6
+ const { isSalutationRequired: l = !1, salutation: o = !1 } = n || {};
7
+ return {
8
+ ...o ? {
9
+ salutation: l ? e.string().required() : e.string().nullable()
10
+ } : {},
11
+ givenName: e.string().test({
12
+ name: "required",
13
+ test: (u, i) => {
14
+ const a = i.resolve(e.ref("additionalName")), t = i.resolve(e.ref("familyName")), d = i.resolve(e.ref("organisation")), m = r(u);
15
+ let s = !0;
16
+ return !m && (r(a) || r(t) || !r(a) && !r(t) && !r(d)) && (s = !1), s;
17
+ }
18
+ }),
19
+ additionalName: e.string(),
20
+ familyName: e.string().test({
21
+ name: "required",
22
+ test: (u, i) => {
23
+ const a = i.resolve(e.ref("additionalName")), t = i.resolve(e.ref("givenName")), d = i.resolve(e.ref("organisation")), m = r(u);
24
+ let s = !0;
25
+ return !m && (r(a) || r(t) || !r(a) && !r(t) && !r(d)) && (s = !1), s;
26
+ }
27
+ }),
28
+ organisation: e.string(),
29
+ country: e.object().nullable().required(),
30
+ postalCode: e.string(),
31
+ premiseNumber: e.string().numbersOnly(),
32
+ premiseNumberSuffix: e.string().maxLength(15),
33
+ addressLine1: e.string(),
34
+ addressLine2: e.string(),
35
+ administrativeArea: e.object().nullable(),
36
+ thoroughfare: e.string(),
37
+ locality: e.string()
38
+ };
39
+ }, N = (n) => {
40
+ const { isSalutationRequired: l = !1, salutation: o = !1 } = n || {};
41
+ return {
42
+ ...o ? {
43
+ salutation: l ? e.string().required() : e.string().nullable()
44
+ } : {},
45
+ givenName: e.string().required(),
46
+ additionalName: e.string().nullable(),
47
+ familyName: e.string().required(),
48
+ country: e.object().nullable().required(),
49
+ countryCode: e.string().required(),
50
+ postalCode: e.string().required(),
51
+ premiseNumber: e.string().numbersOnly().required(),
52
+ premiseNumberSuffix: e.string().maxLength(15).nullable(),
53
+ addressLine1: e.string().required(),
54
+ addressLine2: e.string().nullable(),
55
+ administrativeArea: e.object().nullable(),
56
+ thoroughfare: e.string().required(),
57
+ locality: e.string().required()
58
+ };
47
59
  };
48
60
  export {
49
- f as addressValidationSchema,
50
- g as baseAddressSchema
61
+ N as getAddressValidationSchema,
62
+ c as getBaseAddressSchema
51
63
  };
@@ -1,7 +1,7 @@
1
1
  import { ADDRESS_AUTOCOMPLETE_COUNTRIES_SUPPORTED as S, ADDRESS_VALIDATION_STORAGE_SESSION_KEY as D } from "./addressAutocomplete.js";
2
2
  import { addressDefaultValues as R } from "./addressDefaultValues.js";
3
- import { ADDRESS_DEFAULT_ALLOWED_FIELDS as I, ADDRESS_DEFAULT_REQUIRED_FIELDS as O, ADDRESS_FIELDS_DEFAULT_FORMAT as r, ADDRESS_FIELDS_FORMAT_MACAO as o, ADDRESS_FIELDS_FORMAT_NETHERLANDS as e, ADDRESS_FIELDS_FORMAT_SINGAPORE as P, ADDRESS_FIELDS_REGEX_FORMAT as C, ADDRESS_FIELD_TYPE_MAPPING as F, ADDRESS_SKIP_REQUIRED_FIELDS as L, DEFAULT_ADDRESS_FORMAT as M } from "./addressFields.js";
4
- import { addressValidationSchema as t, baseAddressSchema as a } from "./addressValidationSchema.js";
3
+ import { ADDRESS_DEFAULT_ALLOWED_FIELDS as I, ADDRESS_DEFAULT_REQUIRED_FIELDS as O, ADDRESS_FIELDS_DEFAULT_FORMAT as r, ADDRESS_FIELDS_FORMAT_MACAO as o, ADDRESS_FIELDS_FORMAT_NETHERLANDS as e, ADDRESS_FIELDS_FORMAT_SINGAPORE as P, ADDRESS_FIELDS_REGEX_FORMAT as t, ADDRESS_FIELD_TYPE_MAPPING as C, ADDRESS_SKIP_REQUIRED_FIELDS as F, DEFAULT_ADDRESS_FORMAT as L } from "./addressFields.js";
4
+ import { getAddressValidationSchema as N, getBaseAddressSchema as U } from "./addressValidationSchema.js";
5
5
  import { CHECKOUT_AGREEMENT_TYPE_ICON_MAPPING as m } from "./agreementTypeIconMapping.js";
6
6
  import { analyticsEvents as s } from "./analyticsEvents.js";
7
7
  import { CHECKOUT_CARRIER_ICON_MAPPING as x } from "./carrierIconMapping.js";
@@ -17,19 +17,19 @@ export {
17
17
  o as ADDRESS_FIELDS_FORMAT_MACAO,
18
18
  e as ADDRESS_FIELDS_FORMAT_NETHERLANDS,
19
19
  P as ADDRESS_FIELDS_FORMAT_SINGAPORE,
20
- C as ADDRESS_FIELDS_REGEX_FORMAT,
21
- F as ADDRESS_FIELD_TYPE_MAPPING,
22
- L as ADDRESS_SKIP_REQUIRED_FIELDS,
20
+ t as ADDRESS_FIELDS_REGEX_FORMAT,
21
+ C as ADDRESS_FIELD_TYPE_MAPPING,
22
+ F as ADDRESS_SKIP_REQUIRED_FIELDS,
23
23
  D as ADDRESS_VALIDATION_STORAGE_SESSION_KEY,
24
24
  m as CHECKOUT_AGREEMENT_TYPE_ICON_MAPPING,
25
25
  x as CHECKOUT_CARRIER_ICON_MAPPING,
26
26
  d as CHECKOUT_EXPRESS_PAYMENT_METHOD_CODES,
27
27
  K as CHECKOUT_ISSUER_ICON_MAPPING,
28
28
  l as CHECKOUT_PAYMENT_METHOD_ICON_MAPPING,
29
- M as DEFAULT_ADDRESS_FORMAT,
29
+ L as DEFAULT_ADDRESS_FORMAT,
30
30
  R as addressDefaultValues,
31
- t as addressValidationSchema,
32
31
  s as analyticsEvents,
33
- a as baseAddressSchema,
32
+ N as getAddressValidationSchema,
33
+ U as getBaseAddressSchema,
34
34
  Y as validationTranslations
35
35
  };
@@ -1,8 +1,10 @@
1
1
  import { AdministrativeAreaOption, OnChangeValidationSchema } from '../types';
2
- export declare const useCheckoutAddressOptions: ({ countryCode, enabled, onChangeValidationSchema, validationSchema }: {
2
+ export declare const useCheckoutAddressOptions: ({ countryCode, enabled, isSalutationRequired, onChangeValidationSchema, salutation, validationSchema, }: {
3
3
  countryCode: string;
4
4
  enabled?: boolean;
5
+ isSalutationRequired?: boolean;
5
6
  onChangeValidationSchema?: OnChangeValidationSchema;
7
+ salutation?: boolean;
6
8
  validationSchema: object;
7
9
  }) => {
8
10
  administrativeAreas: AdministrativeAreaOption[];
@@ -1 +1 @@
1
- {"version":3,"file":"useCheckoutAddressOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useCheckoutAddressOptions.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,yBAAyB,GAAI,sEAKvC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;;;mCA0JgB,MAAM,EAAE;oCAMR,MAAM,EAAE;;;;;CAexB,CAAC"}
1
+ {"version":3,"file":"useCheckoutAddressOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useCheckoutAddressOptions.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,yBAAyB,GAAI,yGAOvC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;;;mCA+JgB,MAAM,EAAE;oCAMR,MAAM,EAAE;;;;;CAexB,CAAC"}