@gomusdev/web-components 1.24.0 → 1.25.0

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.
Files changed (38) hide show
  1. package/dist-js/components/cart/mocks/gomusTicketMocks.d.ts +8 -62
  2. package/dist-js/components/ticketSelection/TicketSelectionDetails.svelte.d.ts +1 -0
  3. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/Item.svelte.d.ts +1 -0
  4. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/TicketSegmentDetails.svelte.d.ts +5 -59
  5. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/annualTickets.svelte.d.ts +1 -1
  6. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/dayTickets.svelte.d.ts +1 -1
  7. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/eventScaledPriceTickets.svelte.d.ts +1 -1
  8. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/timeslotTickets.svelte.d.ts +1 -1
  9. package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/utils.svelte.d.ts +2 -3
  10. package/dist-js/gomus-webcomponents.css +6 -0
  11. package/dist-js/gomus-webcomponents.iife.js +6284 -6019
  12. package/dist-js/gomus-webcomponents.js +6284 -6019
  13. package/dist-js/lib/Log.svelte.d.ts +1 -0
  14. package/dist-js/lib/models/cart/CartEvents.svelte.d.ts +2 -1
  15. package/dist-js/lib/models/cart/CartItem.d.ts +2 -1
  16. package/dist-js/lib/models/cart/capacity/CapacityManager.d.ts +80 -0
  17. package/dist-js/lib/models/cart/capacity/calculators/quotaManager/QuotaManager.d.ts +62 -0
  18. package/dist-js/lib/models/cart/capacity/calculators/quotas.d.ts +2 -0
  19. package/dist-js/lib/models/cart/capacity/calculators/seats.d.ts +13 -0
  20. package/dist-js/lib/models/cart/capacity/calculators/unlimited.d.ts +2 -0
  21. package/dist-js/lib/models/cart/capacity/types.d.ts +10 -0
  22. package/dist-js/lib/models/cart/cart.svelte.d.ts +15 -113
  23. package/dist-js/lib/models/cart/localStorage.svelte.d.ts +2 -29
  24. package/dist-js/lib/models/cart/selectOptions.d.ts +1 -7
  25. package/dist-js/lib/models/cart/types.d.ts +1 -1
  26. package/dist-js/lib/models/scalePrice/UIScaledPrice.svelte.d.ts +4 -0
  27. package/dist-js/lib/models/ticket/UITicket.svelte.d.ts +11 -65
  28. package/dist-js/lib/stores/auth.svelte.d.ts +0 -1
  29. package/dist-js/lib/stores/shop.svelte.d.ts +127 -0
  30. package/dist-js/mocks/MSWMocks.d.ts +2 -2
  31. package/dist-js/mocks/TicketMocks.d.ts +74 -0
  32. package/dist-js/mocks/mocks.d.ts +237 -789
  33. package/package.json +1 -1
  34. package/dist-js/lib/models/capacities/capacities.d.ts +0 -44
  35. /package/dist-js/components/ticketSelection/subcomponents/tickets/{Tickets.spec.d.ts → Tickets.svelte.spec.d.ts} +0 -0
  36. /package/dist-js/components/ticketSelection/subcomponents/tickets/subcomponents/segment/lib/event/{eventTickets.spec.d.ts → eventTickets.svelte.spec.d.ts} +0 -0
  37. /package/dist-js/lib/models/{capacities/capacities.spec.d.ts → cart/capacity/calculators/quotaManager/QuotaManager.spec.d.ts} +0 -0
  38. /package/dist-js/lib/models/cart/{selectOptions.spec.d.ts → capacity/calculators/seats.spec.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
@@ -1 +1,2 @@
1
- export declare function dispatchCartEvents(): void;
1
+ import { Cart } from './cart.svelte.ts';
2
+ export declare function dispatchCartEvents(cart: Cart): void;
@@ -24,7 +24,8 @@ export declare function createCartItem<T extends Product>(product: T, options?:
24
24
  };
25
25
  };
26
26
  uuid: string;
27
- subId: string;
27
+ subUId: string;
28
+ toString(): string;
28
29
  price_cents: number;
29
30
  price_formatted: string;
