efficient-storefront-blocks 0.120.0 → 0.120.1

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.
@@ -10,6 +10,7 @@ type FindStage = "form" | "sent" | "opening";
10
10
  export default function SignUpFind({ product, productName, startHref, inert }: SignUpFindProps): import("react").JSX.Element;
11
11
  interface SignUpFindViewProps {
12
12
  stage: FindStage;
13
+ focus?: FindStage;
13
14
  productName: string;
14
15
  startHref: string;
15
16
  email: string;
@@ -23,5 +24,5 @@ interface SignUpFindViewProps {
23
24
  onAnother?: () => void;
24
25
  onRetry?: () => void;
25
26
  }
26
- export declare function SignUpFindView({ stage, productName, startHref, email, wrong, trouble, linkGone, openTrouble, busy, onEmail, onSubmit, onAnother, onRetry, }: SignUpFindViewProps): import("react").JSX.Element;
27
+ export declare function SignUpFindView({ stage, focus, productName, startHref, email, wrong, trouble, linkGone, openTrouble, busy, onEmail, onSubmit, onAnother, onRetry, }: SignUpFindViewProps): import("react").JSX.Element;
27
28
  export {};
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as f,Fragment as O}from"react/jsx-runtime";import _ from"next/link";import{usePathname as C}from"next/navigation";import{useEffect as G,useId as L,useState as s}from"react";import{ApiError as j,askForWorkspaces as U,openWorkspaceFind as B}from"../lib/api/index.js";import{BANNER as v,CARD as E,PRIMARY as P,QUIET as N,TITLE as A}from"../lib/sections/sign-up-look.js";import{FIND_WORDS as t,SIGN_UP_WORDS as g,checkWaitingEmail as M,fill as V,findTokenOf as H,readFindOpenTrouble as Q,readFindRefusal as Y}from"../lib/sections/sign-up.js";function q({product:p,productName:y,startHref:h,inert:m=!1}){const n=m?"":H(C()),[b,i]=s(n?"opening":"form"),[r,x]=s(""),[k,u]=s(null),[F,d]=s(null),[o,c]=s(!1),[S,$]=s(null),[D,I]=s(0),[w,T]=s(!1);return G(()=>{if(!n)return;let l=!1;return B(n).then(a=>{l||(a?window.location.assign(a):(c(!0),i("form")))}).catch(a=>{l||($(a instanceof j?Q(a.status):"failed"),i("form"))}),()=>{l=!0}},[n,D]),e(z,{stage:b,productName:y,startHref:h,email:r,wrong:k,trouble:F,linkGone:o,openTrouble:S,busy:w,onEmail:l=>{x(l),u(null),d(null)},onSubmit:async l=>{if(l.preventDefault(),m||w)return;const a=M(r);if(u(a),d(null),!a){T(!0);try{await U(p,r),c(!1),$(null),i("sent")}catch(R){const W=R instanceof j?Y(R.status,R.data):{email:null,trouble:"failed"};u(W.email),d(W.trouble)}finally{T(!1)}}},onAnother:()=>i("form"),onRetry:()=>{$(null),i("opening"),I(l=>l+1)}})}function z({stage:p,productName:y,startHref:h,email:m,wrong:n,trouble:b,linkGone:i=!1,openTrouble:r=null,busy:x=!1,onEmail:k,onSubmit:u,onAnother:F,onRetry:d}){const o=L();if(p==="opening")return e("div",{className:E,role:"status",children:e("p",{className:N,children:t.opening})});if(p==="sent"){const[c,S]=t.sentBody.split("{email}");return f("div",{className:E,children:[e("h2",{className:A,children:t.sentTitle}),f("p",{className:"mt-[10px]",children:[c,e("span",{className:"font-medium",children:m.trim()}),S]}),e("p",{className:`${N} mt-[10px]`,children:t.sentNote}),e("button",{type:"button",onClick:F,className:"mt-[18px] flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border border-line font-medium text-fg",children:t.another})]})}return f("form",{noValidate:!0,onSubmit:u,className:E,children:[e("h2",{className:A,children:t.title}),r?f(O,{children:[e("p",{role:"alert",className:`${v} mt-[10px]`,children:r==="unreachable"||r==="tooMany"?g.trouble[r]:t.openFailed}),e("button",{type:"button",onClick:d,className:"mt-3 flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border border-line font-medium text-fg",children:t.retry})]}):i?e("p",{role:"alert",className:`${v} mt-[10px]`,children:t.linkGone}):e("p",{className:`${N} mt-1`,children:t.intro}),e("label",{htmlFor:`${o}-email`,className:"mb-1 mt-3 block text-[13px] font-medium",children:g.email}),e("div",{className:`flex h-11 items-center rounded-[10px] border bg-bg px-3 ${n?"border-alert":"border-line focus-within:border-accent"}`,children:e("input",{id:`${o}-email`,name:"email",type:"email",autoComplete:"email",maxLength:254,value:m,"aria-invalid":n?!0:void 0,"aria-describedby":n?`${o}-email-said`:void 0,onChange:c=>k?.(c.target.value),className:"h-full w-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none!"})}),n&&e("p",{id:`${o}-email-said`,role:"alert",className:"mt-1 text-[13px] text-alert",children:n}),b&&e("p",{role:"alert",className:v,children:g.trouble[b]}),e("button",{type:"submit",disabled:x,className:P,children:x?g.sending:t.submit}),h&&f("p",{className:`${N} mt-3 text-center`,children:[V(t.newHere,{name:y})," ",e(_,{href:h,className:"text-accent",children:t.create})]})]})}export{z as SignUpFindView,q as default};
1
+ "use client";import{jsx as e,jsxs as x,Fragment as L}from"react/jsx-runtime";import U from"next/link";import{usePathname as B}from"next/navigation";import{useEffect as A,useId as P,useRef as D,useState as l}from"react";import{ApiError as O,askForWorkspaces as M,openWorkspaceFind as V}from"../lib/api/index.js";import{BANNER as w,CARD as I,PRIMARY as H,QUIET as g,TITLE as _}from"../lib/sections/sign-up-look.js";import{FIND_WORDS as t,SIGN_UP_WORDS as y,checkWaitingEmail as Q,fill as Y,findTokenOf as q,readFindOpenTrouble as z,readFindRefusal as J}from"../lib/sections/sign-up.js";function K({product:o,productName:k,startHref:F,inert:d=!1}){const c=d?"":q(B()),[m,r]=l(c?"opening":"form"),[$,s]=l(),[u,R]=l(""),[S,f]=l(null),[v,a]=l(null),[N,p]=l(!1),[h,b]=l(null),[C,G]=l(0),[T,W]=l(!1);return A(()=>{if(!c)return;let n=!1;return V(c).then(i=>{n||(i?window.location.assign(i):(p(!0),r("form")))}).catch(i=>{n||(b(i instanceof O?z(i.status):"failed"),r("form"))}),()=>{n=!0}},[c,C]),e(X,{stage:m,focus:$,productName:k,startHref:F,email:u,wrong:S,trouble:v,linkGone:N,openTrouble:h,busy:T,onEmail:n=>{R(n),f(null),a(null)},onSubmit:async n=>{if(n.preventDefault(),d||T)return;const i=Q(u);if(f(i),a(null),!i){W(!0);try{await M(o,u),p(!1),b(null),s("sent"),r("sent")}catch(E){const j=E instanceof O?J(E.status,E.data):{email:null,trouble:"failed"};f(j.email),a(j.trouble)}finally{W(!1)}}},onAnother:()=>{s("form"),r("form")},onRetry:()=>{b(null),s(void 0),r("opening"),G(n=>n+1)}})}function X({stage:o,focus:k,productName:F,startHref:d,email:c,wrong:m,trouble:r,linkGone:$=!1,openTrouble:s=null,busy:u=!1,onEmail:R,onSubmit:S,onAnother:f,onRetry:v}){const a=P(),N=D(null),p=D(null);if(A(()=>{k===o&&(o==="sent"?N:p).current?.focus()},[o]),o==="opening")return e("div",{className:I,role:"status",children:e("p",{className:g,children:t.opening})});if(o==="sent"){const[h,b]=t.sentBody.split("{email}");return x("div",{className:I,children:[e("h2",{ref:N,tabIndex:-1,className:`${_} outline-none`,children:t.sentTitle}),x("p",{className:"mt-[10px]",children:[h,e("span",{className:"font-medium",children:c.trim()}),b]}),e("p",{className:`${g} mt-[10px]`,children:t.sentNote}),e("button",{type:"button",onClick:f,className:"mt-[18px] flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border border-line font-medium text-fg",children:t.another})]})}return x("form",{noValidate:!0,onSubmit:S,className:I,children:[e("h2",{className:_,children:t.title}),s?x(L,{children:[e("p",{role:"alert",className:`${w} mt-[10px]`,children:s==="unreachable"||s==="tooMany"?y.trouble[s]:t.openFailed}),e("button",{type:"button",onClick:v,className:"mt-3 flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border border-line font-medium text-fg",children:t.retry})]}):$?e("p",{role:"alert",className:`${w} mt-[10px]`,children:t.linkGone}):e("p",{className:`${g} mt-1`,children:t.intro}),e("label",{htmlFor:`${a}-email`,className:"mb-1 mt-3 block text-[13px] font-medium",children:y.email}),e("div",{className:`flex h-11 items-center rounded-[10px] border bg-bg px-3 ${m?"border-alert":"border-line focus-within:border-accent"}`,children:e("input",{ref:p,id:`${a}-email`,name:"email",type:"email",autoComplete:"email",maxLength:254,value:c,"aria-invalid":m?!0:void 0,"aria-describedby":m?`${a}-email-said`:void 0,onChange:h=>R?.(h.target.value),className:"h-full w-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none!"})}),m&&e("p",{id:`${a}-email-said`,role:"alert",className:"mt-1 text-[13px] text-alert",children:m}),r&&e("p",{role:"alert",className:w,children:y.trouble[r]}),e("button",{type:"submit",disabled:u,className:H,children:u?y.sending:t.submit}),d&&x("p",{className:`${g} mt-3 text-center`,children:[Y(t.newHere,{name:F})," ",e(U,{href:d,className:"text-accent",children:t.create})]})]})}export{X as SignUpFindView,K as default};
@@ -17,6 +17,7 @@ type Stage = "form" | "sent" | "closed";
17
17
  export default function SignUp(props: SignUpProps): import("react").JSX.Element;
