@moonbase.sh/vue 0.1.45 → 0.1.47

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/index.cjs CHANGED
@@ -253,10 +253,12 @@ function useCart() {
253
253
  return { amount: total, currency };
254
254
  }),
255
255
  addToCart: (item, variation) => {
256
+ if ((0, import_vue5.isRef)(item))
257
+ item = item.value;
256
258
  variation != null ? variation : variation = item.defaultVariation;
257
259
  if (!variation)
258
260
  throw new Error("Added item does not have a default variation, and none have been specified");
259
- const id = `b/${item.id}/${variation.id}`;
261
+ const id = `${item.type === "bundle" ? "b" : "p"}/${item.id}/${variation.id}`;
260
262
  let lineItem = storefront.currentOrder.value.items.find((i) => i.id === id);
261
263
  if (!lineItem) {
262
264
  if (item.type === "bundle") {
package/dist/index.d.cts CHANGED
@@ -39,7 +39,7 @@ declare function useCart(): {
39
39
  amount: number;
40
40
  currency: string;
41
41
  }>;
42
- addToCart: (item: StorefrontProduct | StorefrontBundle, variation?: PricingVariation) => void;
42
+ addToCart: (item: StorefrontProduct | StorefrontBundle | Ref<StorefrontProduct> | Ref<StorefrontBundle>, variation?: PricingVariation) => void;
43
43
  setQuantity: (cartItem: CartItem, quantity: number) => void;
44
44
  removeFromCart: (cartItem: CartItem) => void;
45
45
  checkout: (returnUrl: string) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ declare function useCart(): {
39
39
  amount: number;
40
40
  currency: string;
41
41
  }>;
42
- addToCart: (item: StorefrontProduct | StorefrontBundle, variation?: PricingVariation) => void;
42
+ addToCart: (item: StorefrontProduct | StorefrontBundle | Ref<StorefrontProduct> | Ref<StorefrontBundle>, variation?: PricingVariation) => void;
43
43
  setQuantity: (cartItem: CartItem, quantity: number) => void;
44
44
  removeFromCart: (cartItem: CartItem) => void;
45
45
  checkout: (returnUrl: string) => Promise<void>;
package/dist/index.js CHANGED
@@ -192,7 +192,7 @@ function useProducts() {
192
192
  }
193
193
 
194
194
  // src/composables/useCart.ts
195
- import { computed as computed5, inject as inject5 } from "vue";
195
+ import { computed as computed5, inject as inject5, isRef } from "vue";
196
196
  function useCart() {
197
197
  const storefront = inject5(storefrontKey);
198
198
  if (!storefront)
@@ -221,10 +221,12 @@ function useCart() {
221
221
  return { amount: total, currency };
222
222
  }),
223
223
  addToCart: (item, variation) => {
224
+ if (isRef(item))
225
+ item = item.value;
224
226
  variation != null ? variation : variation = item.defaultVariation;
225
227
  if (!variation)
226
228
  throw new Error("Added item does not have a default variation, and none have been specified");
227
- const id = `b/${item.id}/${variation.id}`;
229
+ const id = `${item.type === "bundle" ? "b" : "p"}/${item.id}/${variation.id}`;
228
230
  let lineItem = storefront.currentOrder.value.items.find((i) => i.id === id);
229
231
  if (!lineItem) {
230
232
  if (item.type === "bundle") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/vue",
3
3
  "type": "module",
4
- "version": "0.1.45",
4
+ "version": "0.1.47",
5
5
  "description": "Package to let you build vue.js storefronts with Moonbase.sh as payment and delivery provider",
6
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
7
7
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "@vue/devtools-api": "^6.5.1",
20
20
  "uuid": "^9.0.1",
21
- "@moonbase.sh/api-client": "0.1.45"
21
+ "@moonbase.sh/api-client": "0.1.47"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/uuid": "^9.0.7",