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
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
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.
|
|
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",
|