@dropins/storefront-cart 0.7.0-alpha015 → 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 +2 -0
- package/data/models/store-models.d.ts +1 -0
- package/data/transforms/__fixtures__/productTypesData.d.ts +61 -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 -250
package/chunks/CartFragment.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import{s}from"./resetCart.js";function R(r){var u,n,e,l,t,c,a;return r?{id:r.id,totalQuantity:z(r),errors:k(r==null?void 0:r.itemsV2),items:h(r==null?void 0:r.itemsV2),miniCartMaxItems:h(r==null?void 0:r.itemsV2).slice(0,((u=s.config)==null?void 0:u.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:(n=r.prices.subtotal_excluding_tax)==null?void 0:n.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:(t=r.prices.subtotal_including_tax)==null?void 0:t.currency},includingDiscountOnly:{value:(c=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:c.value,currency:(a=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:a.currency}},appliedTaxes:I(r.prices.applied_taxes),totalTax:S(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:P(r),hasFullyOutOfStockItems:M(r)}:null}function S(r,u){return r!=null&&r.length?r.reduce((n,e)=>({value:n.value+e.amount.value,currency:e.amount.currency}),{value:0,currency:u}):{value:0,currency:u}}function h(r){var n;if(!((n=r==null?void 0:r.items)!=null&&n.length))return[];const u=s.config;return r.items.map(e=>{var l,t,c,a,_,o,i,g,y,f,m,d,b,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:u!=null&&u.useConfigurableParentThumbnail?e.product.thumbnail.url:((t=(l=e.configured_variant)==null?void 0:l.thumbnail)==null?void 0:t.url)||e.product.thumbnail.url,alt:u!=null&&u.useConfigurableParentThumbnail?e.product.thumbnail.label:((a=(c=e.configured_variant)==null?void 0:c.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:(f=(y=e.configured_variant)==null?void 0:y.price_range)==null?void 0:f.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:(m=e.product.price_range)==null?void 0:m.maximum_price.regular_price.value,currency:(d=e.product.price_range)==null?void 0:d.maximum_price.regular_price.currency},discounted:e.__typename==="BundleCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0?!1:e.__typename==="ConfigurableCartItem"?((v=(b=e.configured_variant)==null?void 0:b.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:A(e.configurable_options),customizableOptions:E(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:$(e),productAttributes:V(e)}})}function k(r){var n;const u=(n=r==null?void 0:r.items)==null?void 0:n.reduce((e,l)=>{var t;return(t=l.errors)==null||t.forEach(c=>{e.push({uid:l.uid,text:c.message})}),e},[]);return u!=null&&u.length?u:null}function I(r){return r!=null&&r.length?r.map(u=>({amount:{value:u.amount.value,currency:u.amount.currency},label:u.label})):[]}function w(r){const u=r==null?void 0:r.map(e=>({uid:e.uid,label:e.label,value:e.values.map(l=>l.label).join(", ")})),n={};return u==null||u.forEach(e=>{n[e.label]=e.value}),Object.keys(n).length>0?n:null}function A(r){const u=r==null?void 0:r.map(e=>({uid:e.configurable_product_option_uid,label:e.option_label,value:e.value_label})),n={};return u==null||u.forEach(e=>{n[e.label]=e.value}),Object.keys(n).length>0?n:null}function E(r){const u=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}))})),n={};return u==null||u.forEach(e=>{var l;switch(e.type){case"field":case"area":case"date_time":n[e.label]=e.values[0].value;break;case"radio":case"drop_down":n[e.label]=e.values[0].label;break;case"multiple":case"checkbox":n[e.label]=e.values.reduce((o,i)=>o?`${o}, ${i.label}`:i.label,"");break;case"file":const t=new DOMParser,c=e.values[0].value,_=((l=t.parseFromString(c,"text/html").querySelector("a"))==null?void 0:l.textContent)||"";n[e.label]=_;break}}),n}function z(r){var u,n;return((u=s.config)==null?void 0:u.cartSummaryDisplayTotal)===0?r.itemsV2.items.length:((n=s.config)==null?void 0:n.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(u=>u.title).join(", ")}:null}function N(r){var u,n,e,l;return(u=r.shipping_addresses)!=null&&u.length?(n=r.shipping_addresses)==null?void 0:n.map(t=>({countryCode:t.country.code,zipCode:t.postcode,regionCode:t.region.code})):(e=r.addresses)!=null&&e.length?(l=r.addresses)==null?void 0:l.filter(t=>t.default_shipping).map(t=>{var c;return t.default_shipping&&{countryCode:t.country_id,zipCode:t.postcode,regionCode:(c=t.region)==null?void 0:c.region_code}}):null}function P(r){var u,n;return(n=(u=r==null?void 0:r.itemsV2)==null?void 0:u.items)==null?void 0:n.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 $(r){if(!r.not_available_message)return null;const u=r.not_available_message.match(/-?\d+/);return u?parseInt(u[0]):"noNumber"}function M(r){var u,n;return(n=(u=r==null?void 0:r.itemsV2)==null?void 0:u.items)==null?void 0:n.some(e=>{var l;return((l=e==null?void 0:e.product)==null?void 0:l.stock_status)==="OUT_OF_STOCK"})}function V(r){var u,n,e;return(e=(n=(u=r==null?void 0:r.product)==null?void 0:u.custom_attributesV2)==null?void 0:n.items)==null?void 0:e.map(l=>{const t=l.code.split("_").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join(" ");return{...l,code:t}})}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
|
-
custom_attributesV2(filters: {is_visible_on_front: true}){
|
|
153
|
-
items{
|
|
154
|
-
code
|
|
155
|
-
...on AttributeValue{
|
|
156
|
-
value
|
|
157
|
-
}
|
|
158
|
-
...on AttributeSelectedOptions{
|
|
159
|
-
selected_options {
|
|
160
|
-
value
|
|
161
|
-
label
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
only_x_left_in_stock
|
|
168
|
-
stock_status
|
|
169
|
-
${T}
|
|
170
|
-
}
|
|
171
|
-
...on SimpleCartItem {
|
|
172
|
-
${p}
|
|
173
|
-
}
|
|
174
|
-
... on ConfigurableCartItem {
|
|
175
|
-
configurable_options {
|
|
176
|
-
configurable_product_option_uid
|
|
177
|
-
option_label
|
|
178
|
-
value_label
|
|
179
|
-
}
|
|
180
|
-
configured_variant {
|
|
181
|
-
uid
|
|
182
|
-
sku
|
|
183
|
-
only_x_left_in_stock
|
|
184
|
-
stock_status
|
|
185
|
-
thumbnail {
|
|
186
|
-
label
|
|
187
|
-
url
|
|
188
|
-
}
|
|
189
|
-
${T}
|
|
190
|
-
}
|
|
191
|
-
${p}
|
|
192
|
-
}
|
|
193
|
-
... on DownloadableCartItem {
|
|
194
|
-
links {
|
|
195
|
-
sort_order
|
|
196
|
-
title
|
|
197
|
-
}
|
|
198
|
-
${p}
|
|
199
|
-
}
|
|
200
|
-
... on BundleCartItem {
|
|
201
|
-
bundle_options {
|
|
202
|
-
uid
|
|
203
|
-
label
|
|
204
|
-
values {
|
|
205
|
-
uid
|
|
206
|
-
label
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
... on GiftCardCartItem {
|
|
211
|
-
message
|
|
212
|
-
recipient_email
|
|
213
|
-
recipient_name
|
|
214
|
-
sender_email
|
|
215
|
-
sender_name
|
|
216
|
-
amount{
|
|
217
|
-
currency
|
|
218
|
-
value
|
|
219
|
-
}
|
|
220
|
-
is_available
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
shipping_addresses {
|
|
225
|
-
country {
|
|
226
|
-
code
|
|
227
|
-
}
|
|
228
|
-
region {
|
|
229
|
-
code
|
|
230
|
-
}
|
|
231
|
-
postcode
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
`,U=`
|
|
235
|
-
$pageSize: Int! = 100,
|
|
236
|
-
$currentPage: Int! = 1,
|
|
237
|
-
$itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}
|
|
238
|
-
`,q=`
|
|
239
|
-
customer {
|
|
240
|
-
addresses {
|
|
241
|
-
default_shipping
|
|
242
|
-
country_id
|
|
243
|
-
postcode
|
|
244
|
-
region {
|
|
245
|
-
region
|
|
246
|
-
region_code
|
|
247
|
-
region_id
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}`;export{U as C,D as a,q as b,R as t};
|