@dropins/storefront-cart 0.7.0-alpha017 → 0.7.0-beta1
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/fragments.d.ts +3 -0
- package/api/getStoreConfig/graphql/StoreConfigQuery.d.ts +1 -1
- package/api/graphql/CartFragment.d.ts +0 -2
- package/api/graphql/CartItemFragment.d.ts +2 -0
- package/api/graphql/CustomerAccountFragment.d.ts +2 -0
- package/api/graphql/CustomizableOptionsFragment.d.ts +2 -0
- package/api/graphql/PriceRangeFragment.d.ts +2 -0
- package/api/graphql/arguments.d.ts +2 -0
- package/api/initialize/initialize.d.ts +5 -1
- package/api.js +7 -6
- package/chunks/CartSummaryList.js +1 -1
- package/chunks/ChevronDown.js +1 -0
- package/chunks/MiniCart.js +1 -1
- package/chunks/OrderSummary.js +1 -1
- package/chunks/getEstimatedTotals.js +5 -5
- package/chunks/getStoreConfig.js +36 -15
- package/chunks/updateProductsFromCart.js +6 -5
- package/components/CartSummaryList/CartSummaryList.d.ts +2 -0
- package/containers/Cart/Cart.d.ts +7 -0
- package/containers/Cart.js +1 -1
- package/containers/CartSummaryList/CartSummaryList.d.ts +16 -0
- package/containers/CartSummaryList.js +1 -1
- package/containers/MiniCart/MiniCart.d.ts +4 -0
- package/containers/MiniCart.js +1 -1
- package/containers/OrderSummary.js +1 -1
- package/data/models/cart-model.d.ts +12 -0
- package/data/models/store-models.d.ts +1 -0
- package/data/transforms/__fixtures__/productTypesData.d.ts +140 -1
- package/fragments.d.ts +1 -0
- package/fragments.js +261 -0
- package/i18n/en_US.json.d.ts +7 -2
- package/package.json +1 -1
- package/render.js +2 -2
- package/chunks/CartFragment.js +0 -235
package/chunks/CartFragment.js
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import{s}from"./resetCart.js";function R(r){var n,u,e,l,c,t,a;return r?{id:r.id,totalQuantity:z(r),errors:S(r==null?void 0:r.itemsV2),items:h(r==null?void 0:r.itemsV2),miniCartMaxItems:h(r==null?void 0:r.itemsV2).slice(0,((n=s.config)==null?void 0:n.miniCartMaxItemsDisplay)??10),total:{includingTax:{value:r.prices.grand_total.value,currency:r.prices.grand_total.currency},excludingTax:{value:r.prices.grand_total_excluding_tax.value,currency:r.prices.grand_total_excluding_tax.currency}},subtotal:{excludingTax:{value:(u=r.prices.subtotal_excluding_tax)==null?void 0:u.value,currency:(e=r.prices.subtotal_excluding_tax)==null?void 0:e.currency},includingTax:{value:(l=r.prices.subtotal_including_tax)==null?void 0:l.value,currency:(c=r.prices.subtotal_including_tax)==null?void 0:c.currency},includingDiscountOnly:{value:(t=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:t.value,currency:(a=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:a.currency}},appliedTaxes:I(r.prices.applied_taxes),totalTax:k(r.prices.applied_taxes,r.prices.grand_total.currency),appliedDiscounts:I(r.prices.discounts),isVirtual:r.is_virtual,addresses:{shipping:r.shipping_addresses&&N(r)},isGuestCart:!s.authenticated,hasOutOfStockItems:$(r),hasFullyOutOfStockItems:P(r)}:null}function k(r,n){return r!=null&&r.length?r.reduce((u,e)=>({value:u.value+e.amount.value,currency:e.amount.currency}),{value:0,currency:n}):{value:0,currency:n}}function h(r){var u;if(!((u=r==null?void 0:r.items)!=null&&u.length))return[];const n=s.config;return r.items.map(e=>{var l,c,t,a,_,o,i,g,y,m,f,b,d,v,C,x;return{itemType:e.__typename,uid:e.uid,url:{urlKey:e.product.url_key,categories:e.product.categories.map(O=>O.url_key)},quantity:e.quantity,sku:e.product.sku,name:e.product.name,image:{src:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(l=e.configured_variant)==null?void 0:l.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.label:((a=(t=e.configured_variant)==null?void 0:t.thumbnail)==null?void 0:a.label)||e.product.thumbnail.label},price:{value:e.prices.price.value,currency:e.prices.price.currency},taxedPrice:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency},links:G(e.links),total:e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.row_total.value,currency:e.prices.row_total.currency}:{value:(_=e.prices.original_row_total)==null?void 0:_.value,currency:(o=e.prices.original_row_total)==null?void 0:o.currency},discount:{value:e.prices.total_item_discount.value,currency:e.prices.total_item_discount.currency},regularPrice:e.__typename==="ConfigurableCartItem"?{value:(g=(i=e.configured_variant)==null?void 0:i.price_range)==null?void 0:g.maximum_price.regular_price.value,currency:(m=(y=e.configured_variant)==null?void 0:y.price_range)==null?void 0:m.maximum_price.regular_price.currency}:e.__typename==="GiftCardCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.price.value,currency:e.prices.price.currency}:{value:(f=e.product.price_range)==null?void 0:f.maximum_price.regular_price.value,currency:(b=e.product.price_range)==null?void 0:b.maximum_price.regular_price.currency},discounted:e.__typename==="BundleCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0?!1:e.__typename==="ConfigurableCartItem"?((v=(d=e.configured_variant)==null?void 0:d.price_range)==null?void 0:v.maximum_price.discount.amount_off)>0:((C=e.product.price_range)==null?void 0:C.maximum_price.discount.amount_off)>0,bundleOptions:e.__typename==="BundleCartItem"?w(e.bundle_options):null,selectedOptions:E(e.configurable_options),customizableOptions:A(e.customizable_options),sender:e.__typename==="GiftCardCartItem"?e.sender_name:null,senderEmail:e.__typename==="GiftCardCartItem"?e.sender_email:null,recipient:e.__typename==="GiftCardCartItem"?e.recipient_name:null,recipientEmail:e.__typename==="GiftCardCartItem"?e.recipient_email:null,message:e.__typename==="GiftCardCartItem"?e.message:null,discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},onlyXLeftInStock:e.__typename==="ConfigurableCartItem"?(x=e.configured_variant)==null?void 0:x.only_x_left_in_stock:e.product.only_x_left_in_stock,lowInventory:e.is_available&&e.product.only_x_left_in_stock!==null,insufficientQuantity:(e.__typename==="ConfigurableCartItem"?e.configured_variant:e.product).stock_status==="IN_STOCK"&&!e.is_available,outOfStock:e.product.stock_status==="OUT_OF_STOCK",stockLevel:M(e)}})}function S(r){var u;const n=(u=r==null?void 0:r.items)==null?void 0:u.reduce((e,l)=>{var c;return(c=l.errors)==null||c.forEach(t=>{e.push({uid:l.uid,text:t.message})}),e},[]);return n!=null&&n.length?n:null}function I(r){return r!=null&&r.length?r.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})):[]}function w(r){const n=r==null?void 0:r.map(e=>({uid:e.uid,label:e.label,value:e.values.map(l=>l.label).join(", ")})),u={};return n==null||n.forEach(e=>{u[e.label]=e.value}),Object.keys(u).length>0?u:null}function E(r){const n=r==null?void 0:r.map(e=>({uid:e.configurable_product_option_uid,label:e.option_label,value:e.value_label})),u={};return n==null||n.forEach(e=>{u[e.label]=e.value}),Object.keys(u).length>0?u:null}function A(r){const n=r==null?void 0:r.map(e=>({uid:e.customizable_option_uid,label:e.label,type:e.type,values:e.values.map(l=>({uid:l.customizable_option_value_uid,label:l.label,value:l.value}))})),u={};return n==null||n.forEach(e=>{var l;switch(e.type){case"field":case"area":case"date_time":u[e.label]=e.values[0].value;break;case"radio":case"drop_down":u[e.label]=e.values[0].label;break;case"multiple":case"checkbox":u[e.label]=e.values.reduce((o,i)=>o?`${o}, ${i.label}`:i.label,"");break;case"file":const c=new DOMParser,t=e.values[0].value,_=((l=c.parseFromString(t,"text/html").querySelector("a"))==null?void 0:l.textContent)||"";u[e.label]=_;break}}),u}function z(r){var n,u;return((n=s.config)==null?void 0:n.cartSummaryDisplayTotal)===0?r.itemsV2.items.length:((u=s.config)==null?void 0:u.cartSummaryDisplayTotal)===1?r.total_quantity:r.itemsV2.items.length}function G(r){return(r==null?void 0:r.length)>0?{count:r.length,result:r.map(n=>n.title).join(", ")}:null}function N(r){var n,u,e,l;return(n=r.shipping_addresses)!=null&&n.length?(u=r.shipping_addresses)==null?void 0:u.map(c=>({countryCode:c.country.code,zipCode:c.postcode,regionCode:c.region.code})):(e=r.addresses)!=null&&e.length?(l=r.addresses)==null?void 0:l.filter(c=>c.default_shipping).map(c=>{var t;return c.default_shipping&&{countryCode:c.country_id,zipCode:c.postcode,regionCode:(t=c.region)==null?void 0:t.region_code}}):null}function $(r){var n,u;return(u=(n=r==null?void 0:r.itemsV2)==null?void 0:n.items)==null?void 0:u.some(e=>{var l;return((l=e==null?void 0:e.product)==null?void 0:l.stock_status)==="OUT_OF_STOCK"||e.product.stock_status==="IN_STOCK"&&!e.is_available})}function M(r){if(!r.not_available_message)return null;const n=r.not_available_message.match(/-?\d+/);return n?parseInt(n[0]):"noNumber"}function P(r){var n,u;return(u=(n=r==null?void 0:r.itemsV2)==null?void 0:n.items)==null?void 0:u.some(e=>{var l;return((l=e==null?void 0:e.product)==null?void 0:l.stock_status)==="OUT_OF_STOCK"})}const p=`
|
|
2
|
-
customizable_options {
|
|
3
|
-
type
|
|
4
|
-
customizable_option_uid
|
|
5
|
-
label
|
|
6
|
-
is_required
|
|
7
|
-
values {
|
|
8
|
-
label
|
|
9
|
-
value
|
|
10
|
-
price{
|
|
11
|
-
type
|
|
12
|
-
units
|
|
13
|
-
value
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
`,T=`
|
|
18
|
-
price_range {
|
|
19
|
-
minimum_price {
|
|
20
|
-
regular_price {
|
|
21
|
-
value
|
|
22
|
-
currency
|
|
23
|
-
}
|
|
24
|
-
final_price {
|
|
25
|
-
value
|
|
26
|
-
currency
|
|
27
|
-
}
|
|
28
|
-
discount {
|
|
29
|
-
percent_off
|
|
30
|
-
amount_off
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
maximum_price {
|
|
34
|
-
regular_price {
|
|
35
|
-
value
|
|
36
|
-
currency
|
|
37
|
-
}
|
|
38
|
-
final_price {
|
|
39
|
-
value
|
|
40
|
-
currency
|
|
41
|
-
}
|
|
42
|
-
discount {
|
|
43
|
-
percent_off
|
|
44
|
-
amount_off
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`,D=`
|
|
49
|
-
fragment CartFragment on Cart {
|
|
50
|
-
id
|
|
51
|
-
total_quantity
|
|
52
|
-
is_virtual
|
|
53
|
-
prices {
|
|
54
|
-
subtotal_with_discount_excluding_tax {
|
|
55
|
-
currency
|
|
56
|
-
value
|
|
57
|
-
}
|
|
58
|
-
subtotal_including_tax {
|
|
59
|
-
currency
|
|
60
|
-
value
|
|
61
|
-
}
|
|
62
|
-
subtotal_excluding_tax {
|
|
63
|
-
currency
|
|
64
|
-
value
|
|
65
|
-
}
|
|
66
|
-
grand_total {
|
|
67
|
-
currency
|
|
68
|
-
value
|
|
69
|
-
}
|
|
70
|
-
grand_total_excluding_tax {
|
|
71
|
-
currency
|
|
72
|
-
value
|
|
73
|
-
}
|
|
74
|
-
applied_taxes {
|
|
75
|
-
label,
|
|
76
|
-
amount {
|
|
77
|
-
value
|
|
78
|
-
currency
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
discounts {
|
|
82
|
-
amount {
|
|
83
|
-
value
|
|
84
|
-
currency
|
|
85
|
-
}
|
|
86
|
-
label
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
itemsV2 (
|
|
90
|
-
pageSize:$pageSize,
|
|
91
|
-
currentPage:$currentPage,
|
|
92
|
-
sort: $itemsSortInput
|
|
93
|
-
) {
|
|
94
|
-
items {
|
|
95
|
-
__typename
|
|
96
|
-
uid
|
|
97
|
-
quantity
|
|
98
|
-
is_available
|
|
99
|
-
not_available_message
|
|
100
|
-
errors {
|
|
101
|
-
code
|
|
102
|
-
message
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
prices {
|
|
106
|
-
price {
|
|
107
|
-
value
|
|
108
|
-
currency
|
|
109
|
-
}
|
|
110
|
-
total_item_discount {
|
|
111
|
-
value
|
|
112
|
-
currency
|
|
113
|
-
}
|
|
114
|
-
row_total {
|
|
115
|
-
value
|
|
116
|
-
currency
|
|
117
|
-
}
|
|
118
|
-
row_total_including_tax {
|
|
119
|
-
value
|
|
120
|
-
currency
|
|
121
|
-
}
|
|
122
|
-
price_including_tax {
|
|
123
|
-
value
|
|
124
|
-
currency
|
|
125
|
-
}
|
|
126
|
-
fixed_product_taxes {
|
|
127
|
-
amount {
|
|
128
|
-
value
|
|
129
|
-
currency
|
|
130
|
-
}
|
|
131
|
-
label
|
|
132
|
-
}
|
|
133
|
-
original_row_total{
|
|
134
|
-
value
|
|
135
|
-
currency
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
product {
|
|
140
|
-
name
|
|
141
|
-
sku
|
|
142
|
-
thumbnail {
|
|
143
|
-
url
|
|
144
|
-
label
|
|
145
|
-
}
|
|
146
|
-
url_key
|
|
147
|
-
url_suffix
|
|
148
|
-
categories {
|
|
149
|
-
url_path
|
|
150
|
-
url_key
|
|
151
|
-
}
|
|
152
|
-
only_x_left_in_stock
|
|
153
|
-
stock_status
|
|
154
|
-
${T}
|
|
155
|
-
}
|
|
156
|
-
...on SimpleCartItem {
|
|
157
|
-
${p}
|
|
158
|
-
}
|
|
159
|
-
... on ConfigurableCartItem {
|
|
160
|
-
configurable_options {
|
|
161
|
-
configurable_product_option_uid
|
|
162
|
-
option_label
|
|
163
|
-
value_label
|
|
164
|
-
}
|
|
165
|
-
configured_variant {
|
|
166
|
-
uid
|
|
167
|
-
sku
|
|
168
|
-
only_x_left_in_stock
|
|
169
|
-
stock_status
|
|
170
|
-
thumbnail {
|
|
171
|
-
label
|
|
172
|
-
url
|
|
173
|
-
}
|
|
174
|
-
${T}
|
|
175
|
-
}
|
|
176
|
-
${p}
|
|
177
|
-
}
|
|
178
|
-
... on DownloadableCartItem {
|
|
179
|
-
links {
|
|
180
|
-
sort_order
|
|
181
|
-
title
|
|
182
|
-
}
|
|
183
|
-
${p}
|
|
184
|
-
}
|
|
185
|
-
... on BundleCartItem {
|
|
186
|
-
bundle_options {
|
|
187
|
-
uid
|
|
188
|
-
label
|
|
189
|
-
values {
|
|
190
|
-
uid
|
|
191
|
-
label
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
... on GiftCardCartItem {
|
|
196
|
-
message
|
|
197
|
-
recipient_email
|
|
198
|
-
recipient_name
|
|
199
|
-
sender_email
|
|
200
|
-
sender_name
|
|
201
|
-
amount{
|
|
202
|
-
currency
|
|
203
|
-
value
|
|
204
|
-
}
|
|
205
|
-
is_available
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
shipping_addresses {
|
|
210
|
-
country {
|
|
211
|
-
code
|
|
212
|
-
}
|
|
213
|
-
region {
|
|
214
|
-
code
|
|
215
|
-
}
|
|
216
|
-
postcode
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
`,V=`
|
|
220
|
-
$pageSize: Int! = 100,
|
|
221
|
-
$currentPage: Int! = 1,
|
|
222
|
-
$itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}
|
|
223
|
-
`,q=`
|
|
224
|
-
customer {
|
|
225
|
-
addresses {
|
|
226
|
-
default_shipping
|
|
227
|
-
country_id
|
|
228
|
-
postcode
|
|
229
|
-
region {
|
|
230
|
-
region
|
|
231
|
-
region_code
|
|
232
|
-
region_id
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}`;export{V as C,D as a,q as b,R as t};
|