@suiteop/storefront 0.4.0 → 0.5.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 (47) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +5 -0
  3. package/dist/astro-content-model.cjs +5 -5
  4. package/dist/astro-content-model.js +4 -4
  5. package/dist/{availability-CnzmxuV3.d.cts → availability-Dh0yLSkj.d.cts} +25 -1
  6. package/dist/{availability-CnzmxuV3.d.ts → availability-Dh0yLSkj.d.ts} +25 -1
  7. package/dist/checkout.cjs +4 -4
  8. package/dist/checkout.js +3 -3
  9. package/dist/chunk-5TUJX6GY.js +5 -0
  10. package/dist/{chunk-HMLBMNGA.js → chunk-7ZAI36LH.js} +1 -1
  11. package/dist/{chunk-LVFRVNT3.cjs → chunk-EHQFWSP6.cjs} +2 -1
  12. package/dist/{chunk-6NFURJXI.js → chunk-IBCBDAGY.js} +2 -2
  13. package/dist/{chunk-TLTL7M3O.js → chunk-IUNIQSFB.js} +2 -2
  14. package/dist/{chunk-USOISC2R.cjs → chunk-J5FZ4WDQ.cjs} +2 -2
  15. package/dist/chunk-LY73ZYN5.cjs +20 -0
  16. package/dist/{chunk-IUJTHNB3.cjs → chunk-NNWJZUQL.cjs} +3 -3
  17. package/dist/{chunk-CTHHMNLE.cjs → chunk-NZWYOV5Y.cjs} +4 -4
  18. package/dist/{chunk-VV2UNVQ2.cjs → chunk-UMCI4YBN.cjs} +2 -2
  19. package/dist/{chunk-ZI2PG7LS.js → chunk-W5K7IDYN.js} +1 -1
  20. package/dist/{chunk-UWUKERLK.js → chunk-YSKWSL2F.js} +4 -4
  21. package/dist/{client-oyYRhUv0.d.ts → client-2KyVv-2l.d.cts} +45 -11
  22. package/dist/{client-CZWN4im4.d.cts → client-C9Igm7O-.d.ts} +45 -11
  23. package/dist/components.cjs +2 -2
  24. package/dist/components.d.cts +1 -1
  25. package/dist/components.d.ts +1 -1
  26. package/dist/components.js +1 -1
  27. package/dist/config.cjs +8 -1
  28. package/dist/config.d.cts +168 -11
  29. package/dist/config.d.ts +168 -11
  30. package/dist/config.js +3 -3
  31. package/dist/content.cjs +11 -11
  32. package/dist/content.d.cts +3 -3
  33. package/dist/content.d.ts +3 -3
  34. package/dist/content.js +4 -4
  35. package/dist/{errors-DoXdi1vS.d.ts → errors-BGgJ--XR.d.ts} +1 -1
  36. package/dist/{errors-CAW7nLHr.d.cts → errors-DpImb0Uf.d.cts} +1 -1
  37. package/dist/index.cjs +21 -21
  38. package/dist/index.d.cts +4 -4
  39. package/dist/index.d.ts +4 -4
  40. package/dist/index.js +4 -4
  41. package/dist/react.cjs +6 -6
  42. package/dist/react.d.cts +3 -3
  43. package/dist/react.d.ts +3 -3
  44. package/dist/react.js +5 -5
  45. package/package.json +1 -1
  46. package/dist/chunk-E5CGGMCO.cjs +0 -19
  47. package/dist/chunk-TRXDDUEL.js +0 -5
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { d as StorefrontStay, S as StorefrontAvailability, c as StorefrontCalendarQuery, a as StorefrontCalendar } from './availability-CnzmxuV3.cjs';
2
+ import { e as StorefrontStay, a as StorefrontBuildingAvailabilityQuery, g as StorefrontUnitAvailability, S as StorefrontAvailability, d as StorefrontCalendarQuery, b as StorefrontCalendar } from './availability-Dh0yLSkj.js';
3
3
 
