@lockerverse/react 0.2.234 → 0.2.236

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 (48) hide show
  1. package/MIGRATIONS.md +13 -0
  2. package/dist/accent-contrast.js +1 -1
  3. package/dist/accent-contrast.js.map +1 -1
  4. package/dist/auction-catalog.css +6 -11
  5. package/dist/auction-item-layout.css +1 -1
  6. package/dist/auction-item.d.ts.map +1 -1
  7. package/dist/auction-item.js +1 -1
  8. package/dist/auction-item.js.map +1 -1
  9. package/dist/auction-presentation.d.ts +26 -0
  10. package/dist/auction-presentation.d.ts.map +1 -0
  11. package/dist/auction-presentation.js +2 -0
  12. package/dist/auction-presentation.js.map +1 -0
  13. package/dist/auction-result.d.ts.map +1 -1
  14. package/dist/auction-result2.js +1 -1
  15. package/dist/auction-result2.js.map +1 -1
  16. package/dist/auction.d.ts +2 -1
  17. package/dist/auction.js +1 -1
  18. package/dist/auctions.d.ts.map +1 -1
  19. package/dist/auctions.js +1 -1
  20. package/dist/auctions.js.map +1 -1
  21. package/dist/embed/chunks/{auction-payment-view-ERY7SC6C.js → auction-payment-view-JL33XH24.js} +1 -1
  22. package/dist/embed/chunks/{chunk-ZR6TPDWZ.js → chunk-2UVBCEZX.js} +1 -1
  23. package/dist/embed/chunks/chunk-VMSLTUOW.js +2 -0
  24. package/dist/embed/chunks/{chunk-JJVID3KZ.js → chunk-WBSKHNNJ.js} +2 -2
  25. package/dist/embed/chunks/lockerverse-auction-item-LIDTFDNY.js +2 -0
  26. package/dist/embed/lockerverse.js +2 -2
  27. package/dist/embed/runtime.js +6 -6
  28. package/dist/lockerverse-auction-item-card.d.ts.map +1 -1
  29. package/dist/lockerverse-auction.js +1 -1
  30. package/dist/lockerverse-auction.js.map +1 -1
  31. package/dist/lockerverse-donate-launcher.js +1 -1
  32. package/dist/lockerverse-payment.js +1 -1
  33. package/dist/lockerverse-payment.js.map +1 -1
  34. package/dist/public-events.js +1 -1
  35. package/dist/signup.js +1 -1
  36. package/guides/auctions.md +25 -1
  37. package/guides/bookings.md +1 -1
  38. package/guides/browser-embed.md +9 -4
  39. package/guides/events.md +1 -1
  40. package/guides/integration.md +1 -1
  41. package/guides/payment-widgets.md +1 -1
  42. package/guides/signup.md +1 -1
  43. package/package.json +8 -2
  44. package/dist/embed/chunks/chunk-ZD64W5CW.js +0 -2
  45. package/dist/embed/chunks/lockerverse-auction-item-ETY2D2I2.js +0 -2
  46. /package/dist/embed/chunks/{chunk-ZD64W5CW.js.LEGAL.txt → chunk-VMSLTUOW.js.LEGAL.txt} +0 -0
  47. /package/dist/embed/chunks/{chunk-JJVID3KZ.js.LEGAL.txt → chunk-WBSKHNNJ.js.LEGAL.txt} +0 -0
  48. /package/dist/embed/chunks/{lockerverse-auction-item-ETY2D2I2.js.LEGAL.txt → lockerverse-auction-item-LIDTFDNY.js.LEGAL.txt} +0 -0