30
31
  final_price_cents: number;
@@ -0,0 +1,80 @@
1
+ import { Cart } from '../cart.svelte.ts';
2
+ import { CartItem } from '../types.ts';
3
+ import { Quotas } from '@gomus/types';
4
+ type DateID = number;
5
+ type Seats = {
6
+ min?: number;
7
+ max?: number;
8
+ booked?: number;
9
+ available?: number;
10
+ max_per_registration?: number | null;
11
+ overbook?: boolean;
12
+ };
13
+ export type CapacityManager = ReturnType<typeof createCapacityManager>;
14
+ /**
15
+ * Creates and returns an object to manage capacity for quotas and seats.
16
+ * It provides methods to calculate the maximum quantity of items in a cart.
17
+ *
18
+ * It uses the seats and quotas as constrains
19
+ *
20
+ */
21
+ export declare function createCapacityManager(): {
22
+ allSeats: Record<DateID, Seats>;
23
+ allQuotas: Quotas;
24
+ quotaManager: {
25
+ apiData: {
26
+ [key: string]: {
27
+ ticket_ids: number[];
28
+ capacities: {
29
+ [key: string]: number;
30
+ };
31
+ total_capacities: {
32
+ [key: string]: number;
33
+ };
34
+ };
35
+ };
36
+ _timeslots: {
37
+ timeSlot: string;
38
+ quota: string;
39
+ capacity: number;
40
+ tickets: number[];
41
+ totalCapacity: number;
42
+ }[];
43
+ addQuotas(data: Quotas): void;
44
+ precart: Record<string, number>;
45
+ clearPrecart(): void;
46
+ setPrecartItemQuantity(ticketId: number, quantity: number): void;
47
+ getPrecartItemQuantity(ticketId: number): number;
48
+ timeslots(): {
49
+ timeSlot: string;
50
+ quota: string;
51
+ capacity: number;
52
+ tickets: number[];
53
+ totalCapacity: number;
54
+ }[];
55
+ filterBy({ timeslot, ticketId, date }?: {
56
+ timeslot?: string;
57
+ ticketId?: number;
58
+ }): {
59
+ timeslot: string | undefined;
60
+ ticket: number;
61
+ quota: string;
62
+ capacity: number;
63
+ totalCapacity: number;
64
+ }[];
65
+ ticketCapacity(ticketId: number, timeslot: string): number;
66
+ totalCapacity(ticketId: number, timeslot: string): number;
67
+ timeslotsOn(date: import('@internationalized/date').CalendarDate): {
68
+ timeSlot: string;
69
+ quota: string;
70
+ capacity: number;
71
+ tickets: number[];
72
+ totalCapacity: number;
73
+ }[];
74
+ };
75
+ addQuotas(quotas: Quotas): void;
76
+ addSeats(dateId: DateID, seats: Seats): void;
77
+ capacityPolicy(item: CartItem): "quotas" | "unlimited" | "seats";
78
+ capacity(cart: Cart, item: CartItem, preCart: Cart): import('./types').Capacity;
79
+ };
80
+ export {};
@@ -0,0 +1,62 @@
1
+ import { Quotas } from '@gomus/types';
2
+ import { CalendarDate } from '@internationalized/date';
3
+ export type QuotaManager = ReturnType<typeof createQuotaManager>;
4
+ export declare function createQuotaManager(quotas: Quotas): {
5
+ apiData: {
6
+ [key: string]: {
7
+ ticket_ids: number[];
8
+ capacities: {
9
+ [key: string]: number;
10
+ };
11
+ total_capacities: {
12
+ [key: string]: number;
13
+ };
14
+ };
15
+ };
16
+ _timeslots: {
17
+ timeSlot: string;
18
+ quota: string;
19
+ capacity: number;
20
+ tickets: number[];
21
+ totalCapacity: number;
22
+ }[];
23
+ addQuotas(data: Quotas): void;
24
+ precart: Record<string, number>;
25
+ clearPrecart(): void;
26
+ setPrecartItemQuantity(ticketId: number, quantity: number): void;
27
+ getPrecartItemQuantity(ticketId: number): number;
28
+ /**
29
+ * a flat list of all timeslots and their capacities, respecting preCart.
30
+ */
31
+ timeslots(): {
32
+ timeSlot: string;
33
+ quota: string;
34
+ capacity: number;
35
+ tickets: number[];
36
+ totalCapacity: number;
37
+ }[];
38
+ /**
39
+ * Filters timeslots based on timeslot or ticketId.
40
+ *
41
+ * If timeslot is provided, it will return the timeslot with the closest earlier timeSlot.
42
+ */
43
+ filterBy({ timeslot, ticketId, date }?: {
44
+ timeslot?: string;
45
+ ticketId?: number;
46
+ }): {
47
+ timeslot: string | undefined;
48
+ ticket: number;
49
+ quota: string;
50
+ capacity: number;
51
+ totalCapacity: number;
52
+ }[];
53
+ ticketCapacity(ticketId: number, timeslot: string): number;
54
+ totalCapacity(ticketId: number, timeslot: string): number;
55
+ timeslotsOn(date: CalendarDate): {
56
+ timeSlot: string;
57
+ quota: string;
58
+ capacity: number;
59
+ tickets: number[];
60
+ totalCapacity: number;
61
+ }[];
62
+ };
@@ -0,0 +1,2 @@
1
+ import { CapacityCalculator } from '../types.ts';
2
+ export declare const maxQuantity_Quotas: CapacityCalculator;
@@ -0,0 +1,13 @@
1
+ import { CapacityCalculator } from '../types.ts';
2
+ /**
3
+ * Calculates the maximum number of available seats for a given item in the cart and preCart.
4
+ *
5
+ * @param {CapacityManager} manager - Instance of CapacityManager containing seat information.
6
+ * @param {Cart} cart - The current shopping cart containing items.
7
+ * @param {CartItem} item - The specific cart item for which to calculate seat Quantity.
8
+ * @param {Cart} preCart - The pre-cart containing items that should also be considered.
9
+ *
10
+ * @return {number} The maximum number of available seats for the specific item after considering the cart and preCart.
11
+ * @throws {Error} Throws an error if the item's product is not a valid UI event ticket.
12
+ */
13
+ export declare const maxQuantity_Seats: CapacityCalculator;
@@ -0,0 +1,2 @@
1
+ import { CapacityCalculator } from '../types.ts';
2
+ export declare const maxQuantity_Unlimited: CapacityCalculator;
@@ -0,0 +1,10 @@
1
+ import { CapacityManager } from './CapacityManager.ts';
2
+ import { Cart } from '../cart.svelte.ts';
3
+ import { CartItem } from '../types.ts';
4
+ export type Capacity = {
5
+ min: number;
6
+ max: number;
7
+ unavailable: boolean;
8
+ bookedOut: boolean;
9
+ };
10
+ export type CapacityCalculator = (manager: CapacityManager, cart: Cart, item: CartItem, preCart: Cart) => Capacity;
@@ -1,66 +1,16 @@
1
1
  import { CartItem, Product } from './types.ts';
