@suiteop/storefront 0.4.0 → 0.6.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.
- package/CHANGELOG.md +56 -0
- package/README.md +9 -2
- package/dist/astro-content-model.cjs +5 -5
- package/dist/astro-content-model.js +4 -4
- package/dist/astro.cjs +1 -1
- package/dist/astro.d.cts +66 -1
- package/dist/astro.d.ts +66 -1
- package/dist/astro.js +1 -1
- package/dist/availability.d-Cla9GuGc.d.cts +84 -0
- package/dist/availability.d-Cla9GuGc.d.ts +84 -0
- package/dist/checkout.cjs +4 -4
- package/dist/checkout.d.cts +11 -0
- package/dist/checkout.d.ts +11 -0
- package/dist/checkout.js +3 -3
- package/dist/{chunk-TLTL7M3O.js → chunk-3B6ZYRYF.js} +2 -2
- package/dist/chunk-3NE27PHL.cjs +19 -0
- package/dist/{chunk-HMLBMNGA.js → chunk-7ZAI36LH.js} +1 -1
- package/dist/{chunk-LVFRVNT3.cjs → chunk-EHQFWSP6.cjs} +2 -1
- package/dist/{chunk-6NFURJXI.js → chunk-IBCBDAGY.js} +2 -2
- package/dist/{chunk-USOISC2R.cjs → chunk-J5FZ4WDQ.cjs} +2 -2
- package/dist/chunk-JF245QUY.cjs +9 -0
- package/dist/{chunk-IUJTHNB3.cjs → chunk-OXCLLFCY.cjs} +3 -3
- package/dist/chunk-QBHOJGZI.cjs +21 -0
- package/dist/{chunk-VV2UNVQ2.cjs → chunk-UMCI4YBN.cjs} +2 -2
- package/dist/chunk-UQWQPTHO.js +3 -0
- package/dist/{chunk-ZI2PG7LS.js → chunk-W5K7IDYN.js} +1 -1
- package/dist/chunk-XOCFEVP4.js +6 -0
- package/dist/chunk-YIYGBTAM.js +9 -0
- package/dist/{client-oyYRhUv0.d.ts → client-CX8K7JNt.d.cts} +108 -20
- package/dist/{client-CZWN4im4.d.cts → client-s-lEwqzc.d.ts} +108 -20
- package/dist/components.cjs +2 -2
- package/dist/components.d.cts +43 -1
- package/dist/components.d.ts +43 -1
- package/dist/components.js +1 -1
- package/dist/config.cjs +10 -3
- package/dist/config.d.cts +240 -79
- package/dist/config.d.ts +240 -79
- package/dist/config.js +4 -4
- package/dist/content.cjs +11 -11
- package/dist/content.d.cts +53 -9
- package/dist/content.d.ts +53 -9
- package/dist/content.js +4 -4
- package/dist/{errors-CAW7nLHr.d.cts → errors-Oax7djdp.d.ts} +54 -13
- package/dist/{errors-DoXdi1vS.d.ts → errors-welPvrD6.d.cts} +54 -13
- package/dist/index.cjs +22 -22
- package/dist/index.d.cts +27 -8
- package/dist/index.d.ts +27 -8
- package/dist/index.js +5 -5
- package/dist/react.cjs +7 -7
- package/dist/react.d.cts +24 -3
- package/dist/react.d.ts +24 -3
- package/dist/react.js +6 -6
- package/package.json +1 -1
- package/dist/availability-CnzmxuV3.d.cts +0 -60
- package/dist/availability-CnzmxuV3.d.ts +0 -60
- package/dist/chunk-CTHHMNLE.cjs +0 -19
- package/dist/chunk-E5CGGMCO.cjs +0 -19
- package/dist/chunk-PYVUDQSQ.js +0 -3
- package/dist/chunk-TRXDDUEL.js +0 -5
- package/dist/chunk-UWUKERLK.js +0 -9
- package/dist/chunk-ZLAOY6IF.cjs +0 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { e as StorefrontStay, a as StorefrontBuildingAvailabilityQuery, g as StorefrontUnitAvailability, S as StorefrontAvailability, d as StorefrontCalendarQuery, b as StorefrontCalendar } from './availability.d-Cla9GuGc.js';
|
|
3
3
|
|
|
4
4
|
declare const storefrontGuestInputSchema: z.ZodObject<{
|
|
5
5
|
firstName: z.ZodString;
|
|
@@ -27,13 +27,13 @@ type ConfirmCheckoutSessionInput = z.infer<typeof confirmCheckoutSessionInputSch
|
|
|
27
27
|
declare const bookingResultSchema: z.ZodObject<{
|
|
28
28
|
bookingRequestId: z.ZodUUID;
|
|
29
29
|
confirmationToken: z.ZodString;
|
|
30
|
-
status: z.ZodType<"
|
|
30
|
+
status: z.ZodType<"authorized" | "cancelled" | "confirmed" | "expired" | "failed" | "inquiry" | "pending_payment" | "pending_pms_sync" | "processing" | "reserved" | (string & {}), unknown, z.core.$ZodTypeInternals<"authorized" | "cancelled" | "confirmed" | "expired" | "failed" | "inquiry" | "pending_payment" | "pending_pms_sync" | "processing" | "reserved" | (string & {}), unknown>>;
|
|
31
31
|
confirmationCode: z.ZodNullable<z.ZodString>;
|
|
32
32
|
}, z.core.$strip>;
|
|
33
33
|
type BookingResult = z.infer<typeof bookingResultSchema>;
|
|
34
34
|
declare const storefrontBookingSchema: z.ZodObject<{
|
|
35
35
|
id: z.ZodUUID;
|
|
36
|
-
status: z.ZodType<"
|
|
36
|
+
status: z.ZodType<"authorized" | "cancelled" | "confirmed" | "expired" | "failed" | "inquiry" | "pending_payment" | "pending_pms_sync" | "processing" | "reserved" | (string & {}), unknown, z.core.$ZodTypeInternals<"authorized" | "cancelled" | "confirmed" | "expired" | "failed" | "inquiry" | "pending_payment" | "pending_pms_sync" | "processing" | "reserved" | (string & {}), unknown>>;
|
|
37
37
|
propertyId: z.ZodNullable<z.ZodUUID>;
|
|
38
38
|
checkIn: z.ZodNullable<z.ZodISODate>;
|
|
39
39
|
checkOut: z.ZodNullable<z.ZodISODate>;
|
|
@@ -76,6 +76,8 @@ declare const storefrontListingSummarySchema: z.ZodObject<{
|
|
|
76
76
|
latitude: z.ZodNullable<z.ZodNumber>;
|
|
77
77
|
longitude: z.ZodNullable<z.ZodNumber>;
|
|
78
78
|
bookable: z.ZodBoolean;
|
|
79
|
+
fromPriceMinor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
80
|
+
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
79
81
|
}, z.core.$strip>;
|
|
80
82
|
type StorefrontListingSummary = z.infer<typeof storefrontListingSummarySchema>;
|
|
81
83
|
declare const storefrontImageSchema: z.ZodObject<{
|
|
@@ -100,6 +102,8 @@ declare const storefrontListingSchema: z.ZodObject<{
|
|
|
100
102
|
latitude: z.ZodNullable<z.ZodNumber>;
|
|
101
103
|
longitude: z.ZodNullable<z.ZodNumber>;
|
|
102
104
|
bookable: z.ZodBoolean;
|
|
105
|
+
fromPriceMinor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
106
|
+
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
103
107
|
buildingSlug: z.ZodString;
|
|
104
108
|
buildingAddress: z.ZodUnknown;
|
|
105
109
|
description: z.ZodNullable<z.ZodString>;
|
|
@@ -116,18 +120,47 @@ declare const storefrontListingSchema: z.ZodObject<{
|
|
|
116
120
|
checkInTime: z.ZodNullable<z.ZodString>;
|
|
117
121
|
checkOutTime: z.ZodNullable<z.ZodString>;
|
|
118
122
|
beds: z.ZodNullable<z.ZodNumber>;
|
|
119
|
-
fromPriceMinor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
120
|
-
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
121
123
|
countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
122
124
|
}, z.core.$strip>;
|
|
123
125
|
type StorefrontListing = z.infer<typeof storefrontListingSchema>;
|
|
124
|
-
declare const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
declare const STOREFRONT_LISTING_SORTS: readonly ['recommended', 'price_asc', 'price_desc', 'rating'];
|
|
127
|
+
type StorefrontListingSort = (typeof STOREFRONT_LISTING_SORTS)[number];
|
|
128
|
+
interface StorefrontListingsQuery {
|
|
129
|
+
location?: string | readonly string[];
|
|
130
|
+
building?: string;
|
|
131
|
+
guests?: number;
|
|
132
|
+
bedrooms?: number;
|
|
133
|
+
currency?: string;
|
|
134
|
+
priceMin?: number;
|
|
135
|
+
priceMax?: number;
|
|
136
|
+
amenities?: readonly string[];
|
|
137
|
+
bounds?: readonly [number, number, number, number] | string;
|
|
138
|
+
checkIn?: string;
|
|
139
|
+
checkOut?: string;
|
|
140
|
+
sort?: StorefrontListingSort;
|
|
141
|
+
facets?: boolean;
|
|
142
|
+
limit?: number;
|
|
143
|
+
offset?: number;
|
|
144
|
+
}
|
|
145
|
+
declare const storefrontListingFacetsSchema: z.ZodObject<{
|
|
146
|
+
total: z.ZodNumber;
|
|
147
|
+
areas: z.ZodArray<z.ZodObject<{
|
|
148
|
+
id: z.ZodUUID;
|
|
149
|
+
slug: z.ZodNullable<z.ZodString>;
|
|
150
|
+
count: z.ZodNumber;
|
|
151
|
+
}, z.core.$strip>>;
|
|
152
|
+
bedrooms: z.ZodArray<z.ZodObject<{
|
|
153
|
+
bedrooms: z.ZodNumber;
|
|
154
|
+
count: z.ZodNumber;
|
|
155
|
+
}, z.core.$strip>>;
|
|
156
|
+
price: z.ZodNullable<z.ZodObject<{
|
|
157
|
+
min: z.ZodNumber;
|
|
158
|
+
max: z.ZodNumber;
|
|
159
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
160
|
+
buckets: z.ZodArray<z.ZodNumber>;
|
|
161
|
+
}, z.core.$strip>>;
|
|
129
162
|
}, z.core.$strip>;
|
|
130
|
-
type
|
|
163
|
+
type StorefrontListingFacets = z.infer<typeof storefrontListingFacetsSchema>;
|
|
131
164
|
declare const storefrontBuildingSchema: z.ZodObject<{
|
|
132
165
|
id: z.ZodUUID;
|
|
133
166
|
locationId: z.ZodNullable<z.ZodUUID>;
|
|
@@ -253,7 +286,7 @@ declare const createCheckoutSessionInputSchema: z.ZodObject<{
|
|
|
253
286
|
wbraid: string | null;
|
|
254
287
|
fbclid: string | null;
|
|
255
288
|
msclkid: string | null;
|
|
256
|
-
paidClick: "google" | "
|
|
289
|
+
paidClick: "google" | "meta" | "microsoft" | null;
|
|
257
290
|
} | null;
|
|
258
291
|
last: {
|
|
259
292
|
ts: string;
|
|
@@ -269,7 +302,7 @@ declare const createCheckoutSessionInputSchema: z.ZodObject<{
|
|
|
269
302
|
wbraid: string | null;
|
|
270
303
|
fbclid: string | null;
|
|
271
304
|
msclkid: string | null;
|
|
272
|
-
paidClick: "google" | "
|
|
305
|
+
paidClick: "google" | "meta" | "microsoft" | null;
|
|
273
306
|
} | null;
|
|
274
307
|
ids: {
|
|
275
308
|
gaClientId: string | null;
|
|
@@ -281,7 +314,7 @@ declare const createCheckoutSessionInputSchema: z.ZodObject<{
|
|
|
281
314
|
analytics: boolean;
|
|
282
315
|
ads: boolean;
|
|
283
316
|
source: "default" | "user";
|
|
284
|
-
region: "
|
|
317
|
+
region: "other" | "restricted";
|
|
285
318
|
decidedAt: string | null;
|
|
286
319
|
};
|
|
287
320
|
experiment?: {
|
|
@@ -303,7 +336,7 @@ declare const createCheckoutSessionInputSchema: z.ZodObject<{
|
|
|
303
336
|
wbraid: string | null;
|
|
304
337
|
fbclid: string | null;
|
|
305
338
|
msclkid: string | null;
|
|
306
|
-
paidClick: "google" | "
|
|
339
|
+
paidClick: "google" | "meta" | "microsoft" | null;
|
|
307
340
|
} | null;
|
|
308
341
|
last: {
|
|
309
342
|
ts: string;
|
|
@@ -319,7 +352,7 @@ declare const createCheckoutSessionInputSchema: z.ZodObject<{
|
|
|
319
352
|
wbraid: string | null;
|
|
320
353
|
fbclid: string | null;
|
|
321
354
|
msclkid: string | null;
|
|
322
|
-
paidClick: "google" | "
|
|
355
|
+
paidClick: "google" | "meta" | "microsoft" | null;
|
|
323
356
|
} | null;
|
|
324
357
|
ids: {
|
|
325
358
|
gaClientId: string | null;
|
|
@@ -331,7 +364,7 @@ declare const createCheckoutSessionInputSchema: z.ZodObject<{
|
|
|
331
364
|
analytics: boolean;
|
|
332
365
|
ads: boolean;
|
|
333
366
|
source: "default" | "user";
|
|
334
|
-
region: "
|
|
367
|
+
region: "other" | "restricted";
|
|
335
368
|
decidedAt: string | null;
|
|
336
369
|
};
|
|
337
370
|
experiment?: {
|
|
@@ -351,7 +384,7 @@ declare const createCheckoutSessionInputSchema: z.ZodObject<{
|
|
|
351
384
|
type CreateCheckoutSessionInput = z.infer<typeof createCheckoutSessionInputSchema>;
|
|
352
385
|
declare const checkoutSessionSchema: z.ZodObject<{
|
|
353
386
|
id: z.ZodUUID;
|
|
354
|
-
status: z.ZodType<"
|
|
387
|
+
status: z.ZodType<"authorized" | "cancelled" | "confirmed" | "expired" | "failed" | "inquiry" | "pending_payment" | "pending_pms_sync" | "processing" | "reserved" | (string & {}), unknown, z.core.$ZodTypeInternals<"authorized" | "cancelled" | "confirmed" | "expired" | "failed" | "inquiry" | "pending_payment" | "pending_pms_sync" | "processing" | "reserved" | (string & {}), unknown>>;
|
|
355
388
|
quote: z.ZodObject<{
|
|
356
389
|
listingId: z.ZodUUID;
|
|
357
390
|
checkIn: z.ZodISODate;
|
|
@@ -526,18 +559,33 @@ type StorefrontQuote = z.infer<typeof storefrontQuoteSchema>;
|
|
|
526
559
|
declare const STOREFRONT_API_PATH = "/api/storefront/v1";
|
|
527
560
|
interface StorefrontClientOptions {
|
|
528
561
|
publishableKey: string;
|
|
562
|
+
/**
|
|
563
|
+
* `'same-origin'` → `/api/storefront/v1` on the page's origin (SuiteOp-hosted sites, via the
|
|
564
|
+
* storefront edge). A URL → that origin (a `WrongRegionError.baseUrl` works as is). Omitted →
|
|
565
|
+
* the key's regional host: `https://api-<region>.suiteop.com` for `pk_live_`, the region's
|
|
566
|
+
* staging host for `pk_test_`.
|
|
567
|
+
*/
|
|
529
568
|
baseUrl?: 'same-origin' | (string & {});
|
|
569
|
+
/** Per-request timeout. Default 10 s for reads, 20 s for quotes and checkout. */
|
|
530
570
|
timeoutMs?: number;
|
|
531
571
|
fetch?: typeof fetch;
|
|
572
|
+
/** Sent as `Accept-Language`, so API-side copy (cancellation policy text) localises. */
|
|
532
573
|
locale?: string;
|
|
533
574
|
}
|
|
534
575
|
interface RequestOptions {
|
|
576
|
+
/** Aborting rejects the call with the signal's reason (an `AbortError`). */
|
|
535
577
|
signal?: AbortSignal;
|
|
536
578
|
}
|
|
537
579
|
interface CreateCheckoutSessionOptions extends RequestOptions {
|
|
580
|
+
/**
|
|
581
|
+
* Omitted → one UUID v4 per quoteRef + ratePlanId, reused by every retry on this client until
|
|
582
|
+
* the outcome is final (a dead session or a definitive refusal releases it).
|
|
583
|
+
*/
|
|
538
584
|
idempotencyKey?: string;
|
|
539
585
|
}
|
|
586
|
+
/** `collections.list` paging. */
|
|
540
587
|
interface ContentListQuery {
|
|
588
|
+
/** 1–100, default 20. */
|
|
541
589
|
limit?: number;
|
|
542
590
|
offset?: number;
|
|
543
591
|
}
|
|
@@ -547,38 +595,67 @@ interface Page<T> {
|
|
|
547
595
|
limit: number;
|
|
548
596
|
offset: number;
|
|
549
597
|
}
|
|
598
|
+
/** The session plus the Idempotency-Key it was created with — `<suiteop-checkout>` replays both. */
|
|
550
599
|
type CreatedCheckoutSession = CheckoutSession & {
|
|
551
600
|
idempotencyKey: string;
|
|
552
601
|
};
|
|
602
|
+
/** `POST /checkout-sessions/:id/confirm` body as sent (consents and language are optional). */
|
|
553
603
|
type ConfirmCheckoutSessionRequest = z.input<typeof confirmCheckoutSessionInputSchema>;
|
|
554
604
|
interface StorefrontClient {
|
|
605
|
+
/** The publishable key this client sends (public by design). */
|
|
555
606
|
readonly publishableKey: string;
|
|
607
|
+
/** The resolved Storefront API base, ending in `/api/storefront/v1`. */
|
|
556
608
|
readonly baseUrl: string;
|
|
557
609
|
site: {
|
|
558
610
|
get(opts?: RequestOptions): Promise<StorefrontSite>;
|
|
559
611
|
};
|
|
560
612
|
listings: {
|
|
561
|
-
|
|
613
|
+
/**
|
|
614
|
+
* The site's listings, filtered and sorted. `facets: true` adds the filters sheet's
|
|
615
|
+
* `facets` (one more query on the API).
|
|
616
|
+
*/
|
|
617
|
+
list(query?: StorefrontListingsQuery, opts?: RequestOptions): Promise<Page<StorefrontListingSummary> & {
|
|
618
|
+
facets?: StorefrontListingFacets;
|
|
619
|
+
}>;
|
|
562
620
|
get(id: string, opts?: RequestOptions): Promise<StorefrontListing>;
|
|
563
621
|
};
|
|
564
622
|
buildings: {
|
|
565
623
|
list(opts?: RequestOptions): Promise<StorefrontBuilding[]>;
|
|
566
624
|
get(id: string, opts?: RequestOptions): Promise<StorefrontBuilding>;
|
|
625
|
+
/**
|
|
626
|
+
* Every unit of the building for one stay — status, stay total and the next free window of the
|
|
627
|
+
* same length — in one call. Display only: read from the synced calendar, and the total is the
|
|
628
|
+
* nightly rates plus the cleaning fee, before taxes. `quotes.create` gives the bookable price.
|
|
629
|
+
* Pages like `listings.list` (`limit` 1–100, default 50).
|
|
630
|
+
*/
|
|
631
|
+
availability(id: string, query: StorefrontStay & Partial<Pick<StorefrontBuildingAvailabilityQuery, 'limit' | 'offset'>>, opts?: RequestOptions): Promise<Page<StorefrontUnitAvailability>>;
|
|
567
632
|
};
|
|
568
633
|
locations: {
|
|
569
634
|
list(opts?: RequestOptions): Promise<StorefrontLocation[]>;
|
|
570
635
|
};
|
|
636
|
+
/**
|
|
637
|
+
* "Things to do": the guest-portal guide lists the manager shows on booking sites, with their
|
|
638
|
+
* places, in the client's `locale` (English fallback). Lists with no place are left out.
|
|
639
|
+
*/
|
|
571
640
|
guides: {
|
|
572
641
|
list(opts?: RequestOptions): Promise<StorefrontGuide[]>;
|
|
642
|
+
/** By id; null when the site does not show that list. */
|
|
573
643
|
get(id: string, opts?: RequestOptions): Promise<StorefrontGuide | null>;
|
|
574
644
|
};
|
|
645
|
+
/** The site's content model as its code declared it (hidden types and fields left out). */
|
|
575
646
|
contentModel: {
|
|
576
647
|
get(opts?: RequestOptions): Promise<StorefrontContentModel>;
|
|
577
648
|
};
|
|
649
|
+
/**
|
|
650
|
+
* Items of a collection the site declares (`defineContent`): published ones only, dated up to
|
|
651
|
+
* now, in the collection's order. `createContentReader` gives the typed version.
|
|
652
|
+
*/
|
|
578
653
|
collections: {
|
|
579
654
|
list(key: string, query?: ContentListQuery, opts?: RequestOptions): Promise<Page<StorefrontContentItem>>;
|
|
655
|
+
/** By slug or id; null when there is none published (a draft, a future post, a typo). */
|
|
580
656
|
get(key: string, slugOrId: string, opts?: RequestOptions): Promise<StorefrontContentItem | null>;
|
|
581
657
|
};
|
|
658
|
+
/** A page section's one item. A section nobody filled in yet has `fields: {}`. */
|
|
582
659
|
sections: {
|
|
583
660
|
get(key: string, opts?: RequestOptions): Promise<StorefrontContentItem>;
|
|
584
661
|
};
|
|
@@ -600,7 +677,17 @@ interface StorefrontClient {
|
|
|
600
677
|
checkoutSessions: {
|
|
601
678
|
create(input: CreateCheckoutSessionInput, opts?: CreateCheckoutSessionOptions): Promise<CreatedCheckoutSession>;
|
|
602
679
|
get(id: string, opts?: RequestOptions): Promise<CheckoutSession>;
|
|
680
|
+
/**
|
|
681
|
+
* Drop the kept Idempotency-Key for this quote + rate plan; the next `create` opens a new
|
|
682
|
+
* session and a new payment hold. Never call it after a `failed` session or booking result:
|
|
683
|
+
* the guest may already have been charged, and a new session would take a second payment.
|
|
684
|
+
*/
|
|
603
685
|
forget(quoteRef: string, ratePlanId?: string): void;
|
|
686
|
+
/**
|
|
687
|
+
* Idempotent on the session: a double submit or a second tab gets the same booking. A
|
|
688
|
+
* confirm error that ends the session (`session_expired`, or `requiresNewSession`) releases
|
|
689
|
+
* the quote's key, so the next `create` opens a new session. A `failed` result does not.
|
|
690
|
+
*/
|
|
604
691
|
confirm(id: string, input: ConfirmCheckoutSessionRequest, opts?: RequestOptions): Promise<BookingResult>;
|
|
605
692
|
};
|
|
606
693
|
bookings: {
|
|
@@ -610,6 +697,7 @@ interface StorefrontClient {
|
|
|
610
697
|
create(input: StorefrontContactInput, opts?: RequestOptions): Promise<void>;
|
|
611
698
|
};
|
|
612
699
|
}
|
|
700
|
+
/** A typed client for one site's Storefront API, bound to its publishable key. */
|
|
613
701
|
declare function createStorefrontClient(options: StorefrontClientOptions): StorefrontClient;
|
|
614
702
|
|
|
615
|
-
export { type
|
|
703
|
+
export { type StorefrontQuoteInput as A, type BookingResult as B, type CheckoutMountDescriptor as C, type StorefrontRatePlanQuote as D, type StorefrontReview as E, type StorefrontReviewsQuery as F, type StorefrontSite as G, createStorefrontClient as H, type Page as P, type RequestOptions as R, STOREFRONT_API_PATH as S, type CheckoutSession as a, type ConfirmCheckoutSessionInput as b, type ConfirmCheckoutSessionRequest as c, type ContentListQuery as d, type CreateCheckoutSessionInput as e, type CreateCheckoutSessionOptions as f, type CreatedCheckoutSession as g, type StorefrontBooking as h, type StorefrontBuilding as i, type StorefrontClient as j, type StorefrontClientOptions as k, type StorefrontContactInput as l, type StorefrontContentItem as m, type StorefrontContentModel as n, type StorefrontContentRef as o, type StorefrontGuestInput as p, type StorefrontGuide as q, type StorefrontGuideItem as r, type StorefrontImage as s, type StorefrontListing as t, type StorefrontListingFacets as u, type StorefrontListingSort as v, type StorefrontListingSummary as w, type StorefrontListingsQuery as x, type StorefrontLocation as y, type StorefrontQuote as z };
|
package/dist/components.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkEVSAMV5K_cjs = require('./chunk-EVSAMV5K.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkEHQFWSP6_cjs = require('./chunk-EHQFWSP6.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
8
|
-
var monthFormat=new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"});var dayFormat=new Intl.DateTimeFormat("en-US",{dateStyle:"full",timeZone:"UTC"});var WEEKDAYS=["Su","Mo","Tu","We","Th","Fr","Sa"];var utc=isoDate=>new Date(`${isoDate}T00:00:00Z`);var defaultLabels={dateRangePicker:{month:monthStart=>monthFormat.format(utc(monthStart)),weekday:dayIndex=>WEEKDAYS[dayIndex]??"",day:date=>dayFormat.format(utc(date)),previousMonth:"Previous month",nextMonth:"Next month"},guestPicker:{adults:"Adults",children:"Children",increment:field=>`Add ${field}`,decrement:field=>`Remove ${field}`},gallery:{region:"Photos",photo:(index,total)=>`Photo ${index+1} of ${total}`,previous:"Previous photo",next:"Next photo"}};function unavailableDates(days){return days.filter(d=>d.status!=="available").map(d=>d.date)}var DAY_MS=864e5;var toTime=date=>Date.parse(`${date}T00:00:00Z`);var fromTime=time=>new Date(time).toISOString().slice(0,10);var addDays=(date,days)=>fromTime(toTime(date)+days*DAY_MS);var monthOf=date=>`${date.slice(0,7)}-01`;function addMonths(monthStart,months){const d=new Date(toTime(monthStart));d.setUTCMonth(d.getUTCMonth()+months,1);return fromTime(d.getTime())}function localToday(){const now=new Date;const pad=n=>String(n).padStart(2,"0");return `${now.getFullYear()}-${pad(now.getMonth()+1)}-${pad(now.getDate())}`}function monthWeeks(monthStart,weekStartsOn){const lead=(new Date(toTime(monthStart)).getUTCDay()-weekStartsOn+7)%7;const next=addMonths(monthStart,1);const cells=Array.from({length:lead},()=>null);for(let d=monthStart;d<next;d=addDays(d,1))cells.push(d);while(cells.length%7)cells.push(null);return Array.from({length:cells.length/7},(_,w)=>cells.slice(w*7,w*7+7))}function DateRangePicker({value,onChange,unavailable,minNights=1,today:todayProp,defaultMonth,weekStartsOn=0,labels:labelsProp,className,classNames={}}){const labels={...defaultLabels.dateRangePicker,...labelsProp};const today=todayProp??localToday();const blocked=react.useMemo(()=>new Set(unavailable??[]),[unavailable]);const[focused,setFocused]=react.useState(()=>value.checkIn??today);const[month,setMonth]=react.useState(()=>defaultMonth?`${defaultMonth}-01`:monthOf(value.checkIn??today));const[shownCheckIn,setShownCheckIn]=react.useState(value.checkIn);if(value.checkIn!==shownCheckIn){setShownCheckIn(value.checkIn);if(value.checkIn!==null){setFocused(value.checkIn);setMonth(monthOf(value.checkIn));}}const grid=react.useRef(null);const moveFocus=react.useRef(false);react.useEffect(()=>{if(!moveFocus.current)return;moveFocus.current=false;grid.current?.querySelector(`[data-date="${focused}"]`)?.focus();},[focused,month]);const{checkIn,checkOut}=value;const pickingEnd=checkIn!==null&&checkOut===null;const nightFree=d=>d>=today&&!blocked.has(d);const validEnd=d=>{if(checkIn===null||d<=checkIn)return false;if((toTime(d)-toTime(checkIn))/DAY_MS<minNights)return false;for(let n=checkIn;n<d;n=addDays(n,1))if(!nightFree(n))return false;return true};const disabled=d=>pickingEnd&&checkIn!==null&&d>checkIn?!validEnd(d):!nightFree(d);function select(d){if(disabled(d))return;onChange(pickingEnd&&checkIn!==null&&d>checkIn?{checkIn,checkOut:d}:{checkIn:d,checkOut:null});}function stateOf(d){if(d===checkIn)return "start";if(d===checkOut)return "end";if(checkIn!==null&&checkOut!==null&&d>checkIn&&d<checkOut)return "in-range";return disabled(d)?"disabled":"available"}function focusDate(d){moveFocus.current=true;setFocused(d);setMonth(monthOf(d));}function onKeyDown(event,d){const step={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[event.key];if(step!==void 0){event.preventDefault();focusDate(addDays(d,step));}else if(event.key==="Enter"||event.key===" "){event.preventDefault();select(d);}}const tabStop=monthOf(focused)===month?focused:month;const weekdays=Array.from({length:7},(_,i)=>(i+weekStartsOn)%7);return jsxRuntime.jsxs("div",{className,children:[jsxRuntime.jsxs("div",{className:classNames.header,children:[jsxRuntime.jsx("button",{type:"button",className:classNames.nav,"aria-label":labels.previousMonth,onClick:()=>setMonth(addMonths(month,-1)),children:"\u2039"}),jsxRuntime.jsx("span",{className:classNames.title,"aria-live":"polite",children:labels.month(month)}),jsxRuntime.jsx("button",{type:"button",className:classNames.nav,"aria-label":labels.nextMonth,onClick:()=>setMonth(addMonths(month,1)),children:"\u203A"})]}),jsxRuntime.jsxs("table",{role:"grid","aria-label":labels.month(month),className:classNames.grid,ref:grid,children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsx("tr",{children:weekdays.map(i=>jsxRuntime.jsx("th",{scope:"col",className:classNames.weekday,children:labels.weekday(i)},i))})}),jsxRuntime.jsx("tbody",{children:monthWeeks(month,weekStartsOn).map((week,w)=>jsxRuntime.jsx("tr",{children:week.map((d,i)=>{if(d===null)return jsxRuntime.jsx("td",{role:"gridcell"},`pad-${i}`);const state=stateOf(d);return jsxRuntime.jsx("td",{role:"gridcell","data-date":d,"data-state":state,"data-today":d===today?"":void 0,className:classNames.day,tabIndex:d===tabStop?0:-1,"aria-label":labels.day(d),"aria-selected":state==="start"||state==="end"||state==="in-range","aria-disabled":disabled(d)||void 0,onClick:()=>select(d),onKeyDown:event=>onKeyDown(event,d),onFocus:()=>setFocused(d),children:Number(d.slice(8))},d)})},w))})]})]})}function isRecord(value){return typeof value==="object"&&value!==null}var firstString=(record,keys)=>keys.map(k=>record[k]).find(v=>typeof v==="string"&&v.length>0);function listingPhotos(listingOrPictures){if(isRecord(listingOrPictures)&&!Array.isArray(listingOrPictures)){const{images,pictures:pictures2}=listingOrPictures;if(images?.length){return images.map(({url,alt,width,height})=>({url,caption:alt,width,height}))}return listingPhotos(pictures2)}const pictures=listingOrPictures;if(!Array.isArray(pictures))return [];return pictures.flatMap(picture=>{if(typeof picture==="string")return picture?[{url:picture,caption:null}]:[];if(!isRecord(picture))return [];const url=firstString(picture,["original","url","large","regular","original_path","image_path","thumbnail","thumbnail_path"]);if(!url)return [];return [{url,caption:firstString(picture,["caption","description"])??null}]})}function Gallery({photos,onIndexChange,labels:labelsProp,sizes="100vw",className,classNames={}}){const labels={...defaultLabels.gallery,...labelsProp};const[index,setIndex]=react.useState(0);const total=photos.length;const current=Math.min(index,Math.max(0,total-1));const go=next=>{if(next<0||next>=total||next===current)return;setIndex(next);onIndexChange?.(next);};const onKeyDown=event=>{if(event.key==="ArrowLeft")go(current-1);else if(event.key==="ArrowRight")go(current+1);};return jsxRuntime.jsxs("section",{role:"region","aria-roledescription":"carousel","aria-label":labels.region,className,onKeyDown,children:[jsxRuntime.jsx("div",{className:classNames.viewport,"aria-live":"polite",children:photos.map((photo,i)=>jsxRuntime.jsx("div",{role:"group","aria-roledescription":"slide","aria-label":labels.photo(i,total),"data-state":i===current?"active":"inactive",hidden:i!==current,className:classNames.slide,children:jsxRuntime.jsx("img",{...chunkEVSAMV5K_cjs.cdnImageProps(photo.url,1080,sizes),...photo.width&&photo.height?{width:photo.width,height:photo.height}:{},alt:photo.caption||labels.photo(i,total),loading:i===0?"eager":"lazy",decoding:"async",className:classNames.image})},`${i}-${photo.url}`))}),jsxRuntime.jsx("button",{type:"button",className:classNames.button,"aria-label":labels.previous,disabled:current===0,onClick:()=>go(current-1),children:"\u2039"}),jsxRuntime.jsx("button",{type:"button",className:classNames.button,"aria-label":labels.next,disabled:current>=total-1,onClick:()=>go(current+1),children:"\u203A"})]})}function GuestPicker({value,onChange,max=chunkLVFRVNT3_cjs.STOREFRONT_MAX_GUESTS,labels:labelsProp,className,classNames={}}){const labels={...defaultLabels.guestPicker,...labelsProp};const id=react.useId();const fields=[{key:"adults",label:labels.adults,min:1,max:Math.max(value.adults,max-value.children)},{key:"children",label:labels.children,min:0,max:Math.max(value.children,max-value.adults)}];return jsxRuntime.jsx("div",{className,children:fields.map(field=>{const now=value[field.key];const set=next=>{const clamped=Math.min(field.max,Math.max(field.min,next));if(clamped!==now)onChange({...value,[field.key]:clamped});};const onKeyDown=event=>{const next={ArrowUp:now+1,ArrowRight:now+1,ArrowDown:now-1,ArrowLeft:now-1,Home:field.min,End:field.max}[event.key];if(next===void 0)return;event.preventDefault();set(next);};const labelId=`${id}-${field.key}`;return jsxRuntime.jsxs("div",{className:classNames.field,"data-field":field.key,children:[jsxRuntime.jsx("span",{id:labelId,className:classNames.label,children:field.label}),jsxRuntime.jsx("button",{type:"button",className:classNames.button,"aria-label":labels.decrement(field.label),disabled:now<=field.min,onClick:()=>set(now-1),children:"\u2212"}),jsxRuntime.jsx("div",{role:"spinbutton",tabIndex:0,className:classNames.value,"aria-labelledby":labelId,"aria-valuenow":now,"aria-valuemin":field.min,"aria-valuemax":field.max,onKeyDown,children:now}),jsxRuntime.jsx("button",{type:"button",className:classNames.button,"aria-label":labels.increment(field.label),disabled:now>=field.max,onClick:()=>set(now+1),children:"+"})]},field.key)})})}var usable=(lat,lng)=>typeof lat==="number"&&typeof lng==="number"&&Number.isFinite(lat)&&Number.isFinite(lng)&&Math.abs(lat)<=90&&Math.abs(lng)<=180;function Map({listings,children}){const markers=[];for(const listing of listings){if(usable(listing.latitude,listing.longitude)){markers.push({id:listing.id,lat:listing.latitude,lng:listing.longitude,listing});}}const bounds=markers.length===0?null:{north:Math.max(...markers.map(m=>m.lat)),south:Math.min(...markers.map(m=>m.lat)),east:Math.max(...markers.map(m=>m.lng)),west:Math.min(...markers.map(m=>m.lng))};return jsxRuntime.jsx(jsxRuntime.Fragment,{children:children({markers,bounds})})}
|
|
8
|
+
var monthFormat=new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"});var dayFormat=new Intl.DateTimeFormat("en-US",{dateStyle:"full",timeZone:"UTC"});var WEEKDAYS=["Su","Mo","Tu","We","Th","Fr","Sa"];var utc=isoDate=>new Date(`${isoDate}T00:00:00Z`);var defaultLabels={dateRangePicker:{month:monthStart=>monthFormat.format(utc(monthStart)),weekday:dayIndex=>WEEKDAYS[dayIndex]??"",day:date=>dayFormat.format(utc(date)),previousMonth:"Previous month",nextMonth:"Next month"},guestPicker:{adults:"Adults",children:"Children",increment:field=>`Add ${field}`,decrement:field=>`Remove ${field}`},gallery:{region:"Photos",photo:(index,total)=>`Photo ${index+1} of ${total}`,previous:"Previous photo",next:"Next photo"}};function unavailableDates(days){return days.filter(d=>d.status!=="available").map(d=>d.date)}var DAY_MS=864e5;var toTime=date=>Date.parse(`${date}T00:00:00Z`);var fromTime=time=>new Date(time).toISOString().slice(0,10);var addDays=(date,days)=>fromTime(toTime(date)+days*DAY_MS);var monthOf=date=>`${date.slice(0,7)}-01`;function addMonths(monthStart,months){const d=new Date(toTime(monthStart));d.setUTCMonth(d.getUTCMonth()+months,1);return fromTime(d.getTime())}function localToday(){const now=new Date;const pad=n=>String(n).padStart(2,"0");return `${now.getFullYear()}-${pad(now.getMonth()+1)}-${pad(now.getDate())}`}function monthWeeks(monthStart,weekStartsOn){const lead=(new Date(toTime(monthStart)).getUTCDay()-weekStartsOn+7)%7;const next=addMonths(monthStart,1);const cells=Array.from({length:lead},()=>null);for(let d=monthStart;d<next;d=addDays(d,1))cells.push(d);while(cells.length%7)cells.push(null);return Array.from({length:cells.length/7},(_,w)=>cells.slice(w*7,w*7+7))}function DateRangePicker({value,onChange,unavailable,minNights=1,today:todayProp,defaultMonth,weekStartsOn=0,labels:labelsProp,className,classNames={}}){const labels={...defaultLabels.dateRangePicker,...labelsProp};const today=todayProp??localToday();const blocked=react.useMemo(()=>new Set(unavailable??[]),[unavailable]);const[focused,setFocused]=react.useState(()=>value.checkIn??today);const[month,setMonth]=react.useState(()=>defaultMonth?`${defaultMonth}-01`:monthOf(value.checkIn??today));const[shownCheckIn,setShownCheckIn]=react.useState(value.checkIn);if(value.checkIn!==shownCheckIn){setShownCheckIn(value.checkIn);if(value.checkIn!==null){setFocused(value.checkIn);setMonth(monthOf(value.checkIn));}}const grid=react.useRef(null);const moveFocus=react.useRef(false);react.useEffect(()=>{if(!moveFocus.current)return;moveFocus.current=false;grid.current?.querySelector(`[data-date="${focused}"]`)?.focus();},[focused,month]);const{checkIn,checkOut}=value;const pickingEnd=checkIn!==null&&checkOut===null;const nightFree=d=>d>=today&&!blocked.has(d);const validEnd=d=>{if(checkIn===null||d<=checkIn)return false;if((toTime(d)-toTime(checkIn))/DAY_MS<minNights)return false;for(let n=checkIn;n<d;n=addDays(n,1))if(!nightFree(n))return false;return true};const disabled=d=>pickingEnd&&checkIn!==null&&d>checkIn?!validEnd(d):!nightFree(d);function select(d){if(disabled(d))return;onChange(pickingEnd&&checkIn!==null&&d>checkIn?{checkIn,checkOut:d}:{checkIn:d,checkOut:null});}function stateOf(d){if(d===checkIn)return "start";if(d===checkOut)return "end";if(checkIn!==null&&checkOut!==null&&d>checkIn&&d<checkOut)return "in-range";return disabled(d)?"disabled":"available"}function focusDate(d){moveFocus.current=true;setFocused(d);setMonth(monthOf(d));}function onKeyDown(event,d){const step={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[event.key];if(step!==void 0){event.preventDefault();focusDate(addDays(d,step));}else if(event.key==="Enter"||event.key===" "){event.preventDefault();select(d);}}const tabStop=monthOf(focused)===month?focused:month;const weekdays=Array.from({length:7},(_,i)=>(i+weekStartsOn)%7);return jsxRuntime.jsxs("div",{className,children:[jsxRuntime.jsxs("div",{className:classNames.header,children:[jsxRuntime.jsx("button",{type:"button",className:classNames.nav,"aria-label":labels.previousMonth,onClick:()=>setMonth(addMonths(month,-1)),children:"\u2039"}),jsxRuntime.jsx("span",{className:classNames.title,"aria-live":"polite",children:labels.month(month)}),jsxRuntime.jsx("button",{type:"button",className:classNames.nav,"aria-label":labels.nextMonth,onClick:()=>setMonth(addMonths(month,1)),children:"\u203A"})]}),jsxRuntime.jsxs("table",{role:"grid","aria-label":labels.month(month),className:classNames.grid,ref:grid,children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsx("tr",{children:weekdays.map(i=>jsxRuntime.jsx("th",{scope:"col",className:classNames.weekday,children:labels.weekday(i)},i))})}),jsxRuntime.jsx("tbody",{children:monthWeeks(month,weekStartsOn).map((week,w)=>jsxRuntime.jsx("tr",{children:week.map((d,i)=>{if(d===null)return jsxRuntime.jsx("td",{role:"gridcell"},`pad-${i}`);const state=stateOf(d);return jsxRuntime.jsx("td",{role:"gridcell","data-date":d,"data-state":state,"data-today":d===today?"":void 0,className:classNames.day,tabIndex:d===tabStop?0:-1,"aria-label":labels.day(d),"aria-selected":state==="start"||state==="end"||state==="in-range","aria-disabled":disabled(d)||void 0,onClick:()=>select(d),onKeyDown:event=>onKeyDown(event,d),onFocus:()=>setFocused(d),children:Number(d.slice(8))},d)})},w))})]})]})}function isRecord(value){return typeof value==="object"&&value!==null}var firstString=(record,keys)=>keys.map(k=>record[k]).find(v=>typeof v==="string"&&v.length>0);function listingPhotos(listingOrPictures){if(isRecord(listingOrPictures)&&!Array.isArray(listingOrPictures)){const{images,pictures:pictures2}=listingOrPictures;if(images?.length){return images.map(({url,alt,width,height})=>({url,caption:alt,width,height}))}return listingPhotos(pictures2)}const pictures=listingOrPictures;if(!Array.isArray(pictures))return [];return pictures.flatMap(picture=>{if(typeof picture==="string")return picture?[{url:picture,caption:null}]:[];if(!isRecord(picture))return [];const url=firstString(picture,["original","url","large","regular","original_path","image_path","thumbnail","thumbnail_path"]);if(!url)return [];return [{url,caption:firstString(picture,["caption","description"])??null}]})}function Gallery({photos,onIndexChange,labels:labelsProp,sizes="100vw",className,classNames={}}){const labels={...defaultLabels.gallery,...labelsProp};const[index,setIndex]=react.useState(0);const total=photos.length;const current=Math.min(index,Math.max(0,total-1));const go=next=>{if(next<0||next>=total||next===current)return;setIndex(next);onIndexChange?.(next);};const onKeyDown=event=>{if(event.key==="ArrowLeft")go(current-1);else if(event.key==="ArrowRight")go(current+1);};return jsxRuntime.jsxs("section",{role:"region","aria-roledescription":"carousel","aria-label":labels.region,className,onKeyDown,children:[jsxRuntime.jsx("div",{className:classNames.viewport,"aria-live":"polite",children:photos.map((photo,i)=>jsxRuntime.jsx("div",{role:"group","aria-roledescription":"slide","aria-label":labels.photo(i,total),"data-state":i===current?"active":"inactive",hidden:i!==current,className:classNames.slide,children:jsxRuntime.jsx("img",{...chunkEVSAMV5K_cjs.cdnImageProps(photo.url,1080,sizes),...photo.width&&photo.height?{width:photo.width,height:photo.height}:{},alt:photo.caption||labels.photo(i,total),loading:i===0?"eager":"lazy",decoding:"async",className:classNames.image})},`${i}-${photo.url}`))}),jsxRuntime.jsx("button",{type:"button",className:classNames.button,"aria-label":labels.previous,disabled:current===0,onClick:()=>go(current-1),children:"\u2039"}),jsxRuntime.jsx("button",{type:"button",className:classNames.button,"aria-label":labels.next,disabled:current>=total-1,onClick:()=>go(current+1),children:"\u203A"})]})}function GuestPicker({value,onChange,max=chunkEHQFWSP6_cjs.STOREFRONT_MAX_GUESTS,labels:labelsProp,className,classNames={}}){const labels={...defaultLabels.guestPicker,...labelsProp};const id=react.useId();const fields=[{key:"adults",label:labels.adults,min:1,max:Math.max(value.adults,max-value.children)},{key:"children",label:labels.children,min:0,max:Math.max(value.children,max-value.adults)}];return jsxRuntime.jsx("div",{className,children:fields.map(field=>{const now=value[field.key];const set=next=>{const clamped=Math.min(field.max,Math.max(field.min,next));if(clamped!==now)onChange({...value,[field.key]:clamped});};const onKeyDown=event=>{const next={ArrowUp:now+1,ArrowRight:now+1,ArrowDown:now-1,ArrowLeft:now-1,Home:field.min,End:field.max}[event.key];if(next===void 0)return;event.preventDefault();set(next);};const labelId=`${id}-${field.key}`;return jsxRuntime.jsxs("div",{className:classNames.field,"data-field":field.key,children:[jsxRuntime.jsx("span",{id:labelId,className:classNames.label,children:field.label}),jsxRuntime.jsx("button",{type:"button",className:classNames.button,"aria-label":labels.decrement(field.label),disabled:now<=field.min,onClick:()=>set(now-1),children:"\u2212"}),jsxRuntime.jsx("div",{role:"spinbutton",tabIndex:0,className:classNames.value,"aria-labelledby":labelId,"aria-valuenow":now,"aria-valuemin":field.min,"aria-valuemax":field.max,onKeyDown,children:now}),jsxRuntime.jsx("button",{type:"button",className:classNames.button,"aria-label":labels.increment(field.label),disabled:now>=field.max,onClick:()=>set(now+1),children:"+"})]},field.key)})})}var usable=(lat,lng)=>typeof lat==="number"&&typeof lng==="number"&&Number.isFinite(lat)&&Number.isFinite(lng)&&Math.abs(lat)<=90&&Math.abs(lng)<=180;function Map({listings,children}){const markers=[];for(const listing of listings){if(usable(listing.latitude,listing.longitude)){markers.push({id:listing.id,lat:listing.latitude,lng:listing.longitude,listing});}}const bounds=markers.length===0?null:{north:Math.max(...markers.map(m=>m.lat)),south:Math.min(...markers.map(m=>m.lat)),east:Math.max(...markers.map(m=>m.lng)),west:Math.min(...markers.map(m=>m.lng))};return jsxRuntime.jsx(jsxRuntime.Fragment,{children:children({markers,bounds})})}
|
|
9
9
|
|
|
10
10
|
exports.DateRangePicker = DateRangePicker;
|
|
11
11
|
exports.Gallery = Gallery;
|
package/dist/components.d.cts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { c as StorefrontCalendarDay } from './availability.d-Cla9GuGc.cjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* The components' English defaults. The SDK ships no other copy: pass `labels` (any subset)
|
|
8
|
+
* with your site's own translations.
|
|
9
|
+
*/
|
|
6
10
|
declare const defaultLabels: {
|
|
7
11
|
dateRangePicker: {
|
|
12
|
+
/** Grid label; `monthStart` is the month's first day, YYYY-MM-DD. */
|
|
8
13
|
month: (monthStart: string) => string;
|
|
14
|
+
/** Column header; 0 = Sunday. */
|
|
9
15
|
weekday: (dayIndex: number) => string;
|
|
10
16
|
day: (date: string) => string;
|
|
11
17
|
previousMonth: string;
|
|
@@ -19,6 +25,7 @@ declare const defaultLabels: {
|
|
|
19
25
|
};
|
|
20
26
|
gallery: {
|
|
21
27
|
region: string;
|
|
28
|
+
/** Fallback alt text and slide label; `index` is zero-based. */
|
|
22
29
|
photo: (index: number, total: number) => string;
|
|
23
30
|
previous: string;
|
|
24
31
|
next: string;
|
|
@@ -28,6 +35,7 @@ type DateRangePickerLabels = typeof defaultLabels.dateRangePicker;
|
|
|
28
35
|
type GuestPickerLabels = typeof defaultLabels.guestPicker;
|
|
29
36
|
type GalleryLabels = typeof defaultLabels.gallery;
|
|
30
37
|
|
|
38
|
+
/** Listing-local dates, YYYY-MM-DD. `checkOut` null while the guest is picking it. */
|
|
31
39
|
interface DateRangeValue {
|
|
32
40
|
checkIn: string | null;
|
|
33
41
|
checkOut: string | null;
|
|
@@ -36,16 +44,27 @@ type Slot$2 = 'header' | 'title' | 'nav' | 'grid' | 'weekday' | 'day';
|
|
|
36
44
|
interface DateRangePickerProps {
|
|
37
45
|
value: DateRangeValue;
|
|
38
46
|
onChange(value: DateRangeValue): void;
|
|
47
|
+
/** Nights that cannot be booked (see `unavailableDates`); checking out on one is allowed. */
|
|
39
48
|
unavailable?: Iterable<string>;
|
|
49
|
+
/** Minimum nights for the stay. Default 1. */
|
|
40
50
|
minNights?: number;
|
|
51
|
+
/** Earlier days are disabled. Default: the browser's local date. */
|
|
41
52
|
today?: string;
|
|
53
|
+
/** Month shown first, YYYY-MM. Default: the check-in's month, else today's. */
|
|
42
54
|
defaultMonth?: string;
|
|
55
|
+
/** 0 = Sunday (default), 1 = Monday. */
|
|
43
56
|
weekStartsOn?: 0 | 1;
|
|
44
57
|
labels?: Partial<DateRangePickerLabels>;
|
|
45
58
|
className?: string;
|
|
46
59
|
classNames?: Partial<Record<Slot$2, string>>;
|
|
47
60
|
}
|
|
61
|
+
/** The nights a `calendar.get` answer marks as not bookable. */
|
|
48
62
|
declare function unavailableDates(days: readonly Pick<StorefrontCalendarDay, 'date' | 'status'>[]): string[];
|
|
63
|
+
/**
|
|
64
|
+
* A controlled, unstyled stay picker: one month grid (`role="grid"`), arrow keys move by day
|
|
65
|
+
* and week, Enter / Space / click pick the check-in then the check-out. Each day carries
|
|
66
|
+
* `data-state` = `start` | `end` | `in-range` | `disabled` | `available`.
|
|
67
|
+
*/
|
|
49
68
|
declare function DateRangePicker({ value, onChange, unavailable, minNights, today: todayProp, defaultMonth, weekStartsOn, labels: labelsProp, className, classNames, }: DateRangePickerProps): react.JSX.Element;
|
|
50
69
|
|
|
51
70
|
interface GalleryPhoto {
|
|
@@ -57,13 +76,29 @@ interface GalleryPhoto {
|
|
|
57
76
|
type Slot$1 = 'viewport' | 'slide' | 'image' | 'button';
|
|
58
77
|
interface GalleryProps {
|
|
59
78
|
photos: readonly GalleryPhoto[];
|
|
79
|
+
/** Called with the zero-based index of the photo now shown. */
|
|
60
80
|
onIndexChange?(index: number): void;
|
|
61
81
|
labels?: Partial<GalleryLabels>;
|
|
82
|
+
/** The slide's rendered width, for the browser to pick a size (`<img sizes>`). */
|
|
62
83
|
sizes?: string;
|
|
63
84
|
className?: string;
|
|
64
85
|
classNames?: Partial<Record<Slot$1, string>>;
|
|
65
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* A listing's photos for `Gallery`. Pass the listing: its `images` (the photos as SuiteOp hosts
|
|
89
|
+
* them) come first; with none — not copied yet, or an API revision without them — its `pictures`.
|
|
90
|
+
*
|
|
91
|
+
* `StorefrontListing.pictures` is the PMS's own photo array, passed through untyped (it can also
|
|
92
|
+
* be passed directly). This reads the shapes Guesty (`original` / `thumbnail`, `caption`),
|
|
93
|
+
* Hostaway (`url`, `caption`) and Streamline (`original_path` / `image_path` / `thumbnail_path`,
|
|
94
|
+
* `description`) send, plus bare URL strings, and drops anything without a URL.
|
|
95
|
+
*/
|
|
66
96
|
declare function listingPhotos(listingOrPictures: unknown): GalleryPhoto[];
|
|
97
|
+
/**
|
|
98
|
+
* An unstyled carousel (`role="region"`, `aria-roledescription="carousel"`). Every photo is in
|
|
99
|
+
* the DOM — only the first loads eagerly — and inactive slides are `hidden`; each slide carries
|
|
100
|
+
* `data-state` = `active` | `inactive`.
|
|
101
|
+
*/
|
|
67
102
|
declare function Gallery({ photos, onIndexChange, labels: labelsProp, sizes, className, classNames, }: GalleryProps): react.JSX.Element;
|
|
68
103
|
|
|
69
104
|
interface GuestCounts {
|
|
@@ -74,11 +109,13 @@ type Slot = 'field' | 'label' | 'button' | 'value';
|
|
|
74
109
|
interface GuestPickerProps {
|
|
75
110
|
value: GuestCounts;
|
|
76
111
|
onChange(value: GuestCounts): void;
|
|
112
|
+
/** Most guests in total (the listing's `maxGuests`). Default 50, the API's ceiling. */
|
|
77
113
|
max?: number;
|
|
78
114
|
labels?: Partial<GuestPickerLabels>;
|
|
79
115
|
className?: string;
|
|
80
116
|
classNames?: Partial<Record<Slot, string>>;
|
|
81
117
|
}
|
|
118
|
+
/** Adults (at least 1) and children as two spinbuttons whose sum never exceeds `max`. */
|
|
82
119
|
declare function GuestPicker({ value, onChange, max, labels: labelsProp, className, classNames, }: GuestPickerProps): react.JSX.Element;
|
|
83
120
|
|
|
84
121
|
interface MapListing {
|
|
@@ -100,12 +137,17 @@ interface MapBounds {
|
|
|
100
137
|
}
|
|
101
138
|
interface MapRenderProps<T extends MapListing> {
|
|
102
139
|
markers: MapMarker<T>[];
|
|
140
|
+
/** null when no listing has coordinates. */
|
|
103
141
|
bounds: MapBounds | null;
|
|
104
142
|
}
|
|
105
143
|
interface MapProps<T extends MapListing> {
|
|
106
144
|
listings: readonly T[];
|
|
107
145
|
children(props: MapRenderProps<T>): ReactNode;
|
|
108
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Ships no map library: computes markers (listings without usable coordinates dropped) and
|
|
149
|
+
* their bounds, and hands them to `children` — plug in MapLibre, Google Maps or a static image.
|
|
150
|
+
*/
|
|
109
151
|
declare function Map<T extends MapListing>({ listings, children }: MapProps<T>): react.JSX.Element;
|
|
110
152
|
|
|
111
153
|
export { DateRangePicker, type DateRangePickerLabels, type DateRangePickerProps, type DateRangeValue, Gallery, type GalleryLabels, type GalleryPhoto, type GalleryProps, type GuestCounts, GuestPicker, type GuestPickerLabels, type GuestPickerProps, Map, type MapBounds, type MapListing, type MapMarker, type MapProps, type MapRenderProps, defaultLabels, listingPhotos, unavailableDates };
|
package/dist/components.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { c as StorefrontCalendarDay } from './availability.d-Cla9GuGc.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* The components' English defaults. The SDK ships no other copy: pass `labels` (any subset)
|
|
8
|
+
* with your site's own translations.
|
|
9
|
+
*/
|
|
6
10
|
declare const defaultLabels: {
|
|
7
11
|
dateRangePicker: {
|
|
12
|
+
/** Grid label; `monthStart` is the month's first day, YYYY-MM-DD. */
|
|
8
13
|
month: (monthStart: string) => string;
|
|
14
|
+
/** Column header; 0 = Sunday. */
|
|
9
15
|
weekday: (dayIndex: number) => string;
|
|
10
16
|
day: (date: string) => string;
|
|
11
17
|
previousMonth: string;
|
|
@@ -19,6 +25,7 @@ declare const defaultLabels: {
|
|
|
19
25
|
};
|
|
20
26
|
gallery: {
|
|
21
27
|
region: string;
|
|
28
|
+
/** Fallback alt text and slide label; `index` is zero-based. */
|
|
22
29
|
photo: (index: number, total: number) => string;
|
|
23
30
|
previous: string;
|
|
24
31
|
next: string;
|
|
@@ -28,6 +35,7 @@ type DateRangePickerLabels = typeof defaultLabels.dateRangePicker;
|
|
|
28
35
|
type GuestPickerLabels = typeof defaultLabels.guestPicker;
|
|
29
36
|
type GalleryLabels = typeof defaultLabels.gallery;
|
|
30
37
|
|
|
38
|
+
/** Listing-local dates, YYYY-MM-DD. `checkOut` null while the guest is picking it. */
|
|
31
39
|
interface DateRangeValue {
|
|
32
40
|
checkIn: string | null;
|
|
33
41
|
checkOut: string | null;
|
|
@@ -36,16 +44,27 @@ type Slot$2 = 'header' | 'title' | 'nav' | 'grid' | 'weekday' | 'day';
|
|
|
36
44
|
interface DateRangePickerProps {
|
|
37
45
|
value: DateRangeValue;
|
|
38
46
|
onChange(value: DateRangeValue): void;
|
|
47
|
+
/** Nights that cannot be booked (see `unavailableDates`); checking out on one is allowed. */
|
|
39
48
|
unavailable?: Iterable<string>;
|
|
49
|
+
/** Minimum nights for the stay. Default 1. */
|
|
40
50
|
minNights?: number;
|
|
51
|
+
/** Earlier days are disabled. Default: the browser's local date. */
|
|
41
52
|
today?: string;
|
|
53
|
+
/** Month shown first, YYYY-MM. Default: the check-in's month, else today's. */
|
|
42
54
|
defaultMonth?: string;
|
|
55
|
+
/** 0 = Sunday (default), 1 = Monday. */
|
|
43
56
|
weekStartsOn?: 0 | 1;
|
|
44
57
|
labels?: Partial<DateRangePickerLabels>;
|
|
45
58
|
className?: string;
|
|
46
59
|
classNames?: Partial<Record<Slot$2, string>>;
|
|
47
60
|
}
|
|
61
|
+
/** The nights a `calendar.get` answer marks as not bookable. */
|
|
48
62
|
declare function unavailableDates(days: readonly Pick<StorefrontCalendarDay, 'date' | 'status'>[]): string[];
|
|
63
|
+
/**
|
|
64
|
+
* A controlled, unstyled stay picker: one month grid (`role="grid"`), arrow keys move by day
|
|
65
|
+
* and week, Enter / Space / click pick the check-in then the check-out. Each day carries
|
|
66
|
+
* `data-state` = `start` | `end` | `in-range` | `disabled` | `available`.
|
|
67
|
+
*/
|
|
49
68
|
declare function DateRangePicker({ value, onChange, unavailable, minNights, today: todayProp, defaultMonth, weekStartsOn, labels: labelsProp, className, classNames, }: DateRangePickerProps): react.JSX.Element;
|
|
50
69
|
|
|
51
70
|
interface GalleryPhoto {
|
|
@@ -57,13 +76,29 @@ interface GalleryPhoto {
|
|
|
57
76
|
type Slot$1 = 'viewport' | 'slide' | 'image' | 'button';
|
|
58
77
|
interface GalleryProps {
|
|
59
78
|
photos: readonly GalleryPhoto[];
|
|
79
|
+
/** Called with the zero-based index of the photo now shown. */
|
|
60
80
|
onIndexChange?(index: number): void;
|
|
61
81
|
labels?: Partial<GalleryLabels>;
|
|
82
|
+
/** The slide's rendered width, for the browser to pick a size (`<img sizes>`). */
|
|
62
83
|
sizes?: string;
|
|
63
84
|
className?: string;
|
|
64
85
|
classNames?: Partial<Record<Slot$1, string>>;
|
|
65
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* A listing's photos for `Gallery`. Pass the listing: its `images` (the photos as SuiteOp hosts
|
|
89
|
+
* them) come first; with none — not copied yet, or an API revision without them — its `pictures`.
|
|
90
|
+
*
|
|
91
|
+
* `StorefrontListing.pictures` is the PMS's own photo array, passed through untyped (it can also
|
|
92
|
+
* be passed directly). This reads the shapes Guesty (`original` / `thumbnail`, `caption`),
|
|
93
|
+
* Hostaway (`url`, `caption`) and Streamline (`original_path` / `image_path` / `thumbnail_path`,
|
|
94
|
+
* `description`) send, plus bare URL strings, and drops anything without a URL.
|
|
95
|
+
*/
|
|
66
96
|
declare function listingPhotos(listingOrPictures: unknown): GalleryPhoto[];
|
|
97
|
+
/**
|
|
98
|
+
* An unstyled carousel (`role="region"`, `aria-roledescription="carousel"`). Every photo is in
|
|
99
|
+
* the DOM — only the first loads eagerly — and inactive slides are `hidden`; each slide carries
|
|
100
|
+
* `data-state` = `active` | `inactive`.
|
|
101
|
+
*/
|
|
67
102
|
declare function Gallery({ photos, onIndexChange, labels: labelsProp, sizes, className, classNames, }: GalleryProps): react.JSX.Element;
|
|
68
103
|
|
|
69
104
|
interface GuestCounts {
|
|
@@ -74,11 +109,13 @@ type Slot = 'field' | 'label' | 'button' | 'value';
|
|
|
74
109
|
interface GuestPickerProps {
|
|
75
110
|
value: GuestCounts;
|
|
76
111
|
onChange(value: GuestCounts): void;
|
|
112
|
+
/** Most guests in total (the listing's `maxGuests`). Default 50, the API's ceiling. */
|
|
77
113
|
max?: number;
|
|
78
114
|
labels?: Partial<GuestPickerLabels>;
|
|
79
115
|
className?: string;
|
|
80
116
|
classNames?: Partial<Record<Slot, string>>;
|
|
81
117
|
}
|
|
118
|
+
/** Adults (at least 1) and children as two spinbuttons whose sum never exceeds `max`. */
|
|
82
119
|
declare function GuestPicker({ value, onChange, max, labels: labelsProp, className, classNames, }: GuestPickerProps): react.JSX.Element;
|
|
83
120
|
|
|
84
121
|
interface MapListing {
|
|
@@ -100,12 +137,17 @@ interface MapBounds {
|
|
|
100
137
|
}
|
|
101
138
|
interface MapRenderProps<T extends MapListing> {
|
|
102
139
|
markers: MapMarker<T>[];
|
|
140
|
+
/** null when no listing has coordinates. */
|
|
103
141
|
bounds: MapBounds | null;
|
|
104
142
|
}
|
|
105
143
|
interface MapProps<T extends MapListing> {
|
|
106
144
|
listings: readonly T[];
|
|
107
145
|
children(props: MapRenderProps<T>): ReactNode;
|
|
108
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Ships no map library: computes markers (listings without usable coordinates dropped) and
|
|
149
|
+
* their bounds, and hands them to `children` — plug in MapLibre, Google Maps or a static image.
|
|
150
|
+
*/
|
|
109
151
|
declare function Map<T extends MapListing>({ listings, children }: MapProps<T>): react.JSX.Element;
|
|
110
152
|
|
|
111
153
|
export { DateRangePicker, type DateRangePickerLabels, type DateRangePickerProps, type DateRangeValue, Gallery, type GalleryLabels, type GalleryPhoto, type GalleryProps, type GuestCounts, GuestPicker, type GuestPickerLabels, type GuestPickerProps, Map, type MapBounds, type MapListing, type MapMarker, type MapProps, type MapRenderProps, defaultLabels, listingPhotos, unavailableDates };
|
package/dist/components.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cdnImageProps } from './chunk-A43EXKPY.js';
|
|
2
|
-
import { STOREFRONT_MAX_GUESTS } from './chunk-
|
|
2
|
+
import { STOREFRONT_MAX_GUESTS } from './chunk-IBCBDAGY.js';
|
|
3
3
|
import { useMemo, useState, useRef, useEffect, useId } from 'react';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|