@lockerverse/react 0.2.234 → 0.2.235
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATIONS.md +6 -0
- package/dist/auction-catalog.css +14 -0
- package/dist/auction-item-layout.css +5 -0
- package/dist/auction-presentation.d.ts +24 -0
- package/dist/auction-presentation.d.ts.map +1 -0
- package/dist/auction-presentation.js +2 -0
- package/dist/auction-presentation.js.map +1 -0
- package/dist/auction.d.ts +2 -1
- package/dist/auction.js +1 -1
- package/dist/embed/chunks/{auction-payment-view-ERY7SC6C.js → auction-payment-view-HS2VCXUT.js} +1 -1
- package/dist/embed/chunks/{chunk-JJVID3KZ.js → chunk-ECU3IX4G.js} +2 -2
- package/dist/embed/chunks/{chunk-ZR6TPDWZ.js → chunk-FTKUIA4D.js} +1 -1
- package/dist/embed/chunks/{chunk-ZD64W5CW.js → chunk-JAZVPYXN.js} +2 -2
- package/dist/embed/chunks/{lockerverse-auction-item-ETY2D2I2.js → lockerverse-auction-item-AIEK5XAY.js} +2 -2
- package/dist/embed/lockerverse.js +2 -2
- package/dist/embed/runtime.js +6 -6
- package/dist/lockerverse-payment.js +1 -1
- package/dist/lockerverse-payment.js.map +1 -1
- package/dist/public-events.js +1 -1
- package/dist/signup.js +1 -1
- package/guides/auctions.md +10 -1
- package/guides/bookings.md +1 -1
- package/guides/browser-embed.md +9 -4
- package/guides/events.md +1 -1
- package/guides/integration.md +1 -1
- package/guides/payment-widgets.md +1 -1
- package/guides/signup.md +1 -1
- package/package.json +7 -2
- /package/dist/embed/chunks/{chunk-JJVID3KZ.js.LEGAL.txt → chunk-ECU3IX4G.js.LEGAL.txt} +0 -0
- /package/dist/embed/chunks/{chunk-ZD64W5CW.js.LEGAL.txt → chunk-JAZVPYXN.js.LEGAL.txt} +0 -0
- /package/dist/embed/chunks/{lockerverse-auction-item-ETY2D2I2.js.LEGAL.txt → lockerverse-auction-item-AIEK5XAY.js.LEGAL.txt} +0 -0
package/dist/public-events.js
CHANGED
|
@@ -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{n 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
|
package/guides/auctions.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lockerverse auctions guide
|
|
2
2
|
|
|
3
|
-
Package: @lockerverse/react@0.2.
|
|
3
|
+
Package: @lockerverse/react@0.2.235
|
|
4
4
|
|
|
5
5
|
Generated from this release's maintained documentation. Do not edit this copy.
|
|
6
6
|
|
|
@@ -109,6 +109,15 @@ 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
|
+
### Use the shared embed presentation
|
|
113
|
+
|
|
114
|
+
Call `getAuctionEmbedPresentation(auction)` and spread `catalog` onto `LockerverseAuction`
|
|
115
|
+
or `item` onto `LockerverseAuctionItem` to use the hosted and script embed layout.
|
|
116
|
+
The preset uses the community accent and contrasting action text; a pinned catalog
|
|
117
|
+
starts with item cards. Use `defaultTheme` only when the visitor did not select a theme.
|
|
118
|
+
The helper is also available from `@lockerverse/react/auction-presentation` for server
|
|
119
|
+
components that only need presentation data.
|
|
120
|
+
|
|
112
121
|
### Additional charges and order limits
|
|
113
122
|
|
|
114
123
|
An auction or Buy Now item can have one optional `additionalCharge`: a customer-facing `name`,
|
package/guides/bookings.md
CHANGED
package/guides/browser-embed.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Lockerverse browser-embed guide
|
|
2
2
|
|
|
3
|
-
Package: @lockerverse/react@0.2.
|
|
3
|
+
Package: @lockerverse/react@0.2.235
|
|
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.
|
|
23
|
+
This snippet uses `0.2.235`. 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.
|
|
29
|
+
src="https://unpkg.com/@lockerverse/react@0.2.235/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` |
|
|
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
package/guides/integration.md
CHANGED
package/guides/signup.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lockerverse/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.235",
|
|
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",
|
|
@@ -146,7 +151,7 @@
|
|
|
146
151
|
"embla-carousel-react": "8.6.0",
|
|
147
152
|
"lucide-react": "0.536.0",
|
|
148
153
|
"valibot": "1.4.2",
|
|
149
|
-
"@lockerverse/sdk": "0.2.
|
|
154
|
+
"@lockerverse/sdk": "0.2.235"
|
|
150
155
|
},
|
|
151
156
|
"devDependencies": {
|
|
152
157
|
"@size-limit/file": "13.0.3",
|
|
File without changes
|
|
File without changes
|