2
2
  export type Cart = ReturnType<typeof createCart>;
3
3
  export declare function createCart(products?: Product[], contingent?: number): {
4
- items: {
5
- type: import('./types.ts').ProductType;
6
- product: Product;
7
- orderAttributes(): {
8
- shipped_with_merchandise_id: null;
9
- shipping_mode: string;
10
- id: number;
11
- time: string;
12
- quantity: number;
13
- } | {
14
- shipped_with_merchandise_id: null;
15
- shipping_mode: string;
16
- id: number;
17
- quantities: {
18
- [x: number]: number;
19
- };
20
- };
21
- uuid: string;
22
- subId: string;
23
- price_cents: number;
24
- price_formatted: string;
25
- final_price_cents: number;
26
- final_price_formatted: string;
27
- total_price_cents: number;
28
- total_price_formatted: string;
29
- quantity: number;
30
- time: string;
31
- }[];
4
+ items: CartItem[];
32
5
  contingent: number;
33
6
  uid: string;
34
- readonly nonEmptyItems: {
35
- type: import('./types.ts').ProductType;
36
- product: Product;
37
- orderAttributes(): {
38
- shipped_with_merchandise_id: null;
39
- shipping_mode: string;
40
- id: number;
41
- time: string;
42
- quantity: number;
43
- } | {
44
- shipped_with_merchandise_id: null;
45
- shipping_mode: string;
46
- id: number;
47
- quantities: {
48
- [x: number]: number;
49
- };
50
- };
51
- uuid: string;
52
- subId: string;
53
- price_cents: number;
54
- price_formatted: string;
55
- final_price_cents: number;
56
- final_price_formatted: string;
57
- total_price_cents: number;
58
- total_price_formatted: string;
59
- quantity: number;
60
- time: string;
61
- }[];
7
+ readonly nonEmptyItems: CartItem[];
62
8
  readonly totalPriceCents: number;
63
9
  readonly totalQuantity: number;
10
+ /**
11
+ * Generates a formatted string representation of the current object.
12
+ */
13
+ toString(): string;
64
14
  orderData(): {
65
15
  items: {
66
16
  type: import('./types.ts').ProductType;
@@ -93,69 +43,20 @@ export declare function createCart(products?: Product[], contingent?: number): {
93
43
  deleteItem(item: CartItem): void;
94
44
  addItem(item: CartItem): void;
95
45
  addItems(items: CartItem[]): void;
46
+ addProducts(products: Product[]): void;
96
47
  };
97
48
  export declare function formatCurrency(priceCents: number): string;
98
- export declare const cart: {
99
- items: {
100
- type: import('./types.ts').ProductType;
101
- product: Product;
102
- orderAttributes(): {
103
- shipped_with_merchandise_id: null;
104
- shipping_mode: string;
105
- id: number;
106
- time: string;
107
- quantity: number;
108
- } | {
109
- shipped_with_merchandise_id: null;
110
- shipping_mode: string;
111
- id: number;
112
- quantities: {
113
- [x: number]: number;
114
- };
115
- };
116
- uuid: string;
117
- subId: string;
118
- price_cents: number;
119
- price_formatted: string;
120
- final_price_cents: number;
121
- final_price_formatted: string;
122
- total_price_cents: number;
123
- total_price_formatted: string;
124
- quantity: number;
125
- time: string;
126
- }[];
49
+ export declare function createMainCart(): {
50
+ items: CartItem[];
127
51
  contingent: number;
128
52
  uid: string;
129
- readonly nonEmptyItems: {
130
- type: import('./types.ts').ProductType;
131
- product: Product;
132
- orderAttributes(): {
133
- shipped_with_merchandise_id: null;
134
- shipping_mode: string;
135
- id: number;
136
- time: string;
137
- quantity: number;
138
- } | {
139
- shipped_with_merchandise_id: null;
140
- shipping_mode: string;
141
- id: number;
142
- quantities: {
143
- [x: number]: number;
144
- };
145
- };
146
- uuid: string;
147
- subId: string;
148
- price_cents: number;
149
- price_formatted: string;
150
- final_price_cents: number;
151
- final_price_formatted: string;
152
- total_price_cents: number;
153
- total_price_formatted: string;
154
- quantity: number;
155
- time: string;
156
- }[];
53
+ readonly nonEmptyItems: CartItem[];
157
54
  readonly totalPriceCents: number;
158
55
  readonly totalQuantity: number;
56
+ /**
57
+ * Generates a formatted string representation of the current object.
58
+ */
59
+ toString(): string;
159
60
  orderData(): {
160
61
  items: {
161
62
  type: import('./types.ts').ProductType;
@@ -188,4 +89,5 @@ export declare const cart: {
188
89
  deleteItem(item: CartItem): void;
189
90
  addItem(item: CartItem): void;
190
91
  addItems(items: CartItem[]): void;
92
+ addProducts(products: Product[]): void;
191
93
  };
@@ -1,5 +1,5 @@
1
1
  import { Cart } from './cart.svelte.ts';
2
- import { CartItem, ProductType } from './types.ts';
2
+ import { CartItem } from './types.ts';
3
3
  export declare function updateLocalStorage(cart: Cart): string;
4
4
  /**
5
5
  * Generates a cart item based on the provided json object.
@@ -9,34 +9,7 @@ export declare function updateLocalStorage(cart: Cart): string;
9
9
  */
10
10
  export declare function generateCartItem(cartItem: any): CartItem | undefined;
11
11
  export declare function clearLocalStorage(): void;
12
- export declare function loadFromLocalStorage(cart: Cart): {
13
- type: ProductType;
14
- product: import('./types.ts').Product;
15
- orderAttributes(): {
16
- shipped_with_merchandise_id: null;
17
- shipping_mode: string;
18
- id: number;
19
- time: string;
20
- quantity: number;
21
- } | {
22
- shipped_with_merchandise_id: null;
23
- shipping_mode: string;
24
- id: number;
25
- quantities: {
26
- [x: number]: number;
27
- };
28
- };
29
- uuid: string;
30
- subId: string;
31
- price_cents: number;
32
- price_formatted: string;
33
- final_price_cents: number;
34
- final_price_formatted: string;
35
- total_price_cents: number;
36
- total_price_formatted: string;
37
- quantity: number;
38
- time: string;
39
- }[];
12
+ export declare function loadFromLocalStorage(cart: Cart): CartItem[];
40
13
  /**
41
14
  * Synchronizes the given shopping cart with the local storage. The method ensures that the cart is loaded from local storage,
42
15
  * updates are reflected in the local storage, and any external changes to the local storage are propagated to the cart.
@@ -1,10 +1,4 @@
1
- import { Cart } from './cart.svelte.ts';
2
- import { CartItem } from './types.ts';
3
- export declare function selectOptions(cart: Cart, item: CartItem): {
4
- min: number;
5
- max: number;
6
- };
7
- export declare function generateQuantityOptions(cart: Cart, item: CartItem): {
1
+ export declare function generateQuantityOptions(min: number, max: number): {
8
2
  value: number;
9
3
  label: string;
10
4
  }[];
@@ -1,6 +1,6 @@
1
1
  import { createCartItem } from './CartItem.ts';
2
2
  export type ProductType = 'Ticket' | 'Event';
3
- export type CartItem = ReturnType<typeof createCartItem>;
3
+ export type CartItem<T extends Product = Product> = ReturnType<typeof createCartItem<T>>;
4
4
  /**
5
5
  * minimal props to define a Product in a CartItem
6
6
  */
@@ -26,6 +26,8 @@ export declare function createUIEventTicket(apiTicket: EventScalePriceTicket, da
26
26
  tax_included: boolean;
27
27
  product_type: ProductType;
28
28
  uid: number;
29
+ dateId: number;
30
+ scalePriceId: number;
29
31
  } | {
30
32
  type: UIEventTicketTypes;
31
33
  product_type: ProductType;
@@ -41,5 +43,7 @@ export declare function createUIEventTicket(apiTicket: EventScalePriceTicket, da
41
43
  id: number;
42
44
  tax_included: boolean;
43
45
  uid: number;
46
+ dateId: number;
47
+ scalePriceId: number;
44
48
  };
45
49
  export {};
@@ -1,16 +1,17 @@
1
1
  import { Product, ProductType } from '../cart/types.ts';
2
- import { AnnualTicket, Ticket, Tickets } from '@gomus/types';
2
+ import { AnnualTicket, NormalTickets, Ticket, Tickets } from '@gomus/types';
3
3
  interface Options {
4
4
  selectedTime?: string;
5
5
  }
6
6
  export type UITicketType = 'timeslot' | 'annual' | 'day' | 'event:ticket';
7
7
  export type UITicket = ReturnType<typeof createUITicket>;
8
8
  export declare function isUITicket(x: Product): x is UITicket;
9
- export declare function createUITicket(apiTicket: Ticket | AnnualTicket, options?: Options): {
9
+ export declare function createUITicket(apiTicket: Ticket | AnnualTicket | NormalTickets[number], options?: Options): {
10
+ uid: number;
11
+ selectedTime: string;
10
12
  product_type: ProductType;
11
13
  type: UITicketType;
12
14
  shop_order: number;
13
- selectedTime: string;
14
15
  id: number;
15
16
  title: string;
16
17
  ticket_type: "time_slot" | "annual" | "normal";
@@ -61,8 +62,9 @@ export declare function createUITicket(apiTicket: Ticket | AnnualTicket, options
61
62
  dynamic_prices: {
62
63
  [key: string]: number;
63
64
  } | null;
64
- uid: number;
65
65
  } | {
66
+ uid: number;
67
+ selectedTime: string;
66
68
  product_type: ProductType;
67
69
  type: UITicketType;
68
70
  shop_order: number;
@@ -105,23 +107,15 @@ export declare function createUITicket(apiTicket: Ticket | AnnualTicket, options
105
107
  shipped_with_merchandise_id: number | null;
106
108
  restricted_shop_account: boolean;
107
109
  cash_point_order: number;
108
- capacities: {
109
- [key: string]: number;
110
- };
111
- total_capacities: {
112
- [key: string]: number;
113
- };
114
- max_capacity: number;
115
- max_total_capacity: number;
116
110
  dynamic_prices: {
117
111
  [key: string]: number;
118
112
  } | null;
119
- uid: number;
120
113
  } | {
114
+ uid: number;
115
+ selectedTime: string;
121
116
  product_type: ProductType;
122
117
  type: UITicketType;
123
118
  shop_order: number;
124
- selectedTime: string;
125
119
  id: number;
126
120
  title: string;
127
121
  ticket_type: "time_slot" | "annual" | "normal";
@@ -133,8 +127,6 @@ export declare function createUITicket(apiTicket: Ticket | AnnualTicket, options
133
127
  vat_pct: number;
134
128
  tax_included: boolean;
135
129
  entry_duration: number | null;
136
- min_persons: number;
137
- max_persons: number;
138
130
  quota_ids: number[];
139
131
  first_entry: number;
140
132
  last_entry: number;
@@ -158,60 +150,14 @@ export declare function createUITicket(apiTicket: Ticket | AnnualTicket, options
158
150
  is_sub_ticket: boolean;
159
151
  created_at: string;
160
152
  updated_at: string;
153
+ cash_point_order: number;
161
154
  shipped_with_merchandise_id: number | null;
162
155
  restricted_shop_account: boolean;
163
- cash_point_order: number;
164
- dynamic_prices: {
165
- [key: string]: number;
166
- } | null;
167
- uid: number;
168
- } | {
169
- product_type: ProductType;
170
- type: UITicketType;
171
- shop_order: number;
172
- id: number;
173
- title: string;
174
- ticket_type: "time_slot" | "annual" | "normal";
175
- bookable: boolean;
176
- museum_ids: number[];
177
- exhibition_ids: number[];
178
- price_cents: number;
179
- discount: number;
180
- vat_pct: number;
181
- tax_included: boolean;
182
- entry_duration: number | null;
183
156
  min_persons: number;
184
157
  max_persons: number;
185
- quota_ids: number[];
186
- first_entry: number;
187
- last_entry: number;
188
- personalizeable: boolean;
189
- attendees: boolean | string;
190
- identification: boolean | string;
191
- free_timing: boolean;
192
- is_collective: boolean;
193
- is_upgrade: boolean;
194
- is_mantle: boolean;
195
- description: string | null;
196
- sub_ticket_ids: number[];
197
- sub_tickets: {
198
- [key: string]: {
199
- title?: string;
200
- min_persons?: number;
201
- max_persons?: number;
202
- description?: string | null;
203
- };
204
- } | null;
205
- is_sub_ticket: boolean;
206
- created_at: string;
207
- updated_at: string;
208
- shipped_with_merchandise_id: number | null;
209
- restricted_shop_account: boolean;
210
- cash_point_order: number;
211
- dynamic_prices: {
158
+ dynamic_prices?: {
212
159
  [key: string]: number;
213
160
  } | null;
214
- uid: number;
215
161
  };
216
- export declare function initUITimeslotTickets(tickets: Tickets): UITicket[];
162
+ export declare function initUITimeslotTickets(tickets: Tickets, selectedTime?: string): UITicket[];
217
163
  export {};
@@ -22,4 +22,3 @@ export declare class Auth {
22
22
  save(): void;
23
23
  load(): void;
24
24
  }
25
- export declare const auth: Auth;