@meaple-com/react-headless-components 1.0.4 → 1.0.5
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 +42 -9
- package/dist/index.d.cts +10 -11
- package/dist/index.d.ts +10 -11
- package/dist/index.js +44 -11
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -276,8 +276,13 @@ var ListEventProducts = ({
|
|
|
276
276
|
privateToken,
|
|
277
277
|
options
|
|
278
278
|
);
|
|
279
|
+
const { data: platformFee } = (0, import_react_query4.usePlatformFee)(eventId, {
|
|
280
|
+
enabled: !!eventId
|
|
281
|
+
});
|
|
282
|
+
const fee = platformFee?.fee ?? 0;
|
|
279
283
|
return children({
|
|
280
284
|
products: data?.products ?? [],
|
|
285
|
+
fee,
|
|
281
286
|
isPending,
|
|
282
287
|
error
|
|
283
288
|
});
|
|
@@ -309,9 +314,14 @@ var ListEventTickets = ({
|
|
|
309
314
|
predecessorIds,
|
|
310
315
|
options
|
|
311
316
|
);
|
|
317
|
+
const { data: platformFee } = (0, import_react_query6.usePlatformFee)(eventId, {
|
|
318
|
+
enabled: !!eventId
|
|
319
|
+
});
|
|
320
|
+
const fee = platformFee?.fee ?? 0;
|
|
312
321
|
return children({
|
|
313
322
|
tickets: data?.tickets ?? [],
|
|
314
323
|
groups: data?.groups ?? [],
|
|
324
|
+
fee,
|
|
315
325
|
isPending,
|
|
316
326
|
error
|
|
317
327
|
});
|
|
@@ -343,7 +353,7 @@ var ListUserEventTickets = ({
|
|
|
343
353
|
options
|
|
344
354
|
);
|
|
345
355
|
return children({
|
|
346
|
-
userTickets: data
|
|
356
|
+
userTickets: data ?? [],
|
|
347
357
|
isPending,
|
|
348
358
|
error
|
|
349
359
|
});
|
|
@@ -379,17 +389,28 @@ var TicketQuantityController = ({
|
|
|
379
389
|
const item = cart.getItem(ticket.id);
|
|
380
390
|
const amount = item?.amount ?? 0;
|
|
381
391
|
const incrementAmount = ticket.minBuy ?? 1;
|
|
382
|
-
const
|
|
383
|
-
const
|
|
384
|
-
const
|
|
392
|
+
const maxByPolicy = ticket.maxBuy ?? Infinity;
|
|
393
|
+
const maxByStock = ticket.availableAmount != null ? ticket.availableAmount : Infinity;
|
|
394
|
+
const effectiveMax = Math.min(maxByPolicy, maxByStock);
|
|
395
|
+
const isMaxLimitReached = amount + incrementAmount > effectiveMax;
|
|
396
|
+
const disabled = ticket.availableAmount === 0 || maxByPolicy === 0 || effectiveMax === 0;
|
|
385
397
|
const increment = (0, import_react4.useCallback)(() => {
|
|
386
398
|
if (disabled) return;
|
|
387
|
-
if (amount + incrementAmount
|
|
399
|
+
if (amount + incrementAmount > effectiveMax) return;
|
|
400
|
+
if (ticket.availableAmount != null && amount + incrementAmount >= ticket.availableAmount && onSoldOut)
|
|
388
401
|
onSoldOut();
|
|
389
402
|
for (let i = 0; i < incrementAmount; i++) {
|
|
390
403
|
cart.incrementToCart(ticket);
|
|
391
404
|
}
|
|
392
|
-
}, [
|
|
405
|
+
}, [
|
|
406
|
+
amount,
|
|
407
|
+
incrementAmount,
|
|
408
|
+
ticket,
|
|
409
|
+
onSoldOut,
|
|
410
|
+
cart,
|
|
411
|
+
disabled,
|
|
412
|
+
effectiveMax
|
|
413
|
+
]);
|
|
393
414
|
const decrement = (0, import_react4.useCallback)(() => {
|
|
394
415
|
if (disabled) return;
|
|
395
416
|
for (let i = 0; i < incrementAmount; i++) {
|
|
@@ -416,15 +437,27 @@ function useTicketQuantity({
|
|
|
416
437
|
const item = cart.getItem(ticket.id);
|
|
417
438
|
const amount = item?.amount ?? 0;
|
|
418
439
|
const incrementAmount = ticket.minBuy ?? 1;
|
|
419
|
-
const
|
|
440
|
+
const maxByPolicy = ticket.maxBuy ?? Infinity;
|
|
441
|
+
const maxByStock = ticket.availableAmount != null ? ticket.availableAmount : Infinity;
|
|
442
|
+
const effectiveMax = Math.min(maxByPolicy, maxByStock);
|
|
443
|
+
const isMaxLimitReached = amount + incrementAmount > effectiveMax;
|
|
420
444
|
const increment = (0, import_react5.useCallback)(() => {
|
|
421
445
|
if (disabled) return;
|
|
422
|
-
if (amount + incrementAmount
|
|
446
|
+
if (amount + incrementAmount > effectiveMax) return;
|
|
447
|
+
if (ticket.availableAmount != null && amount + incrementAmount >= ticket.availableAmount && onSoldOut)
|
|
423
448
|
onSoldOut();
|
|
424
449
|
for (let i = 0; i < incrementAmount; i++) {
|
|
425
450
|
cart.incrementToCart(ticket);
|
|
426
451
|
}
|
|
427
|
-
}, [
|
|
452
|
+
}, [
|
|
453
|
+
amount,
|
|
454
|
+
incrementAmount,
|
|
455
|
+
ticket,
|
|
456
|
+
onSoldOut,
|
|
457
|
+
cart,
|
|
458
|
+
disabled,
|
|
459
|
+
effectiveMax
|
|
460
|
+
]);
|
|
428
461
|
const decrement = (0, import_react5.useCallback)(() => {
|
|
429
462
|
if (disabled) return;
|
|
430
463
|
for (let i = 0; i < incrementAmount; i++) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import * as _meaple_com_types from '@meaple-com/types';
|
|
3
|
-
import { TicketProps, GroupProps
|
|
3
|
+
import { TicketProps, GroupProps, CouponProps, GetOrderProps as GetOrderProps$1, CategoryProps, FindEventProductItemProps, FindEventItemProps, FindEventsParams, FindEventTicketItemProps, FindEventTicketGroupProps, GetUserEventsProps, UserTicketProps, UserOrderProps } from '@meaple-com/types';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { useCheckCoupon, useOrder, useCategories, useEventProducts, useEvents, useEventTickets, useUserEvents, useUserEventTickets, useUserOrders } from '@meaple-com/react-query';
|
|
6
6
|
|
|
7
7
|
type ItemProps$1 = Pick<TicketProps, 'id' | 'name' | 'price' | 'amount' | 'type'> & {
|
|
8
|
-
group?: Pick<GroupProps
|
|
8
|
+
group?: Pick<GroupProps, 'name'>;
|
|
9
9
|
};
|
|
10
10
|
type PlatformFeeData = {
|
|
11
11
|
fee: number;
|
|
@@ -34,7 +34,7 @@ type CartProps = {
|
|
|
34
34
|
declare const Cart: ({ children, feeType, platformFee, }: CartProps) => ReactNode;
|
|
35
35
|
|
|
36
36
|
type ItemProps = Pick<TicketProps, 'id' | 'name' | 'price' | 'amount' | 'type'> & {
|
|
37
|
-
group?: Pick<GroupProps
|
|
37
|
+
group?: Pick<GroupProps, 'name'>;
|
|
38
38
|
};
|
|
39
39
|
type SeatProps = {
|
|
40
40
|
id: string;
|
|
@@ -117,7 +117,8 @@ declare const ListCategories: ({ children, options }: ListCategoriesProps) => Re
|
|
|
117
117
|
|
|
118
118
|
type ListEventProductsProps = {
|
|
119
119
|
children: (props: {
|
|
120
|
-
products:
|
|
120
|
+
products: FindEventProductItemProps[];
|
|
121
|
+
fee: number;
|
|
121
122
|
isPending: boolean;
|
|
122
123
|
error: Error | null;
|
|
123
124
|
}) => ReactNode;
|
|
@@ -129,7 +130,7 @@ declare const ListEventProducts: ({ children, eventId, privateToken, options, }:
|
|
|
129
130
|
|
|
130
131
|
type ListEventsProps = {
|
|
131
132
|
children: (props: {
|
|
132
|
-
events:
|
|
133
|
+
events: FindEventItemProps[];
|
|
133
134
|
isPending: boolean;
|
|
134
135
|
error: Error | null;
|
|
135
136
|
}) => ReactNode;
|
|
@@ -138,13 +139,11 @@ type ListEventsProps = {
|
|
|
138
139
|
};
|
|
139
140
|
declare const ListEvents: ({ children, params, options }: ListEventsProps) => ReactNode;
|
|
140
141
|
|
|
141
|
-
type GroupProps = GroupProps$1 & {
|
|
142
|
-
maxBuyAmount?: number;
|
|
143
|
-
};
|
|
144
142
|
type ListEventTicketsProps = {
|
|
145
143
|
children: (props: {
|
|
146
|
-
tickets:
|
|
147
|
-
groups:
|
|
144
|
+
tickets: FindEventTicketItemProps[];
|
|
145
|
+
groups: FindEventTicketGroupProps[];
|
|
146
|
+
fee: number;
|
|
148
147
|
isPending: boolean;
|
|
149
148
|
error: Error | null;
|
|
150
149
|
}) => ReactNode;
|
|
@@ -158,7 +157,7 @@ declare const ListEventTickets: ({ children, eventId, privateToken, predecessorI
|
|
|
158
157
|
type SectionType = 'coming_soon' | 'past' | 'awards';
|
|
159
158
|
type ListUserEventsProps = {
|
|
160
159
|
children: (props: {
|
|
161
|
-
events:
|
|
160
|
+
events: GetUserEventsProps[];
|
|
162
161
|
isPending: boolean;
|
|
163
162
|
error: Error | null;
|
|
164
163
|
}) => ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import * as _meaple_com_types from '@meaple-com/types';
|
|
3
|
-
import { TicketProps, GroupProps
|
|
3
|
+
import { TicketProps, GroupProps, CouponProps, GetOrderProps as GetOrderProps$1, CategoryProps, FindEventProductItemProps, FindEventItemProps, FindEventsParams, FindEventTicketItemProps, FindEventTicketGroupProps, GetUserEventsProps, UserTicketProps, UserOrderProps } from '@meaple-com/types';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { useCheckCoupon, useOrder, useCategories, useEventProducts, useEvents, useEventTickets, useUserEvents, useUserEventTickets, useUserOrders } from '@meaple-com/react-query';
|
|
6
6
|
|
|
7
7
|
type ItemProps$1 = Pick<TicketProps, 'id' | 'name' | 'price' | 'amount' | 'type'> & {
|
|
8
|
-
group?: Pick<GroupProps
|
|
8
|
+
group?: Pick<GroupProps, 'name'>;
|
|
9
9
|
};
|
|
10
10
|
type PlatformFeeData = {
|
|
11
11
|
fee: number;
|
|
@@ -34,7 +34,7 @@ type CartProps = {
|
|
|
34
34
|
declare const Cart: ({ children, feeType, platformFee, }: CartProps) => ReactNode;
|
|
35
35
|
|
|
36
36
|
type ItemProps = Pick<TicketProps, 'id' | 'name' | 'price' | 'amount' | 'type'> & {
|
|
37
|
-
group?: Pick<GroupProps
|
|
37
|
+
group?: Pick<GroupProps, 'name'>;
|
|
38
38
|
};
|
|
39
39
|
type SeatProps = {
|
|
40
40
|
id: string;
|
|
@@ -117,7 +117,8 @@ declare const ListCategories: ({ children, options }: ListCategoriesProps) => Re
|
|
|
117
117
|
|
|
118
118
|
type ListEventProductsProps = {
|
|
119
119
|
children: (props: {
|
|
120
|
-
products:
|
|
120
|
+
products: FindEventProductItemProps[];
|
|
121
|
+
fee: number;
|
|
121
122
|
isPending: boolean;
|
|
122
123
|
error: Error | null;
|
|
123
124
|
}) => ReactNode;
|
|
@@ -129,7 +130,7 @@ declare const ListEventProducts: ({ children, eventId, privateToken, options, }:
|
|
|
129
130
|
|
|
130
131
|
type ListEventsProps = {
|
|
131
132
|
children: (props: {
|
|
132
|
-
events:
|
|
133
|
+
events: FindEventItemProps[];
|
|
133
134
|
isPending: boolean;
|
|
134
135
|
error: Error | null;
|
|
135
136
|
}) => ReactNode;
|
|
@@ -138,13 +139,11 @@ type ListEventsProps = {
|
|
|
138
139
|
};
|
|
139
140
|
declare const ListEvents: ({ children, params, options }: ListEventsProps) => ReactNode;
|
|
140
141
|
|
|
141
|
-
type GroupProps = GroupProps$1 & {
|
|
142
|
-
maxBuyAmount?: number;
|
|
143
|
-
};
|
|
144
142
|
type ListEventTicketsProps = {
|
|
145
143
|
children: (props: {
|
|
146
|
-
tickets:
|
|
147
|
-
groups:
|
|
144
|
+
tickets: FindEventTicketItemProps[];
|
|
145
|
+
groups: FindEventTicketGroupProps[];
|
|
146
|
+
fee: number;
|
|
148
147
|
isPending: boolean;
|
|
149
148
|
error: Error | null;
|
|
150
149
|
}) => ReactNode;
|
|
@@ -158,7 +157,7 @@ declare const ListEventTickets: ({ children, eventId, privateToken, predecessorI
|
|
|
158
157
|
type SectionType = 'coming_soon' | 'past' | 'awards';
|
|
159
158
|
type ListUserEventsProps = {
|
|
160
159
|
children: (props: {
|
|
161
|
-
events:
|
|
160
|
+
events: GetUserEventsProps[];
|
|
162
161
|
isPending: boolean;
|
|
163
162
|
error: Error | null;
|
|
164
163
|
}) => ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -230,7 +230,7 @@ var ListCategories = ({ children, options }) => {
|
|
|
230
230
|
};
|
|
231
231
|
|
|
232
232
|
// src/components/ListEventProducts.tsx
|
|
233
|
-
import { useEventProducts } from "@meaple-com/react-query";
|
|
233
|
+
import { useEventProducts, usePlatformFee } from "@meaple-com/react-query";
|
|
234
234
|
var ListEventProducts = ({
|
|
235
235
|
children,
|
|
236
236
|
eventId,
|
|
@@ -242,8 +242,13 @@ var ListEventProducts = ({
|
|
|
242
242
|
privateToken,
|
|
243
243
|
options
|
|
244
244
|
);
|
|
245
|
+
const { data: platformFee } = usePlatformFee(eventId, {
|
|
246
|
+
enabled: !!eventId
|
|
247
|
+
});
|
|
248
|
+
const fee = platformFee?.fee ?? 0;
|
|
245
249
|
return children({
|
|
246
250
|
products: data?.products ?? [],
|
|
251
|
+
fee,
|
|
247
252
|
isPending,
|
|
248
253
|
error
|
|
249
254
|
});
|
|
@@ -261,7 +266,7 @@ var ListEvents = ({ children, params, options }) => {
|
|
|
261
266
|
};
|
|
262
267
|
|
|
263
268
|
// src/components/ListEventTickets.tsx
|
|
264
|
-
import { useEventTickets } from "@meaple-com/react-query";
|
|
269
|
+
import { useEventTickets, usePlatformFee as usePlatformFee2 } from "@meaple-com/react-query";
|
|
265
270
|
var ListEventTickets = ({
|
|
266
271
|
children,
|
|
267
272
|
eventId,
|
|
@@ -275,9 +280,14 @@ var ListEventTickets = ({
|
|
|
275
280
|
predecessorIds,
|
|
276
281
|
options
|
|
277
282
|
);
|
|
283
|
+
const { data: platformFee } = usePlatformFee2(eventId, {
|
|
284
|
+
enabled: !!eventId
|
|
285
|
+
});
|
|
286
|
+
const fee = platformFee?.fee ?? 0;
|
|
278
287
|
return children({
|
|
279
288
|
tickets: data?.tickets ?? [],
|
|
280
289
|
groups: data?.groups ?? [],
|
|
290
|
+
fee,
|
|
281
291
|
isPending,
|
|
282
292
|
error
|
|
283
293
|
});
|
|
@@ -309,7 +319,7 @@ var ListUserEventTickets = ({
|
|
|
309
319
|
options
|
|
310
320
|
);
|
|
311
321
|
return children({
|
|
312
|
-
userTickets: data
|
|
322
|
+
userTickets: data ?? [],
|
|
313
323
|
isPending,
|
|
314
324
|
error
|
|
315
325
|
});
|
|
@@ -345,17 +355,28 @@ var TicketQuantityController = ({
|
|
|
345
355
|
const item = cart.getItem(ticket.id);
|
|
346
356
|
const amount = item?.amount ?? 0;
|
|
347
357
|
const incrementAmount = ticket.minBuy ?? 1;
|
|
348
|
-
const
|
|
349
|
-
const
|
|
350
|
-
const
|
|
358
|
+
const maxByPolicy = ticket.maxBuy ?? Infinity;
|
|
359
|
+
const maxByStock = ticket.availableAmount != null ? ticket.availableAmount : Infinity;
|
|
360
|
+
const effectiveMax = Math.min(maxByPolicy, maxByStock);
|
|
361
|
+
const isMaxLimitReached = amount + incrementAmount > effectiveMax;
|
|
362
|
+
const disabled = ticket.availableAmount === 0 || maxByPolicy === 0 || effectiveMax === 0;
|
|
351
363
|
const increment = useCallback3(() => {
|
|
352
364
|
if (disabled) return;
|
|
353
|
-
if (amount + incrementAmount
|
|
365
|
+
if (amount + incrementAmount > effectiveMax) return;
|
|
366
|
+
if (ticket.availableAmount != null && amount + incrementAmount >= ticket.availableAmount && onSoldOut)
|
|
354
367
|
onSoldOut();
|
|
355
368
|
for (let i = 0; i < incrementAmount; i++) {
|
|
356
369
|
cart.incrementToCart(ticket);
|
|
357
370
|
}
|
|
358
|
-
}, [
|
|
371
|
+
}, [
|
|
372
|
+
amount,
|
|
373
|
+
incrementAmount,
|
|
374
|
+
ticket,
|
|
375
|
+
onSoldOut,
|
|
376
|
+
cart,
|
|
377
|
+
disabled,
|
|
378
|
+
effectiveMax
|
|
379
|
+
]);
|
|
359
380
|
const decrement = useCallback3(() => {
|
|
360
381
|
if (disabled) return;
|
|
361
382
|
for (let i = 0; i < incrementAmount; i++) {
|
|
@@ -382,15 +403,27 @@ function useTicketQuantity({
|
|
|
382
403
|
const item = cart.getItem(ticket.id);
|
|
383
404
|
const amount = item?.amount ?? 0;
|
|
384
405
|
const incrementAmount = ticket.minBuy ?? 1;
|
|
385
|
-
const
|
|
406
|
+
const maxByPolicy = ticket.maxBuy ?? Infinity;
|
|
407
|
+
const maxByStock = ticket.availableAmount != null ? ticket.availableAmount : Infinity;
|
|
408
|
+
const effectiveMax = Math.min(maxByPolicy, maxByStock);
|
|
409
|
+
const isMaxLimitReached = amount + incrementAmount > effectiveMax;
|
|
386
410
|
const increment = useCallback4(() => {
|
|
387
411
|
if (disabled) return;
|
|
388
|
-
if (amount + incrementAmount
|
|
412
|
+
if (amount + incrementAmount > effectiveMax) return;
|
|
413
|
+
if (ticket.availableAmount != null && amount + incrementAmount >= ticket.availableAmount && onSoldOut)
|
|
389
414
|
onSoldOut();
|
|
390
415
|
for (let i = 0; i < incrementAmount; i++) {
|
|
391
416
|
cart.incrementToCart(ticket);
|
|
392
417
|
}
|
|
393
|
-
}, [
|
|
418
|
+
}, [
|
|
419
|
+
amount,
|
|
420
|
+
incrementAmount,
|
|
421
|
+
ticket,
|
|
422
|
+
onSoldOut,
|
|
423
|
+
cart,
|
|
424
|
+
disabled,
|
|
425
|
+
effectiveMax
|
|
426
|
+
]);
|
|
394
427
|
const decrement = useCallback4(() => {
|
|
395
428
|
if (disabled) return;
|
|
396
429
|
for (let i = 0; i < incrementAmount; i++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meaple-com/react-headless-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Headless React components for Meaple SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"clean": "rimraf dist"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@meaple-com/types": "^1.0.
|
|
31
|
+
"@meaple-com/types": "^1.0.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@eslint/js": "^9.36.0",
|
|
35
|
-
"@meaple-com/react-query": "^1.0.
|
|
35
|
+
"@meaple-com/react-query": "^1.0.5",
|
|
36
36
|
"@types/react": "^19.0.0",
|
|
37
37
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
38
38
|
"@typescript-eslint/parser": "^7.18.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"rimraf": "^5.0.5"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@meaple-com/react-query": "^1.0.
|
|
47
|
+
"@meaple-com/react-query": "^1.0.5",
|
|
48
48
|
"react": "^19.0.0"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|