4
4
  declare const storefrontGuestInputSchema: z.ZodObject<{
5
5
  firstName: z.ZodString;
@@ -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,45 @@ 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 storefrontListingsQuerySchema: z.ZodObject<{
125
- location: z.ZodOptional<z.ZodString>;
126
- building: z.ZodOptional<z.ZodUUID>;
127
- limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
128
- offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
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
+ sort?: StorefrontListingSort;
139
+ facets?: boolean;
140
+ limit?: number;
141
+ offset?: number;
142
+ }
143
+ declare const storefrontListingFacetsSchema: z.ZodObject<{
144
+ total: z.ZodNumber;
145
+ areas: z.ZodArray<z.ZodObject<{
146
+ id: z.ZodUUID;
147
+ slug: z.ZodNullable<z.ZodString>;
148
+ count: z.ZodNumber;
149
+ }, z.core.$strip>>;
150
+ bedrooms: z.ZodArray<z.ZodObject<{
151
+ bedrooms: z.ZodNumber;
152
+ count: z.ZodNumber;
153
+ }, z.core.$strip>>;
154
+ price: z.ZodNullable<z.ZodObject<{
155
+ min: z.ZodNumber;
156
+ max: z.ZodNumber;
157
+ currency: z.ZodNullable<z.ZodString>;
158
+ buckets: z.ZodArray<z.ZodNumber>;
159
+ }, z.core.$strip>>;
129
160
  }, z.core.$strip>;
130
- type StorefrontListingsQuery = z.infer<typeof storefrontListingsQuerySchema>;
161
+ type StorefrontListingFacets = z.infer<typeof storefrontListingFacetsSchema>;
131
162
  declare const storefrontBuildingSchema: z.ZodObject<{
132
163
  id: z.ZodUUID;
133
164
  locationId: z.ZodNullable<z.ZodUUID>;
@@ -558,12 +589,15 @@ interface StorefrontClient {
558
589
  get(opts?: RequestOptions): Promise<StorefrontSite>;
559
590
  };
560
591
  listings: {
561
- list(query?: Partial<StorefrontListingsQuery>, opts?: RequestOptions): Promise<Page<StorefrontListingSummary>>;
592
+ list(query?: StorefrontListingsQuery, opts?: RequestOptions): Promise<Page<StorefrontListingSummary> & {
593
+ facets?: StorefrontListingFacets;
594
+ }>;
562
595
  get(id: string, opts?: RequestOptions): Promise<StorefrontListing>;
563
596
  };
564
597
  buildings: {
565
598
  list(opts?: RequestOptions): Promise<StorefrontBuilding[]>;
566
599
  get(id: string, opts?: RequestOptions): Promise<StorefrontBuilding>;
600
+ availability(id: string, query: StorefrontStay & Partial<Pick<StorefrontBuildingAvailabilityQuery, 'limit' | 'offset'>>, opts?: RequestOptions): Promise<Page<StorefrontUnitAvailability>>;
567
601
  };
568
602
  locations: {
569
603
  list(opts?: RequestOptions): Promise<StorefrontLocation[]>;
@@ -612,4 +646,4 @@ interface StorefrontClient {
612
646
  }
613
647
  declare function createStorefrontClient(options: StorefrontClientOptions): StorefrontClient;
614
648
 
615
- export { type StorefrontReview as A, type BookingResult as B, type CheckoutMountDescriptor as C, type StorefrontReviewsQuery as D, type StorefrontSite as E, createStorefrontClient as F, 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 StorefrontListingSummary as u, type StorefrontListingsQuery as v, type StorefrontLocation as w, type StorefrontQuote as x, type StorefrontQuoteInput as y, type StorefrontRatePlanQuote as z };
649
+ 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 };
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkEVSAMV5K_cjs = require('./chunk-EVSAMV5K.cjs');
4
- var chunkLVFRVNT3_cjs = require('./chunk-LVFRVNT3.cjs');
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;
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { b as StorefrontCalendarDay } from './availability-CnzmxuV3.cjs';
3
+ import { c as StorefrontCalendarDay } from './availability-Dh0yLSkj.cjs';
4
4
  import 'zod';
5
5
 
6
6
  declare const defaultLabels: {
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { b as StorefrontCalendarDay } from './availability-CnzmxuV3.js';
3
+ import { c as StorefrontCalendarDay } from './availability-Dh0yLSkj.js';
4
4
  import 'zod';
5
5
 
6
6
  declare const defaultLabels: {
@@ -1,5 +1,5 @@
1
1
  import { cdnImageProps } from './chunk-A43EXKPY.js';
2
- import { STOREFRONT_MAX_GUESTS } from './chunk-6NFURJXI.js';
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
 
package/dist/config.cjs CHANGED
@@ -3,12 +3,19 @@
3
3
  var chunkZLAOY6IF_cjs = require('./chunk-ZLAOY6IF.cjs');
4
4
  var zod = require('zod');
5
5
 
6
- var STOREFRONT_LOCALES=["en","fr","es","de","it","pt","nl"];var REQUIRED="validation.required";var TOO_LONG="validation.max_length";var TOO_MANY="validation.too_large";var INVALID="validation.invalid";var text=max=>zod.z.string(INVALID).max(max,TOO_LONG);var localeSchema=zod.z.enum(STOREFRONT_LOCALES,"validation.storefront.locale_unsupported");var hexSchema=zod.z.string(INVALID).regex(/^#[0-9A-Fa-f]{6}$/,"validation.storefront.color_hex");var assetUrlSchema=zod.z.url({protocol:/^https$/,error:"validation.storefront.url_https"});var localizedSchema=zod.z.partialRecord(localeSchema,text(200),INVALID);var linkSchema=zod.z.object({label:localizedSchema,href:text(500).regex(/^(\/(?!\/)|https:\/\/)/,"validation.storefront.link_href")},INVALID);var fontSchema=zod.z.enum(chunkZLAOY6IF_cjs.STOREFRONT_FONTS,"validation.invalid_option");var storefrontSiteConfigSchema=zod.z.object({brand:zod.z.object({name:text(80).min(1,REQUIRED),logoUrl:assetUrlSchema.nullable(),faviconUrl:assetUrlSchema.nullable()},INVALID),colors:zod.z.object({primary:hexSchema,primaryForeground:hexSchema,background:hexSchema,foreground:hexSchema,accent:hexSchema},INVALID),fonts:zod.z.object({heading:fontSchema,body:fontSchema},INVALID),nav:zod.z.array(linkSchema,INVALID).max(8,TOO_MANY),footer:zod.z.object({text:localizedSchema,links:zod.z.array(linkSchema,INVALID).max(12,TOO_MANY)},INVALID),defaultLocale:localeSchema,locales:zod.z.array(localeSchema,INVALID).min(1,REQUIRED).max(STOREFRONT_LOCALES.length,TOO_MANY),seo:zod.z.object({titleTemplate:text(80).includes("%s",{error:"validation.storefront.title_template_placeholder"}),defaultDescription:localizedSchema,ogImageUrl:assetUrlSchema.nullable()},INVALID)},INVALID).refine(c=>c.locales.includes(c.defaultLocale),{path:["defaultLocale"],message:"validation.storefront.default_locale_not_listed"});function defineSuiteOpConfig(config){return storefrontSiteConfigSchema.parse(config)}
6
+ var STOREFRONT_LOCALES=["en","fr","es","de","it","pt","nl"];var STOREFRONT_LAYOUTS=["listings","locations","areas","single"];var STOREFRONT_THEMES=["folio","hearth","circuit","tide","noir","fjord"];var REQUIRED="validation.required";var TOO_LONG="validation.max_length";var TOO_MANY="validation.too_large";var INVALID="validation.invalid";var text=max=>zod.z.string(INVALID).max(max,TOO_LONG);var localeSchema=zod.z.enum(STOREFRONT_LOCALES,"validation.storefront.locale_unsupported");var hexSchema=zod.z.string(INVALID).regex(/^#[0-9A-Fa-f]{6}$/,"validation.storefront.color_hex");var assetUrlSchema=zod.z.url({protocol:/^https$/,error:"validation.storefront.url_https"});var localizedSchema=zod.z.partialRecord(localeSchema,text(200),INVALID);var linkSchema=zod.z.object({label:localizedSchema,href:text(500).regex(/^(\/(?!\/)|https:\/\/)/,"validation.storefront.link_href")},INVALID);var fontSchema=zod.z.enum(chunkZLAOY6IF_cjs.STOREFRONT_FONTS,"validation.invalid_option");var storefrontSiteConfigSchema=zod.z.object({layout:zod.z.enum(STOREFRONT_LAYOUTS).optional().catch(void 0),theme:zod.z.enum(STOREFRONT_THEMES).optional().catch(void 0),brand:zod.z.object({name:text(80).min(1,REQUIRED),logoUrl:assetUrlSchema.nullable(),logoOnDarkUrl:assetUrlSchema.nullable().optional(),faviconUrl:assetUrlSchema.nullable()},INVALID),colors:zod.z.object({primary:hexSchema,secondary:hexSchema.nullable().optional(),primaryForeground:hexSchema.optional(),background:hexSchema.optional(),foreground:hexSchema.optional(),accent:hexSchema.optional()},INVALID),fonts:zod.z.object({heading:fontSchema.optional(),body:fontSchema.optional()},INVALID).optional(),nav:zod.z.array(linkSchema,INVALID).max(8,TOO_MANY),footer:zod.z.object({text:localizedSchema,links:zod.z.array(linkSchema,INVALID).max(12,TOO_MANY)},INVALID),defaultLocale:localeSchema,locales:zod.z.array(localeSchema,INVALID).min(1,REQUIRED).max(STOREFRONT_LOCALES.length,TOO_MANY),seo:zod.z.object({titleTemplate:text(80).includes("%s",{error:"validation.storefront.title_template_placeholder"}),defaultDescription:localizedSchema,ogImageUrl:assetUrlSchema.nullable()},INVALID)},INVALID).refine(c=>c.locales.includes(c.defaultLocale),{path:["defaultLocale"],message:"validation.storefront.default_locale_not_listed"});var DEFAULT_STOREFRONT_LAYOUT="listings";var DEFAULT_STOREFRONT_THEME="tide";var STOREFRONT_THEME_RECIPES={folio:{mode:"light",fonts:{heading:"eb_garamond",body:"libre_franklin"},radius:{sm:0,md:0,lg:0,btn:0},btn:{size:12,w:600,ls:"0.14em",tt:"uppercase",h:46},type:{display:[88,1,400,"-0.015em"],h1:[56,1.05,400,"-0.01em"],h2:[36,1.15,400,"0"],h3:[24,1.25,500,"0"],body:[18,1.6,400,"0"],small:[14,1.5,400,"0"],label:[11,1.3,600,"0.16em","uppercase"]},space:{section:144,gutter:32},neutral:{hue:null,mix:0,c:.006},L:{bg:.985,surface:1,surface2:.955,tint:.95,border:.87,ink:.19,muted:.47,dark:.22},C:{ink:.02,dark:.04,tint:.022},shadow:false},hearth:{mode:"light",fonts:{heading:"lora",body:"karla"},radius:{sm:6,md:12,lg:18,btn:8},btn:{size:15,w:700,ls:"0",tt:"none",h:48},type:{display:[64,1.08,500,"-0.01em"],h1:[48,1.12,500,"-0.01em"],h2:[32,1.2,500,"0"],h3:[22,1.3,600,"0"],body:[17,1.6,400,"0"],small:[14,1.5,400,"0"],label:[12,1.3,700,"0.1em","uppercase"]},space:{section:112,gutter:28},neutral:{hue:75,mix:.85,c:.014},L:{bg:.972,surface:.99,surface2:.945,tint:.935,border:.885,ink:.25,muted:.48,dark:.28},C:{ink:.025,dark:.05,tint:.032},shadow:true},circuit:{mode:"light",fonts:{heading:"space_grotesk",body:"ibm_plex_sans"},radius:{sm:8,md:12,lg:16,btn:999},btn:{size:15,w:600,ls:"-0.005em",tt:"none",h:44},type:{display:[64,1.02,600,"-0.035em"],h1:[44,1.08,600,"-0.03em"],h2:[30,1.15,600,"-0.02em"],h3:[20,1.3,600,"-0.01em"],body:[16,1.55,400,"0"],small:[14,1.45,400,"0"],label:[12,1.3,600,"0.02em"]},space:{section:88,gutter:20},neutral:{hue:null,mix:0,c:.004},L:{bg:1,surface:.975,surface2:.958,tint:.958,border:.915,ink:.17,muted:.48,dark:.19},C:{ink:.012,dark:.03,tint:.035},shadow:true},tide:{mode:"light",fonts:{heading:"outfit",body:"mulish"},radius:{sm:12,md:20,lg:28,btn:999},btn:{size:15,w:700,ls:"0.01em",tt:"none",h:50},type:{display:[76,1.02,300,"-0.02em"],h1:[48,1.1,400,"-0.015em"],h2:[34,1.15,400,"-0.01em"],h3:[21,1.3,500,"0"],body:[17,1.6,400,"0"],small:[14,1.5,400,"0"],label:[12,1.3,700,"0.08em","uppercase"]},space:{section:120,gutter:24},neutral:{hue:null,mix:0,c:.005},L:{bg:.99,surface:.968,surface2:.945,tint:.95,border:.905,ink:.26,muted:.48,dark:.29},C:{ink:.035,dark:.055,tint:.028},shadow:true},noir:{mode:"dark",fonts:{heading:"cormorant_garamond",body:"manrope"},radius:{sm:0,md:2,lg:2,btn:0},btn:{size:11,w:600,ls:"0.22em",tt:"uppercase",h:48},type:{display:[84,1,300,"0.02em","uppercase"],h1:[56,1.05,300,"0.01em"],h2:[38,1.15,400,"0"],h3:[24,1.25,500,"0.02em"],body:[16,1.7,400,"0"],small:[13,1.55,400,"0.01em"],label:[11,1.3,600,"0.24em","uppercase"]},space:{section:152,gutter:32},neutral:{hue:null,mix:0,c:.016},L:{bg:.165,surface:.205,surface2:.245,tint:.24,border:.34,ink:.94,muted:.76,dark:.12},C:{ink:.01,dark:.014,tint:.035},shadow:false},fjord:{mode:"light",fonts:{heading:"dm_sans",body:"dm_sans"},radius:{sm:2,md:4,lg:6,btn:4},btn:{size:14,w:500,ls:"0",tt:"none",h:44},type:{display:[60,1.05,500,"-0.03em"],h1:[42,1.1,500,"-0.025em"],h2:[28,1.2,500,"-0.015em"],h3:[19,1.35,500,"-0.005em"],body:[16,1.6,400,"0"],small:[13,1.5,400,"0"],label:[12,1.3,500,"0"]},space:{section:128,gutter:24},neutral:{hue:85,mix:.85,c:.006},L:{bg:.976,surface:.995,surface2:.948,tint:.945,border:.895,ink:.23,muted:.49,dark:.26},C:{ink:.008,dark:.02,tint:.022},shadow:false}};var clamp=(v,a,b)=>Math.min(b,Math.max(a,v));var toLin=c=>c<=.04045?c/12.92:Math.pow((c+.055)/1.055,2.4);var toGam=c=>c<=.0031308?12.92*c:1.055*Math.pow(c,1/2.4)-.055;var hexToRgb=hex=>{const h=hex.replace("#","");return [0,2,4].map(i=>parseInt(h.slice(i,i+2),16)/255)};var rgbToHex=rgb=>"#"+rgb.map(v=>Math.round(clamp(v,0,1)*255).toString(16).padStart(2,"0")).join("").toUpperCase();function hexToOklch(hex){const[r,g,b]=hexToRgb(hex).map(toLin);const l=Math.cbrt(.4122214708*r+.5363325363*g+.0514459929*b);const m=Math.cbrt(.2119034982*r+.6806995451*g+.1073969566*b);const s=Math.cbrt(.0883024619*r+.2817188376*g+.6299787005*b);const L=.2104542553*l+.793617785*m-.0040720468*s;const A=1.9779984951*l-2.428592205*m+.4505937099*s;const B=.0259040371*l+.7827717662*m-.808675766*s;let H=Math.atan2(B,A)*180/Math.PI;if(H<0)H+=360;return [L,Math.sqrt(A*A+B*B),H]}function oklchToLinear(L,C,H){const a=C*Math.cos(H*Math.PI/180);const b=C*Math.sin(H*Math.PI/180);const l=(L+.3963377774*a+.2158037573*b)**3;const m=(L-.1055613458*a-.0638541728*b)**3;const s=(L-.0894841775*a-1.291485548*b)**3;return [4.0767416621*l-3.3077115913*m+.2309699292*s,-1.2684380046*l+2.6097574011*m-.3413193965*s,-0.0041960863*l-.7034186147*m+1.707614701*s]}var inGamut=rgb=>rgb.every(v=>v>=-1e-4&&v<=1.0001);function oklchToHex(lightness,C,H){const L=clamp(lightness,0,1);let rgb=oklchToLinear(L,C,H);if(!inGamut(rgb)){let lo=0;let hi=C;for(let i=0;i<22;i++){const mid=(lo+hi)/2;if(inGamut(oklchToLinear(L,mid,H)))lo=mid;else hi=mid;}rgb=oklchToLinear(L,lo,H);}return rgbToHex(rgb.map(v=>toGam(clamp(v,0,1))))}var luminance=hex=>{const[r,g,b]=hexToRgb(hex).map(toLin);return .2126*r+.7152*g+.0722*b};function contrastRatio(a,b){const x=luminance(a);const y=luminance(b);return (Math.max(x,y)+.05)/(Math.min(x,y)+.05)}var minContrast=(hex,grounds)=>Math.min(...grounds.map(g=>contrastRatio(hex,g)));var rgba=(hex,alpha)=>{const[r,g,b]=hexToRgb(hex).map(v=>Math.round(v*255));return `rgba(${r},${g},${b},${alpha})`};var mixHue=(a,b,t)=>{const d=(b-a+540)%360-180;return (a+d*t+360)%360};function fit(lightness,C,H,grounds,target,dir){let L=lightness;let hex=oklchToHex(L,C,H);let steps=0;while(minContrast(hex,grounds)<target&&steps<100){L=clamp(L+dir*.01,0,1);hex=oklchToHex(L,C,H);steps++;}return {hex,L,steps}}var SERIF_FONTS=new Set(["playfair_display","merriweather","bitter","fraunces","cormorant_garamond","eb_garamond","lora","crimson_pro","source_serif_4","ibm_plex_serif"]);function storefrontFontStack(font){return `'${chunkZLAOY6IF_cjs.STOREFRONT_FONT_FAMILIES[font]}', ${SERIF_FONTS.has(font)?"serif":"sans-serif"}`}var AA=4.5;var INK=7;function derivePalette(recipe,brandHex,secondary,overrides){const[bL,bC,bH]=hexToOklch(brandHex);const nh=recipe.neutral.hue==null?bH:mixHue(bH,recipe.neutral.hue,recipe.neutral.mix);const nc=recipe.neutral.c;const{L,C}=recipe;const dark=recipe.mode==="dark";const dir=dark?1:-1;const N=(l,c=nc)=>oklchToHex(l,c,nh);const bg=overrides.background?.toUpperCase()??N(L.bg);const surface=N(L.surface,L.surface>=.999?0:nc);const surface2=N(L.surface2);const tint=oklchToHex(L.tint,Math.min(bC,C.tint),bH);const border=N(L.border,nc*1.5);const borderStrong=N(dark?L.border+.12:L.border-.2,nc*1.5);const grounds=[bg,surface,surface2,tint];const ink=overrides.foreground?.toUpperCase()??fit(L.ink,C.ink,nh,grounds,INK,dir).hex;const muted=fit(L.muted,nc*2.5,nh,grounds,AA,dir).hex;const brandText=fit(bL,bC,bH,grounds,AA,dir);const accentText=overrides.accent?.toUpperCase()??brandText.hex;const notes=[];let p;let on;if(!dark){const white=oklchToHex(.995,.003,bH);if(contrastRatio(brandHex,white)>=AA){p={hex:brandHex.toUpperCase(),L:bL};on=white;}else if(bL>=.7&&contrastRatio(brandHex,ink)>=AA){p={hex:brandHex.toUpperCase(),L:bL};on=ink;notes.push({code:"light_brand_ink_label",text:"Light brand: button keeps the colour and takes an ink label"});}else {p=fit(bL,bC,bH,[white],AA,-1);on=white;notes.push({code:"button_darkened",from:round2(bL),to:round2(p.L),text:`Button darkened L ${bL.toFixed(2)} \u2192 ${p.L.toFixed(2)} for a white label`});}}else {on=bg;p=fit(Math.max(bL,.72),bC,bH,[bg,surface],AA,1);if(p.L>bL+.005){notes.push({code:"brand_lifted",from:round2(bL),to:round2(p.L),text:`Brand lifted L ${bL.toFixed(2)} \u2192 ${p.L.toFixed(2)} to read on dark`});}}const onPrimary=overrides.primaryForeground?.toUpperCase()??on;let primaryHover=oklchToHex(p.L+(dark?.05:-0.06),bC,bH);if(contrastRatio(primaryHover,onPrimary)<AA){primaryHover=oklchToHex(p.L+(dark?-0.04:.04),bC,bH);}const darkToken=oklchToHex(L.dark,Math.min(bC,C.dark),bH);const phBg=dark?oklchToHex(.27,Math.min(bC,.03),bH):oklchToHex(L.tint-.045,Math.min(bC,.03),bH);const t={bg,surface,surface2,tint,border,borderStrong,ink,muted,primary:p.hex,onPrimary,primaryHover,accentText,dark:darkToken,onDark:oklchToHex(.97,.008,bH),onDarkMuted:fit(.82,.012,bH,[darkToken],AA,1).hex,darkAccent:fit(Math.max(bL,.72),bC,bH,[darkToken],AA,1).hex,focus:dark?p.hex:accentText,phBg,phText:fit(dark?.7:.48,.02,bH,[phBg],AA,dir).hex};if(secondary)t.accent2=fit(...hexToOklch(secondary),grounds,AA,dir).hex;if(!dark&&brandText.steps>0&&accentText===brandText.hex){notes.push({code:"brand_text_darkened",steps:brandText.steps,text:`Brand text darkened ${brandText.steps} step${brandText.steps>1?"s":""} to reach 4.5:1`});}return {t,notes}}var round2=n=>Math.round(n*100)/100;function failingOverride(t,overrides){const grounds=[t.bg,t.surface,t.surface2,t.tint];if(overrides.foreground){const ratio=minContrast(t.ink,grounds);if(ratio<AA)return {field:"foreground",ratio,against:"background"}}if(overrides.accent){const ratio=minContrast(t.accentText,grounds);if(ratio<AA)return {field:"accent",ratio,against:"background"}}if(overrides.primaryForeground){const ratio=contrastRatio(t.onPrimary,t.primary);if(ratio<AA)return {field:"primaryForeground",ratio,against:"button"}}if(overrides.background){const ratio=Math.min(contrastRatio(t.ink,t.bg),contrastRatio(t.muted,t.bg));if(ratio<AA)return {field:"background",ratio,against:"text"}}return null}function deriveStorefrontTheme(theme,brandHex,opts={}){const recipe=STOREFRONT_THEME_RECIPES[theme];const overrides={...opts.overrides};const problems=[];let palette=derivePalette(recipe,brandHex,opts.secondary,overrides);for(let problem=failingOverride(palette.t,overrides);problem;){problems.push({...problem,ratio:Math.round(problem.ratio*10)/10});delete overrides[problem.field];palette=derivePalette(recipe,brandHex,opts.secondary,overrides);problem=failingOverride(palette.t,overrides);}const{t,notes}=palette;const r=recipe.radius;const px=n=>`${n}px`;const vars={"--so-bg":t.bg,"--so-surface":t.surface,"--so-surface-2":t.surface2,"--so-tint":t.tint,"--so-border":t.border,"--so-border-strong":t.borderStrong,"--so-ink":t.ink,"--so-muted":t.muted,"--so-primary":t.primary,"--so-on-primary":t.onPrimary,"--so-primary-hover":t.primaryHover,"--so-accent-text":t.accentText,"--so-dark":t.dark,"--so-on-dark":t.onDark,"--so-on-dark-muted":t.onDarkMuted,"--so-dark-accent":t.darkAccent,"--so-focus":t.focus,"--so-ph-bg":t.phBg,"--so-ph-text":t.phText,"--so-ph-line":rgba(t.phText,.16),"--so-accent-2":t.accent2??t.accentText,"--so-scrim":`linear-gradient(180deg, ${rgba(t.dark,.55)} 0%, ${rgba(t.dark,0)} 26%, ${rgba(t.dark,0)} 40%, ${rgba(t.dark,.72)} 100%)`,"--so-scrim-solid":rgba(t.dark,.45),"--so-shadow":recipe.shadow?`0 1px 2px ${rgba(t.dark,.06)}, 0 10px 30px ${rgba(t.dark,.1)}`:"none","--so-shadow-float":`0 2px 6px ${rgba(t.dark,.08)}, 0 18px 50px ${rgba(t.dark,.18)}`,"--so-font-heading":storefrontFontStack(opts.heading??recipe.fonts.heading),"--so-font-body":storefrontFontStack(opts.body??recipe.fonts.body),"--so-r-sm":px(r.sm),"--so-r-md":px(r.md),"--so-r-lg":px(r.lg),"--so-r-btn":px(r.btn),"--so-btn-size":px(recipe.btn.size),"--so-btn-w":String(recipe.btn.w),"--so-btn-ls":recipe.btn.ls,"--so-btn-tt":recipe.btn.tt,"--so-btn-h":px(recipe.btn.h),"--so-section":px(recipe.space.section),"--so-gutter":px(recipe.space.gutter)};for(const[step,[size,lh,w,ls,tt]]of Object.entries(recipe.type)){vars[`--t-${step}-size`]=px(size);vars[`--t-${step}-lh`]=String(lh);vars[`--t-${step}-w`]=String(w);vars[`--t-${step}-ls`]=ls;vars[`--t-${step}-tt`]=tt??"none";}const grade=x=>x>=7?"AAA":x>=AA?"AA":"Fail";const checks=[["Body text",t.ink,t.bg],["Muted text",t.muted,t.surface2],["Button label",t.onPrimary,t.primary],["Brand text",t.accentText,t.bg],["On dark section",t.onDark,t.dark],["Brand on dark",t.darkAccent,t.dark]].map(([label,a,b])=>{const x=Math.round(contrastRatio(a,b)*10)/10;return {label,ratio:x.toFixed(1),grade:grade(x),pass:x>=AA}});return {theme,tokens:t,vars,checks,notes,problems}}function storefrontThemeFonts(theme,fonts){const pair=STOREFRONT_THEME_RECIPES[theme].fonts;return {heading:fonts?.heading??pair.heading,body:fonts?.body??pair.body}}function resolveStorefrontTheme(config){const theme=config.theme??DEFAULT_STOREFRONT_THEME;const fonts=storefrontThemeFonts(theme,config.fonts);const{primary,secondary,background,foreground,accent,primaryForeground}=explicitThemeChoices(config).colors;const derived=deriveStorefrontTheme(theme,primary,{secondary,...fonts,overrides:{background,foreground,accent,primaryForeground}});return {theme,layout:config.layout??DEFAULT_STOREFRONT_LAYOUT,fonts,derived,cssVariables:derived.vars}}var OVERRIDE_TOKENS={background:"bg",foreground:"ink",accent:"accentText",primaryForeground:"onPrimary"};var OVERRIDES=Object.keys(OVERRIDE_TOKENS);function legacyButtonLabel(primary,t){if(contrastRatio(t.onPrimary,primary)>=AA)return t.onPrimary;const reads=[t.onDark,t.ink,t.dark,t.bg].filter(hex=>contrastRatio(hex,primary)>=AA);return (reads.length?reads:["#FFFFFF","#000000"]).reduce((best,hex)=>contrastRatio(hex,primary)>contrastRatio(best,primary)?hex:best)}function explicitThemeChoices(config){const theme=config.theme??DEFAULT_STOREFRONT_THEME;const given=pickOverrides(config.colors);const colors={...config.colors};for(const field of OVERRIDES){const value=given[field];if(!value)continue;const others={...given};delete others[field];const{tokens}=deriveStorefrontTheme(theme,config.colors.primary,{overrides:others});const derived=field==="primaryForeground"?[tokens.onPrimary,legacyButtonLabel(config.colors.primary,tokens)]:[tokens[OVERRIDE_TOKENS[field]]];if(derived.includes(value.toUpperCase()))delete colors[field];}const pair=STOREFRONT_THEME_RECIPES[theme].fonts;const fonts={...config.fonts?.heading&&config.fonts.heading!==pair.heading?{heading:config.fonts.heading}:{},...config.fonts?.body&&config.fonts.body!==pair.body?{body:config.fonts.body}:{}};const{fonts:_fonts,...rest}=config;return {...rest,colors,...fonts.heading||fonts.body?{fonts}:{}}}function pickOverrides(colors){const{background,foreground,accent,primaryForeground}=colors;return Object.fromEntries(Object.entries({background,foreground,accent,primaryForeground}).filter(([,v])=>!!v))}function defineSuiteOpConfig(config){return storefrontSiteConfigSchema.parse(config)}
7
7
 
8
8
  Object.defineProperty(exports, "STOREFRONT_FONT_FAMILIES", {
9
9
  enumerable: true,
10
10
  get: function () { return chunkZLAOY6IF_cjs.STOREFRONT_FONT_FAMILIES; }
11
11
  });
12
+ exports.DEFAULT_STOREFRONT_LAYOUT = DEFAULT_STOREFRONT_LAYOUT;
13
+ exports.DEFAULT_STOREFRONT_THEME = DEFAULT_STOREFRONT_THEME;
14
+ exports.STOREFRONT_LAYOUTS = STOREFRONT_LAYOUTS;
12
15
  exports.STOREFRONT_LOCALES = STOREFRONT_LOCALES;
16
+ exports.STOREFRONT_THEMES = STOREFRONT_THEMES;
17
+ exports.STOREFRONT_THEME_RECIPES = STOREFRONT_THEME_RECIPES;
13
18
  exports.defineSuiteOpConfig = defineSuiteOpConfig;
19
+ exports.deriveStorefrontTheme = deriveStorefrontTheme;
20
+ exports.resolveStorefrontTheme = resolveStorefrontTheme;
14
21
  exports.storefrontSiteConfigSchema = storefrontSiteConfigSchema;
package/dist/config.d.cts CHANGED
@@ -6,21 +6,41 @@ declare const STOREFRONT_FONT_FAMILIES: Record<StorefrontFont, string>;
6
6
 
7
7
  declare const STOREFRONT_LOCALES: readonly ["en", "fr", "es", "de", "it", "pt", "nl"];
8
8
  type StorefrontLocale = (typeof STOREFRONT_LOCALES)[number];
9
+ declare const STOREFRONT_LAYOUTS: readonly ["listings", "locations", "areas", "single"];
10
+ type StorefrontLayout = (typeof STOREFRONT_LAYOUTS)[number];
11
+ declare const STOREFRONT_THEMES: readonly ["folio", "hearth", "circuit", "tide", "noir", "fjord"];
12
+ type StorefrontTheme = (typeof STOREFRONT_THEMES)[number];
9
13
  declare const storefrontSiteConfigSchema: z.ZodObject<{
14
+ layout: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
15
+ areas: "areas";
16
+ listings: "listings";
17
+ locations: "locations";
18
+ single: "single";
19
+ }>>>;
20
+ theme: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
21
+ folio: "folio";
22
+ hearth: "hearth";
23
+ circuit: "circuit";
24
+ tide: "tide";
25
+ noir: "noir";
26
+ fjord: "fjord";
27
+ }>>>;
10
28
  brand: z.ZodObject<{
11
29
  name: z.ZodString;
12
30
  logoUrl: z.ZodNullable<z.ZodURL>;
31
+ logoOnDarkUrl: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
13
32
  faviconUrl: z.ZodNullable<z.ZodURL>;
14
33
  }, z.core.$strip>;
15
34
  colors: z.ZodObject<{
16
35
  primary: z.ZodString;
17
- primaryForeground: z.ZodString;
18
- background: z.ZodString;
19
- foreground: z.ZodString;
20
- accent: z.ZodString;
36
+ secondary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ primaryForeground: z.ZodOptional<z.ZodString>;
38
+ background: z.ZodOptional<z.ZodString>;
39
+ foreground: z.ZodOptional<z.ZodString>;
40
+ accent: z.ZodOptional<z.ZodString>;
21
41
  }, z.core.$strip>;
22
- fonts: z.ZodObject<{
23
- heading: z.ZodEnum<{
42
+ fonts: z.ZodOptional<z.ZodObject<{
43
+ heading: z.ZodOptional<z.ZodEnum<{
24
44
  inter: "inter";
25
45
  montserrat: "montserrat";
26
46
  poppins: "poppins";
@@ -58,8 +78,8 @@ declare const storefrontSiteConfigSchema: z.ZodObject<{
58
78
  ibm_plex_sans: "ibm_plex_sans";
59
79
  libre_franklin: "libre_franklin";
60
80
  josefin_sans: "josefin_sans";
61
- }>;
62
- body: z.ZodEnum<{
81
+ }>>;
82
+ body: z.ZodOptional<z.ZodEnum<{
63
83
  inter: "inter";
64
84
  montserrat: "montserrat";
65
85
  poppins: "poppins";
@@ -97,8 +117,8 @@ declare const storefrontSiteConfigSchema: z.ZodObject<{
97
117
  ibm_plex_sans: "ibm_plex_sans";
98
118
  libre_franklin: "libre_franklin";
99
119
  josefin_sans: "josefin_sans";
100
- }>;
101
- }, z.core.$strip>;
120
+ }>>;
121
+ }, z.core.$strip>>;
102
122
  nav: z.ZodArray<z.ZodObject<{
103
123
  label: z.ZodRecord<z.ZodEnum<{
104
124
  en: "en";
@@ -168,6 +188,143 @@ declare const storefrontSiteConfigSchema: z.ZodObject<{
168
188
  }, z.core.$strip>;
169
189
  type StorefrontSiteConfig = z.infer<typeof storefrontSiteConfigSchema>;
170
190
 
191
+ declare const DEFAULT_STOREFRONT_LAYOUT: StorefrontLayout;
192
+ declare const DEFAULT_STOREFRONT_THEME: StorefrontTheme;
193
+ type TypeStep = readonly [number, number, number, string, ('uppercase' | 'none')?];
194
+ type TypeScale = Record<'display' | 'h1' | 'h2' | 'h3' | 'body' | 'small' | 'label', TypeStep>;
195
+ interface StorefrontThemeRecipe {
196
+ mode: 'light' | 'dark';
197
+ fonts: {
198
+ heading: StorefrontFont;
199
+ body: StorefrontFont;
200
+ };
201
+ radius: {
202
+ sm: number;
203
+ md: number;
204
+ lg: number;
205
+ btn: number;
206
+ };
207
+ btn: {
208
+ size: number;
209
+ w: number;
210
+ ls: string;
211
+ tt: 'uppercase' | 'none';
212
+ h: number;
213
+ };
214
+ type: TypeScale;
215
+ space: {
216
+ section: number;
217
+ gutter: number;
218
+ };
219
+ neutral: {
220
+ hue: number | null;
221
+ mix: number;
222
+ c: number;
223
+ };
224
+ L: {
225
+ bg: number;
226
+ surface: number;
227
+ surface2: number;
228
+ tint: number;
229
+ border: number;
230
+ ink: number;
231
+ muted: number;
232
+ dark: number;
233
+ };
234
+ C: {
235
+ ink: number;
236
+ dark: number;
237
+ tint: number;
238
+ };
239
+ shadow: boolean;
240
+ }
241
+ declare const STOREFRONT_THEME_RECIPES: Readonly<Record<StorefrontTheme, StorefrontThemeRecipe>>;
242
+ interface StorefrontThemeTokens {
243
+ bg: string;
244
+ surface: string;
245
+ surface2: string;
246
+ tint: string;
247
+ border: string;
248
+ borderStrong: string;
249
+ ink: string;
250
+ muted: string;
251
+ primary: string;
252
+ onPrimary: string;
253
+ primaryHover: string;
254
+ accentText: string;
255
+ dark: string;
256
+ onDark: string;
257
+ onDarkMuted: string;
258
+ darkAccent: string;
259
+ focus: string;
260
+ phBg: string;
261
+ phText: string;
262
+ accent2?: string;
263
+ }
264
+ interface StorefrontColorOverrides {
265
+ background?: string;
266
+ foreground?: string;
267
+ accent?: string;
268
+ primaryForeground?: string;
269
+ }
270
+ type StorefrontColorOverride = keyof StorefrontColorOverrides;
271
+ type StorefrontThemeNote = {
272
+ code: 'light_brand_ink_label';
273
+ text: string;
274
+ } | {
275
+ code: 'button_darkened';
276
+ from: number;
277
+ to: number;
278
+ text: string;
279
+ } | {
280
+ code: 'brand_lifted';
281
+ from: number;
282
+ to: number;
283
+ text: string;
284
+ } | {
285
+ code: 'brand_text_darkened';
286
+ steps: number;
287
+ text: string;
288
+ };
289
+ interface StorefrontOverrideProblem {
290
+ field: StorefrontColorOverride;
291
+ ratio: number;
292
+ against: 'background' | 'text' | 'button';
293
+ }
294
+ interface StorefrontThemeCheck {
295
+ label: 'Body text' | 'Muted text' | 'Button label' | 'Brand text' | 'On dark section' | 'Brand on dark';
296
+ ratio: string;
297
+ grade: 'AAA' | 'AA' | 'Fail';
298
+ pass: boolean;
299
+ }
300
+ interface DerivedStorefrontTheme {
301
+ theme: StorefrontTheme;
302
+ tokens: StorefrontThemeTokens;
303
+ vars: Record<string, string>;
304
+ checks: StorefrontThemeCheck[];
305
+ notes: StorefrontThemeNote[];
306
+ problems: StorefrontOverrideProblem[];
307
+ }
308
+ interface DeriveThemeOptions {
309
+ secondary?: string | null;
310
+ heading?: StorefrontFont;
311
+ body?: StorefrontFont;
312
+ overrides?: StorefrontColorOverrides;
313
+ }
314
+ declare function deriveStorefrontTheme(theme: StorefrontTheme, brandHex: string, opts?: DeriveThemeOptions): DerivedStorefrontTheme;
315
+ interface ResolvedStorefrontTheme {
316
+ theme: StorefrontTheme;
317
+ layout: StorefrontLayout;
318
+ fonts: {
319
+ heading: StorefrontFont;
320
+ body: StorefrontFont;
321
+ };
322
+ derived: DerivedStorefrontTheme;
323
+ cssVariables: Record<string, string>;
324
+ }
325
+ type ThemeConfig = Pick<StorefrontSiteConfig, 'colors'> & Partial<Pick<StorefrontSiteConfig, 'theme' | 'layout' | 'fonts'>>;
326
+ declare function resolveStorefrontTheme(config: ThemeConfig): ResolvedStorefrontTheme;
327
+
171
328
  declare function defineSuiteOpConfig(config: StorefrontSiteConfig): StorefrontSiteConfig;
172
329
 
173
- export { STOREFRONT_FONT_FAMILIES, STOREFRONT_LOCALES, type StorefrontLocale, type StorefrontSiteConfig, defineSuiteOpConfig, storefrontSiteConfigSchema };
330
+ export { DEFAULT_STOREFRONT_LAYOUT, DEFAULT_STOREFRONT_THEME, type DerivedStorefrontTheme, type ResolvedStorefrontTheme, STOREFRONT_FONT_FAMILIES, STOREFRONT_LAYOUTS, STOREFRONT_LOCALES, STOREFRONT_THEMES, STOREFRONT_THEME_RECIPES, type StorefrontLayout, type StorefrontLocale, type StorefrontSiteConfig, type StorefrontTheme, type StorefrontThemeRecipe, defineSuiteOpConfig, deriveStorefrontTheme, resolveStorefrontTheme, storefrontSiteConfigSchema };