@dropins/storefront-checkout 0.1.0-alpha40 → 0.1.0-alpha42
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/api.js +1 -1
- package/chunks/BillToShippingAddress.js +1 -0
- package/chunks/EmptyCart.js +1 -0
- package/chunks/OutOfStock.js +1 -1
- package/chunks/ShippingMethods.js +1 -1
- package/chunks/getCart.graphql.js +20 -6
- package/chunks/getCustomer.js +1 -1
- package/chunks/placeOrder.js +127 -0
- package/chunks/resetCustomer.js +1 -1
- package/chunks/setBillingAddress.js +3 -3
- package/chunks/setShippingMethods.js +85 -3
- package/components/AddressForm/useCheckoutAddressEventEmitter.d.ts +2 -1
- package/components/Checkout/Checkout.d.ts +8 -12
- package/components/ShippingMethods/ShippingMethods.d.ts +1 -1
- package/containers/BillToShippingAddress/BillToShippingAddress.d.ts +4 -2
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/BillingForm/BillingForm.d.ts +4 -2
- package/containers/BillingForm.js +1 -1
- package/containers/Checkout/Checkout.d.ts +2 -6
- package/containers/Checkout.js +1 -1
- package/containers/EmptyCart/EmptyCart.d.ts +8 -0
- package/containers/EmptyCart/index.d.ts +3 -0
- package/containers/EmptyCart.d.ts +3 -0
- package/containers/EmptyCart.js +1 -0
- package/containers/EstimateShipping.js +1 -1
- package/containers/LoginForm/LoginForm.d.ts +4 -2
- package/containers/LoginForm.js +1 -1
- package/containers/OutOfStock.js +1 -1
- package/containers/PaymentMethods/PaymentMethods.d.ts +6 -4
- package/containers/PaymentMethods.js +1 -1
- package/containers/PlaceOrder/PlaceOrder.d.ts +4 -2
- package/containers/PlaceOrder.js +1 -1
- package/containers/ShippingForm/ShippingForm.d.ts +5 -3
- package/containers/ShippingForm.js +1 -1
- package/containers/ShippingMethods/ShippingMethods.d.ts +4 -2
- package/containers/ShippingMethods.js +1 -1
- package/containers/index.d.ts +1 -0
- package/hocs/index.d.ts +1 -0
- package/hocs/withConditionalRendering.d.ts +13 -0
- package/i18n/en_US.json.d.ts +8 -0
- package/package.json +1 -1
- package/render.js +3 -3
- package/utils/getDisplayName/getDisplayName.d.ts +4 -0
- package/utils/getDisplayName/index.d.ts +2 -0
- package/utils/index.d.ts +1 -0
- package/chunks/BillToShippingAddress2.js +0 -1
- package/chunks/BillingForm.js +0 -1
- package/chunks/LoginForm.js +0 -1
- package/chunks/PlaceOrder.js +0 -1
- package/chunks/ShippingForm.js +0 -1
- package/chunks/ToggleButton.js +0 -1
- package/chunks/ToggleButton2.js +0 -1
- package/chunks/constants.js +0 -1
- package/chunks/constants2.js +0 -1
- package/chunks/constants3.js +0 -1
- package/chunks/fixtures.js +0 -15
- package/chunks/getMultilineValues.js +0 -43
- package/chunks/placeOrder2.js +0 -127
- package/chunks/setGuestEmailOnCart.js +0 -17
- package/chunks/setPaymentMethod.js +0 -13
- package/chunks/setShippingAddress.js +0 -13
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import{o as _,M as y,d as h,p as g,t as l,y as I}from"./fixtures.js";import"@dropins/tools/event-bus.js";const m=`
|
|
2
|
-
mutation estimateShippingMethods(
|
|
3
|
-
$cartId: String!
|
|
4
|
-
$address: EstimateAddressInput!
|
|
5
|
-
) {
|
|
6
|
-
estimateShippingMethods(
|
|
7
|
-
input: {
|
|
8
|
-
cart_id: $cartId
|
|
9
|
-
address: $address
|
|
10
|
-
}
|
|
11
|
-
) {
|
|
12
|
-
carrier_title
|
|
13
|
-
carrier_code
|
|
14
|
-
method_title
|
|
15
|
-
method_code
|
|
16
|
-
available
|
|
17
|
-
amount {
|
|
18
|
-
currency
|
|
19
|
-
value
|
|
20
|
-
}
|
|
21
|
-
price_excl_tax {
|
|
22
|
-
currency
|
|
23
|
-
value
|
|
24
|
-
}
|
|
25
|
-
price_incl_tax {
|
|
26
|
-
currency
|
|
27
|
-
value
|
|
28
|
-
}
|
|
29
|
-
error_message
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`,M=t=>t?!!t.id&&!!t.code&&!!t.name:!1,S=t=>{if(t)return t.filter(M).map(e=>{const{id:a,code:n,name:i}=e;return{id:a,code:n,name:i}})};var v=(t=>(t.SHIPPING="shipping_addresses",t.BILLING="billing_address",t))(v||{}),f=(t=>(t.City="city",t.Company="company",t.Country="country_id",t.FirstName="firstname",t.LastName="lastname",t.PostCode="postcode",t.Region="region",t.RegionId="region_id",t.SaveInAddressBook="save_in_address_book",t.Street="street",t.Telephone="telephone",t.Vat="vat_id",t))(f||{});const b=async t=>{const e=_.cartId,{criteria:a}=t||{},{country_code:n,region_id:i,region_name:s,zip:r}=a||{};if(!e)throw new y;if(!n)throw new h;const o=typeof i=="string"?parseInt(i,10):i,c=i||s?{...o&&{region_id:o},...s&&{region_code:s}}:void 0,u={country_code:n,...r&&{postcode:r},...c&&{region:c}};return await g({type:"mutation",query:m,options:{variables:{cartId:e,address:u}},path:"estimateShippingMethods",signalType:"estimateShippingMethods",transformer:l})},d=`
|
|
33
|
-
query getRegions($countryCode: String!) {
|
|
34
|
-
country(id: $countryCode) {
|
|
35
|
-
id
|
|
36
|
-
available_regions {
|
|
37
|
-
id
|
|
38
|
-
code
|
|
39
|
-
name
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}`,L=async(t,e)=>(I.value.addressType=e,g({type:"query",query:d,options:{variables:{countryCode:t}},path:"country.available_regions",signalType:"regions",transformer:S})),p="-",N=`
|
|
43
|
-
`,R=2e3,E=(t,e)=>Object.keys(e).filter(a=>a.startsWith(t)).sort((a,n)=>parseInt(a.replace(`${t}${p}`,""),10)-parseInt(n.replace(`${t}${p}`,""),10)).map(a=>e[a]);export{v as A,R as D,p as M,f as a,E as b,N as c,b as e,L as g};
|
package/chunks/placeOrder2.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import{o as T,M as w,g as A,v as k,n as D,F as L,U as R}from"./fixtures.js";import{events as f}from"@dropins/tools/event-bus.js";const V=n=>({id:T.cartId,totalQuantity:n.totalQuantity,possibleOnepageCheckout:!0,items:n.items.map(a=>{var t;return{canApplyMsrp:!0,formattedPrice:"",id:a.id,quantity:a.totalQuantity,product:{canonicalUrl:a.product.canonicalUrl||"",mainImageUrl:a.product.image||"",name:a.product.name,productId:0,productType:a.product.productType,sku:a.product.sku},prices:{price:{value:a.price.value,currency:a.price.currency}},configurableOptions:((t=a.selectedOptions)==null?void 0:t.map(i=>({optionLabel:i.label,valueLabel:i.value})))||[]}})}),q=n=>{var i,c,l;const a=n.coupons[0],t=(i=n.payments)==null?void 0:i[0];return{appliedCouponCode:(a==null?void 0:a.code)||"",email:n.email,grandTotal:n.total,orderId:n.number,orderType:"checkout",otherTax:0,salesTax:n.totalTax,shipping:{shippingMethod:((c=n.shipping)==null?void 0:c.code)||"",shippingAmount:((l=n.shipping)==null?void 0:l.amount)||0},subtotalExcludingTax:n.subtotal,subtotalIncludingTax:0,payments:t?[{paymentMethodCode:(t==null?void 0:t.code)||"",paymentMethodName:(t==null?void 0:t.name)||"",total:n.total}]:[]}},Q=n=>n||0,S=n=>{var a;return{canonicalUrl:(n==null?void 0:n.canonical_url)||"",id:(n==null?void 0:n.uid)||"",name:(n==null?void 0:n.name)||"",sku:(n==null?void 0:n.sku)||"",image:((a=n==null?void 0:n.image)==null?void 0:a.url)||"",productType:(n==null?void 0:n.__typename)||""}};function M(n){if(!n||!("selected_options"in n))return;const a={};for(const t of n.selected_options)a[t.label]=t.value;return a}const P=n=>n?n.map(a=>{var t,i,c,l,u,s,e,p,_,o,y,g,h,v;return{type:a==null?void 0:a.__typename,id:a==null?void 0:a.id,discounted:(a==null?void 0:a.product.price_range.maximum_price.regular_price.value)*(a==null?void 0:a.quantity_ordered)!==(a==null?void 0:a.product_sale_price.value)*(a==null?void 0:a.quantity_ordered),total:{value:(a==null?void 0:a.product_sale_price.value)*(a==null?void 0:a.quantity_ordered),currency:a==null?void 0:a.product_sale_price.currency},totalInclTax:{value:(a==null?void 0:a.product_sale_price.value)*(a==null?void 0:a.quantity_ordered),currency:a==null?void 0:a.product_sale_price.currency},price:{value:a==null?void 0:a.product_sale_price.value,currency:a==null?void 0:a.product_sale_price.currency},priceInclTax:{value:a==null?void 0:a.product_sale_price.value,currency:a==null?void 0:a.product_sale_price.currency},totalQuantity:Q(a==null?void 0:a.quantity_ordered),regularPrice:{value:(c=(i=(t=a==null?void 0:a.product)==null?void 0:t.price_range)==null?void 0:i.maximum_price)==null?void 0:c.regular_price.value,currency:(s=(u=(l=a==null?void 0:a.product)==null?void 0:l.price_range)==null?void 0:u.maximum_price)==null?void 0:s.regular_price.currency},product:S(a==null?void 0:a.product),thumbnail:{label:((p=(e=a==null?void 0:a.product)==null?void 0:e.thumbnail)==null?void 0:p.label)||"",url:((o=(_=a==null?void 0:a.product)==null?void 0:_.thumbnail)==null?void 0:o.url)||""},giftCard:(a==null?void 0:a.__typename)==="GiftCardOrderItem"?{senderName:((y=a.gift_card)==null?void 0:y.sender_name)||"",senderEmail:((g=a.gift_card)==null?void 0:g.sender_email)||"",recipientEmail:((h=a.gift_card)==null?void 0:h.recipient_email)||"",recipientName:((v=a.gift_card)==null?void 0:v.recipient_name)||""}:void 0,configurableOptions:M(a)}}):[];function U(n){return n!==null&&n.value!==void 0}const C=n=>n?{city:n.city,company:n.company||"",country:n.country_code||"",firstName:n.firstname,middleName:n.middlename||"",lastName:n.lastname,postCode:n.postcode||"",regionId:n.region_id||"",region:n.region||"",street:n.street.filter(a=>a!==null),telephone:n.telephone||"",customAttributes:n.custom_attributesV2.filter(U).map(a=>({code:a.code,value:a.value}))}:null,G=n=>{var u,s,e,p,_,o,y,g,h,v;const a=(u=n.payment_methods)==null?void 0:u[0],t=(a==null?void 0:a.type)??"",i=(a==null?void 0:a.name)??"",c=P(n.items),l=c.reduce((b,N)=>b+N.totalQuantity,0);return{status:n.status,isVirtual:n.is_virtual,coupons:((s=n==null?void 0:n.applied_coupons)==null?void 0:s.map(b=>({code:(b==null?void 0:b.code)??""})))||[],email:n.email??"",items:c,number:n.number,token:n.token,grandTotal:{value:((e=n.total)==null?void 0:e.grand_total.value)??0,currency:((p=n.total)==null?void 0:p.grand_total.currency)||""},totalQuantity:l,totalTax:{value:((_=n.total)==null?void 0:_.total_tax.value)??0,currency:((o=n.total)==null?void 0:o.total_tax.currency)||""},subtotal:{value:((y=n.total)==null?void 0:y.subtotal.value)??0,currency:((g=n.total)==null?void 0:g.subtotal.currency)||""},shipping:{amount:((h=n.total)==null?void 0:h.total_shipping.value)??0,currency:((v=n.total)==null?void 0:v.total_shipping.currency)||"",code:n.shipping_method??""},payments:[{code:t,name:i}],shippingAddress:C(n.shipping_address),billingAddress:C(n.billing_address)}},F=`
|
|
2
|
-
mutation placeOrder($cartId: String!) {
|
|
3
|
-
placeOrder(input: { cart_id: $cartId }) {
|
|
4
|
-
orderV2 {
|
|
5
|
-
number
|
|
6
|
-
status
|
|
7
|
-
token
|
|
8
|
-
is_virtual
|
|
9
|
-
applied_coupons {
|
|
10
|
-
code
|
|
11
|
-
}
|
|
12
|
-
email
|
|
13
|
-
id
|
|
14
|
-
total {
|
|
15
|
-
grand_total {
|
|
16
|
-
currency
|
|
17
|
-
value
|
|
18
|
-
}
|
|
19
|
-
subtotal {
|
|
20
|
-
currency
|
|
21
|
-
value
|
|
22
|
-
}
|
|
23
|
-
total_shipping {
|
|
24
|
-
currency
|
|
25
|
-
value
|
|
26
|
-
}
|
|
27
|
-
total_tax {
|
|
28
|
-
currency
|
|
29
|
-
value
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
shipping_method
|
|
33
|
-
payment_methods {
|
|
34
|
-
name
|
|
35
|
-
type
|
|
36
|
-
}
|
|
37
|
-
billing_address {
|
|
38
|
-
firstname
|
|
39
|
-
middlename
|
|
40
|
-
lastname
|
|
41
|
-
street
|
|
42
|
-
city
|
|
43
|
-
postcode
|
|
44
|
-
telephone
|
|
45
|
-
country_code
|
|
46
|
-
region
|
|
47
|
-
region_id
|
|
48
|
-
company
|
|
49
|
-
custom_attributesV2 {
|
|
50
|
-
code
|
|
51
|
-
... on AttributeValue {
|
|
52
|
-
value
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
shipping_address {
|
|
57
|
-
firstname
|
|
58
|
-
middlename
|
|
59
|
-
lastname
|
|
60
|
-
street
|
|
61
|
-
city
|
|
62
|
-
postcode
|
|
63
|
-
telephone
|
|
64
|
-
country_code
|
|
65
|
-
region
|
|
66
|
-
region_id
|
|
67
|
-
company
|
|
68
|
-
custom_attributesV2 {
|
|
69
|
-
code
|
|
70
|
-
... on AttributeValue {
|
|
71
|
-
value
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
items {
|
|
76
|
-
__typename
|
|
77
|
-
id
|
|
78
|
-
discounts {
|
|
79
|
-
amount {
|
|
80
|
-
value
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
product {
|
|
84
|
-
__typename
|
|
85
|
-
canonical_url
|
|
86
|
-
image {
|
|
87
|
-
url
|
|
88
|
-
}
|
|
89
|
-
thumbnail {
|
|
90
|
-
label
|
|
91
|
-
url
|
|
92
|
-
}
|
|
93
|
-
name
|
|
94
|
-
sku
|
|
95
|
-
uid
|
|
96
|
-
price_range {
|
|
97
|
-
maximum_price {
|
|
98
|
-
regular_price {
|
|
99
|
-
currency
|
|
100
|
-
value
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
selected_options {
|
|
106
|
-
label
|
|
107
|
-
value
|
|
108
|
-
}
|
|
109
|
-
product_sale_price {
|
|
110
|
-
value
|
|
111
|
-
currency
|
|
112
|
-
}
|
|
113
|
-
quantity_ordered
|
|
114
|
-
... on GiftCardOrderItem {
|
|
115
|
-
gift_card {
|
|
116
|
-
recipient_name
|
|
117
|
-
recipient_email
|
|
118
|
-
sender_name
|
|
119
|
-
sender_email
|
|
120
|
-
message
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
`,x={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},X={PLACE_ORDER:"place-order"};function E(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function O(n,a){const t=E();t.push({[n]:null}),t.push({[n]:a})}function $(n,a){E().push(i=>{const c=i.getState?i.getState():{};i.push({event:n,eventInfo:{...c,...a}})})}function H(n){const a=V(n),t=q(n);console.debug({shoppingCartContext:a,orderContext:t}),O(x.SHOPPING_CART_CONTEXT,{...a}),O(x.ORDER_CONTEXT,{...t}),$(X.PLACE_ORDER)}function j(n){throw n.every(t=>{var i;return(i=t.extensions)==null?void 0:i.category})?new L(n):new R(n[0].message)}const J=async()=>{const n=T.cartId;if(!n)throw new w;const{data:a,errors:t}=await A(F,{variables:{cartId:n}}).catch(k);t&&j(t);const i=G(a.placeOrder.orderV2);return H(i),f.emit("checkout/order",i),D.value={pending:!1,data:null},f.emit("cart/reset",void 0),i};export{J as p};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{a as r,g as s,v as e,o as l,M as n,p as o}from"./fixtures.js";import"@dropins/tools/event-bus.js";import{C as m,t as c}from"./getCart.graphql.js";const E=a=>!!(a!=null&&a.is_email_available),u=`
|
|
2
|
-
query isEmailAvailable($email: String!) {
|
|
3
|
-
isEmailAvailable(email: $email) {
|
|
4
|
-
is_email_available
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
`,h=a=>{if(!(!a||a.length===0))throw Error(a.map(t=>t.message).join(" "))},A=async a=>{if(!a)throw new r;const{data:t,errors:i}=await s(u,{method:"GET",cache:"no-cache",variables:{email:a}}).catch(e);return i&&h(i),E(t.isEmailAvailable)},p=`
|
|
8
|
-
mutation setGuestEmail($cartId: String!, $email: String!) {
|
|
9
|
-
setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {
|
|
10
|
-
cart {
|
|
11
|
-
id
|
|
12
|
-
...CheckoutData
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
${m}
|
|
17
|
-
`,C=async a=>{const t=l.cartId;if(!t)throw new n;return await o({type:"mutation",query:p,options:{variables:{cartId:t,email:a}},path:"setGuestEmailOnCart.cart",signalType:"cart",transformer:c})};export{A as i,C as s};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{o as e,M as r,b as n,p as o}from"./fixtures.js";import{C as s,t as i}from"./getCart.graphql.js";const m=`
|
|
2
|
-
mutation setPaymentMethod($cartId: String!, $paymentMethod: String!) {
|
|
3
|
-
setPaymentMethodOnCart(
|
|
4
|
-
input: { cart_id: $cartId, payment_method: { code: $paymentMethod } }
|
|
5
|
-
) {
|
|
6
|
-
cart {
|
|
7
|
-
id
|
|
8
|
-
...CheckoutData
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
${s}
|
|
13
|
-
`,h=async t=>{const a=e.cartId;if(!a)throw new r;if(!t)throw new n;return await o({type:"mutation",query:m,options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:i})};export{h as s};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{a as s,b as p,M as u,c as _}from"./getMultilineValues.js";import{o as I,M as g,p as C}from"./fixtures.js";import{C as h,t as A}from"./getCart.graphql.js";import"@dropins/tools/event-bus.js";const T=/^\d+$/,l=t=>{if(T.test(t))return parseInt(t,10)},m=`
|
|
2
|
-
mutation setShippingAddress($cartId: String!, $address: CartAddressInput!) {
|
|
3
|
-
setShippingAddressesOnCart(
|
|
4
|
-
input: { cart_id: $cartId, shipping_addresses: [{ address: $address }] }
|
|
5
|
-
) {
|
|
6
|
-
cart {
|
|
7
|
-
id
|
|
8
|
-
...CheckoutData
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
${h}
|
|
13
|
-
`,y=["city","company","country_code","firstname","lastname","postcode","region","region_id","save_in_address_book","street","telephone","vat_id"],v=t=>{const a={city:t[s.City],company:t[s.Company],country_code:t[s.Country],firstname:t[s.FirstName],lastname:t[s.LastName],postcode:t[s.PostCode],save_in_address_book:!0,street:p(s.Street,t),telephone:t[s.Telephone],vat_id:t[s.Vat]},r=t[s.Region],d=l(r);d?a.region_id=d:a.region=r;const c=Object.keys(t).filter(e=>!e.startsWith("street")).filter(e=>!y.includes(e)).filter(e=>e!=="country_id").map(e=>{const[n,i]=e.split(u);if(!i)return{attribute_code:n,value:t[e]};const o=p(n,t).join(_);return{attribute_code:n,value:o}}).filter((e,n,i)=>n===i.findIndex(o=>o.attribute_code===e.attribute_code));return c.length>0&&(a.custom_attributes=c),a},N=async({signal:t,address:a})=>{const r=I.cartId;if(!r)throw new g;return await C({type:"mutation",query:m,options:{signal:t,variables:{cartId:r,address:a}},path:"setShippingAddressesOnCart.cart",signalType:"cart",transformer:A})};export{y as S,v as p,N as s};
|