@gomusdev/web-components 1.55.1 → 1.55.2

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.
@@ -11335,22 +11335,16 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11335
11335
  };
11336
11336
  const defined = (x) => x !== void 0;
11337
11337
  let lastUuid = 0;
11338
- function createCart(products, contingent = 20) {
11338
+ function createCart(products) {
11339
11339
  const items = proxy([]);
11340
11340
  const coupons = proxy([]);
11341
- let paymentModeId = /* @__PURE__ */ state(void 0);
11341
+ let paymentModeId = void 0;
11342
11342
  const cart = {
11343
11343
  items,
11344
11344
  coupons,
11345
- contingent,
11345
+ paymentModeId,
11346
11346
  // caps the total number of items in the cart
11347
11347
  uid: `cart-${lastUuid++}`,
11348
- get paymentModeId() {
11349
- return get$2(paymentModeId);
11350
- },
11351
- set paymentModeId(value) {
11352
- set(paymentModeId, value, true);
11353
- },
11354
11348
  get nonEmptyItems() {
11355
11349
  return this.items.filter((i) => i.quantity > 0);
11356
11350
  },
@@ -11397,9 +11391,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
11397
11391
  addItems(items2) {
11398
11392
  items2.forEach((item) => this.addItem(item));
11399
11393
  },
11400
- addProducts(products2) {
11401
- products2.forEach((p2) => this.addItem(createCartItem(p2)));
11402
- },
11403
11394
  addCoupon(token) {
11404
11395
  if (!this.coupons.includes(token)) {
11405
11396
  this.coupons.push(token);
@@ -17467,11 +17458,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17467
17458
  wrapInElement($$props.$$host, "go-form", { "form-id": "checkoutGuest", custom: custom2() });
17468
17459
  $$props.$$host.addEventListener("submit", async (e) => {
17469
17460
  const form = e.target;
17461
+ if (!get$2(cart)) return;
17470
17462
  const auth = await shop.signUp(form.details.formData, true);
17471
17463
  if (auth.error) {
17472
17464
  form.details.apiErrors = auth.error.errors;
17473
17465
  return;
17474
17466
  }
17467
+ const paymentMode = form.details.fieldValue("paymentMode");
17468
+ get$2(cart).paymentModeId = paymentMode == null ? void 0 : String(paymentMode);
17475
17469
  const checkout = await shop.checkout(get$2(cart).orderData());
17476
17470
  if (checkout.error) {
17477
17471
  form.details.apiErrors = checkout.error;
@@ -11335,22 +11335,16 @@ const inTheFuture = (time2) => {
11335
11335
  };
11336
11336
  const defined = (x) => x !== void 0;
11337
11337
  let lastUuid = 0;
11338
- function createCart(products, contingent = 20) {
11338
+ function createCart(products) {
11339
11339
  const items = proxy([]);
11340
11340
  const coupons = proxy([]);
11341
- let paymentModeId = /* @__PURE__ */ state(void 0);
11341
+ let paymentModeId = void 0;
11342
11342
  const cart = {
11343
11343
  items,
11344
11344
  coupons,
11345
- contingent,
11345
+ paymentModeId,
11346
11346
  // caps the total number of items in the cart
11347
11347
  uid: `cart-${lastUuid++}`,
11348
- get paymentModeId() {
11349
- return get$2(paymentModeId);
11350
- },
11351
- set paymentModeId(value) {
11352
- set(paymentModeId, value, true);
11353
- },
11354
11348
  get nonEmptyItems() {
11355
11349
  return this.items.filter((i) => i.quantity > 0);
11356
11350
  },
@@ -11397,9 +11391,6 @@ function createCart(products, contingent = 20) {
11397
11391
  addItems(items2) {
11398
11392
  items2.forEach((item) => this.addItem(item));
11399
11393
  },
11400
- addProducts(products2) {
11401
- products2.forEach((p2) => this.addItem(createCartItem(p2)));
11402
- },
11403
11394
  addCoupon(token) {
11404
11395
  if (!this.coupons.includes(token)) {
11405
11396
  this.coupons.push(token);
@@ -17467,11 +17458,14 @@ function CheckoutForm($$anchor, $$props) {
17467
17458
  wrapInElement($$props.$$host, "go-form", { "form-id": "checkoutGuest", custom: custom2() });
17468
17459
  $$props.$$host.addEventListener("submit", async (e) => {
17469
17460
  const form = e.target;
17461
+ if (!get$2(cart)) return;
17470
17462
  const auth = await shop.signUp(form.details.formData, true);
17471
17463
  if (auth.error) {
17472
17464
  form.details.apiErrors = auth.error.errors;
17473
17465
  return;
17474
17466
  }
17467
+ const paymentMode = form.details.fieldValue("paymentMode");
17468
+ get$2(cart).paymentModeId = paymentMode == null ? void 0 : String(paymentMode);
17475
17469
  const checkout = await shop.checkout(get$2(cart).orderData());
17476
17470
  if (checkout.error) {
17477
17471
  form.details.apiErrors = checkout.error;
@@ -1,11 +1,10 @@
1
1
  import { CartItem, Product } from './types.ts';
2
2
  export type Cart = ReturnType<typeof createCart>;
3
- export declare function createCart(products?: Product[], contingent?: number): {
3
+ export declare function createCart(products?: Product[]): {
4
4
  items: CartItem[];
5
5
  coupons: string[];
6
- contingent: number;
6
+ paymentModeId: undefined;
7
7
  uid: string;
8
- paymentModeId: string | undefined;
9
8
  readonly nonEmptyItems: CartItem[];
10
9
  readonly totalPriceCents: number;
11
10
  readonly totalQuantity: number;
@@ -45,7 +44,6 @@ export declare function createCart(products?: Product[], contingent?: number): {
45
44
  deleteItem(item: CartItem): void;
46
45
  addItem(item: CartItem): void;
47
46
  addItems(items: CartItem[]): void;
48
- addProducts(products: Product[]): void;
49
47
  addCoupon(token: string): void;
50
48
  removeCoupon(token: string): void;
51
49
  clearCoupons(): void;
@@ -54,9 +52,8 @@ export declare function formatCurrency(priceCents: number): string;
54
52
  export declare function createMainCart(): {
55
53
  items: CartItem[];
56
54
  coupons: string[];
57
- contingent: number;
55
+ paymentModeId: undefined;
58
56
  uid: string;
59
- paymentModeId: string | undefined;
60
57
  readonly nonEmptyItems: CartItem[];
61
58
  readonly totalPriceCents: number;
62
59
  readonly totalQuantity: number;
@@ -96,7 +93,6 @@ export declare function createMainCart(): {
96
93
  deleteItem(item: CartItem): void;
97
94
  addItem(item: CartItem): void;
98
95
  addItems(items: CartItem[]): void;
99
- addProducts(products: Product[]): void;
100
96
  addCoupon(token: string): void;
101
97
  removeCoupon(token: string): void;
102
98
  clearCoupons(): void;
@@ -75,9 +75,8 @@ export declare class Shop {
75
75
  get cart(): {
76
76
  items: import('../models/cart/types').CartItem[];
77
77
  coupons: string[];
78
- contingent: number;
78
+ paymentModeId: undefined;
79
79
  uid: string;
80
- paymentModeId: string | undefined;
81
80
  readonly nonEmptyItems: import('../models/cart/types').CartItem[];
82
81
  readonly totalPriceCents: number;
83
82
  readonly totalQuantity: number;
@@ -114,7 +113,6 @@ export declare class Shop {
114
113
  deleteItem(item: import('../models/cart/types').CartItem): void;
115
114
  addItem(item: import('../models/cart/types').CartItem): void;
116
115
  addItems(items: import('../models/cart/types').CartItem[]): void;
117
- addProducts(products: import('../models/cart/types').Product[]): void;
118
116
  addCoupon(token: string): void;
119
117
  removeCoupon(token: string): void;
120
118
  clearCoupons(): void;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Giantmonkey GmbH"
5
5
  },
6
6
  "license": "MIT",
7
- "version": "1.55.1",
7
+ "version": "1.55.2",
8
8
  "type": "module",
9
9
  "main": "./dist-js/gomus-webcomponents.iife.js",
10
10
  "module": "./dist-js/gomus-webcomponents.iife.js",
@@ -20,6 +20,7 @@
20
20
  "build": "vite build",
21
21
  "preview": "vite preview",
22
22
  "check": "svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json",
23
+ "prettier": "prettier --write \"src/**/*.{ts,js,svelte,css,scss,html,json,md}\"",
23
24
  "open-test": "vite build && vite --open src/test.html",
24
25
  "=== W E B C O M P O N E N T S ===": "",
25
26
  "build-web-components-and-copy": "pnpm build-web-components; pnpm copy-web-components",