@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.
- package/dist/CheckoutAddressFields/CheckoutAddressFields.d.ts +2 -0
- package/dist/CheckoutAddressFields/CheckoutAddressFields.d.ts.map +1 -1
- package/dist/CheckoutAddressFields/CheckoutAddressFields.js +155 -130
- package/dist/CheckoutAddressSection/CheckoutAddressSection.d.ts +6 -2
- package/dist/CheckoutAddressSection/CheckoutAddressSection.d.ts.map +1 -1
- package/dist/CheckoutAddressSection/CheckoutAddressSection.js +82 -71
- package/dist/CheckoutInformationStep/CheckoutInformationStep.d.ts +0 -2
- package/dist/CheckoutInformationStep/CheckoutInformationStep.d.ts.map +1 -1
- package/dist/CheckoutInformationStep/CheckoutInformationStep.js +30 -37
- package/dist/constants/addressDefaultValues.d.ts +1 -0
- package/dist/constants/addressDefaultValues.d.ts.map +1 -1
- package/dist/constants/addressDefaultValues.js +1 -0
- package/dist/constants/addressFields.d.ts.map +1 -1
- package/dist/constants/addressFields.js +6 -5
- package/dist/constants/addressValidationSchema.d.ts +10 -2
- package/dist/constants/addressValidationSchema.d.ts.map +1 -1
- package/dist/constants/addressValidationSchema.js +58 -46
- package/dist/constants/index.js +8 -8
- package/dist/hooks/useCheckoutAddressOptions.d.ts +3 -1
- package/dist/hooks/useCheckoutAddressOptions.d.ts.map +1 -1
- package/dist/hooks/useCheckoutAddressOptions.js +64 -57
- package/dist/hooks/useCheckoutCart.d.ts.map +1 -1
- package/dist/hooks/useCheckoutForm.d.ts.map +1 -1
- package/dist/hooks/useCheckoutForm.js +45 -41
- package/dist/hooks/useCheckoutOrder.d.ts.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +426 -428
- package/dist/operations/cartOperations.d.ts.map +1 -1
- package/dist/operations/cartOperations.js +120 -108
- package/dist/operations/orderOperations.d.ts.map +1 -1
- package/dist/operations/orderOperations.js +123 -111
- package/dist/steps/informationStep.d.ts +0 -1
- package/dist/steps/informationStep.d.ts.map +1 -1
- package/dist/steps/informationStep.js +234 -238
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/createAddressValidationSchema.d.ts +4 -1
- package/dist/utils/createAddressValidationSchema.d.ts.map +1 -1
- package/dist/utils/createAddressValidationSchema.js +8 -8
- package/package.json +1 -1
- package/dist/CheckoutSalutationSection/CheckoutSalutationSection.d.ts +0 -13
- package/dist/CheckoutSalutationSection/CheckoutSalutationSection.d.ts.map +0 -1
- package/dist/CheckoutSalutationSection/CheckoutSalutationSection.js +0 -26
- package/dist/CheckoutSalutationSection/index.d.ts +0 -3
- package/dist/CheckoutSalutationSection/index.d.ts.map +0 -1
- package/dist/CheckoutSalutationSection/index.js +0 -4
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useFormContext as
|
|
3
|
-
import { CheckoutAddressCard as
|
|
4
|
-
import { CheckoutSection as
|
|
5
|
-
import { CheckoutSectionHeader as
|
|
6
|
-
import { CheckoutAddressFields as
|
|
7
|
-
import { string as e, object as
|
|
8
|
-
import { useState as
|
|
9
|
-
import { isDefined as
|
|
10
|
-
import { useCheckout as
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
},
|
|
53
|
+
}, de = (r) => {
|
|
45
54
|
const {
|
|
46
|
-
address:
|
|
47
|
-
addressCardProps:
|
|
48
|
-
availableCountryCodes:
|
|
49
|
-
canEdit:
|
|
50
|
-
checkFieldsState:
|
|
51
|
-
children:
|
|
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:
|
|
55
|
-
showAddressCard:
|
|
63
|
+
onChangeValidationSchema: w,
|
|
64
|
+
showAddressCard: n,
|
|
56
65
|
showOrganisationField: N = !1,
|
|
57
|
-
title:
|
|
58
|
-
translations:
|
|
59
|
-
validationSchema:
|
|
60
|
-
...
|
|
61
|
-
} =
|
|
62
|
-
|
|
63
|
-
), { translations:
|
|
64
|
-
|
|
65
|
-
|
|
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
|
|
68
|
-
|
|
76
|
+
const S = await p(s);
|
|
77
|
+
f(s), S || d(`${s}.isDirty`, !0), a(S);
|
|
69
78
|
} catch {
|
|
70
|
-
|
|
79
|
+
a(!1);
|
|
71
80
|
}
|
|
72
|
-
})() :
|
|
73
|
-
}, [
|
|
74
|
-
const
|
|
75
|
-
...
|
|
76
|
-
...
|
|
81
|
+
})() : a(!1);
|
|
82
|
+
}, [f, s, d, C, p]);
|
|
83
|
+
const D = {
|
|
84
|
+
...h?.addressSection || {},
|
|
85
|
+
...c || {},
|
|
77
86
|
addressFields: {
|
|
78
|
-
...
|
|
79
|
-
...
|
|
80
|
-
...
|
|
87
|
+
...Q.addressFields || {},
|
|
88
|
+
...h?.addressFields || {},
|
|
89
|
+
...c?.addressFields || {}
|
|
81
90
|
}
|
|
82
91
|
};
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
|
|
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:
|
|
89
|
-
canEdit:
|
|
97
|
+
address: V,
|
|
98
|
+
canEdit: g,
|
|
90
99
|
onEdit: () => {
|
|
91
|
-
|
|
100
|
+
a(!1), d(`${s}.isDirty`, !0);
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
103
|
) }),
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
|
|
104
|
+
/* @__PURE__ */ t(b, { in: !u, children: /* @__PURE__ */ t(
|
|
105
|
+
z,
|
|
97
106
|
{
|
|
98
107
|
addressCardProps: {
|
|
99
108
|
editComponentType: "link",
|
|
100
|
-
...
|
|
109
|
+
...i
|
|
101
110
|
},
|
|
102
111
|
name: s,
|
|
103
|
-
title:
|
|
104
|
-
availableCountryCodes:
|
|
105
|
-
fieldLabels:
|
|
112
|
+
title: l,
|
|
113
|
+
availableCountryCodes: F,
|
|
114
|
+
fieldLabels: D.addressFields,
|
|
115
|
+
isSalutationRequired: q,
|
|
106
116
|
onChangeCountry: A,
|
|
107
|
-
onChangeValidationSchema:
|
|
117
|
+
onChangeValidationSchema: w,
|
|
108
118
|
showOrganisationField: N,
|
|
109
|
-
|
|
119
|
+
showSalutationField: M,
|
|
120
|
+
validationSchema: j
|
|
110
121
|
}
|
|
111
122
|
) }),
|
|
112
|
-
|
|
123
|
+
v
|
|
113
124
|
] });
|
|
114
125
|
};
|
|
115
126
|
export {
|
|
116
|
-
|
|
117
|
-
|
|
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;
|
|
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
|
|
2
|
-
import { useFormContext as
|
|
3
|
-
import { CheckoutContactInformationSection as
|
|
4
|
-
import { CheckoutTypeSection as
|
|
5
|
-
import { useCheckout as
|
|
6
|
-
import { CheckoutBusinessInformationSection as
|
|
7
|
-
import { CheckoutShippingAddressSection as
|
|
8
|
-
import { CheckoutBillingAddressSection as
|
|
9
|
-
import { CheckoutExpressCheckoutSection as
|
|
10
|
-
|
|
11
|
-
const
|
|
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 =
|
|
17
|
-
return /* @__PURE__ */
|
|
18
|
-
!a && r.length > 0 && /* @__PURE__ */
|
|
19
|
-
|
|
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:
|
|
20
|
+
translations: t.expressCheckoutSection,
|
|
22
21
|
sx: {
|
|
23
22
|
mb: 3
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
),
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
-
|
|
26
|
+
/* @__PURE__ */ o(
|
|
27
|
+
C,
|
|
29
28
|
{
|
|
30
|
-
translations:
|
|
29
|
+
translations: t.contactInformationSection
|
|
31
30
|
}
|
|
32
31
|
),
|
|
33
|
-
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
|
|
32
|
+
S && /* @__PURE__ */ o(k, { translations: t.typeSection }),
|
|
33
|
+
/* @__PURE__ */ o(i, { in: s, children: /* @__PURE__ */ o(
|
|
34
|
+
A,
|
|
36
35
|
{
|
|
37
|
-
translations:
|
|
36
|
+
translations: t.businessInformationSection
|
|
38
37
|
}
|
|
39
38
|
) }),
|
|
40
|
-
|
|
41
|
-
|
|
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:
|
|
43
|
+
translations: t.shippingAddressSection
|
|
51
44
|
}
|
|
52
45
|
),
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
|
|
46
|
+
/* @__PURE__ */ o(i, { in: !n, children: /* @__PURE__ */ o(
|
|
47
|
+
B,
|
|
55
48
|
{
|
|
56
|
-
translations:
|
|
49
|
+
translations: t.billingAddressSection
|
|
57
50
|
}
|
|
58
51
|
) })
|
|
59
52
|
] });
|
|
60
53
|
};
|
|
61
54
|
export {
|
|
62
|
-
|
|
55
|
+
P as CheckoutInformationStep
|
|
63
56
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressDefaultValues.d.ts","sourceRoot":"","sources":["../../src/constants/addressDefaultValues.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"addressDefaultValues.d.ts","sourceRoot":"","sources":["../../src/constants/addressDefaultValues.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;CAsBhC,CAAC"}
|
|
@@ -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,
|
|
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
|
-
],
|
|
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
|
-
|
|
59
|
+
n as ADDRESS_FIELDS_DEFAULT_FORMAT,
|
|
59
60
|
m as ADDRESS_FIELDS_FORMAT_MACAO,
|
|
60
|
-
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
2
|
+
import { setupCustomValidationRules as g } from "../utils/setupCustomValidationRules.js";
|
|
3
3
|
import { isDefined as r } from "@afosto/utils";
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
50
|
-
|
|
61
|
+
N as getAddressValidationSchema,
|
|
62
|
+
c as getBaseAddressSchema
|
|
51
63
|
};
|
package/dist/constants/index.js
CHANGED
|
@@ -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
|
|
4
|
-
import {
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
29
|
+
L as DEFAULT_ADDRESS_FORMAT,
|
|
30
30
|
R as addressDefaultValues,
|
|
31
|
-
t as addressValidationSchema,
|
|
32
31
|
s as analyticsEvents,
|
|
33
|
-
|
|
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,
|
|
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"}
|