18
18
  interface SignUpViewProps {
19
19
  stage: Stage;
20
+ focus?: Stage;
20
21
  product?: string;
21
22
  onOpen?: () => void;
22
23
  productName: string;
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as x,Fragment as K}from"react/jsx-runtime";import le from"next/link";import{usePathname as ce}from"next/navigation";import{useEffect as P,useId as J,useMemo as ee,useRef as oe,useState as m}from"react";import Q from"efficient-web-builder/render/components/BlockFrame";import{userZone as ue}from"efficient-shell/format";import{ApiError as ne,askToSignUp as de,fetchSignUpAvailability as te,joinSignUpWaitingList as me}from"../lib/api/index.js";import fe from"./SignUpFind.js";import he from"./SignUpLink.js";import{BANNER as X,CARD as Z,PRIMARY as re,QUIET as E,TITLE as q}from"../lib/sections/sign-up-look.js";import{ROW_INPUT_CLASS as pe}from"../lib/field-input.js";import{COUNTRY_CURRENCY as ge}from"../lib/sections/sign-up-catalogue.js";import{CHECK_AFTER_MS as be,EMPTY_DRAFT as Ne,SIGN_UP_WORDS as n,addressSuffix as ae,checkDraft as ye,checkWaitingEmail as xe,countryChoices as ve,currencyChoices as $e,fill as D,linkEnds as Se,linkTokenOf as ke,normaliseSlug as Ce,readSignUpRefusal as Ue,readWaitingRefusal as Re,signUpBody as Te,slugCheckOf as Ae,slugFromName as Ee}from"../lib/sections/sign-up.js";function Oe(t){return t.mode==="find"?e(Q,{contained:t.contained,className:"py-6",children:e(fe,{product:t.product,productName:t.productName,startHref:"/start",inert:!!t.sample})}):e(_e,{...t})}function _e({product:t,productName:a,freeLine:l,zone:i,askCountry:o,termsHref:u,privacyHref:c,findHref:s,contained:y,sample:p}){const[g,f]=m(p??Ne),[U,R]=m(!1),[B,O]=m({}),[T,S]=m(null),[b,h]=m("form"),[G,H]=m(null),[F,L]=m(!1),[_,j]=m(!1),[A,W]=m(()=>ae(i,"")),r=ke(ce()),k=!!r&&!p,w=we(t,g.slug,!!p||k);P(()=>{W(ae(i,window.location.hostname))},[i]),P(()=>{if(p||k)return;let d=!1;return te(t).then(N=>{d||(N.open||h("closed"),f(v=>({...v,country:v.country||N.country,currency:v.currency||N.currency})))}).catch(()=>{}),()=>{d=!0}},[t,p,k]);const C=d=>{f(N=>({...N,...d})),O(N=>{const v={...N};for(const se of Object.keys(d))delete v[se];return v}),S(null)},$=async d=>{L(!0),S(null);try{H(await de(Te(g,t,o))),j(d),h("sent")}catch(N){const v=N instanceof ne?Ue(N.status,N.data):{fields:{},trouble:"failed"};v.trouble==="closed"?h("closed"):Object.keys(v.fields).length?(O(v.fields),h("form")):S(v.trouble)}finally{L(!1)}},I=d=>{if(d.preventDefault(),p||F)return;const N=ye(g,w);O(N),!Object.keys(N).length&&$(!1)};return k?e(Q,{contained:y,className:"py-6",children:e(he,{token:r,productName:a,suffix:A,startHref:"/start",findHref:s})}):e(Q,{contained:y,className:"py-6",children:e(Be,{stage:b,product:t,onOpen:()=>h("form"),productName:a,freeLine:l,suffix:A,askCountry:o,termsHref:u,privacyHref:c,findHref:s,draft:g,wrong:B,slug:w,trouble:T,busy:F,sent:G,resent:_,onChange:C,onCompany:d=>C(U?{company:d}:{company:d,slug:Ee(d)}),onSlug:d=>{R(!0),C({slug:Ce(d)})},onCountry:d=>C({country:d,currency:ge[d]??g.currency}),onSubmit:I,onAgain:()=>{$(!0)},onEdit:()=>{R(!0),S(null),h("form")}})})}function we(t,a,l){const[i,o]=m({slug:"",found:{state:"empty"}}),u=oe("");return P(()=>{if(l||!a)return;u.current=a;const c=window.setTimeout(()=>{te(t,a).then(s=>{u.current===a&&o({slug:a,found:Ae(s)})}).catch(()=>{u.current===a&&o({slug:a,found:{state:"unknown"}})})},be);return()=>window.clearTimeout(c)},[t,a,l]),l?{state:"available"}:a?i.slug===a?i.found:{state:"checking"}:{state:"empty"}}const M="flex h-11 items-center rounded-[10px] border bg-bg px-3",z="h-full w-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none! placeholder:text-fg-dim",ie="flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border font-medium text-fg disabled:cursor-wait disabled:opacity-60";function Be(t){const{stage:a,productName:l,findHref:i,trouble:o}=t,u=i?x("p",{className:`${E} mt-[10px] text-center`,children:[n.haveOne," ",e(le,{href:i,className:"text-accent",children:n.find})]}):null;return a==="closed"?e(He,{...t,children:u}):a==="sent"?e(Le,{...t}):e(De,{...t,trouble:o,children:u})}function Y({id:t,label:a,error:l,hint:i,children:o}){return x("div",{className:"min-w-0",children:[e("label",{htmlFor:t,className:"mb-1 mt-3 block text-[13px] font-medium",children:a}),o,l?e("p",{id:`${t}-said`,role:"alert",className:"mt-1 text-[13px] text-alert",children:l}):i&&e("p",{id:`${t}-said`,className:"mt-1 text-[13px]",children:i})]})}const V=t=>t?"border-alert":"border-line focus-within:border-accent";function De({productName:t,freeLine:a,suffix:l,askCountry:i,termsHref:o,privacyHref:u,draft:c,wrong:s,slug:y,trouble:p,busy:g=!1,locale:f,onChange:U,onCompany:R,onSlug:B,onCountry:O,onSubmit:T,children:S}){const b=J(),[h,G]=m(f!==void 0);P(()=>G(!0),[]);const H=r=>r?[{value:r,label:r}]:[],F=ee(()=>i?h?ve(c.country,f):H(c.country):[],[i,h,c.country,f]),L=ee(()=>i?h?$e(c.currency,f):H(c.currency):[],[i,h,c.currency,f]),_=(r,k,w,C,$)=>e(Y,{id:`${b}-${r}`,label:k,error:s[r],children:e("div",{className:`${M} ${V(s[r])}`,children:e("input",{id:`${b}-${r}`,name:r,type:w,autoComplete:C,maxLength:$,value:c[r],"aria-invalid":s[r]?!0:void 0,"aria-describedby":s[r]?`${b}-${r}-said`:void 0,onChange:I=>r==="company"?R?.(I.target.value):U?.({[r]:I.target.value}),className:z})})}),j=(r,k,w,C)=>e(Y,{id:`${b}-${r}`,label:k,error:s[r],children:e("div",{className:`${M} ${V(s[r])}`,children:e("select",{id:`${b}-${r}`,name:r,value:c[r],"aria-invalid":s[r]?!0:void 0,onChange:$=>C($.target.value),className:`${z} cursor-pointer`,children:w.map($=>e("option",{value:$.value,children:$.label},$.value))})})}),A=s.slug??(y.state==="problem"?n.slugProblem[y.problem]:void 0),W=y.state==="checking"?e("span",{className:"text-fg-dim",children:n.checking}):y.state==="available"?x("span",{className:"text-green",children:[e("span",{"aria-hidden":!0,children:"✓ "}),n.available]}):void 0;return x("form",{noValidate:!0,onSubmit:T,className:Z,children:[e("h2",{className:q,children:D(n.title,{name:t})}),a&&e("p",{className:`${E} mt-1`,children:a}),x("div",{className:"grid grid-cols-2 gap-[10px]",children:[_("firstName",n.firstName,"text","given-name",150),_("lastName",n.lastName,"text","family-name",150)]}),_("email",n.email,"email","email",254),_("company",n.company,"text","organization",200),e(Y,{id:`${b}-slug`,label:n.address,error:A,hint:W,children:x("div",{className:`${M} gap-2 ${V(A)}`,children:[e("input",{id:`${b}-slug`,name:"slug",type:"text",autoComplete:"off",autoCapitalize:"none",spellCheck:!1,maxLength:30,value:c.slug,"aria-invalid":A?!0:void 0,"aria-describedby":A||W?`${b}-slug-said`:void 0,onChange:r=>B?.(r.target.value),className:`${pe} h-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none!`}),l&&e("span",{className:`${E} shrink-0`,children:l})]})}),i&&x(K,{children:[j("country",n.country,F,r=>O?.(r)),j("currency",n.currency,L,r=>U?.({currency:r})),e("p",{className:`${E} mt-[6px]`,children:n.countryHint})]}),p&&e("p",{role:"alert",className:X,children:n.trouble[p]}),e("button",{type:"submit",disabled:g,className:re,children:g?n.sending:n.submit}),e("p",{className:`${E} mt-3 text-center`,children:e(Fe,{termsHref:o,privacyHref:u})}),S]})}function He({product:t="",productName:a,children:l,onOpen:i}){const o=J(),[u,c]=m(""),[s,y]=m(null),[p,g]=m(null),[f,U]=m(!1),[R,B]=m(!1);return x("form",{noValidate:!0,onSubmit:async T=>{if(T.preventDefault(),f)return;const S=xe(u);if(y(S),g(null),!S){U(!0);try{await me(t,u),B(!0)}catch(b){const h=b instanceof ne?Re(b.status,b.data):{open:!1,email:null,trouble:"failed"};h.open&&i?.(),y(h.email),g(h.trouble)}finally{U(!1)}}},className:Z,children:[e("h2",{className:q,children:n.closedTitle}),x("p",{className:"mt-[10px]",children:[D(n.closedBody,{name:a})," ",R?"":n.closedLeave]}),R?e("p",{role:"status",className:"mt-[10px] font-medium",children:D(n.waitingDone,{email:u.trim()})}):x(K,{children:[e(Y,{id:`${o}-email`,label:n.email,error:s??void 0,children:e("div",{className:`${M} ${V(s??void 0)}`,children:e("input",{id:`${o}-email`,name:"email",type:"email",autoComplete:"email",maxLength:254,value:u,"aria-invalid":s?!0:void 0,"aria-describedby":s?`${o}-email-said`:void 0,onChange:T=>{c(T.target.value),y(null),g(null)},className:z})})}),p&&e("p",{role:"alert",className:X,children:n.trouble[p]}),e("button",{type:"submit",disabled:f,className:re,children:f?n.sending:n.tellMe})]}),l]})}function Fe({termsHref:t,privacyHref:a}){const l=(c,s)=>c?e("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2",children:s}):s,[i,o,u]=n.agree.split(/\{terms\}|\{privacy\}/);return x(K,{children:[i,l(t,n.terms),o,l(a,n.privacy),u]})}function Le({draft:t,sent:a,trouble:l,busy:i=!1,resent:o=!1,locale:u,timeZone:c,onAgain:s,onEdit:y}){const[p,g]=D(n.sentBody,{company:t.company.trim()}).split("{email}"),f=Se(a?.expiresAt??"",u,c??ue()??"");return x("div",{className:Z,children:[e("h2",{className:q,children:n.sentTitle}),x("p",{className:"mt-[10px]",children:[p,e("span",{className:"font-medium",children:t.email.trim()}),g]}),f&&e("p",{className:`${E} mt-[10px]`,children:D(n.sentUntil,{when:f})}),l?e("p",{role:"alert",className:X,children:n.trouble[l]}):o&&!i&&e("p",{role:"status",className:`${E} mt-[10px]`,children:n.sentAgain}),e("button",{type:"button",disabled:i,onClick:s,className:`${ie} mt-[18px] border-line`,children:i?n.sendingAgain:n.sendAgain}),e("button",{type:"button",disabled:i,onClick:y,className:`${ie} mt-2 border-transparent`,children:n.change})]})}export{Be as SignUpView,Oe as default};
1
+ "use client";import{jsx as e,jsxs as y,Fragment as X}from"react/jsx-runtime";import ue from"next/link";import{usePathname as de}from"next/navigation";import{useEffect as D,useId as te,useMemo as re,useRef as Z,useState as f}from"react";import q from"efficient-web-builder/render/components/BlockFrame";import{userZone as me}from"efficient-shell/format";import{ApiError as ae,askToSignUp as fe,fetchSignUpAvailability as se,joinSignUpWaitingList as he}from"../lib/api/index.js";import pe from"./SignUpFind.js";import ge from"./SignUpLink.js";import{BANNER as z,CARD as J,PRIMARY as ie,QUIET as O,TITLE as ee}from"../lib/sections/sign-up-look.js";import{ROW_INPUT_CLASS as be}from"../lib/field-input.js";import{COUNTRY_CURRENCY as Ne}from"../lib/sections/sign-up-catalogue.js";import{CHECK_AFTER_MS as ye,EMPTY_DRAFT as xe,SIGN_UP_WORDS as n,addressSuffix as le,checkDraft as ve,checkWaitingEmail as $e,countryChoices as Se,currencyChoices as ke,fill as H,linkEnds as Ce,linkTokenOf as Ue,normaliseSlug as Re,readSignUpRefusal as Te,readWaitingRefusal as Ae,signUpBody as Ee,slugCheckOf as Oe,slugFromName as _e}from"../lib/sections/sign-up.js";function we(t){return t.mode==="find"?e(q,{contained:t.contained,className:"py-6",children:e(pe,{product:t.product,productName:t.productName,startHref:"/start",inert:!!t.sample})}):e(Be,{...t})}function Be({product:t,productName:a,freeLine:l,zone:s,askCountry:o,termsHref:u,privacyHref:c,findHref:i,contained:b,sample:h}){const[p,$]=f(h??xe),[N,x]=f(!1),[F,_]=f({}),[R,k]=f(null),[T,d]=f("form"),[L,A]=f(),[Q,j]=f(null),[I,W]=f(!1),[w,P]=f(!1),[E,M]=f(()=>le(s,"")),r=Ue(de()),C=!!r&&!h,B=De(t,p.slug,!!h||C);D(()=>{M(le(s,window.location.hostname))},[s]),D(()=>{if(h||C)return;let m=!1;return se(t).then(g=>{m||(g.open||d("closed"),$(v=>({...v,country:v.country||g.country,currency:v.currency||g.currency})))}).catch(()=>{}),()=>{m=!0}},[t,h,C]);const U=m=>{$(g=>({...g,...m})),_(g=>{const v={...g};for(const oe of Object.keys(m))delete v[oe];return v}),k(null)},S=async m=>{W(!0),k(null);try{j(await fe(Ee(p,t,o))),P(m),m||A("sent"),d("sent")}catch(g){const v=g instanceof ae?Te(g.status,g.data):{fields:{},trouble:"failed"};v.trouble==="closed"?d("closed"):Object.keys(v.fields).length?(_(v.fields),d("form")):k(v.trouble)}finally{W(!1)}},Y=m=>{if(m.preventDefault(),h||I)return;const g=ve(p,B);_(g),!Object.keys(g).length&&S(!1)};return C?e(q,{contained:b,className:"py-6",children:e(ge,{token:r,productName:a,suffix:E,startHref:"/start",findHref:i})}):e(q,{contained:b,className:"py-6",children:e(Fe,{stage:T,focus:L,product:t,onOpen:()=>d("form"),productName:a,freeLine:l,suffix:E,askCountry:o,termsHref:u,privacyHref:c,findHref:i,draft:p,wrong:F,slug:B,trouble:R,busy:I,sent:Q,resent:w,onChange:U,onCompany:m=>U(N?{company:m}:{company:m,slug:_e(m)}),onSlug:m=>{x(!0),U({slug:Re(m)})},onCountry:m=>U({country:m,currency:Ne[m]??p.currency}),onSubmit:Y,onAgain:()=>{S(!0)},onEdit:()=>{x(!0),k(null),A("form"),d("form")}})})}function De(t,a,l){const[s,o]=f({slug:"",found:{state:"empty"}}),u=Z("");return D(()=>{if(l||!a)return;u.current=a;const c=window.setTimeout(()=>{se(t,a).then(i=>{u.current===a&&o({slug:a,found:Oe(i)})}).catch(()=>{u.current===a&&o({slug:a,found:{state:"unknown"}})})},ye);return()=>window.clearTimeout(c)},[t,a,l]),l?{state:"available"}:a?s.slug===a?s.found:{state:"checking"}:{state:"empty"}}const V="flex h-11 items-center rounded-[10px] border bg-bg px-3",ne="h-full w-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none! placeholder:text-fg-dim",ce="flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border font-medium text-fg disabled:cursor-wait disabled:opacity-60";function Fe(t){const{stage:a,productName:l,findHref:s,trouble:o}=t,u=s?y("p",{className:`${O} mt-[10px] text-center`,children:[n.haveOne," ",e(ue,{href:s,className:"text-accent",children:n.find})]}):null;return a==="closed"?e(Le,{...t,children:u}):a==="sent"?e(Ie,{...t}):e(He,{...t,trouble:o,children:u})}function G({id:t,label:a,error:l,hint:s,children:o}){return y("div",{className:"min-w-0",children:[e("label",{htmlFor:t,className:"mb-1 mt-3 block text-[13px] font-medium",children:a}),o,l?e("p",{id:`${t}-said`,role:"alert",className:"mt-1 text-[13px] text-alert",children:l}):s&&e("p",{id:`${t}-said`,className:"mt-1 text-[13px]",children:s})]})}const K=t=>t?"border-alert":"border-line focus-within:border-accent";function He({productName:t,freeLine:a,suffix:l,askCountry:s,termsHref:o,privacyHref:u,draft:c,wrong:i,slug:b,trouble:h,busy:p=!1,focus:$,locale:N,onChange:x,onCompany:F,onSlug:_,onCountry:R,onSubmit:k,children:T}){const d=te(),L=Z(null);D(()=>{$==="form"&&L.current?.focus()},[]);const[A,Q]=f(N!==void 0);D(()=>Q(!0),[]);const j=r=>r?[{value:r,label:r}]:[],I=re(()=>s?A?Se(c.country,N):j(c.country):[],[s,A,c.country,N]),W=re(()=>s?A?ke(c.currency,N):j(c.currency):[],[s,A,c.currency,N]),w=(r,C,B,U,S)=>e(G,{id:`${d}-${r}`,label:C,error:i[r],children:e("div",{className:`${V} ${K(i[r])}`,children:e("input",{ref:r==="firstName"?L:void 0,id:`${d}-${r}`,name:r,type:B,autoComplete:U,maxLength:S,value:c[r],"aria-invalid":i[r]?!0:void 0,"aria-describedby":i[r]?`${d}-${r}-said`:void 0,onChange:Y=>r==="company"?F?.(Y.target.value):x?.({[r]:Y.target.value}),className:ne})})}),P=(r,C,B,U)=>e(G,{id:`${d}-${r}`,label:C,error:i[r],children:e("div",{className:`${V} ${K(i[r])}`,children:e("select",{id:`${d}-${r}`,name:r,value:c[r],"aria-invalid":i[r]?!0:void 0,onChange:S=>U(S.target.value),className:`${ne} cursor-pointer`,children:B.map(S=>e("option",{value:S.value,children:S.label},S.value))})})}),E=i.slug??(b.state==="problem"?n.slugProblem[b.problem]:void 0),M=b.state==="checking"?e("span",{className:"text-fg-dim",children:n.checking}):b.state==="available"?y("span",{className:"text-green",children:[e("span",{"aria-hidden":!0,children:"✓ "}),n.available]}):void 0;return y("form",{noValidate:!0,onSubmit:k,className:J,children:[e("h2",{className:ee,children:H(n.title,{name:t})}),a&&e("p",{className:`${O} mt-1`,children:a}),y("div",{className:"grid grid-cols-2 gap-[10px]",children:[w("firstName",n.firstName,"text","given-name",150),w("lastName",n.lastName,"text","family-name",150)]}),w("email",n.email,"email","email",254),w("company",n.company,"text","organization",200),e(G,{id:`${d}-slug`,label:n.address,error:E,hint:M,children:y("div",{className:`${V} gap-2 ${K(E)}`,children:[e("input",{id:`${d}-slug`,name:"slug",type:"text",autoComplete:"off",autoCapitalize:"none",spellCheck:!1,maxLength:30,value:c.slug,"aria-invalid":E?!0:void 0,"aria-describedby":E||M?`${d}-slug-said`:void 0,onChange:r=>_?.(r.target.value),className:`${be} h-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none!`}),l&&e("span",{className:`${O} shrink-0`,children:l})]})}),s&&y(X,{children:[P("country",n.country,I,r=>R?.(r)),P("currency",n.currency,W,r=>x?.({currency:r})),e("p",{className:`${O} mt-[6px]`,children:n.countryHint})]}),h&&e("p",{role:"alert",className:z,children:n.trouble[h]}),e("button",{type:"submit",disabled:p,className:ie,children:p?n.sending:n.submit}),e("p",{className:`${O} mt-3 text-center`,children:e(je,{termsHref:o,privacyHref:u})}),T]})}function Le({product:t="",productName:a,children:l,onOpen:s}){const o=te(),[u,c]=f(""),[i,b]=f(null),[h,p]=f(null),[$,N]=f(!1),[x,F]=f(!1);return y("form",{noValidate:!0,onSubmit:async R=>{if(R.preventDefault(),$)return;const k=$e(u);if(b(k),p(null),!k){N(!0);try{await he(t,u),F(!0)}catch(T){const d=T instanceof ae?Ae(T.status,T.data):{open:!1,email:null,trouble:"failed"};d.open&&s?.(),b(d.email),p(d.trouble)}finally{N(!1)}}},className:J,children:[e("h2",{className:ee,children:n.closedTitle}),y("p",{className:"mt-[10px]",children:[H(n.closedBody,{name:a})," ",x?"":n.closedLeave]}),x?e("p",{role:"status",className:"mt-[10px] font-medium",children:H(n.waitingDone,{email:u.trim()})}):y(X,{children:[e(G,{id:`${o}-email`,label:n.email,error:i??void 0,children:e("div",{className:`${V} ${K(i??void 0)}`,children:e("input",{id:`${o}-email`,name:"email",type:"email",autoComplete:"email",maxLength:254,value:u,"aria-invalid":i?!0:void 0,"aria-describedby":i?`${o}-email-said`:void 0,onChange:R=>{c(R.target.value),b(null),p(null)},className:ne})})}),h&&e("p",{role:"alert",className:z,children:n.trouble[h]}),e("button",{type:"submit",disabled:$,className:ie,children:$?n.sending:n.tellMe})]}),l]})}function je({termsHref:t,privacyHref:a}){const l=(c,i)=>c?e("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2",children:i}):i,[s,o,u]=n.agree.split(/\{terms\}|\{privacy\}/);return y(X,{children:[s,l(t,n.terms),o,l(a,n.privacy),u]})}function Ie({draft:t,sent:a,trouble:l,busy:s=!1,resent:o=!1,focus:u,locale:c,timeZone:i,onAgain:b,onEdit:h}){const[p,$]=H(n.sentBody,{company:t.company.trim()}).split("{email}"),N=Ce(a?.expiresAt??"",c,i??me()??""),x=Z(null);return D(()=>{u==="sent"&&x.current?.focus()},[]),y("div",{className:J,children:[e("h2",{ref:x,tabIndex:-1,className:`${ee} outline-none`,children:n.sentTitle}),y("p",{className:"mt-[10px]",children:[p,e("span",{className:"font-medium",children:t.email.trim()}),$]}),N&&e("p",{className:`${O} mt-[10px]`,children:H(n.sentUntil,{when:N})}),l?e("p",{role:"alert",className:z,children:n.trouble[l]}):o&&!s&&e("p",{role:"status",className:`${O} mt-[10px]`,children:n.sentAgain}),e("button",{type:"button",disabled:s,onClick:b,className:`${ce} mt-[18px] border-line`,children:s?n.sendingAgain:n.sendAgain}),e("button",{type:"button",disabled:s,onClick:h,className:`${ce} mt-2 border-transparent`,children:n.change})]})}export{Fe as SignUpView,we as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efficient-storefront-blocks",
3
- "version": "0.120.0",
3
+ "version": "0.120.1",
4
4
  "description": "The EFFICIENT storefront's website editor — the website builder assembled with the storefront's own sections — for an app that edits a storefront website inside its own page. Built from the efficient-storefront-blocks repository.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Efficient Pty Ltd",