@@ -1,2 +1,2 @@
1
- import{t as e}from"./immutable-resource-identity.js";import{t}from"./accent-contrast.js";import{CalendarDays as n,CalendarX2 as r,Check as i,Copy as a,Facebook as o,Forward as s,Mail as c}from"lucide-react";import{useCallback as l,useEffect as u,useId as d,useRef as f,useState as p}from"react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";import{createLockerversePublicEventsClient as _}from"@lockerverse/sdk/public-events";function v(e,t){return new Intl.DateTimeFormat(`en-US`,{day:`numeric`,month:`short`,timeZone:t,year:`numeric`}).format(new Date(e))}function y(e,t){return new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,timeZone:t,timeZoneName:`short`}).format(new Date(e))}function b(e){if(!e)return null;try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`?t.toString():null}catch{return null}}function x(e,t){let n=b(e.link);if(n)return n;let r=new URL(window.location.href);return t?r.searchParams.set(`lockerverseEvents`,`past`):r.searchParams.delete(`lockerverseEvents`),r.searchParams.delete(`lockerverseEventOffset`),r.hash=`event-${e.id}`,r.toString()}function S(e){let n=e?.[`--lockerverse-accent`];if(!n||e?.[`--lockerverse-accent-contrast`]!==void 0)return e;let r=t(n);return r?{...e,"--lockerverse-accent-contrast":r}:e}function C(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t);try{return t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function w({item:e,past:t}){let[n,r]=p(!1),[l,d]=p(null),[m,_]=p(null),[v,y]=p(!1),S=f(null),w=f(null),T=b(e.link),E=e=>e instanceof Node&&S.current?.contains(e);u(()=>{if(!m)return;let e=e=>{E(e.target)||_(null)},t=e=>{e.key===`Escape`&&(_(null),S.current?.contains(document.activeElement)&&w.current?.focus())},n=e=>{E(e.target)||_(null)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),document.addEventListener(`focusin`,n),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t),document.removeEventListener(`focusin`,n)}},[m]),u(()=>{if(!n)return;let e=window.setTimeout(()=>r(!1),2200);return()=>window.clearTimeout(e)},[n]);async function D(){if(m)try{await navigator.clipboard.writeText(m),r(!0),_(null),w.current?.focus()}catch{C(m)?(r(!0),_(null),w.current?.focus()):d(m)}}return g(`div`,{className:`lockerverse-public-events__actions`,ref:S,children:[T?g(`a`,{className:`lockerverse-public-events__link`,href:T,rel:`noopener noreferrer`,target:`_blank`,children:[`View event `,h(`span`,{"aria-hidden":`true`,children:`↗`})]}):null,h(`button`,{"aria-expanded":m!==null,"aria-label":`Share ${e.name}`,className:`lockerverse-public-events__share`,"data-copied":n,onClick:()=>{!m&&w.current&&y(window.innerHeight-w.current.getBoundingClientRect().bottom<72),_(m?null:x(e,t)),r(!1),d(null)},ref:w,title:`Share ${e.name}`,type:`button`,children:n?h(i,{"aria-hidden":`true`,size:22,strokeWidth:2}):h(s,{"aria-hidden":`true`,size:22,strokeWidth:1.9})}),n?h(`span`,{className:`lockerverse-public-events__visually-hidden`,role:`status`,children:`Link copied`}):null,m?g(`fieldset`,{className:`lockerverse-public-events__share-menu`,"data-above":v,children:[g(`legend`,{className:`lockerverse-public-events__visually-hidden`,children:[`Share `,e.name]}),h(`button`,{"aria-label":`Copy event link`,onClick:D,title:`Copy link`,type:`button`,children:h(a,{"aria-hidden":`true`,size:18})}),h(`a`,{"aria-label":`Share by email`,href:`mailto:?subject=${encodeURIComponent(e.name)}&body=${encodeURIComponent(m)}`,title:`Email`,children:h(c,{"aria-hidden":`true`,size:18})}),h(`a`,{"aria-label":`Share on Facebook`,href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(m)}`,rel:`noopener noreferrer`,target:`_blank`,title:`Facebook`,children:h(o,{"aria-hidden":`true`,size:18})}),h(`a`,{"aria-label":`Share on X`,href:`https://twitter.com/intent/tweet?url=${encodeURIComponent(m)}&text=${encodeURIComponent(e.name)}`,rel:`noopener noreferrer`,target:`_blank`,title:`X`,children:h(`span`,{children:`𝕏`})}),l?g(`label`,{className:`lockerverse-public-events__copy-link`,children:[`Select and copy this event link`,h(`input`,{autoFocus:!0,onFocus:e=>e.currentTarget.select(),readOnly:!0,value:l})]}):null]}):null]})}function T({item:e,timeZone:t,active:n,past:r=!1}){let[i,a]=p(!1),o=new Date(e.startAt),s=new Intl.DateTimeFormat(`en-US`,{month:`short`,timeZone:t}).format(o),c=new Intl.DateTimeFormat(`en-US`,{day:`numeric`,timeZone:t}).format(o),l=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`}).format(o),u=v(e.startAt,t),d=u===v(e.endAt,t)?y(e.endAt,t):`${v(e.endAt,t)} at ${y(e.endAt,t)}`,f=b(e.imageUrl),_=(e.description?.length??0)>130;return h(`li`,{className:`lockerverse-public-events__item`,id:`event-${e.id}`,children:g(`article`,{className:`lockerverse-public-events__row`,children:[f?h(`img`,{alt:``,className:`lockerverse-public-events__image`,height:124,loading:`lazy`,src:f,width:154}):g(`time`,{className:`lockerverse-public-events__date`,dateTime:e.startAt,children:[h(`span`,{className:`lockerverse-public-events__month`,children:s}),h(`span`,{className:`lockerverse-public-events__day`,children:c}),h(`span`,{className:`lockerverse-public-events__year`,children:l})]}),g(`div`,{className:`lockerverse-public-events__content`,children:[g(`div`,{className:`lockerverse-public-events__heading`,children:[h(`h3`,{children:e.name}),n?h(`span`,{className:`lockerverse-public-events__live`,children:`Live now`}):null]}),g(`p`,{className:`lockerverse-public-events__schedule`,children:[f?g(m,{children:[h(`time`,{dateTime:e.startAt,children:u}),h(`span`,{"aria-hidden":`true`,children:` · `})]}):null,h(`time`,{dateTime:e.startAt,children:y(e.startAt,t)}),h(`span`,{"aria-hidden":`true`,children:` — `}),h(`time`,{dateTime:e.endAt,children:d})]}),e.location?h(`p`,{className:`lockerverse-public-events__place`,children:e.location}):null,e.description?g(m,{children:[h(`p`,{className:[`lockerverse-public-events__description`,_&&!i?`lockerverse-public-events__description--clamped`:``].filter(Boolean).join(` `),children:e.description}),_?h(`button`,{"aria-expanded":i,className:`lockerverse-public-events__more`,onClick:()=>a(!i),type:`button`,children:i?`Show less`:`Read more`}):null]}):null]}),h(w,{item:e,past:r})]})})}function E({items:e,now:t,timeZone:n,past:r=!1}){return h(`ol`,{className:`lockerverse-public-events__list`,children:e.map(e=>h(T,{active:!r&&new Date(e.startAt).getTime()<=t&&new Date(e.endAt).getTime()>t,item:e,past:r,timeZone:n},e.id))})}function D({disabled:e,label:t,onClick:n}){return h(`button`,{className:`lockerverse-public-events__load-more`,disabled:e,onClick:n,type:`button`,children:e?`Loading…`:t})}function O({events:e,view:t,tabId:n,sort:r,now:i,emptyMessage:a,timeZone:o}){let s=e.events??[],c=s.filter(e=>new Date(e.startAt).getTime()<=i&&new Date(e.endAt).getTime()>i),l=s.filter(e=>new Date(e.startAt).getTime()>i),u=s.filter(e=>new Date(e.endAt).getTime()>i),d=r?u.length===0:c.length===0&&l.length===0;return g(`section`,{"aria-labelledby":`${n}-current-tab`,hidden:t!==`current`,id:`${n}-current-panel`,children:[e.loading&&!e.events?h(`p`,{role:`status`,children:`Loading events…`}):null,e.error?g(`div`,{role:`alert`,children:[h(`p`,{children:e.error.message}),h(`button`,{onClick:e.refresh,type:`button`,children:`Try again`})]}):null,e.events&&d?h(`p`,{className:`lockerverse-public-events__empty`,children:a}):null,r&&u.length>0?h(E,{items:u,now:i,timeZone:o}):null,!r&&c.length>0?h(`div`,{className:`lockerverse-public-events__group`,children:h(E,{items:c,now:i,timeZone:o})}):null,!r&&l.length>0?h(`div`,{className:`lockerverse-public-events__group`,children:h(E,{items:l,now:i,timeZone:o})}):null,e.hasMore?h(D,{disabled:e.loadingMore,label:`Load more events`,onClick:e.loadMore}):null]})}function k({events:e,title:t,now:n,emptyMessage:r,timeZone:i}){return g(`section`,{"aria-label":t,children:[e.loading&&!e.events?h(`p`,{role:`status`,children:`Loading events…`}):null,e.error?g(`div`,{role:`alert`,children:[h(`p`,{children:e.error.message}),h(`button`,{onClick:e.refresh,type:`button`,children:`Try again`})]}):null,e.events&&e.events.length===0?h(`p`,{className:`lockerverse-public-events__empty`,children:r}):null,e.events&&e.events.length>0?h(E,{items:e.events,now:n,timeZone:i}):null,e.hasMore?h(D,{disabled:e.loadingMore,label:`Load more events`,onClick:e.loadMore}):null]})}function A({tabId:e,view:t,pastEvents:n,pastLoaded:r,pastLoading:i,pastError:a,pastHasMore:o,pastOffset:s,loadPast:c,now:l,timeZone:u}){return g(`section`,{"aria-labelledby":`${e}-past-tab`,hidden:t!==`past`,id:`${e}-past-panel`,children:[a?g(`div`,{role:`alert`,children:[h(`p`,{children:a}),h(`button`,{onClick:()=>c(r?s:0,!r),type:`button`,children:`Try again`})]}):null,i&&!r?h(`p`,{role:`status`,children:`Loading past events…`}):null,r&&n.length===0?h(`p`,{className:`lockerverse-public-events__empty`,children:`No past events yet.`}):null,n.length>0?h(E,{items:n,now:l,past:!0,timeZone:u}):null,o?h(D,{disabled:i,label:`Load more past events`,onClick:()=>c(s)}):null]})}function j({events:e,title:t=`Events`,showHeading:i=!0,emptyMessage:a=`No events yet.`,timeZone:o=`America/New_York`,theme:s=`dark`,style:c,className:_}){let[v,y]=p(()=>Date.now()),[b,x]=p(`current`),[C,w]=p([]),[T,E]=p(0),[D,j]=p(!1),[M,N]=p(!1),[P,F]=p(!1),[I,L]=p(null),[R,z]=p(null),B=d(),{showTabs:V,includePast:H,from:U,to:W,sort:G}=e.config,K=!!(U||W||G),q=JSON.stringify([U,W,G,V,H]),J=f(q),[Y,X]=p(!1),Z=f(0),[ee,te]=p(0),Q=f({key:``,pages:0}),$=l(async(t,n=!1)=>{Z.current+=1;let r=Z.current;F(!0),L(null);try{let i=K?await e.client.search({from:U,limit:20,offset:t,sort:G??`endAtDesc`,timeScope:`past`,to:W}):await e.client.listPast({offset:t});if(r!==Z.current)return;w(e=>n?i.events:[...e,...i.events]),E(t+i.events.length),j(i.hasMore),N(!0)}catch(e){if(r!==Z.current)return;L(e instanceof Error?e.message:`Unable to load past events.`)}finally{r===Z.current&&F(!1)}},[e.client,K,U,W,G]);u(()=>{let e=window.setInterval(()=>y(Date.now()),6e4);return()=>window.clearInterval(e)},[]),u(()=>{if(Y||(X(!0),!(V&&H)))return;let e=new URL(window.location.href);e.searchParams.get(`lockerverseEvents`)===`past`&&(x(`past`),z(e.hash.slice(1)),$(0,!0))},[Y,$,V,H]),u(()=>{J.current!==q&&(J.current=q,Z.current+=1,w([]),E(0),j(!1),N(!1),V&&H?b===`past`&&$(0,!0):x(`current`))},[q,V,H,b,$]),u(()=>{let e=()=>te(e=>e+1);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),u(()=>{if(V)return;let t=window.location.hash.slice(1),n=`${q}:${t}`;if(Q.current.key!==n&&(Q.current={key:n,pages:0}),!t.startsWith(`event-`))return;let r=document.getElementById(t);r?r.scrollIntoView({block:`center`}):!(e.loading||e.loadingMore||e.error)&&e.hasMore&&Q.current.pages<5&&(Q.current.pages+=1,e.loadMore())},[e.events,e.error,e.hasMore,e.loading,e.loadingMore,e.loadMore,ee,q,V]),u(()=>{if(!V||b!==`current`)return;let t=window.location.hash.slice(1);if(!t.startsWith(`event-`))return;let n=document.getElementById(t);n?n.scrollIntoView({block:`center`}):!(e.loading||e.loadingMore||e.error)&&e.hasMore&&e.loadMore()},[e.events,e.error,e.hasMore,e.loading,e.loadingMore,e.loadMore,V,b]),u(()=>{if(!V||b!==`past`||!R||P||I||!M)return;let e=document.getElementById(R);e?(e.scrollIntoView({block:`center`}),z(null)):D?$(T):z(null)},[$,I,D,M,P,T,R,V,b]);function ne(){x(`past`),!(M||P)&&$(0,!0)}return h(`section`,{"aria-busy":V&&b===`past`?P:e.loading,"aria-label":t,className:[`lockerverse-public-events`,_].filter(Boolean).join(` `),"data-lockerverse-tabs":V,"data-lockerverse-theme":s,style:S(c),children:g(`div`,{className:`lockerverse-public-events__layout`,children:[i?h(`h2`,{children:t}):null,V?g(`nav`,{"aria-label":`Event views`,className:`lockerverse-public-events__tabs`,children:[g(`button`,{"aria-controls":`${B}-current-panel`,"aria-pressed":b===`current`,className:`lockerverse-public-events__tab`,id:`${B}-current-tab`,onClick:()=>x(`current`),type:`button`,children:[h(n,{"aria-hidden":`true`,size:18}),`Upcoming Events`]}),H?g(`button`,{"aria-controls":`${B}-past-panel`,"aria-pressed":b===`past`,className:`lockerverse-public-events__tab`,id:`${B}-past-tab`,onClick:ne,type:`button`,children:[h(r,{"aria-hidden":`true`,size:18}),`Past Events`]}):null]}):null,V?g(m,{children:[h(O,{emptyMessage:a,events:e,now:v,sort:G,tabId:B,timeZone:o,view:b}),H?h(A,{loadPast:$,now:v,pastError:I,pastEvents:C,pastHasMore:D,pastLoaded:M,pastLoading:P,pastOffset:T,tabId:B,timeZone:o,view:b}):null]}):h(k,{emptyMessage:a,events:e,now:v,timeZone:o,title:t})]})})}function M(t,{initialEvents:n,initialPage:r,config:i}={}){e(`public events`,{apiBaseUrl:t.apiBaseUrl,communitySlug:t.communitySlug,environment:t.environment,slug:``});let a=f(t.onError);a.current=t.onError;let[o]=p(()=>_({...t,onError:e=>a.current?.(e)})),s=i?.showTabs??!0,c=i?.includePast??!0,d=i?.from,m=i?.to,h=i?.sort,g=h??(!s&&c?`startAtDesc`:`startAtAsc`),v=!s||!!(d||m||h),y=!s&&c?`all`:`current`,b=JSON.stringify([s,c,d,m,h]),x=f(b);x.current=b;let S=f(0),C=f(!1),[w,T]=p(0),[E,D]=p(()=>({error:null,events:(v?r?.events:n)??null,hasMore:v&&r?r.hasMore:!1,loading:!0,loadingMore:!1}));u(()=>{let e=!0;return S.current+=1,C.current=!1,D(e=>({...e,loading:!0,loadingMore:!1})),(v?o.search({from:d,limit:20,offset:0,sort:g,timeScope:y,to:m}):o.list().then(e=>({events:e,hasMore:!1}))).then(t=>{e&&D({error:null,events:t.events,hasMore:t.hasMore,loading:!1,loadingMore:!1})},t=>{e&&D(e=>({...e,error:t,loading:!1,loadingMore:!1}))}),()=>{e=!1}},[o,d,m,y,g,v,w]);let O=l(()=>{S.current+=1,C.current=!1,D(e=>({...e,error:null,loading:!0})),T(e=>e+1)},[]),k=l(()=>{if(!(v&&E.hasMore)||E.loading||C.current)return;let e=E.events?.length??0,t=S.current;C.current=!0,D(e=>({...e,error:null,loadingMore:!0})),o.search({from:d,limit:20,offset:e,sort:g,timeScope:y,to:m}).then(e=>{x.current===b&&S.current===t&&(C.current=!1,D(t=>({...t,events:[...t.events??[],...e.events],hasMore:e.hasMore,loadingMore:!1})))},e=>{x.current===b&&S.current===t&&(C.current=!1,D(t=>({...t,error:e,loadingMore:!1})))})},[o,d,m,y,g,v,E,b]);return{...E,client:o,config:{from:d,includePast:c,showTabs:s,sort:h,to:m},loadMore:k,refresh:O}}export{j as LockerversePublicEvents,M as useLockerversePublicEvents};
1
+ import{t as e}from"./accent-contrast.js";import{t}from"./immutable-resource-identity.js";import{CalendarDays as n,CalendarX2 as r,Check as i,Copy as a,Facebook as o,Forward as s,Mail as c}from"lucide-react";import{useCallback as l,useEffect as u,useId as d,useRef as f,useState as p}from"react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";import{createLockerversePublicEventsClient as _}from"@lockerverse/sdk/public-events";function v(e,t){return new Intl.DateTimeFormat(`en-US`,{day:`numeric`,month:`short`,timeZone:t,year:`numeric`}).format(new Date(e))}function y(e,t){return new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,timeZone:t,timeZoneName:`short`}).format(new Date(e))}function b(e){if(!e)return null;try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`?t.toString():null}catch{return null}}function x(e,t){let n=b(e.link);if(n)return n;let r=new URL(window.location.href);return t?r.searchParams.set(`lockerverseEvents`,`past`):r.searchParams.delete(`lockerverseEvents`),r.searchParams.delete(`lockerverseEventOffset`),r.hash=`event-${e.id}`,r.toString()}function S(t){let n=t?.[`--lockerverse-accent`];if(!n||t?.[`--lockerverse-accent-contrast`]!==void 0)return t;let r=e(n);return r?{...t,"--lockerverse-accent-contrast":r}:t}function C(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t);try{return t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function w({item:e,past:t}){let[n,r]=p(!1),[l,d]=p(null),[m,_]=p(null),[v,y]=p(!1),S=f(null),w=f(null),T=b(e.link),E=e=>e instanceof Node&&S.current?.contains(e);u(()=>{if(!m)return;let e=e=>{E(e.target)||_(null)},t=e=>{e.key===`Escape`&&(_(null),S.current?.contains(document.activeElement)&&w.current?.focus())},n=e=>{E(e.target)||_(null)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),document.addEventListener(`focusin`,n),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t),document.removeEventListener(`focusin`,n)}},[m]),u(()=>{if(!n)return;let e=window.setTimeout(()=>r(!1),2200);return()=>window.clearTimeout(e)},[n]);async function D(){if(m)try{await navigator.clipboard.writeText(m),r(!0),_(null),w.current?.focus()}catch{C(m)?(r(!0),_(null),w.current?.focus()):d(m)}}return g(`div`,{className:`lockerverse-public-events__actions`,ref:S,children:[T?g(`a`,{className:`lockerverse-public-events__link`,href:T,rel:`noopener noreferrer`,target:`_blank`,children:[`View event `,h(`span`,{"aria-hidden":`true`,children:`↗`})]}):null,h(`button`,{"aria-expanded":m!==null,"aria-label":`Share ${e.name}`,className:`lockerverse-public-events__share`,"data-copied":n,onClick:()=>{!m&&w.current&&y(window.innerHeight-w.current.getBoundingClientRect().bottom<72),_(m?null:x(e,t)),r(!1),d(null)},ref:w,title:`Share ${e.name}`,type:`button`,children:n?h(i,{"aria-hidden":`true`,size:22,strokeWidth:2}):h(s,{"aria-hidden":`true`,size:22,strokeWidth:1.9})}),n?h(`span`,{className:`lockerverse-public-events__visually-hidden`,role:`status`,children:`Link copied`}):null,m?g(`fieldset`,{className:`lockerverse-public-events__share-menu`,"data-above":v,children:[g(`legend`,{className:`lockerverse-public-events__visually-hidden`,children:[`Share `,e.name]}),h(`button`,{"aria-label":`Copy event link`,onClick:D,title:`Copy link`,type:`button`,children:h(a,{"aria-hidden":`true`,size:18})}),h(`a`,{"aria-label":`Share by email`,href:`mailto:?subject=${encodeURIComponent(e.name)}&body=${encodeURIComponent(m)}`,title:`Email`,children:h(c,{"aria-hidden":`true`,size:18})}),h(`a`,{"aria-label":`Share on Facebook`,href:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(m)}`,rel:`noopener noreferrer`,target:`_blank`,title:`Facebook`,children:h(o,{"aria-hidden":`true`,size:18})}),h(`a`,{"aria-label":`Share on X`,href:`https://twitter.com/intent/tweet?url=${encodeURIComponent(m)}&text=${encodeURIComponent(e.name)}`,rel:`noopener noreferrer`,target:`_blank`,title:`X`,children:h(`span`,{children:`𝕏`})}),l?g(`label`,{className:`lockerverse-public-events__copy-link`,children:[`Select and copy this event link`,h(`input`,{autoFocus:!0,onFocus:e=>e.currentTarget.select(),readOnly:!0,value:l})]}):null]}):null]})}function T({item:e,timeZone:t,active:n,past:r=!1}){let[i,a]=p(!1),o=new Date(e.startAt),s=new Intl.DateTimeFormat(`en-US`,{month:`short`,timeZone:t}).format(o),c=new Intl.DateTimeFormat(`en-US`,{day:`numeric`,timeZone:t}).format(o),l=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`}).format(o),u=v(e.startAt,t),d=u===v(e.endAt,t)?y(e.endAt,t):`${v(e.endAt,t)} at ${y(e.endAt,t)}`,f=b(e.imageUrl),_=(e.description?.length??0)>130;return h(`li`,{className:`lockerverse-public-events__item`,id:`event-${e.id}`,children:g(`article`,{className:`lockerverse-public-events__row`,children:[f?h(`img`,{alt:``,className:`lockerverse-public-events__image`,height:124,loading:`lazy`,src:f,width:154}):g(`time`,{className:`lockerverse-public-events__date`,dateTime:e.startAt,children:[h(`span`,{className:`lockerverse-public-events__month`,children:s}),h(`span`,{className:`lockerverse-public-events__day`,children:c}),h(`span`,{className:`lockerverse-public-events__year`,children:l})]}),g(`div`,{className:`lockerverse-public-events__content`,children:[g(`div`,{className:`lockerverse-public-events__heading`,children:[h(`h3`,{children:e.name}),n?h(`span`,{className:`lockerverse-public-events__live`,children:`Live now`}):null]}),g(`p`,{className:`lockerverse-public-events__schedule`,children:[f?g(m,{children:[h(`time`,{dateTime:e.startAt,children:u}),h(`span`,{"aria-hidden":`true`,children:` · `})]}):null,h(`time`,{dateTime:e.startAt,children:y(e.startAt,t)}),h(`span`,{"aria-hidden":`true`,children:` — `}),h(`time`,{dateTime:e.endAt,children:d})]}),e.location?h(`p`,{className:`lockerverse-public-events__place`,children:e.location}):null,e.description?g(m,{children:[h(`p`,{className:[`lockerverse-public-events__description`,_&&!i?`lockerverse-public-events__description--clamped`:``].filter(Boolean).join(` `),children:e.description}),_?h(`button`,{"aria-expanded":i,className:`lockerverse-public-events__more`,onClick:()=>a(!i),type:`button`,children:i?`Show less`:`Read more`}):null]}):null]}),h(w,{item:e,past:r})]})})}function E({items:e,now:t,timeZone:n,past:r=!1}){return h(`ol`,{className:`lockerverse-public-events__list`,children:e.map(e=>h(T,{active:!r&&new Date(e.startAt).getTime()<=t&&new Date(e.endAt).getTime()>t,item:e,past:r,timeZone:n},e.id))})}function D({disabled:e,label:t,onClick:n}){return h(`button`,{className:`lockerverse-public-events__load-more`,disabled:e,onClick:n,type:`button`,children:e?`Loading…`:t})}function O({events:e,view:t,tabId:n,sort:r,now:i,emptyMessage:a,timeZone:o}){let s=e.events??[],c=s.filter(e=>new Date(e.startAt).getTime()<=i&&new Date(e.endAt).getTime()>i),l=s.filter(e=>new Date(e.startAt).getTime()>i),u=s.filter(e=>new Date(e.endAt).getTime()>i),d=r?u.length===0:c.length===0&&l.length===0;return g(`section`,{"aria-labelledby":`${n}-current-tab`,hidden:t!==`current`,id:`${n}-current-panel`,children:[e.loading&&!e.events?h(`p`,{role:`status`,children:`Loading events…`}):null,e.error?g(`div`,{role:`alert`,children:[h(`p`,{children:e.error.message}),h(`button`,{onClick:e.refresh,type:`button`,children:`Try again`})]}):null,e.events&&d?h(`p`,{className:`lockerverse-public-events__empty`,children:a}):null,r&&u.length>0?h(E,{items:u,now:i,timeZone:o}):null,!r&&c.length>0?h(`div`,{className:`lockerverse-public-events__group`,children:h(E,{items:c,now:i,timeZone:o})}):null,!r&&l.length>0?h(`div`,{className:`lockerverse-public-events__group`,children:h(E,{items:l,now:i,timeZone:o})}):null,e.hasMore?h(D,{disabled:e.loadingMore,label:`Load more events`,onClick:e.loadMore}):null]})}function k({events:e,title:t,now:n,emptyMessage:r,timeZone:i}){return g(`section`,{"aria-label":t,children:[e.loading&&!e.events?h(`p`,{role:`status`,children:`Loading events…`}):null,e.error?g(`div`,{role:`alert`,children:[h(`p`,{children:e.error.message}),h(`button`,{onClick:e.refresh,type:`button`,children:`Try again`})]}):null,e.events&&e.events.length===0?h(`p`,{className:`lockerverse-public-events__empty`,children:r}):null,e.events&&e.events.length>0?h(E,{items:e.events,now:n,timeZone:i}):null,e.hasMore?h(D,{disabled:e.loadingMore,label:`Load more events`,onClick:e.loadMore}):null]})}function A({tabId:e,view:t,pastEvents:n,pastLoaded:r,pastLoading:i,pastError:a,pastHasMore:o,pastOffset:s,loadPast:c,now:l,timeZone:u}){return g(`section`,{"aria-labelledby":`${e}-past-tab`,hidden:t!==`past`,id:`${e}-past-panel`,children:[a?g(`div`,{role:`alert`,children:[h(`p`,{children:a}),h(`button`,{onClick:()=>c(r?s:0,!r),type:`button`,children:`Try again`})]}):null,i&&!r?h(`p`,{role:`status`,children:`Loading past events…`}):null,r&&n.length===0?h(`p`,{className:`lockerverse-public-events__empty`,children:`No past events yet.`}):null,n.length>0?h(E,{items:n,now:l,past:!0,timeZone:u}):null,o?h(D,{disabled:i,label:`Load more past events`,onClick:()=>c(s)}):null]})}function j({events:e,title:t=`Events`,showHeading:i=!0,emptyMessage:a=`No events yet.`,timeZone:o=`America/New_York`,theme:s=`dark`,style:c,className:_}){let[v,y]=p(()=>Date.now()),[b,x]=p(`current`),[C,w]=p([]),[T,E]=p(0),[D,j]=p(!1),[M,N]=p(!1),[P,F]=p(!1),[I,L]=p(null),[R,z]=p(null),B=d(),{showTabs:V,includePast:H,from:U,to:W,sort:G}=e.config,K=!!(U||W||G),q=JSON.stringify([U,W,G,V,H]),J=f(q),[Y,X]=p(!1),Z=f(0),[ee,te]=p(0),Q=f({key:``,pages:0}),$=l(async(t,n=!1)=>{Z.current+=1;let r=Z.current;F(!0),L(null);try{let i=K?await e.client.search({from:U,limit:20,offset:t,sort:G??`endAtDesc`,timeScope:`past`,to:W}):await e.client.listPast({offset:t});if(r!==Z.current)return;w(e=>n?i.events:[...e,...i.events]),E(t+i.events.length),j(i.hasMore),N(!0)}catch(e){if(r!==Z.current)return;L(e instanceof Error?e.message:`Unable to load past events.`)}finally{r===Z.current&&F(!1)}},[e.client,K,U,W,G]);u(()=>{let e=window.setInterval(()=>y(Date.now()),6e4);return()=>window.clearInterval(e)},[]),u(()=>{if(Y||(X(!0),!(V&&H)))return;let e=new URL(window.location.href);e.searchParams.get(`lockerverseEvents`)===`past`&&(x(`past`),z(e.hash.slice(1)),$(0,!0))},[Y,$,V,H]),u(()=>{J.current!==q&&(J.current=q,Z.current+=1,w([]),E(0),j(!1),N(!1),V&&H?b===`past`&&$(0,!0):x(`current`))},[q,V,H,b,$]),u(()=>{let e=()=>te(e=>e+1);return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),u(()=>{if(V)return;let t=window.location.hash.slice(1),n=`${q}:${t}`;if(Q.current.key!==n&&(Q.current={key:n,pages:0}),!t.startsWith(`event-`))return;let r=document.getElementById(t);r?r.scrollIntoView({block:`center`}):!(e.loading||e.loadingMore||e.error)&&e.hasMore&&Q.current.pages<5&&(Q.current.pages+=1,e.loadMore())},[e.events,e.error,e.hasMore,e.loading,e.loadingMore,e.loadMore,ee,q,V]),u(()=>{if(!V||b!==`current`)return;let t=window.location.hash.slice(1);if(!t.startsWith(`event-`))return;let n=document.getElementById(t);n?n.scrollIntoView({block:`center`}):!(e.loading||e.loadingMore||e.error)&&e.hasMore&&e.loadMore()},[e.events,e.error,e.hasMore,e.loading,e.loadingMore,e.loadMore,V,b]),u(()=>{if(!V||b!==`past`||!R||P||I||!M)return;let e=document.getElementById(R);e?(e.scrollIntoView({block:`center`}),z(null)):D?$(T):z(null)},[$,I,D,M,P,T,R,V,b]);function ne(){x(`past`),!(M||P)&&$(0,!0)}return h(`section`,{"aria-busy":V&&b===`past`?P:e.loading,"aria-label":t,className:[`lockerverse-public-events`,_].filter(Boolean).join(` `),"data-lockerverse-tabs":V,"data-lockerverse-theme":s,style:S(c),children:g(`div`,{className:`lockerverse-public-events__layout`,children:[i?h(`h2`,{children:t}):null,V?g(`nav`,{"aria-label":`Event views`,className:`lockerverse-public-events__tabs`,children:[g(`button`,{"aria-controls":`${B}-current-panel`,"aria-pressed":b===`current`,className:`lockerverse-public-events__tab`,id:`${B}-current-tab`,onClick:()=>x(`current`),type:`button`,children:[h(n,{"aria-hidden":`true`,size:18}),`Upcoming Events`]}),H?g(`button`,{"aria-controls":`${B}-past-panel`,"aria-pressed":b===`past`,className:`lockerverse-public-events__tab`,id:`${B}-past-tab`,onClick:ne,type:`button`,children:[h(r,{"aria-hidden":`true`,size:18}),`Past Events`]}):null]}):null,V?g(m,{children:[h(O,{emptyMessage:a,events:e,now:v,sort:G,tabId:B,timeZone:o,view:b}),H?h(A,{loadPast:$,now:v,pastError:I,pastEvents:C,pastHasMore:D,pastLoaded:M,pastLoading:P,pastOffset:T,tabId:B,timeZone:o,view:b}):null]}):h(k,{emptyMessage:a,events:e,now:v,timeZone:o,title:t})]})})}function M(e,{initialEvents:n,initialPage:r,config:i}={}){t(`public events`,{apiBaseUrl:e.apiBaseUrl,communitySlug:e.communitySlug,environment:e.environment,slug:``});let a=f(e.onError);a.current=e.onError;let[o]=p(()=>_({...e,onError:e=>a.current?.(e)})),s=i?.showTabs??!0,c=i?.includePast??!0,d=i?.from,m=i?.to,h=i?.sort,g=h??(!s&&c?`startAtDesc`:`startAtAsc`),v=!s||!!(d||m||h),y=!s&&c?`all`:`current`,b=JSON.stringify([s,c,d,m,h]),x=f(b);x.current=b;let S=f(0),C=f(!1),[w,T]=p(0),[E,D]=p(()=>({error:null,events:(v?r?.events:n)??null,hasMore:v&&r?r.hasMore:!1,loading:!0,loadingMore:!1}));u(()=>{let e=!0;return S.current+=1,C.current=!1,D(e=>({...e,loading:!0,loadingMore:!1})),(v?o.search({from:d,limit:20,offset:0,sort:g,timeScope:y,to:m}):o.list().then(e=>({events:e,hasMore:!1}))).then(t=>{e&&D({error:null,events:t.events,hasMore:t.hasMore,loading:!1,loadingMore:!1})},t=>{e&&D(e=>({...e,error:t,loading:!1,loadingMore:!1}))}),()=>{e=!1}},[o,d,m,y,g,v,w]);let O=l(()=>{S.current+=1,C.current=!1,D(e=>({...e,error:null,loading:!0})),T(e=>e+1)},[]),k=l(()=>{if(!(v&&E.hasMore)||E.loading||C.current)return;let e=E.events?.length??0,t=S.current;C.current=!0,D(e=>({...e,error:null,loadingMore:!0})),o.search({from:d,limit:20,offset:e,sort:g,timeScope:y,to:m}).then(e=>{x.current===b&&S.current===t&&(C.current=!1,D(t=>({...t,events:[...t.events??[],...e.events],hasMore:e.hasMore,loadingMore:!1})))},e=>{x.current===b&&S.current===t&&(C.current=!1,D(t=>({...t,error:e,loadingMore:!1})))})},[o,d,m,y,g,v,E,b]);return{...E,client:o,config:{from:d,includePast:c,showTabs:s,sort:h,to:m},loadMore:k,refresh:O}}export{j as LockerversePublicEvents,M as useLockerversePublicEvents};
2
2
  //# sourceMappingURL=public-events.js.map
package/dist/signup.js CHANGED
@@ -1,2 +1,2 @@
1
- import{t as e}from"./immutable-resource-identity.js";import{c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,s as l,t as u}from"./phone-field.js";import{t as d}from"./host-callback.js";import{n as f,t as p}from"./accent-contrast.js";import{i as m,n as h,o as g,r as _,s as v}from"./custom-fields.js";import{t as y}from"./form-skeleton.js";import{useCallback as b,useEffect as x,useId as S,useRef as C,useState as w}from"react";import{jsx as T,jsxs as E}from"react/jsx-runtime";import{check as D,nonEmpty as O,nullable as k,object as A,pipe as j,regex as M,safeParse as N,string as P,transform as F,trim as I}from"valibot";import{createLockerverseSignupClient as L}from"@lockerverse/sdk/signup";const R=`lockerverse-signup-google-places`,z=[`premise`,`subpremise`,`street_address`,`route`];let B=null;function ee(e){let t=window;if(t.google?.maps?.importLibrary)return;t.google||={};let n=t.google;n.maps||={};let r=n.maps,i=null;r.importLibrary=n=>(i||=new Promise((t,i)=>{let a=document.getElementById(R);if(r.__lockerverseSignupReady=t,a){a.addEventListener(`error`,()=>i(Error(`Unable to load Google Places.`)),{once:!0});return}let o=document.createElement(`script`),s=new URLSearchParams({callback:`google.maps.__lockerverseSignupReady`,key:e,libraries:n,v:`weekly`});o.async=!0,o.id=R,o.src=`https://maps.googleapis.com/maps/api/js?${s}`,o.onerror=()=>i(Error(`Unable to load Google Places.`)),document.head.append(o)}),i.then(()=>{let e=t.google?.maps?.importLibrary;if(!e)throw Error(`Unable to load Google Places.`);return e(n)}).catch(e=>{throw i=null,document.getElementById(R)?.remove(),e}))}function V(e){return B||=(async()=>{try{ee(e);let t=window.google?.maps?.importLibrary;if(!t)throw Error(`Unable to load Google Places.`);return await t(`places`)}catch(e){throw B=null,e}})(),B}function H(e,t,n=`longText`){return e.find(e=>e.types.includes(t))?.[n]??``}function te(e,t){let n=t.addressComponents??[],r=[H(n,`street_number`),H(n,`route`)].filter(Boolean).join(` `);return{...e,city:H(n,`locality`)||H(n,`postal_town`)||H(n,`sublocality_level_1`),country:H(n,`country`,`shortText`)||`US`,line1:r||t.formattedAddress?.split(`,`)[0]||``,line2:H(n,`subpremise`),postalCode:[H(n,`postal_code`),H(n,`postal_code_suffix`)].filter(Boolean).join(`-`),state:H(n,`administrative_area_level_1`,`shortText`)}}function ne({apiKey:e,errorId:t,invalid:n,onChange:r,required:i,value:a}){let o=S(),s=`${o}-suggestions`,[c,l]=w(-1),[u,d]=w(!1),[f,p]=w(!1),[m,h]=w([]),g=C(0),_=C(0),v=C(null);x(()=>()=>{g.current+=1},[]),x(()=>{let t=_.current+1;_.current=t;let n=a.line1.trim();if(l(-1),p(!1),!(e&&u&&n.length>=3)){h([]);return}let r=window.setTimeout(async()=>{if(t===_.current){p(!0);try{let{AutocompleteSessionToken:r,AutocompleteSuggestion:i}=await V(e);v.current??=new r;let a=await i.fetchAutocompleteSuggestions({includedPrimaryTypes:z,includedRegionCodes:[`US`],input:n,region:`US`,sessionToken:v.current});t===_.current&&h(a.suggestions.flatMap(({placePrediction:e})=>e?[{id:e.placeId,label:e.mainText?.text??e.text.text,prediction:e,secondaryLabel:e.secondaryText?.text??``}]:[]))}catch{t===_.current&&h([])}finally{t===_.current&&p(!1)}}},250);return()=>{window.clearTimeout(r)}},[e,u,a.line1]);let y=e=>{g.current+=1,r({...a,...e})},b=async e=>{let t=g.current+1;g.current=t;let n=e.prediction.toPlace();try{if(await n.fetchFields({fields:[`addressComponents`,`formattedAddress`]}),t!==g.current)return;r(te(a,n)),v.current=null,h([]),l(-1),d(!1)}catch{if(t!==g.current)return;h([]),l(-1)}},D=e=>{if(e.key===`Escape`){e.preventDefault(),h([]),l(-1);return}if(m.length===0)return;if(e.key===`ArrowDown`){e.preventDefault(),l(e=>e<m.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),l(e=>e>0?e-1:m.length-1);return}let t=m[c];e.key===`Enter`&&t&&(e.preventDefault(),b(t).catch(()=>void 0))},O=e=>{e.currentTarget.closest(`.lockerverse-signup__address-search`)?.contains(e.relatedTarget)||window.setTimeout(()=>d(!1),120)};return E(`fieldset`,{"aria-describedby":n?t:void 0,"aria-invalid":n?`true`:void 0,className:`lockerverse-signup__address`,children:[T(`legend`,{children:`Address`}),E(`label`,{htmlFor:`${o}-line1`,children:[T(`span`,{children:`Street address`}),E(`div`,{className:`lockerverse-signup__address-search`,children:[T(`input`,{"aria-activedescendant":c>=0?`${o}-suggestion-${c}`:void 0,"aria-autocomplete":`list`,"aria-controls":s,"aria-describedby":n?t:void 0,"aria-expanded":u&&m.length>0,"aria-invalid":n?`true`:void 0,autoComplete:`street-address`,id:`${o}-line1`,name:`address.line1`,onBlur:O,onChange:e=>y({line1:e.currentTarget.value}),onFocus:()=>d(!0),onKeyDown:D,required:i,role:`combobox`,value:a.line1}),f?T(`span`,{className:`lockerverse-signup__address-loading`,children:`Searching…`}):null,m.length>0?T(`div`,{className:`lockerverse-signup__address-suggestions`,id:s,role:`listbox`,children:m.map((e,t)=>E(`button`,{"aria-selected":c===t,id:`${o}-suggestion-${t}`,onBlur:O,onClick:t=>{t.detail===0&&b(e).catch(()=>void 0)},onMouseDown:t=>{t.preventDefault(),b(e).catch(()=>void 0)},role:`option`,type:`button`,children:[T(`strong`,{children:e.label}),e.secondaryLabel?T(`span`,{children:e.secondaryLabel}):null]},e.id))}):null]})]}),E(`label`,{htmlFor:`${o}-line2`,children:[T(`span`,{children:`Apartment, suite, or unit`}),T(`input`,{autoComplete:`address-line2`,id:`${o}-line2`,onChange:e=>y({line2:e.currentTarget.value}),placeholder:`Optional`,value:a.line2??``})]}),E(`div`,{className:`lockerverse-signup__address-row`,children:[E(`label`,{htmlFor:`${o}-city`,children:[T(`span`,{children:`City`}),T(`input`,{autoComplete:`address-level2`,id:`${o}-city`,onChange:e=>y({city:e.currentTarget.value}),required:i,value:a.city})]}),E(`label`,{htmlFor:`${o}-state`,children:[T(`span`,{children:`State`}),T(`input`,{autoComplete:`address-level1`,id:`${o}-state`,onChange:e=>y({state:e.currentTarget.value}),required:i,value:a.state})]})]}),E(`div`,{className:`lockerverse-signup__address-row`,children:[E(`label`,{htmlFor:`${o}-postal`,children:[T(`span`,{children:`Postal code`}),T(`input`,{autoComplete:`postal-code`,id:`${o}-postal`,onChange:e=>y({postalCode:e.currentTarget.value}),required:i,value:a.postalCode})]}),E(`label`,{htmlFor:`${o}-country`,children:[T(`span`,{children:`Country`}),T(`input`,{autoComplete:`country`,id:`${o}-country`,maxLength:2,onChange:e=>y({country:e.currentTarget.value.toUpperCase()}),required:i,value:a.country})]})]})]})}const re=/^[1-9]\d*$/,ie=/^(?:$|[1-9]\d*)$/,ae=j(P(),I(),O(`Name is required.`)),U=j(P(),I(),M(ie,`Guest count must be a positive whole number.`),F(e=>e?Number(e):null),D(e=>e===null||Number.isSafeInteger(e),`Guest count must be a positive whole number.`)),W=j(P(),I(),O(`Guest count is required.`),M(re,`Guest count must be a positive whole number.`),F(Number),D(e=>Number.isSafeInteger(e),`Guest count must be a positive whole number.`)),G=A({city:P(),country:P(),line1:P(),line2:k(P()),postalCode:P(),state:P()}),K=j(G,D(Y,`Complete the address.`)),q={city:``,country:`US`,line1:``,line2:null,postalCode:``,state:``},oe=j(G,D(e=>J(e)||Y(e),`Complete the address or leave it blank.`));function J(e){return![e.city,e.line1,e.line2,e.postalCode,e.state].some(e=>e?.trim())}function Y(e){return[e.city,e.country,e.line1,e.postalCode,e.state].every(e=>e.trim())}function se(e,n){let r={...n,address:e.fields.address.enabled?n.address:q,customFields:g(e.customFields,n.customFields),email:e.fields.email.enabled?n.email:``,participantCount:e.fields.participantCount.enabled?n.participantCount:``,phone:e.fields.phone.enabled?n.phone:``},i=A({address:e.fields.address.enabled&&e.fields.address.required?K:oe,email:e.fields.email.enabled&&e.fields.email.required?t:s,name:ae,participantCount:e.fields.participantCount.enabled&&e.fields.participantCount.required?W:U,phone:e.fields.phone.enabled&&e.fields.phone.required?a:l}),o=N(i,r),c=v(e.customFields,r.customFields);if(!o.success)for(let e of o.issues){let t=e.path?.[0]?.key,n=[`address`,`email`,`name`,`participantCount`,`phone`].find(e=>e===t);n&&!c[n]&&(c[n]=e.message)}return o.success?{errors:c,value:{...r,...o.output}}:{errors:c,value:null}}const ce={city:``,country:`US`,line1:``,line2:``,postalCode:``,state:``};function le(e){return{address:ce,customFields:m(e.customFields),email:``,honeypot:``,name:``,participantCount:``,phone:``,phoneCountry:`US`}}function X(e,t){let n=e.elements.namedItem(t);if(n instanceof HTMLElement)return!n.matches(`:disabled`)&&(n.focus(),!0);if(n instanceof RadioNodeList){let e=Array.from(n).find(e=>e instanceof HTMLElement&&!e.matches(`:disabled`));return e?.focus(),!!e}return!1}function Z(e,t){let n=[[`name`,`name`],[`email`,`email`],[`phone`,`phone`],[`participantCount`,`participantCount`],[`address`,`address.line1`]];for(let[r,i]of n)if(t[r]&&X(e,i))return;let r=new Set(n.map(([e])=>e)),i=Object.keys(t).find(e=>!r.has(e));i&&X(e,`custom:${i}`)}function Q({children:e,loading:t=!1,status:n=!1,viewProps:r}){let{branding:i,className:a,googlePlacesApiKey:o,onSignupComplete:s,style:c,theme:l=`dark`,...u}=r,d=f(c?.[`--lockerverse-accent`]??c?.[`--lockerverse-signup-accent`]??i?.accentColor??`#5751f2`),m={...c};if((c?.[`--lockerverse-accent`]!==void 0||c?.[`--lockerverse-signup-accent`]!==void 0||i?.accentColor)&&(m[`--lockerverse-accent`]=d),c?.[`--lockerverse-accent-contrast`]===void 0&&c?.[`--lockerverse-signup-accent-contrast`]===void 0){let e=p(d);e&&(m[`--lockerverse-accent-contrast`]=e)}return T(`section`,{...u,...t?{"aria-busy":!0}:{},className:[`lockerverse-signup`,n?`lockerverse-signup__status`:null,a].filter(Boolean).join(` `),"data-lockerverse-theme":l,style:m,children:e})}function ue({client:e,loadError:t,onRetry:a,signup:s,...l}){let{branding:f,googlePlacesApiKey:p,onSignupComplete:m}=l,v=S(),y=C(!0),b=C(null),D=C(!1),[O,k]=w({phase:`idle`}),[A,j]=w(()=>le(s)),[M,N]=w({}),[P,F]=w(),I=g(s.customFields,A.customFields);if(x(()=>{I!==A.customFields&&j(e=>({...e,customFields:g(s.customFields,e.customFields)}))},[I,s.customFields,A.customFields]),x(()=>(y.current=!0,()=>{y.current=!1}),[]),x(()=>{O.phase!==`submitting`&&M.phone&&b.current?.focus()},[M.phone,O.phase]),!s.isActive)return E(Q,{status:!0,viewProps:l,children:[T(`h1`,{children:`Signup closed`}),T(`p`,{children:`This signup is not accepting submissions.`})]});if(O.phase===`submitted`)return E(Q,{status:!0,viewProps:l,children:[f?T($,{branding:f}):null,T(`span`,{"aria-hidden":`true`,className:`lockerverse-signup__success`,children:`✓`}),T(`h1`,{children:`Thank you`}),T(`p`,{children:`Your signup has been received.`})]});let L=e=>j(t=>({...t,...e})),R=O.phase===`submitting`,z=O.phase===`submit_error`?O.error.message:void 0;return E(Q,{viewProps:l,children:[s.coverImageUrl?T(`img`,{alt:``,className:`lockerverse-signup__cover`,height:192,src:s.coverImageUrl,width:440}):null,f?T($,{branding:f}):null,E(`header`,{children:[s.title?.trim()?T(`h1`,{children:s.title}):null,s.description?T(`p`,{children:s.description}):null]}),t?E(`div`,{role:`alert`,children:[T(`p`,{children:t.message}),T(`button`,{onClick:a,type:`button`,children:`Retry`})]}):null,E(`form`,{noValidate:!0,onSubmit:async t=>{if(t.preventDefault(),D.current)return;let n=se(s,{...A,customFields:I,phone:s.fields.phone.enabled?o(A.phone,A.phoneCountry):``});if(N(n.errors),Object.keys(n.errors).length>0||!n.value){let e=t.currentTarget;queueMicrotask(()=>Z(e,n.errors));return}let r=n.value,a={address:s.fields.address.enabled&&!J(r.address)?r.address:null,answers:_(s.customFields,r.customFields),email:s.fields.email.enabled&&r.email||null,honeypot:r.honeypot,name:r.name,participantCount:s.fields.participantCount.enabled?r.participantCount:null,phone:s.fields.phone.enabled&&r.phone||null},c=JSON.stringify(a),l=P?.payloadKey===c?P.reference:globalThis.crypto.randomUUID(),u;D.current=!0,k({phase:`submitting`});try{u=await e.submit(a,{submissionReference:l})}catch(e){if(!y.current)return;let t=e,n=i(t.serverCode);if(n){N(e=>({...e,phone:n})),k({phase:`idle`}),F(void 0);return}k({error:t,phase:`submit_error`}),t.recoveryRecommended?F({payloadKey:c,reference:l}):F(void 0);return}finally{D.current=!1}y.current&&(F(void 0),k({phase:`submitted`}),d(m,u))},children:[T(`input`,{"aria-hidden":`true`,autoComplete:`off`,className:`lockerverse-signup__honeypot`,onChange:e=>L({honeypot:e.currentTarget.value}),tabIndex:-1,value:A.honeypot}),E(`div`,{className:`lockerverse-signup__fields`,children:[E(`label`,{htmlFor:`${v}-name`,children:[T(`span`,{children:`Name`}),T(`input`,{"aria-describedby":M.name?`${v}-name-error`:void 0,"aria-invalid":M.name?`true`:void 0,autoComplete:`name`,id:`${v}-name`,name:`name`,onChange:e=>L({name:e.currentTarget.value}),required:!0,value:A.name}),T(r,{error:M.name,id:`${v}-name-error`})]}),s.fields.email.enabled?T(n,{error:M.email,id:`${v}-email`,label:`Email`,name:`email`,onChange:e=>L({email:e.currentTarget.value}),required:s.fields.email.required,value:A.email}):null,s.fields.phone.enabled?T(c,{error:M.phone,id:`${v}-phone`,label:`Phone`,children:T(u,{country:A.phoneCountry,error:M.phone,errorId:`${v}-phone-error`,id:`${v}-phone`,inputRef:b,name:`phone`,onChange:({value:e,country:t})=>L({phone:e,phoneCountry:t}),required:s.fields.phone.required,value:A.phone})}):null,s.fields.participantCount.enabled?E(`label`,{htmlFor:`${v}-participant-count`,children:[T(`span`,{children:`Guest count`}),T(`input`,{"aria-describedby":M.participantCount?`${v}-participant-count-error`:void 0,"aria-invalid":M.participantCount?`true`:void 0,id:`${v}-participant-count`,min:1,name:`participantCount`,onChange:e=>L({participantCount:e.currentTarget.value}),required:s.fields.participantCount.required,type:`number`,value:A.participantCount}),T(r,{error:M.participantCount,id:`${v}-participant-count-error`})]}):null,s.fields.address.enabled?E(`div`,{className:`lockerverse-signup__field-group`,children:[T(ne,{apiKey:p,errorId:M.address?`${v}-address-error`:void 0,invalid:!!M.address,onChange:e=>L({address:e}),required:s.fields.address.required,value:A.address}),T(r,{error:M.address,id:`${v}-address-error`})]}):null,T(h,{choiceClassName:`lockerverse-signup__choice`,errorClassName:`lockerverse-signup__field-error`,errors:M,fields:s.customFields,idPrefix:v,onChange:e=>L({customFields:e}),values:I})]}),z?E(`p`,{className:`lockerverse-signup__submit-error`,role:`alert`,children:[z,` Try again.`]}):null,T(`button`,{className:`lockerverse-signup__submit`,disabled:R,type:`submit`,children:R?`Submitting…`:`Submit`})]})]})}function de({widget:e,...t}){return e.error&&!e.signup?E(Q,{status:!0,viewProps:t,children:[T(`h1`,{children:`Signup unavailable`}),T(`p`,{role:`alert`,children:e.error.message}),T(`button`,{onClick:e.refresh,type:`button`,children:`Retry`})]}):e.signup?T(ue,{client:e.client,loadError:e.error,onRetry:e.refresh,signup:e.signup,...t}):T(Q,{loading:!0,viewProps:t,children:T(y,{fieldCount:4,label:`Loading signup…`})})}function $({branding:e}){return E(`div`,{className:`lockerverse-signup__branding`,children:[e.imageUrl?T(`img`,{alt:``,height:48,src:e.imageUrl,width:48}):null,T(`strong`,{children:e.name})]})}function fe(t,{initialSignup:n}={}){let{onError:r}=t;e(`signup`,{apiBaseUrl:t.apiBaseUrl,communitySlug:t.communitySlug,environment:t.environment,slug:t.signupSlug});let i=C(r);i.current=r;let[a]=w(()=>{let e={...t,onError:e=>i.current?.(e)};return L(e)}),[o,s]=w(0),[c,l]=w(()=>({error:null,loading:!0,signup:n??null}));x(()=>{let e=!0;return a.load().then(t=>{e&&l({error:null,loading:!1,signup:t})},t=>{e&&l(e=>({...e,error:t,loading:!1}))}),()=>{e=!1}},[a,o]);let u=b(()=>{l(e=>({...e,error:null,loading:!0})),s(e=>e+1)},[]);return{client:a,error:c.error,loading:c.loading,refresh:u,signup:c.signup}}export{de as LockerverseSignup,fe as useLockerverseSignup};
1
+ import{r as e,t}from"./accent-contrast.js";import{t as n}from"./immutable-resource-identity.js";import{c as r,d as i,f as a,i as o,l as s,n as c,o as l,p as u,s as d,t as f}from"./phone-field.js";import{t as p}from"./host-callback.js";import{i as m,n as h,o as g,r as _,s as v}from"./custom-fields.js";import{t as y}from"./form-skeleton.js";import{useCallback as b,useEffect as x,useId as S,useRef as C,useState as w}from"react";import{jsx as T,jsxs as E}from"react/jsx-runtime";import{check as D,nonEmpty as O,nullable as k,object as A,pipe as j,regex as M,safeParse as N,string as P,transform as F,trim as I}from"valibot";import{createLockerverseSignupClient as L}from"@lockerverse/sdk/signup";const R=`lockerverse-signup-google-places`,z=[`premise`,`subpremise`,`street_address`,`route`];let B=null;function ee(e){let t=window;if(t.google?.maps?.importLibrary)return;t.google||={};let n=t.google;n.maps||={};let r=n.maps,i=null;r.importLibrary=n=>(i||=new Promise((t,i)=>{let a=document.getElementById(R);if(r.__lockerverseSignupReady=t,a){a.addEventListener(`error`,()=>i(Error(`Unable to load Google Places.`)),{once:!0});return}let o=document.createElement(`script`),s=new URLSearchParams({callback:`google.maps.__lockerverseSignupReady`,key:e,libraries:n,v:`weekly`});o.async=!0,o.id=R,o.src=`https://maps.googleapis.com/maps/api/js?${s}`,o.onerror=()=>i(Error(`Unable to load Google Places.`)),document.head.append(o)}),i.then(()=>{let e=t.google?.maps?.importLibrary;if(!e)throw Error(`Unable to load Google Places.`);return e(n)}).catch(e=>{throw i=null,document.getElementById(R)?.remove(),e}))}function V(e){return B||=(async()=>{try{ee(e);let t=window.google?.maps?.importLibrary;if(!t)throw Error(`Unable to load Google Places.`);return await t(`places`)}catch(e){throw B=null,e}})(),B}function H(e,t,n=`longText`){return e.find(e=>e.types.includes(t))?.[n]??``}function te(e,t){let n=t.addressComponents??[],r=[H(n,`street_number`),H(n,`route`)].filter(Boolean).join(` `);return{...e,city:H(n,`locality`)||H(n,`postal_town`)||H(n,`sublocality_level_1`),country:H(n,`country`,`shortText`)||`US`,line1:r||t.formattedAddress?.split(`,`)[0]||``,line2:H(n,`subpremise`),postalCode:[H(n,`postal_code`),H(n,`postal_code_suffix`)].filter(Boolean).join(`-`),state:H(n,`administrative_area_level_1`,`shortText`)}}function ne({apiKey:e,errorId:t,invalid:n,onChange:r,required:i,value:a}){let o=S(),s=`${o}-suggestions`,[c,l]=w(-1),[u,d]=w(!1),[f,p]=w(!1),[m,h]=w([]),g=C(0),_=C(0),v=C(null);x(()=>()=>{g.current+=1},[]),x(()=>{let t=_.current+1;_.current=t;let n=a.line1.trim();if(l(-1),p(!1),!(e&&u&&n.length>=3)){h([]);return}let r=window.setTimeout(async()=>{if(t===_.current){p(!0);try{let{AutocompleteSessionToken:r,AutocompleteSuggestion:i}=await V(e);v.current??=new r;let a=await i.fetchAutocompleteSuggestions({includedPrimaryTypes:z,includedRegionCodes:[`US`],input:n,region:`US`,sessionToken:v.current});t===_.current&&h(a.suggestions.flatMap(({placePrediction:e})=>e?[{id:e.placeId,label:e.mainText?.text??e.text.text,prediction:e,secondaryLabel:e.secondaryText?.text??``}]:[]))}catch{t===_.current&&h([])}finally{t===_.current&&p(!1)}}},250);return()=>{window.clearTimeout(r)}},[e,u,a.line1]);let y=e=>{g.current+=1,r({...a,...e})},b=async e=>{let t=g.current+1;g.current=t;let n=e.prediction.toPlace();try{if(await n.fetchFields({fields:[`addressComponents`,`formattedAddress`]}),t!==g.current)return;r(te(a,n)),v.current=null,h([]),l(-1),d(!1)}catch{if(t!==g.current)return;h([]),l(-1)}},D=e=>{if(e.key===`Escape`){e.preventDefault(),h([]),l(-1);return}if(m.length===0)return;if(e.key===`ArrowDown`){e.preventDefault(),l(e=>e<m.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),l(e=>e>0?e-1:m.length-1);return}let t=m[c];e.key===`Enter`&&t&&(e.preventDefault(),b(t).catch(()=>void 0))},O=e=>{e.currentTarget.closest(`.lockerverse-signup__address-search`)?.contains(e.relatedTarget)||window.setTimeout(()=>d(!1),120)};return E(`fieldset`,{"aria-describedby":n?t:void 0,"aria-invalid":n?`true`:void 0,className:`lockerverse-signup__address`,children:[T(`legend`,{children:`Address`}),E(`label`,{htmlFor:`${o}-line1`,children:[T(`span`,{children:`Street address`}),E(`div`,{className:`lockerverse-signup__address-search`,children:[T(`input`,{"aria-activedescendant":c>=0?`${o}-suggestion-${c}`:void 0,"aria-autocomplete":`list`,"aria-controls":s,"aria-describedby":n?t:void 0,"aria-expanded":u&&m.length>0,"aria-invalid":n?`true`:void 0,autoComplete:`street-address`,id:`${o}-line1`,name:`address.line1`,onBlur:O,onChange:e=>y({line1:e.currentTarget.value}),onFocus:()=>d(!0),onKeyDown:D,required:i,role:`combobox`,value:a.line1}),f?T(`span`,{className:`lockerverse-signup__address-loading`,children:`Searching…`}):null,m.length>0?T(`div`,{className:`lockerverse-signup__address-suggestions`,id:s,role:`listbox`,children:m.map((e,t)=>E(`button`,{"aria-selected":c===t,id:`${o}-suggestion-${t}`,onBlur:O,onClick:t=>{t.detail===0&&b(e).catch(()=>void 0)},onMouseDown:t=>{t.preventDefault(),b(e).catch(()=>void 0)},role:`option`,type:`button`,children:[T(`strong`,{children:e.label}),e.secondaryLabel?T(`span`,{children:e.secondaryLabel}):null]},e.id))}):null]})]}),E(`label`,{htmlFor:`${o}-line2`,children:[T(`span`,{children:`Apartment, suite, or unit`}),T(`input`,{autoComplete:`address-line2`,id:`${o}-line2`,onChange:e=>y({line2:e.currentTarget.value}),placeholder:`Optional`,value:a.line2??``})]}),E(`div`,{className:`lockerverse-signup__address-row`,children:[E(`label`,{htmlFor:`${o}-city`,children:[T(`span`,{children:`City`}),T(`input`,{autoComplete:`address-level2`,id:`${o}-city`,onChange:e=>y({city:e.currentTarget.value}),required:i,value:a.city})]}),E(`label`,{htmlFor:`${o}-state`,children:[T(`span`,{children:`State`}),T(`input`,{autoComplete:`address-level1`,id:`${o}-state`,onChange:e=>y({state:e.currentTarget.value}),required:i,value:a.state})]})]}),E(`div`,{className:`lockerverse-signup__address-row`,children:[E(`label`,{htmlFor:`${o}-postal`,children:[T(`span`,{children:`Postal code`}),T(`input`,{autoComplete:`postal-code`,id:`${o}-postal`,onChange:e=>y({postalCode:e.currentTarget.value}),required:i,value:a.postalCode})]}),E(`label`,{htmlFor:`${o}-country`,children:[T(`span`,{children:`Country`}),T(`input`,{autoComplete:`country`,id:`${o}-country`,maxLength:2,onChange:e=>y({country:e.currentTarget.value.toUpperCase()}),required:i,value:a.country})]})]})]})}const re=/^[1-9]\d*$/,ie=/^(?:$|[1-9]\d*)$/,ae=j(P(),I(),O(`Name is required.`)),U=j(P(),I(),M(ie,`Guest count must be a positive whole number.`),F(e=>e?Number(e):null),D(e=>e===null||Number.isSafeInteger(e),`Guest count must be a positive whole number.`)),W=j(P(),I(),O(`Guest count is required.`),M(re,`Guest count must be a positive whole number.`),F(Number),D(e=>Number.isSafeInteger(e),`Guest count must be a positive whole number.`)),G=A({city:P(),country:P(),line1:P(),line2:k(P()),postalCode:P(),state:P()}),K=j(G,D(Y,`Complete the address.`)),q={city:``,country:`US`,line1:``,line2:null,postalCode:``,state:``},oe=j(G,D(e=>J(e)||Y(e),`Complete the address or leave it blank.`));function J(e){return![e.city,e.line1,e.line2,e.postalCode,e.state].some(e=>e?.trim())}function Y(e){return[e.city,e.country,e.line1,e.postalCode,e.state].every(e=>e.trim())}function se(e,t){let n={...t,address:e.fields.address.enabled?t.address:q,customFields:g(e.customFields,t.customFields),email:e.fields.email.enabled?t.email:``,participantCount:e.fields.participantCount.enabled?t.participantCount:``,phone:e.fields.phone.enabled?t.phone:``},i=A({address:e.fields.address.enabled&&e.fields.address.required?K:oe,email:e.fields.email.enabled&&e.fields.email.required?r:l,name:ae,participantCount:e.fields.participantCount.enabled&&e.fields.participantCount.required?W:U,phone:e.fields.phone.enabled&&e.fields.phone.required?s:d}),a=N(i,n),o=v(e.customFields,n.customFields);if(!a.success)for(let e of a.issues){let t=e.path?.[0]?.key,n=[`address`,`email`,`name`,`participantCount`,`phone`].find(e=>e===t);n&&!o[n]&&(o[n]=e.message)}return a.success?{errors:o,value:{...n,...a.output}}:{errors:o,value:null}}const ce={city:``,country:`US`,line1:``,line2:``,postalCode:``,state:``};function le(e){return{address:ce,customFields:m(e.customFields),email:``,honeypot:``,name:``,participantCount:``,phone:``,phoneCountry:`US`}}function X(e,t){let n=e.elements.namedItem(t);if(n instanceof HTMLElement)return!n.matches(`:disabled`)&&(n.focus(),!0);if(n instanceof RadioNodeList){let e=Array.from(n).find(e=>e instanceof HTMLElement&&!e.matches(`:disabled`));return e?.focus(),!!e}return!1}function Z(e,t){let n=[[`name`,`name`],[`email`,`email`],[`phone`,`phone`],[`participantCount`,`participantCount`],[`address`,`address.line1`]];for(let[r,i]of n)if(t[r]&&X(e,i))return;let r=new Set(n.map(([e])=>e)),i=Object.keys(t).find(e=>!r.has(e));i&&X(e,`custom:${i}`)}function Q({children:n,loading:r=!1,status:i=!1,viewProps:a}){let{branding:o,className:s,googlePlacesApiKey:c,onSignupComplete:l,style:u,theme:d=`dark`,...f}=a,p=e(u?.[`--lockerverse-accent`]??u?.[`--lockerverse-signup-accent`]??o?.accentColor??`#5751f2`),m={...u};if((u?.[`--lockerverse-accent`]!==void 0||u?.[`--lockerverse-signup-accent`]!==void 0||o?.accentColor)&&(m[`--lockerverse-accent`]=p),u?.[`--lockerverse-accent-contrast`]===void 0&&u?.[`--lockerverse-signup-accent-contrast`]===void 0){let e=t(p);e&&(m[`--lockerverse-accent-contrast`]=e)}return T(`section`,{...f,...r?{"aria-busy":!0}:{},className:[`lockerverse-signup`,i?`lockerverse-signup__status`:null,s].filter(Boolean).join(` `),"data-lockerverse-theme":d,style:m,children:n})}function ue({client:e,loadError:t,onRetry:n,signup:r,...s}){let{branding:l,googlePlacesApiKey:d,onSignupComplete:m}=s,v=S(),y=C(!0),b=C(null),D=C(!1),[O,k]=w({phase:`idle`}),[A,j]=w(()=>le(r)),[M,N]=w({}),[P,F]=w(),I=g(r.customFields,A.customFields);if(x(()=>{I!==A.customFields&&j(e=>({...e,customFields:g(r.customFields,e.customFields)}))},[I,r.customFields,A.customFields]),x(()=>(y.current=!0,()=>{y.current=!1}),[]),x(()=>{O.phase!==`submitting`&&M.phone&&b.current?.focus()},[M.phone,O.phase]),!r.isActive)return E(Q,{status:!0,viewProps:s,children:[T(`h1`,{children:`Signup closed`}),T(`p`,{children:`This signup is not accepting submissions.`})]});if(O.phase===`submitted`)return E(Q,{status:!0,viewProps:s,children:[l?T($,{branding:l}):null,T(`span`,{"aria-hidden":`true`,className:`lockerverse-signup__success`,children:`✓`}),T(`h1`,{children:`Thank you`}),T(`p`,{children:`Your signup has been received.`})]});let L=e=>j(t=>({...t,...e})),R=O.phase===`submitting`,z=O.phase===`submit_error`?O.error.message:void 0;return E(Q,{viewProps:s,children:[r.coverImageUrl?T(`img`,{alt:``,className:`lockerverse-signup__cover`,height:192,src:r.coverImageUrl,width:440}):null,l?T($,{branding:l}):null,E(`header`,{children:[r.title?.trim()?T(`h1`,{children:r.title}):null,r.description?T(`p`,{children:r.description}):null]}),t?E(`div`,{role:`alert`,children:[T(`p`,{children:t.message}),T(`button`,{onClick:n,type:`button`,children:`Retry`})]}):null,E(`form`,{noValidate:!0,onSubmit:async t=>{if(t.preventDefault(),D.current)return;let n=se(r,{...A,customFields:I,phone:r.fields.phone.enabled?c(A.phone,A.phoneCountry):``});if(N(n.errors),Object.keys(n.errors).length>0||!n.value){let e=t.currentTarget;queueMicrotask(()=>Z(e,n.errors));return}let i=n.value,a={address:r.fields.address.enabled&&!J(i.address)?i.address:null,answers:_(r.customFields,i.customFields),email:r.fields.email.enabled&&i.email||null,honeypot:i.honeypot,name:i.name,participantCount:r.fields.participantCount.enabled?i.participantCount:null,phone:r.fields.phone.enabled&&i.phone||null},s=JSON.stringify(a),l=P?.payloadKey===s?P.reference:globalThis.crypto.randomUUID(),u;D.current=!0,k({phase:`submitting`});try{u=await e.submit(a,{submissionReference:l})}catch(e){if(!y.current)return;let t=e,n=o(t.serverCode);if(n){N(e=>({...e,phone:n})),k({phase:`idle`}),F(void 0);return}k({error:t,phase:`submit_error`}),t.recoveryRecommended?F({payloadKey:s,reference:l}):F(void 0);return}finally{D.current=!1}y.current&&(F(void 0),k({phase:`submitted`}),p(m,u))},children:[T(`input`,{"aria-hidden":`true`,autoComplete:`off`,className:`lockerverse-signup__honeypot`,onChange:e=>L({honeypot:e.currentTarget.value}),tabIndex:-1,value:A.honeypot}),E(`div`,{className:`lockerverse-signup__fields`,children:[E(`label`,{htmlFor:`${v}-name`,children:[T(`span`,{children:`Name`}),T(`input`,{"aria-describedby":M.name?`${v}-name-error`:void 0,"aria-invalid":M.name?`true`:void 0,autoComplete:`name`,id:`${v}-name`,name:`name`,onChange:e=>L({name:e.currentTarget.value}),required:!0,value:A.name}),T(a,{error:M.name,id:`${v}-name-error`})]}),r.fields.email.enabled?T(i,{error:M.email,id:`${v}-email`,label:`Email`,name:`email`,onChange:e=>L({email:e.currentTarget.value}),required:r.fields.email.required,value:A.email}):null,r.fields.phone.enabled?T(u,{error:M.phone,id:`${v}-phone`,label:`Phone`,children:T(f,{country:A.phoneCountry,error:M.phone,errorId:`${v}-phone-error`,id:`${v}-phone`,inputRef:b,name:`phone`,onChange:({value:e,country:t})=>L({phone:e,phoneCountry:t}),required:r.fields.phone.required,value:A.phone})}):null,r.fields.participantCount.enabled?E(`label`,{htmlFor:`${v}-participant-count`,children:[T(`span`,{children:`Guest count`}),T(`input`,{"aria-describedby":M.participantCount?`${v}-participant-count-error`:void 0,"aria-invalid":M.participantCount?`true`:void 0,id:`${v}-participant-count`,min:1,name:`participantCount`,onChange:e=>L({participantCount:e.currentTarget.value}),required:r.fields.participantCount.required,type:`number`,value:A.participantCount}),T(a,{error:M.participantCount,id:`${v}-participant-count-error`})]}):null,r.fields.address.enabled?E(`div`,{className:`lockerverse-signup__field-group`,children:[T(ne,{apiKey:d,errorId:M.address?`${v}-address-error`:void 0,invalid:!!M.address,onChange:e=>L({address:e}),required:r.fields.address.required,value:A.address}),T(a,{error:M.address,id:`${v}-address-error`})]}):null,T(h,{choiceClassName:`lockerverse-signup__choice`,errorClassName:`lockerverse-signup__field-error`,errors:M,fields:r.customFields,idPrefix:v,onChange:e=>L({customFields:e}),values:I})]}),z?E(`p`,{className:`lockerverse-signup__submit-error`,role:`alert`,children:[z,` Try again.`]}):null,T(`button`,{className:`lockerverse-signup__submit`,disabled:R,type:`submit`,children:R?`Submitting…`:`Submit`})]})]})}function de({widget:e,...t}){return e.error&&!e.signup?E(Q,{status:!0,viewProps:t,children:[T(`h1`,{children:`Signup unavailable`}),T(`p`,{role:`alert`,children:e.error.message}),T(`button`,{onClick:e.refresh,type:`button`,children:`Retry`})]}):e.signup?T(ue,{client:e.client,loadError:e.error,onRetry:e.refresh,signup:e.signup,...t}):T(Q,{loading:!0,viewProps:t,children:T(y,{fieldCount:4,label:`Loading signup…`})})}function $({branding:e}){return E(`div`,{className:`lockerverse-signup__branding`,children:[e.imageUrl?T(`img`,{alt:``,height:48,src:e.imageUrl,width:48}):null,T(`strong`,{children:e.name})]})}function fe(e,{initialSignup:t}={}){let{onError:r}=e;n(`signup`,{apiBaseUrl:e.apiBaseUrl,communitySlug:e.communitySlug,environment:e.environment,slug:e.signupSlug});let i=C(r);i.current=r;let[a]=w(()=>{let t={...e,onError:e=>i.current?.(e)};return L(t)}),[o,s]=w(0),[c,l]=w(()=>({error:null,loading:!0,signup:t??null}));x(()=>{let e=!0;return a.load().then(t=>{e&&l({error:null,loading:!1,signup:t})},t=>{e&&l(e=>({...e,error:t,loading:!1}))}),()=>{e=!1}},[a,o]);let u=b(()=>{l(e=>({...e,error:null,loading:!0})),s(e=>e+1)},[]);return{client:a,error:c.error,loading:c.loading,refresh:u,signup:c.signup}}export{de as LockerverseSignup,fe as useLockerverseSignup};
2
2
  //# sourceMappingURL=signup.js.map
@@ -1,6 +1,6 @@
1
1
  # Lockerverse auctions guide
2
2
 
3
- Package: @lockerverse/react@0.2.234
3
+ Package: @lockerverse/react@0.2.236
4
4
 
5
5
  Generated from this release's maintained documentation. Do not edit this copy.
6
6
 
@@ -109,6 +109,30 @@ import "@lockerverse/react/auction.css";
109
109
 
110
110
  `showFilters` and `showHeader` default to `true`. `showLineup` defaults to `false`, so the static introduction and separate count are hidden. These options also work on `LockerverseAuctions`. The auction header omits the auction date range; item dates remain on item cards. Hiding filters shows all items and clears the previous filter. Changing the auction resets its filter. Hiding headings never removes the section's accessible name. `onBack` is optional, so a dedicated auction page does not need a link to all auctions.
111
111
 
112
+ ### Community appearance
113
+
114
+ The ready-made auction browser, catalog, standalone item card, item view and its
115
+ result use the auction's community accent. A card's action and hover/focus border
116
+ share that color. The SDK chooses contrasting text for hex, CSS named, RGB, and HSL accents. It composites
117
+ translucent colors against the selected theme. The `style` prop overrides the defaults.
118
+ For contextual colors such as `var(--brand)` or `currentColor`, supply
119
+ `--lockerverse-accent-contrast` because a server cannot resolve the host CSS.
120
+
121
+ Use `getAuctionPresentationStyle(auction, overrides?, theme?)` from
122
+ `@lockerverse/react/auction-presentation` for custom hosts or for a result that
123
+ has only community color available. The helper is safe during server rendering.
124
+ This style helper controls appearance only. Full catalog pages keep their own
125
+ header, filters, navigation, and section layout.
126
+
127
+ ### Use the shared embed presentation
128
+
129
+ Call `getAuctionEmbedPresentation(auction)` and spread `catalog` onto `LockerverseAuction`
130
+ or `item` onto `LockerverseAuctionItem` to use the hosted and script embed layout.
131
+ The preset uses the community accent and contrasting action text; a pinned catalog
132
+ starts with item cards. Use `defaultTheme` only when the visitor did not select a theme.
133
+ The helper is also available from `@lockerverse/react/auction-presentation` for server
134
+ components that only need presentation data.
135
+
112
136
  ### Additional charges and order limits
113
137
 
114
138
  An auction or Buy Now item can have one optional `additionalCharge`: a customer-facing `name`,
@@ -1,6 +1,6 @@
1
1
  # Lockerverse bookings guide
2
2
 
3
- Package: @lockerverse/react@0.2.234
3
+ Package: @lockerverse/react@0.2.236
4
4
 
5
5
  Generated from this release's maintained documentation. Do not edit this copy.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Lockerverse browser-embed guide
2
2
 
3
- Package: @lockerverse/react@0.2.234
3
+ Package: @lockerverse/react@0.2.236
4
4
 
5
5
  Generated from this release's maintained documentation. Do not edit this copy.
6
6
 
@@ -20,13 +20,13 @@ promise of compatibility with every CMS or site security policy.
20
20
 
21
21
  ## Add an auction
22
22
 
23
- This snippet uses `0.2.234`. Keep the version pinned so a package release does not change the
23
+ This snippet uses `0.2.236`. Keep the version pinned so a package release does not change the
24
24
  host's integration without a review.
25
25
 
26
26
  ```html
27
27
  <script
28
28
  type="module"
29
- src="https://unpkg.com/@lockerverse/react@0.2.234/dist/embed/lockerverse.js"
29
+ src="https://unpkg.com/@lockerverse/react@0.2.236/dist/embed/lockerverse.js"
30
30
  ></script>
31
31
 
32
32
  <lockerverse-auctions
@@ -41,6 +41,11 @@ It starts the public catalog request alongside the interface download.
41
41
  The host can provide its own placeholder inside the element for the time
42
42
  before the script executes.
43
43
 
44
+ A pinned auction uses the same catalog presentation as its hosted iframe. The
45
+ item cards use the community accent and contrasting text. An explicit `accent`
46
+ attribute overrides the community color. The community browser keeps its catalog
47
+ heading and filters when a visitor selects an auction.
48
+
44
49
  Load the script once per page. No separate stylesheet is required. Remove the
45
50
  `auction` attribute to show all public auctions for the community. No API secret
46
51
  or private credential belongs in the markup.
@@ -52,7 +57,7 @@ or private credential belongs in the markup.
52
57
  | `community` | Required | Public community slug, such as `auburn`. |
53
58
  | `auction` | Not set | Public auction slug. Omit it to start with the community's auctions. |
54
59
  | `theme` | `light` | `light` or `dark`. Can change while the element is mounted. |
55
- | `accent` | SDK default | Optional CSS color for the supported accent treatment. Can change while mounted. |
60
+ | `accent` | Community color | Optional CSS color for the supported accent treatment. Can change while mounted. |
56
61
  | `instance` | `main` | Stable name for this embed's URL parameters. Give each embed on a page a different name. |
57
62
  | `nonce` | Not set | Optional server-generated CSP nonce, copied to the embedded stylesheet. Set it before inserting the element. |
58
63
  | `environment` | `production` | `production` uses `https://portal.lockerverse.com/api`; `development` uses `https://portal-dev.lockerverse.com/api`. |
package/guides/events.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Lockerverse events guide
2
2
 
3
- Package: @lockerverse/react@0.2.234
3
+ Package: @lockerverse/react@0.2.236
4
4
 
5
5
  Generated from this release's maintained documentation. Do not edit this copy.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Lockerverse integration guide
2
2
 
3
- Package: @lockerverse/react@0.2.234
3
+ Package: @lockerverse/react@0.2.236
4
4
 
5
5
  Generated from this release's maintained documentation. Do not edit this copy.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Lockerverse payment-widgets guide
2
2
 
3
- Package: @lockerverse/react@0.2.234
3
+ Package: @lockerverse/react@0.2.236
4
4
 
5
5
  Generated from this release's maintained documentation. Do not edit this copy.
6
6
 
package/guides/signup.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Lockerverse signup guide
2
2
 
3
- Package: @lockerverse/react@0.2.234
3
+ Package: @lockerverse/react@0.2.236
4
4
 
5
5
  Generated from this release's maintained documentation. Do not edit this copy.
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lockerverse/react",
3
- "version": "0.2.234",
3
+ "version": "0.2.236",
4
4
  "description": "Tree-shakable React payment and signup UI for Lockerverse",
5
5
  "repository": {
6
6
  "type": "git",
@@ -83,6 +83,11 @@
83
83
  "import": "./dist/auction.js",
84
84
  "default": "./dist/auction.js"
85
85
  },
86
+ "./auction-presentation": {
87
+ "types": "./dist/auction-presentation.d.ts",
88
+ "import": "./dist/auction-presentation.js",
89
+ "default": "./dist/auction-presentation.js"
90
+ },
86
91
  "./auction-data": {
87
92
  "types": "./dist/auction-data.d.ts",
88
93
  "import": "./dist/auction-data.js",
@@ -142,11 +147,12 @@
142
147
  ],
143
148
  "dependencies": {
144
149
  "@base-ui/react": "1.6.0",
150
+ "colord": "2.9.3",
145
151
  "embla-carousel-autoplay": "8.6.0",
146
152
  "embla-carousel-react": "8.6.0",
147
153
  "lucide-react": "0.536.0",
148
154
  "valibot": "1.4.2",
149
- "@lockerverse/sdk": "0.2.234"
155
+ "@lockerverse/sdk": "0.2.236"
150
156
  },
151
157
  "devDependencies": {
152
158
  "@size-limit/file": "13.0.3",
@@ -1,2 +0,0 @@
1
- import{a as _,r as f}from"./chunk-JJVID3KZ.js";import{a as R,c as a}from"./chunk-DCANE7XH.js";var H=R(o=>{"use strict";var Z=_();function P(t){var e="https://react.dev/errors/"+t;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)e+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(){}var s={d:{f:u,r:function(){throw Error(P(522))},D:u,C:u,L:u,m:u,X:u,S:u,M:u},p:0,findDOMNode:null},ee=Symbol.for("react.portal");function te(t,e,r){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ee,key:n==null?null:""+n,children:t,containerInfo:e,implementation:r}}var h=Z.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function S(t,e){if(t==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s;o.createPortal=function(t,e){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(P(299));return te(t,e,null,r)};o.flushSync=function(t){var e=h.T,r=s.p;try{if(h.T=null,s.p=2,t)return t()}finally{h.T=e,s.p=r,s.d.f()}};o.preconnect=function(t,e){typeof t=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,s.d.C(t,e))};o.prefetchDNS=function(t){typeof t=="string"&&s.d.D(t)};o.preinit=function(t,e){if(typeof t=="string"&&e&&typeof e.as=="string"){var r=e.as,n=S(r,e.crossOrigin),c=typeof e.integrity=="string"?e.integrity:void 0,i=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;r==="style"?s.d.S(t,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:n,integrity:c,fetchPriority:i}):r==="script"&&s.d.X(t,{crossOrigin:n,integrity:c,fetchPriority:i,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};o.preinitModule=function(t,e){if(typeof t=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var r=S(e.as,e.crossOrigin);s.d.M(t,{crossOrigin:r,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&s.d.M(t)};o.preload=function(t,e){if(typeof t=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var r=e.as,n=S(r,e.crossOrigin);s.d.L(t,r,{crossOrigin:n,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};o.preloadModule=function(t,e){if(typeof t=="string")if(e){var r=S(e.as,e.crossOrigin);s.d.m(t,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:r,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else s.d.m(t)};o.requestFormReset=function(t){s.d.r(t)};o.unstable_batchedUpdates=function(t,e){return t(e)};o.useFormState=function(t,e,r){return h.H.useFormState(t,e,r)};o.useFormStatus=function(){return h.H.useHostTransitionStatus()};o.version="19.2.8"});var re=R((me,k)=>{"use strict";function U(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(U)}catch(t){console.error(t)}}U(),k.exports=H()});var E=a(f(),1);function ne({href:t,onBack:e,className:r,children:n,elementRef:c}){return t?(0,E.jsx)("a",{className:r,href:t,onClick:i=>{e&&i.button===0&&!i.metaKey&&!i.ctrlKey&&!i.shiftKey&&!i.altKey&&(i.preventDefault(),e())},ref:c,children:n}):e?(0,E.jsx)("button",{className:r,onClick:e,ref:c,type:"button",children:n}):null}var l=a(_(),1),N=a(f(),1),B=(0,l.createContext)(void 0),F=[96,192,320,480,640,960,1280,1920],z=/\.(jpe?g|png|webp|avif)$/i,W=/\/+$/,j=new Set(["media.lockerverse.com","dev-media.lockerverse.com"]);function q(t,e){if(j.has(t.hostname)&&!t.port)return t.pathname;if(!e)return;let r=new URL(e),n=`${r.pathname.replace(W,"")}/`;if(!(r.username||r.password||r.search||r.hash||t.origin!==r.origin||!t.pathname.startsWith(n)))return`/${t.pathname.slice(n.length)}`}function G(t,e){if(t)try{let r=new URL(t),n=q(r,e);return r.protocol!=="https:"||!n||r.username||r.password||r.search||r.hash||n.startsWith("/__image/")||n.includes("/chat-media/")||!z.test(n)?void 0:r}catch{}}function A(t,e){return t.searchParams.set("w",String(e)),t.searchParams.set("f","webp"),t.href}function se({alt:t,width:e,height:r,src:n,maxWidth:c,onError:i,decoding:p="async",...v}){let[x,K]=(0,l.useState)(),V=(0,l.useContext)(B),y=x===n?void 0:G(n,V),L=F.filter(d=>d<=c),$=L.at(-1)??96;return(0,N.jsx)("img",{...v,alt:t,decoding:p,height:r,onError:d=>{y?K(n):i?.(d)},src:y?A(y,$):n,srcSet:y?L.map(d=>`${A(y,d)} ${d}w`).join(", "):void 0,width:e})}var b=a(_(),1),g=new Map,O,I=0,Y=2147483647;function T(){clearTimeout(O),O=void 0;let t=Date.now(),e=Number.POSITIVE_INFINITY;for(let r of g.values())for(let n of r)n>t&&(e=Math.min(e,n));Number.isFinite(e)&&(O=setTimeout(w,Math.min(e-t+1,Y)))}function w(){I+=1;for(let t of g.keys())t();T()}function D(){document.hidden||w()}var X=()=>I,J=()=>0;function ce(t,e,r=[]){let n=[t,e,...r.flatMap(i=>[i.startAt??t,i.endAt??e])].join(","),c=(0,b.useCallback)(i=>(g.size||document.addEventListener("visibilitychange",D),g.set(i,n.split(",").map(Date.parse)),T(),()=>{g.delete(i),T(),g.size||document.removeEventListener("visibilitychange",D)}),[n]);(0,b.useSyncExternalStore)(c,X,J)}var Q=/<\/?(?:p|br|strong|em|u|s|ul|ol|li|blockquote|pre|code|hr|h[1-6]|a)(?:\s|\/?>)/i;function C(t){return Q.test(t)?t:t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r\n|\r|\n/g,"<br>")}var M=a(f(),1);function fe({description:t,className:e,id:r}){return(0,M.jsx)("div",{className:["lockerverse-auctions__description",e].filter(Boolean).join(" "),dangerouslySetInnerHTML:{__html:C(t)},id:r})}var m=a(_(),1);function ye(){let t=(0,m.useRef)(null),[e,r]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let n=t.current;if(!(n&&"IntersectionObserver"in window))return;let c=!1,i=()=>r(c&&!document.hidden),p=new IntersectionObserver(([v])=>{c=!!(v?.isIntersecting&&v.intersectionRatio>0),i()});return p.observe(n),document.addEventListener("visibilitychange",i),()=>{p.disconnect(),document.removeEventListener("visibilitychange",i)}},[]),{ref:t,visible:e}}export{re as a,ne as b,fe as c,B as d,se as e,ye as f,ce as g};
2
- /*! For license information please see chunk-ZD64W5CW.js.LEGAL.txt */