headroom-cms 0.1.10 → 0.1.11
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/README.md +11 -6
- package/admin/assets/{AdminsPage-BIWASote.js → AdminsPage-BnzH9TL3.js} +1 -1
- package/admin/assets/{AllContentPage-1gXe2OC7.js → AllContentPage-BtObN6oy.js} +1 -1
- package/admin/assets/{ApiKeysPage-BBW4ATBx.js → ApiKeysPage-DEAa8eyC.js} +1 -1
- package/admin/assets/{AuditPage-B5GGFWGG.js → AuditPage-BN9yNsxh.js} +1 -1
- package/admin/assets/{BlockEditor-ClskiZoX.js → BlockEditor-3wnisTOZ.js} +3 -3
- package/admin/assets/{BlockTypeEditPage-CY0gCPei.js → BlockTypeEditPage-C2evAESK.js} +1 -1
- package/admin/assets/{BlockTypesPage-D8Me6OeX.js → BlockTypesPage-Dhkho6T_.js} +1 -1
- package/admin/assets/{BulkActionBar--35xjnOP.js → BulkActionBar-BxdfUSrN.js} +1 -1
- package/admin/assets/CollectionEditPage-lOb4hEZy.js +1 -0
- package/admin/assets/{CollectionsPage-BQmGXpvW.js → CollectionsPage-CgtOloa1.js} +1 -1
- package/admin/assets/{ContentCreatePage-DlgxamOe.js → ContentCreatePage-LeQjahp_.js} +1 -1
- package/admin/assets/ContentEditPage-xczr4d_h.js +1 -0
- package/admin/assets/{ContentField-D04Uo1Ov.js → ContentField-pilCbdnA.js} +1 -1
- package/admin/assets/{ContentListPage-BDMx7pWb.js → ContentListPage-BAKDn1Xy.js} +1 -1
- package/admin/assets/{CustomBlockPreview-Cs9bFDh4.js → CustomBlockPreview-DNnTFM0z.js} +1 -1
- package/admin/assets/FieldRenderer-DiOKvkWV.js +2 -0
- package/admin/assets/{FilterBar-kFcOLffg.js → FilterBar-BZoa63zh.js} +1 -1
- package/admin/assets/{FloatingComposerController-D4uLQfUX-C0Lhbmda.js → FloatingComposerController-D4uLQfUX-BMIvFCoE.js} +1 -1
- package/admin/assets/{IconPicker-BrgSAsa_.js → IconPicker-CpIgiQTC.js} +2 -2
- package/admin/assets/{LoginPage-Bi7TBzK4.js → LoginPage-D9ZsGLIi.js} +1 -1
- package/admin/assets/{MediaField-B-Cz8TlK.js → MediaField-CxccCFGQ.js} +1 -1
- package/admin/assets/{MediaPage-C84p9d1U.js → MediaPage-QvMaH2YJ.js} +1 -1
- package/admin/assets/{Pagination-CuHwUPHi.js → Pagination-Df9nQ7Z0.js} +1 -1
- package/admin/assets/{RelationshipPicker-Dv7GaLcU.js → RelationshipPicker-B3Ftmqxp.js} +1 -1
- package/admin/assets/{SiteSettingsPage-nBT7NzkA.js → SiteSettingsPage-6NvH7CiQ.js} +1 -1
- package/admin/assets/{SiteUserEditPage-DroUTii9.js → SiteUserEditPage-D5VaQ1Xq.js} +1 -1
- package/admin/assets/{SiteUsersPage-iVXPCBPe.js → SiteUsersPage-BYVduiqs.js} +1 -1
- package/admin/assets/{SitesPage-BefZeWuJ.js → SitesPage-rfWWE0yK.js} +1 -1
- package/admin/assets/{SubmissionDetailPage-ktmzzOE1.js → SubmissionDetailPage-BSUR685F.js} +1 -1
- package/admin/assets/{SubmissionEditPage-C-ykTI2t.js → SubmissionEditPage-DjLXHjWU.js} +1 -1
- package/admin/assets/{SubmissionListPage-DA-8deUy.js → SubmissionListPage-DBxNEvde.js} +1 -1
- package/admin/assets/{TagInput-d-Hw1fkL.js → TagInput-57c4DG1w.js} +1 -1
- package/admin/assets/{TagsPage-BZzDvcKa.js → TagsPage-BEO5AwCv.js} +1 -1
- package/admin/assets/{UsersPage-CnQAOOGF.js → UsersPage-BpIRorJ1.js} +1 -1
- package/admin/assets/{WebhookEditPage-KeS8hmdW.js → WebhookEditPage-D5xgi56h.js} +1 -1
- package/admin/assets/{WebhooksPage-CASjmlPN.js → WebhooksPage-BY7AaiGr.js} +1 -1
- package/admin/assets/{card-CZTHR2Qa.js → card-C9hfyHXf.js} +1 -1
- package/admin/assets/{checkbox-DEgzM8H9.js → checkbox-DVJcwUt1.js} +1 -1
- package/admin/assets/{command-CdzYw11U.js → command-Bfmj0MEL.js} +1 -1
- package/admin/assets/index-BB9Syqw2.css +1 -0
- package/admin/assets/{index-BA3y7HJs.js → index-Ce5pmRMj.js} +2 -2
- package/admin/assets/media-url-DdCoIedP.js +1 -0
- package/admin/assets/{popover-BFw_h3j6.js → popover-CzaQYEEP.js} +1 -1
- package/admin/assets/{select-dX9e6VDt.js → select-CrRhFGIi.js} +1 -1
- package/admin/assets/serializeToText-2VrsuRUh.js +2 -0
- package/admin/assets/{table-Dk7eeOt2.js → table-_3bMY0_z.js} +1 -1
- package/admin/assets/{textarea-CpDSUg2s.js → textarea-6fq0R6VV.js} +1 -1
- package/admin/assets/{useAdminResolver-Bljb4XGQ.js → useAdminResolver-BJNPz3OG.js} +1 -1
- package/admin/assets/{useContent-CW0tm0FY.js → useContent-Bs7nel7C.js} +1 -1
- package/admin/assets/{useContentSearch-_bwacEth.js → useContentSearch-B3aTjuCu.js} +1 -1
- package/admin/assets/{useMedia-Cu5N4rY8.js → useMedia-ae3s_ajC.js} +1 -1
- package/admin/assets/{usePageTitle-DYvuJQp6.js → usePageTitle-C1r1-C00.js} +1 -1
- package/admin/assets/{useSiteUsers-CKtC_8Jc.js → useSiteUsers-DIaqgNSp.js} +1 -1
- package/admin/assets/{useTags-ybsMbCst.js → useTags-B-HgMVwo.js} +1 -1
- package/admin/assets/{useWebhooks-BAB-3sLa.js → useWebhooks-BvZjUJkJ.js} +1 -1
- package/admin/favicon-16x16.png +0 -0
- package/admin/favicon-32x32.png +0 -0
- package/admin/icons/icon-180x180.png +0 -0
- package/admin/icons/icon-192x192.png +0 -0
- package/admin/icons/icon-512x512.png +0 -0
- package/admin/icons/maskable-icon-512x512.png +0 -0
- package/admin/index.html +2 -2
- package/admin/sw.js +1 -1
- package/dist/admin-site.d.ts +4 -2
- package/dist/admin-site.d.ts.map +1 -1
- package/dist/admin-site.js +3 -3
- package/dist/admin-site.js.map +1 -1
- package/dist/cdn-api.d.ts +25 -0
- package/dist/cdn-api.d.ts.map +1 -0
- package/dist/{cdn.js → cdn-api.js} +7 -139
- package/dist/cdn-api.js.map +1 -0
- package/dist/cdn-media.d.ts +26 -0
- package/dist/cdn-media.d.ts.map +1 -0
- package/dist/cdn-media.js +202 -0
- package/dist/cdn-media.js.map +1 -0
- package/dist/index.d.ts +15 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -9
- package/dist/index.js.map +1 -1
- package/lambda/api/bootstrap +0 -0
- package/lambda/image-lambda/node_modules/.package-lock.json +3 -3
- package/lambda/image-lambda/node_modules/semver/README.md +19 -4
- package/lambda/image-lambda/node_modules/semver/bin/semver.js +14 -10
- package/lambda/image-lambda/node_modules/semver/functions/truncate.js +48 -0
- package/lambda/image-lambda/node_modules/semver/index.js +2 -0
- package/lambda/image-lambda/node_modules/semver/internal/re.js +1 -1
- package/lambda/image-lambda/node_modules/semver/package.json +3 -3
- package/lambda/image-lambda/node_modules/semver/range.bnf +5 -4
- package/lambda/webhook-worker/bootstrap +0 -0
- package/package.json +1 -1
- package/src/admin-site.ts +7 -5
- package/src/{cdn.ts → cdn-api.ts} +8 -161
- package/src/cdn-media.ts +250 -0
- package/src/index.ts +34 -11
- package/admin/assets/CollectionEditPage-y8t0ZO89.js +0 -1
- package/admin/assets/ContentEditPage-WkSbCnnG.js +0 -1
- package/admin/assets/FieldRenderer-wE-mtqZB.js +0 -2
- package/admin/assets/index-c7UygSvP.css +0 -1
- package/admin/assets/media-url-DIg_vSyf.js +0 -1
- package/admin/assets/serializeToText-Zin3gYPm.js +0 -2
- package/dist/cdn.d.ts +0 -27
- package/dist/cdn.d.ts.map +0 -1
- package/dist/cdn.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,a as V}from"./tanstack-Bs3zYPPV.js";import{r as u,u as Z,f as z}from"./react-vendor-C2CvUxFh.js";import{L as r,I as m,B as c,v as n,aO as J,S as L,b7 as W,b8 as X,b9 as ee,aN as se,x as te,j as ae,a as C,aY as ie,D as M,k as I,l as B,m as U,n as q,o as _}from"./index-BA3y7HJs.js";import{C as T,a as w,b as k,d as re,c as F}from"./card-CZTHR2Qa.js";import{f as ne}from"./format-C88SDH8g.js";import{u as le}from"./usePageTitle-DYvuJQp6.js";import{u as oe,a as de,b as ce,c as me}from"./useSiteUsers-CKtC_8Jc.js";import{C as H}from"./checkbox-DEgzM8H9.js";import{T as R}from"./textarea-CpDSUg2s.js";import"./radix-C5ZmWuuL.js";function he({host:t}){const{data:h,isLoading:l}=oe(t),p=de(t),j=ce(t),v=me(t),[i,d]=u.useState({}),[x,f]=u.useState(""),[g,y]=u.useState("");u.useEffect(()=>{h&&d(h)},[h]);async function P(){try{await p.mutateAsync(i),n.success("Auth settings saved")}catch(s){n.error("Failed to save",{description:s instanceof Error?s.message:void 0})}}async function b(){if(x)try{await j.mutateAsync(x),n.success("Test email sent")}catch(s){n.error("Failed to send test email",{description:s instanceof Error?s.message:void 0})}}async function A(){if(g)try{const s=await v.mutateAsync(g);n.success(`OTP code: ${s.code}`,{description:`For ${s.email} — valid until ${new Date(s.expiresAt*1e3).toLocaleTimeString()}`,duration:15e3})}catch(s){n.error("Failed to fetch OTP",{description:s instanceof Error?s.message:void 0})}}if(l||!h)return null;const o=(i.mode??"test")!=="production";function S(s){d({...i,mode:s})}return e.jsxs(T,{children:[e.jsxs(w,{children:[e.jsx(k,{children:"Site Authentication"}),e.jsx(re,{children:"Enable email OTP authentication for site visitors."})]}),e.jsxs(F,{className:"space-y-6",children:[i.enabled&&e.jsx("div",{role:"status",className:o?"rounded-md border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-200":"rounded-md border border-emerald-300 bg-emerald-50 p-3 text-sm text-emerald-900 dark:border-emerald-800 dark:bg-emerald-950 dark:text-emerald-200",children:o?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Test Mode:"})," OTP codes are not currently sent via email. Retrieve the latest code for a user from the admin API or CLI (",e.jsx("code",{children:"headroom auth latest-otp"}),")."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Production Mode:"})," Auth is live. OTP codes are delivered to users via email using the templates below."]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(H,{id:"auth-enabled",checked:i.enabled??!1,onCheckedChange:s=>d({...i,enabled:s})}),e.jsx(r,{htmlFor:"auth-enabled",children:"Enable site auth"})]}),i.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Mode"}),e.jsxs("div",{className:"inline-flex rounded-md border p-0.5",role:"radiogroup","aria-label":"Auth mode",children:[e.jsx("button",{type:"button",role:"radio","aria-checked":o,onClick:()=>S("test"),className:"rounded px-3 py-1 text-sm transition-colors "+(o?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"),children:"Test"}),e.jsx("button",{type:"button",role:"radio","aria-checked":!o,onClick:()=>S("production"),className:"rounded px-3 py-1 text-sm transition-colors "+(o?"text-muted-foreground hover:text-foreground":"bg-primary text-primary-foreground"),children:"Production"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:o?"OTP codes are generated and stored but not emailed. Use the admin API or CLI to fetch the latest code for a user. Safe for development and automated testing.":"OTP codes are delivered via email using your configured templates. Only switch to Production when you're ready to accept real user logins."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(H,{id:"allow-signup",checked:i.allowSignup??!1,onCheckedChange:s=>d({...i,allowSignup:s})}),e.jsx(r,{htmlFor:"allow-signup",children:"Allow self-registration"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"session-ttl",children:"Session duration (days)"}),e.jsx(m,{id:"session-ttl",type:"number",min:1,value:Math.round((i.sessionTtl??2592e3)/86400),onChange:s=>d({...i,sessionTtl:parseInt(s.target.value)*86400})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-subject",children:"Email subject (Liquid)"}),e.jsx(m,{id:"email-subject",placeholder:"Your login code for {{ site_name }}",value:i.emailSubject??"",onChange:s=>d({...i,emailSubject:s.target.value})}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Variables: ","{{ code }}",", ","{{ site_name }}",", ","{{ user_email }}",", ","{{ user_name }}",", ","{{ expires_minutes }}"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-body",children:"Email HTML body (Liquid)"}),e.jsx(R,{id:"email-body",rows:5,placeholder:"<p>Your code: <strong>{{ code }}</strong></p>",value:i.emailBody??"",onChange:s=>d({...i,emailBody:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-text",children:"Email text body (Liquid)"}),e.jsx(R,{id:"email-text",rows:3,placeholder:"Your code: {{ code }}",value:i.emailTextBody??"",onChange:s=>d({...i,emailTextBody:s.target.value})})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(r,{htmlFor:"test-email",children:"Send test email"}),e.jsx(m,{id:"test-email",type:"email",placeholder:"admin@example.com",value:x,onChange:s=>f(s.target.value)})]}),e.jsx(c,{variant:"outline",onClick:b,disabled:j.isPending||!x,children:"Send"})]})}),o&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(r,{htmlFor:"otp-lookup-email",children:"Fetch latest OTP code"}),e.jsx(m,{id:"otp-lookup-email",type:"email",placeholder:"user@example.com",value:g,onChange:s=>y(s.target.value)})]}),e.jsx(c,{variant:"outline",onClick:A,disabled:v.isPending||!g,children:"Fetch"})]}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs",children:"Returns the latest unexpired OTP for the given email. Only works in test mode."})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(c,{onClick:P,disabled:p.isPending,children:"Save"})})]})]})}function Ce(){const{host:t}=Z(),{data:h,isLoading:l}=J(t);return l?e.jsxs("div",{className:"space-y-4",children:[e.jsx(L,{className:"h-8 w-64"}),e.jsx(L,{className:"h-48 w-full"})]}):h?e.jsx(ue,{site:h},h.host):e.jsx("p",{className:"text-muted-foreground",children:"Site not found."})}function ue({site:t}){const h=V(),l=W(t.host),p=X(t.host),j=ee(t.host),v=z(),d=se()==="admin",x=t.status==="archived",[f,g]=u.useState(t.name),[y,P]=u.useState(t.fromEmail??""),[b,A]=u.useState(t.fromName??""),[E,o]=u.useState(!1),[S,s]=u.useState(!1),[D,N]=u.useState(""),Y=te();le({title:"Configuration"});async function $(a){a.preventDefault();try{await l.mutateAsync({name:f,fromEmail:y,fromName:b}),n.success("Site updated")}catch(O){n.error("Failed to update site",{description:O instanceof Error?O.message:void 0})}}async function Q(){try{await l.mutateAsync({status:"archived"}),n.success("Site archived"),o(!1),v("/sites")}catch(a){n.error("Failed to archive site",{description:a instanceof Error?a.message:void 0})}}async function G(){try{await l.mutateAsync({status:"active"}),n.success("Site unarchived")}catch(a){n.error("Failed to unarchive site",{description:a instanceof Error?a.message:void 0})}}async function K(){try{await p.mutateAsync(),await j.mutateAsync(),await h.invalidateQueries({queryKey:["sites"]}),n.success("Site deleted"),s(!1),N(""),v("/sites")}catch(a){n.error("Failed to delete site",{description:a instanceof Error?a.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!Y&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Site Settings"}),e.jsxs(T,{children:[e.jsx(w,{children:e.jsx(k,{children:"General"})}),e.jsx(F,{children:e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"name",children:"Site Name"}),e.jsx(m,{id:"name",value:f,onChange:a=>g(a.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"fromEmail",children:"Sender email (optional)"}),e.jsx(m,{id:"fromEmail",type:"email",placeholder:"Uses global default",value:y,onChange:a=>P(a.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'"From" address for emails sent by this site. Must be verified in SES.'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"fromName",children:"Sender name (optional)"}),e.jsx(m,{id:"fromName",placeholder:"My Site",value:b,onChange:a=>A(a.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display name shown alongside the sender email address."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Host"}),e.jsx(m,{value:t.host,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Status"}),e.jsx("div",{className:"flex items-center gap-2",children:x?e.jsx(ae,{variant:"outline",children:"Archived"}):e.jsx(m,{value:t.status,disabled:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Created"}),e.jsx(m,{value:ne(t.createdAt),disabled:!0})]}),e.jsxs(c,{type:"submit",disabled:l.isPending,children:[l.isPending&&e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),d&&e.jsxs(T,{className:"mt-6",children:[e.jsx(w,{children:e.jsx(k,{children:"Site Status"})}),e.jsx(F,{className:"space-y-4",children:x?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"This site is archived. Unarchive it to allow content changes."}),e.jsxs(c,{variant:"outline",onClick:G,disabled:l.isPending,children:[l.isPending&&e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Unarchive Site"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Archiving a site makes it read-only. Content cannot be created or modified while archived."}),e.jsxs(c,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),"Archive Site"]}),e.jsx(M,{open:E,onOpenChange:o,children:e.jsxs(I,{children:[e.jsxs(B,{children:[e.jsx(U,{children:"Archive Site"}),e.jsxs(q,{children:["Are you sure you want to archive ",e.jsx("strong",{children:t.host}),"? The site will become read-only."]})]}),e.jsxs(_,{children:[e.jsx(c,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(c,{onClick:Q,disabled:l.isPending,children:[l.isPending&&e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Archive"]})]})]})})]})})]}),d&&e.jsx("div",{className:"mt-6",children:e.jsx(he,{host:t.host})}),d&&x&&e.jsxs(T,{className:"border-destructive mt-6",children:[e.jsx(w,{children:e.jsx(k,{className:"text-destructive",children:"Danger Zone"})}),e.jsxs(F,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Permanently delete this site and all its content, media, collections, and block types. This action cannot be undone."}),e.jsx(c,{variant:"destructive",onClick:()=>s(!0),children:"Delete Site"}),e.jsx(M,{open:S,onOpenChange:a=>{s(a),a||N("")},children:e.jsxs(I,{children:[e.jsxs(B,{children:[e.jsx(U,{children:"Delete Site"}),e.jsxs(q,{children:["This will permanently delete this site and all its content. Type ",e.jsx("strong",{children:t.host})," to confirm."]})]}),e.jsx(m,{placeholder:t.host,value:D,onChange:a=>N(a.target.value)}),e.jsxs(_,{children:[e.jsx(c,{variant:"outline",onClick:()=>{s(!1),N("")},children:"Cancel"}),e.jsxs(c,{variant:"destructive",onClick:K,disabled:D!==t.host||p.isPending||j.isPending,children:[(p.isPending||j.isPending)&&e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete Everything"]})]})]})})]})]})]})}export{Ce as SiteSettingsPage};
|
|
1
|
+
import{j as e,a as V}from"./tanstack-Bs3zYPPV.js";import{r as u,u as Z,f as z}from"./react-vendor-C2CvUxFh.js";import{L as r,I as m,B as c,v as n,aO as J,S as L,b7 as W,b8 as X,b9 as ee,aN as se,x as te,j as ae,a as C,aY as ie,D as M,k as I,l as B,m as U,n as q,o as _}from"./index-Ce5pmRMj.js";import{C as T,a as w,b as k,d as re,c as F}from"./card-C9hfyHXf.js";import{f as ne}from"./format-C88SDH8g.js";import{u as le}from"./usePageTitle-C1r1-C00.js";import{u as oe,a as de,b as ce,c as me}from"./useSiteUsers-DIaqgNSp.js";import{C as H}from"./checkbox-DVJcwUt1.js";import{T as R}from"./textarea-6fq0R6VV.js";import"./radix-C5ZmWuuL.js";function he({host:t}){const{data:h,isLoading:l}=oe(t),p=de(t),j=ce(t),v=me(t),[i,d]=u.useState({}),[x,f]=u.useState(""),[g,y]=u.useState("");u.useEffect(()=>{h&&d(h)},[h]);async function P(){try{await p.mutateAsync(i),n.success("Auth settings saved")}catch(s){n.error("Failed to save",{description:s instanceof Error?s.message:void 0})}}async function b(){if(x)try{await j.mutateAsync(x),n.success("Test email sent")}catch(s){n.error("Failed to send test email",{description:s instanceof Error?s.message:void 0})}}async function A(){if(g)try{const s=await v.mutateAsync(g);n.success(`OTP code: ${s.code}`,{description:`For ${s.email} — valid until ${new Date(s.expiresAt*1e3).toLocaleTimeString()}`,duration:15e3})}catch(s){n.error("Failed to fetch OTP",{description:s instanceof Error?s.message:void 0})}}if(l||!h)return null;const o=(i.mode??"test")!=="production";function S(s){d({...i,mode:s})}return e.jsxs(T,{children:[e.jsxs(w,{children:[e.jsx(k,{children:"Site Authentication"}),e.jsx(re,{children:"Enable email OTP authentication for site visitors."})]}),e.jsxs(F,{className:"space-y-6",children:[i.enabled&&e.jsx("div",{role:"status",className:o?"rounded-md border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-200":"rounded-md border border-emerald-300 bg-emerald-50 p-3 text-sm text-emerald-900 dark:border-emerald-800 dark:bg-emerald-950 dark:text-emerald-200",children:o?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Test Mode:"})," OTP codes are not currently sent via email. Retrieve the latest code for a user from the admin API or CLI (",e.jsx("code",{children:"headroom auth latest-otp"}),")."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Production Mode:"})," Auth is live. OTP codes are delivered to users via email using the templates below."]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(H,{id:"auth-enabled",checked:i.enabled??!1,onCheckedChange:s=>d({...i,enabled:s})}),e.jsx(r,{htmlFor:"auth-enabled",children:"Enable site auth"})]}),i.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Mode"}),e.jsxs("div",{className:"inline-flex rounded-md border p-0.5",role:"radiogroup","aria-label":"Auth mode",children:[e.jsx("button",{type:"button",role:"radio","aria-checked":o,onClick:()=>S("test"),className:"rounded px-3 py-1 text-sm transition-colors "+(o?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"),children:"Test"}),e.jsx("button",{type:"button",role:"radio","aria-checked":!o,onClick:()=>S("production"),className:"rounded px-3 py-1 text-sm transition-colors "+(o?"text-muted-foreground hover:text-foreground":"bg-primary text-primary-foreground"),children:"Production"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:o?"OTP codes are generated and stored but not emailed. Use the admin API or CLI to fetch the latest code for a user. Safe for development and automated testing.":"OTP codes are delivered via email using your configured templates. Only switch to Production when you're ready to accept real user logins."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(H,{id:"allow-signup",checked:i.allowSignup??!1,onCheckedChange:s=>d({...i,allowSignup:s})}),e.jsx(r,{htmlFor:"allow-signup",children:"Allow self-registration"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"session-ttl",children:"Session duration (days)"}),e.jsx(m,{id:"session-ttl",type:"number",min:1,value:Math.round((i.sessionTtl??2592e3)/86400),onChange:s=>d({...i,sessionTtl:parseInt(s.target.value)*86400})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-subject",children:"Email subject (Liquid)"}),e.jsx(m,{id:"email-subject",placeholder:"Your login code for {{ site_name }}",value:i.emailSubject??"",onChange:s=>d({...i,emailSubject:s.target.value})}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Variables: ","{{ code }}",", ","{{ site_name }}",", ","{{ user_email }}",", ","{{ user_name }}",", ","{{ expires_minutes }}"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-body",children:"Email HTML body (Liquid)"}),e.jsx(R,{id:"email-body",rows:5,placeholder:"<p>Your code: <strong>{{ code }}</strong></p>",value:i.emailBody??"",onChange:s=>d({...i,emailBody:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-text",children:"Email text body (Liquid)"}),e.jsx(R,{id:"email-text",rows:3,placeholder:"Your code: {{ code }}",value:i.emailTextBody??"",onChange:s=>d({...i,emailTextBody:s.target.value})})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(r,{htmlFor:"test-email",children:"Send test email"}),e.jsx(m,{id:"test-email",type:"email",placeholder:"admin@example.com",value:x,onChange:s=>f(s.target.value)})]}),e.jsx(c,{variant:"outline",onClick:b,disabled:j.isPending||!x,children:"Send"})]})}),o&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(r,{htmlFor:"otp-lookup-email",children:"Fetch latest OTP code"}),e.jsx(m,{id:"otp-lookup-email",type:"email",placeholder:"user@example.com",value:g,onChange:s=>y(s.target.value)})]}),e.jsx(c,{variant:"outline",onClick:A,disabled:v.isPending||!g,children:"Fetch"})]}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs",children:"Returns the latest unexpired OTP for the given email. Only works in test mode."})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(c,{onClick:P,disabled:p.isPending,children:"Save"})})]})]})}function Ce(){const{host:t}=Z(),{data:h,isLoading:l}=J(t);return l?e.jsxs("div",{className:"space-y-4",children:[e.jsx(L,{className:"h-8 w-64"}),e.jsx(L,{className:"h-48 w-full"})]}):h?e.jsx(ue,{site:h},h.host):e.jsx("p",{className:"text-muted-foreground",children:"Site not found."})}function ue({site:t}){const h=V(),l=W(t.host),p=X(t.host),j=ee(t.host),v=z(),d=se()==="admin",x=t.status==="archived",[f,g]=u.useState(t.name),[y,P]=u.useState(t.fromEmail??""),[b,A]=u.useState(t.fromName??""),[E,o]=u.useState(!1),[S,s]=u.useState(!1),[D,N]=u.useState(""),Y=te();le({title:"Configuration"});async function $(a){a.preventDefault();try{await l.mutateAsync({name:f,fromEmail:y,fromName:b}),n.success("Site updated")}catch(O){n.error("Failed to update site",{description:O instanceof Error?O.message:void 0})}}async function Q(){try{await l.mutateAsync({status:"archived"}),n.success("Site archived"),o(!1),v("/sites")}catch(a){n.error("Failed to archive site",{description:a instanceof Error?a.message:void 0})}}async function G(){try{await l.mutateAsync({status:"active"}),n.success("Site unarchived")}catch(a){n.error("Failed to unarchive site",{description:a instanceof Error?a.message:void 0})}}async function K(){try{await p.mutateAsync(),await j.mutateAsync(),await h.invalidateQueries({queryKey:["sites"]}),n.success("Site deleted"),s(!1),N(""),v("/sites")}catch(a){n.error("Failed to delete site",{description:a instanceof Error?a.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!Y&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Site Settings"}),e.jsxs(T,{children:[e.jsx(w,{children:e.jsx(k,{children:"General"})}),e.jsx(F,{children:e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"name",children:"Site Name"}),e.jsx(m,{id:"name",value:f,onChange:a=>g(a.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"fromEmail",children:"Sender email (optional)"}),e.jsx(m,{id:"fromEmail",type:"email",placeholder:"Uses global default",value:y,onChange:a=>P(a.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'"From" address for emails sent by this site. Must be verified in SES.'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"fromName",children:"Sender name (optional)"}),e.jsx(m,{id:"fromName",placeholder:"My Site",value:b,onChange:a=>A(a.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display name shown alongside the sender email address."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Host"}),e.jsx(m,{value:t.host,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Status"}),e.jsx("div",{className:"flex items-center gap-2",children:x?e.jsx(ae,{variant:"outline",children:"Archived"}):e.jsx(m,{value:t.status,disabled:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Created"}),e.jsx(m,{value:ne(t.createdAt),disabled:!0})]}),e.jsxs(c,{type:"submit",disabled:l.isPending,children:[l.isPending&&e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),d&&e.jsxs(T,{className:"mt-6",children:[e.jsx(w,{children:e.jsx(k,{children:"Site Status"})}),e.jsx(F,{className:"space-y-4",children:x?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"This site is archived. Unarchive it to allow content changes."}),e.jsxs(c,{variant:"outline",onClick:G,disabled:l.isPending,children:[l.isPending&&e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Unarchive Site"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Archiving a site makes it read-only. Content cannot be created or modified while archived."}),e.jsxs(c,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),"Archive Site"]}),e.jsx(M,{open:E,onOpenChange:o,children:e.jsxs(I,{children:[e.jsxs(B,{children:[e.jsx(U,{children:"Archive Site"}),e.jsxs(q,{children:["Are you sure you want to archive ",e.jsx("strong",{children:t.host}),"? The site will become read-only."]})]}),e.jsxs(_,{children:[e.jsx(c,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(c,{onClick:Q,disabled:l.isPending,children:[l.isPending&&e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Archive"]})]})]})})]})})]}),d&&e.jsx("div",{className:"mt-6",children:e.jsx(he,{host:t.host})}),d&&x&&e.jsxs(T,{className:"border-destructive mt-6",children:[e.jsx(w,{children:e.jsx(k,{className:"text-destructive",children:"Danger Zone"})}),e.jsxs(F,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Permanently delete this site and all its content, media, collections, and block types. This action cannot be undone."}),e.jsx(c,{variant:"destructive",onClick:()=>s(!0),children:"Delete Site"}),e.jsx(M,{open:S,onOpenChange:a=>{s(a),a||N("")},children:e.jsxs(I,{children:[e.jsxs(B,{children:[e.jsx(U,{children:"Delete Site"}),e.jsxs(q,{children:["This will permanently delete this site and all its content. Type ",e.jsx("strong",{children:t.host})," to confirm."]})]}),e.jsx(m,{placeholder:t.host,value:D,onChange:a=>N(a.target.value)}),e.jsxs(_,{children:[e.jsx(c,{variant:"outline",onClick:()=>{s(!1),N("")},children:"Cancel"}),e.jsxs(c,{variant:"destructive",onClick:K,disabled:D!==t.host||p.isPending||j.isPending,children:[(p.isPending||j.isPending)&&e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete Everything"]})]})]})})]})]})]})}export{Ce as SiteSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as R,f as V,r as n}from"./react-vendor-C2CvUxFh.js";import{g as $,h as q,i as z,f as X}from"./useSiteUsers-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as R,f as V,r as n}from"./react-vendor-C2CvUxFh.js";import{g as $,h as q,i as z,f as X}from"./useSiteUsers-DIaqgNSp.js";import{S as T,x as G,L as u,I as j,j as p,X as J,B as r,a as I,D as Q,i as W,T as Y,k as Z,l as _,m as ee,n as se,o as ae,v as l}from"./index-Ce5pmRMj.js";import{C as f,a as g,b as v,c as N}from"./card-C9hfyHXf.js";import{f as k}from"./format-C88SDH8g.js";import{u as te}from"./usePageTitle-C1r1-C00.js";import"./radix-C5ZmWuuL.js";function xe(){const{host:t,userId:a}=R(),{data:c,isLoading:d}=$(t,a);return d?e.jsxs("div",{className:"space-y-4",children:[e.jsx(T,{className:"h-8 w-64"}),e.jsx(T,{className:"h-64 w-full"})]}):c?e.jsx(ie,{host:t,user:c},c.userId):e.jsx("p",{className:"text-muted-foreground",children:"User not found."})}function ie({host:t,user:a}){const c=V(),d=q(t),x=z(t),y=X(t),A=G(),[b,L]=n.useState(a.name??""),[h,C]=n.useState(a.status),[o,D]=n.useState(a.tags??[]),[w,S]=n.useState(""),[m,P]=n.useState(a.email),[F,U]=n.useState(!1);te({title:a.name||a.email,showBack:!0,backTo:`/sites/${t}/settings/site-users`});async function B(s){s.preventDefault();try{await d.mutateAsync({userId:a.userId,name:b,status:h,tags:o}),l.success("User updated")}catch(i){l.error("Failed to update user",{description:i instanceof Error?i.message:void 0})}}async function O(s){if(s.preventDefault(),m!==a.email)try{await x.mutateAsync({userId:a.userId,email:m}),l.success("Email updated")}catch(i){l.error("Failed to change email",{description:i instanceof Error?i.message:void 0})}}async function H(){try{await y.mutateAsync(a.userId),l.success("User deleted"),c(`/sites/${t}/settings/site-users`)}catch(s){l.error("Failed to delete user",{description:s instanceof Error?s.message:void 0})}}function E(){const s=w.trim();s&&!o.includes(s)&&D([...o,s]),S("")}function K(s){D(o.filter(i=>i!==s))}function M(s){s.key==="Enter"&&(s.preventDefault(),E())}return e.jsxs("div",{className:"mx-auto max-w-2xl space-y-6",children:[!A&&e.jsx("h1",{className:"text-2xl font-semibold",children:"Edit User"}),e.jsxs(f,{children:[e.jsx(g,{children:e.jsx(v,{children:"User Details"})}),e.jsx(N,{children:e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"name",children:"Name"}),e.jsx(j,{id:"name",value:b,onChange:s=>L(s.target.value),placeholder:"User name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"Status"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{variant:h==="active"?"default":"outline",className:"cursor-pointer",onClick:()=>C("active"),children:"active"}),e.jsx(p,{variant:h==="disabled"?"default":"outline",className:"cursor-pointer",onClick:()=>C("disabled"),children:"disabled"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:o.map(s=>e.jsxs(p,{variant:"secondary",className:"gap-1",children:[s,e.jsx("button",{type:"button",onClick:()=>K(s),className:"hover:text-destructive",children:e.jsx(J,{className:"h-3 w-3"})})]},s))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:w,onChange:s=>S(s.target.value),onKeyDown:M,placeholder:"Add tag...",className:"max-w-xs"}),e.jsx(r,{type:"button",variant:"outline",size:"sm",onClick:E,children:"Add"})]})]}),e.jsxs(r,{type:"submit",disabled:d.isPending,children:[d.isPending&&e.jsx(I,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),e.jsxs(f,{children:[e.jsx(g,{children:e.jsx(v,{children:"Email"})}),e.jsx(N,{children:e.jsxs("form",{onSubmit:O,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"email",children:"Email Address"}),e.jsx(j,{id:"email",type:"email",value:m,onChange:s=>P(s.target.value),required:!0})]}),e.jsxs(r,{type:"submit",variant:"outline",disabled:x.isPending||m===a.email,children:[x.isPending&&e.jsx(I,{className:"mr-2 h-4 w-4 animate-spin"}),"Change Email"]})]})})]}),e.jsxs(f,{children:[e.jsx(g,{children:e.jsx(v,{children:"Info"})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"User ID"}),e.jsx("span",{className:"font-mono",children:a.userId})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Created"}),e.jsx("span",{children:k(a.createdAt)})]}),a.lastLogin&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last Login"}),e.jsx("span",{children:k(a.lastLogin)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Session Version"}),e.jsx("span",{children:a.sessionVersion})]})]})]}),e.jsxs(Q,{open:F,onOpenChange:U,children:[e.jsx(W,{asChild:!0,children:e.jsxs(r,{variant:"destructive",children:[e.jsx(Y,{className:"mr-2 h-4 w-4"}),"Delete User"]})}),e.jsxs(Z,{children:[e.jsxs(_,{children:[e.jsx(ee,{children:"Delete user?"}),e.jsx(se,{children:"This will permanently delete this user and all their identities. This action cannot be undone."})]}),e.jsxs(ae,{children:[e.jsx(r,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),e.jsx(r,{variant:"destructive",onClick:H,disabled:y.isPending,children:"Delete"})]})]})]})]})}export{xe as SiteUserEditPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as Z,f as _,m as ee,r as n}from"./react-vendor-C2CvUxFh.js";import{d as se,e as ae,f as te}from"./useSiteUsers-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as Z,f as _,m as ee,r as n}from"./react-vendor-C2CvUxFh.js";import{d as se,e as ae,f as te}from"./useSiteUsers-DIaqgNSp.js";import{x as re,B as c,P as I,I as v,S as ne,j as E,D as F,k,l as L,m as R,n as A,L as M,o as B,v as x}from"./index-Ce5pmRMj.js";import{T as ie,a as le,b as O,c as o,d as ce,e as d}from"./table-_3bMY0_z.js";import{f as oe}from"./format-C88SDH8g.js";import{u as de}from"./usePageTitle-C1r1-C00.js";import{P as me}from"./Pagination-Df9nQ7Z0.js";import"./radix-C5ZmWuuL.js";import"./select-CrRhFGIi.js";function Se(){const{host:m}=Z(),H=_(),[h,i]=ee(),r=Number(h.get("page"))||1,P=Number(h.get("perPage"))||20,[N,$]=n.useState(""),S=n.useMemo(()=>{const s=h.get("after")||"";return s?s.split(","):[]},[h]),b=r>1?S[r-2]:void 0,q=b?`USER#${b}`:void 0,{data:C,isLoading:z}=se(m,{cursor:q,tag:N||void 0,limit:P}),w=ae(m),y=te(m),[G,u]=n.useState(!1),[g,U]=n.useState(""),[D,T]=n.useState(""),[j,p]=n.useState(null),J=re();de({title:"Site Users",actions:e.jsx(c,{size:"sm",onClick:()=>u(!0),children:e.jsx(I,{className:"h-4 w-4"})})});const K=n.useCallback(()=>{i(s=>{const a=new URLSearchParams(s);return a.delete("page"),a.delete("perPage"),a.delete("after"),a},{replace:!0})},[i]);async function Q(s){s.preventDefault();try{await w.mutateAsync({email:g,name:D||void 0}),u(!1),U(""),T(""),x.success("User created")}catch(a){x.error("Failed to create user",{description:a instanceof Error?a.message:void 0})}}async function V(){if(j)try{await y.mutateAsync(j),p(null),x.success("User deleted")}catch(s){x.error("Failed to delete user",{description:s instanceof Error?s.message:void 0})}}const l=C?.items??[],W=!!C?.cursor;function X(s){i(a=>{const t=new URLSearchParams(a);return s===1?t.delete("page"):t.set("page",String(s)),t})}function Y(s){i(a=>{const t=new URLSearchParams(a);return t.delete("page"),t.delete("after"),s===20?t.delete("perPage"):t.set("perPage",String(s)),t},{replace:!0})}return e.jsxs("div",{children:[!J&&e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Site Users"}),e.jsxs(c,{onClick:()=>u(!0),children:[e.jsx(I,{className:"mr-2 h-4 w-4"}),"Add User"]})]}),e.jsx("div",{className:"mb-4",children:e.jsx(v,{placeholder:"Filter by tag...",value:N,onChange:s=>{$(s.target.value),K()},className:"max-w-xs"})}),z?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(s=>e.jsx(ne,{className:"h-12 w-full"},s))}):l.length===0?e.jsx("p",{className:"text-muted-foreground py-8 text-center",children:"No site users yet"}):e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(le,{children:e.jsxs(O,{children:[e.jsx(o,{children:"Email"}),e.jsx(o,{children:"Name"}),e.jsx(o,{children:"Status"}),e.jsx(o,{children:"Tags"}),e.jsx(o,{children:"Created"})]})}),e.jsx(ce,{children:l.map(s=>e.jsxs(O,{className:"cursor-pointer",onClick:()=>H(`/sites/${m}/settings/site-users/${s.userId}`),children:[e.jsx(d,{className:"font-medium",children:s.email}),e.jsx(d,{children:s.name||"—"}),e.jsx(d,{children:e.jsx(E,{variant:s.status==="active"?"default":"secondary",children:s.status})}),e.jsx(d,{children:s.tags?.map(a=>e.jsx(E,{variant:"outline",className:"mr-1",children:a},a))}),e.jsx(d,{children:oe(s.createdAt)})]},s.userId))})]}),e.jsx(me,{page:r,hasNext:W,hasPrevious:r>1,onNext:()=>{if(l.length){const s=l[l.length-1].userId,a=[...S.slice(0,r-1),s];i(t=>{const f=new URLSearchParams(t);return f.set("page",String(r+1)),f.set("after",a.join(",")),f})}},onPrevious:()=>X(r-1),perPage:P,onPerPageChange:Y})]}),e.jsx(F,{open:G,onOpenChange:u,children:e.jsxs(k,{children:[e.jsxs(L,{children:[e.jsx(R,{children:"Add Site User"}),e.jsx(A,{children:"Create a new user for this site."})]}),e.jsxs("form",{onSubmit:Q,children:[e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"email",children:"Email"}),e.jsx(v,{id:"email",type:"email",value:g,onChange:s=>U(s.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"name",children:"Name (optional)"}),e.jsx(v,{id:"name",value:D,onChange:s=>T(s.target.value)})]})]}),e.jsx(B,{children:e.jsx(c,{type:"submit",disabled:w.isPending||!g,children:"Create"})})]})]})}),e.jsx(F,{open:!!j,onOpenChange:()=>p(null),children:e.jsxs(k,{children:[e.jsxs(L,{children:[e.jsx(R,{children:"Delete User"}),e.jsx(A,{children:"This will permanently delete this user and all their identities."})]}),e.jsxs(B,{children:[e.jsx(c,{variant:"outline",onClick:()=>p(null),children:"Cancel"}),e.jsx(c,{variant:"destructive",onClick:V,disabled:y.isPending,children:"Delete"})]})]})})]})}export{Se as SiteUsersPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as u,f as V}from"./react-vendor-C2CvUxFh.js";import{b as X,u as Z,d as ee,e as te,g as se,h as ae,H as U,D as G,i as J,B as k,P as R,U as ne,j as oe,k as ie,l as le,m as re,n as ce,L as W,I as Y,o as de}from"./index-BA3y7HJs.js";import{C as me,a as he,b as ue,d as ge}from"./card-CZTHR2Qa.js";import{C as b}from"./checkbox-DEgzM8H9.js";import"./radix-C5ZmWuuL.js";const pe={name:"pages",label:"Pages",labelSingular:"Page",slug:"pages",singleton:!1,fields:[{name:"content",label:"Content",type:"blocks",options:{}}]},xe={name:"posts",label:"Blog Posts",labelSingular:"Blog Post",slug:"/blog",singleton:!1,fields:[{name:"author",label:"Author",type:"text",options:{}},{name:"content",label:"Content",type:"blocks",options:{}}]},fe={name:"site-settings",label:"Site Settings",labelSingular:"Site Settings",slug:"site-settings",singleton:!0,fields:[{name:"siteName",label:"Site Name",type:"text",options:{}},{name:"tagline",label:"Tagline",type:"text",options:{}},{name:"footerText",label:"Footer Text",type:"text",options:{}},{name:"menuItems",label:"Menu Items",type:"array",options:{itemFields:[{name:"label",label:"Label",type:"text",options:{}},{name:"href",label:"URL",type:"text",options:{}}]}}]};function C(s,o){return{id:o,type:"paragraph",props:{textColor:"default",backgroundColor:"default",textAlignment:"left"},content:[{type:"text",text:s}],children:[]}}function $(s,o,d){return{id:d,type:"heading",props:{textColor:"default",backgroundColor:"default",textAlignment:"left",level:o},content:[{type:"text",text:s}],children:[]}}const z=[{title:"Home",slug:"home",body:{content:[$("Welcome to Headroom",1,"home-h1"),C("This is your new site powered by Headroom CMS. Edit this page to add your own content.","home-p1"),$("Getting Started",2,"home-h2"),C("Head over to the admin panel to manage your content, collections, and media.","home-p2")]}},{title:"About",slug:"about",body:{content:[$("About Us",1,"about-h1"),C("Tell your visitors about your company, team, or project. This is a great place to share your story.","about-p1")]}},{title:"Contact",slug:"contact",body:{content:[$("Contact",1,"contact-h1"),C("Get in touch with us. Replace this with your contact information or a contact form.","contact-p1")]}}],K=[{title:"Welcome to Headroom",slug:"welcome-to-headroom",body:{author:"Admin",content:[C("This is your first blog post. You can edit or delete it and start writing your own content.","post-p1"),C("Headroom makes it easy to create and manage your content with a powerful block editor, media library, and flexible collections.","post-p2")]}}],Se={siteName:"Headroom Site",tagline:"A site powered by Headroom CMS",footerText:"© 2026 Headroom Site. Built with Headroom CMS.",menuItems:[{label:"Home",href:"/"},{label:"About",href:"/about"},{label:"Blog",href:"/blog"},{label:"Contact",href:"/contact"}]};function Q(s){const d=[s.createPages,s.createPosts,s.createSettings].filter(Boolean).length;if(!s.addSampleContent)return d;let g=0;return s.createPages&&(g+=z.length*2),s.createPosts&&(g+=K.length*2),s.createSettings&&(g+=3),d+g}async function be(s,o,d,g){const r={collectionsCreated:[],contentCreated:[],errors:[]},x=Q(d);let a=0;const m=t=>{g?.({completed:a,total:x,label:t})},y=[{key:"pages",enabled:d.createPages,schema:pe},{key:"posts",enabled:d.createPosts,schema:xe},{key:"site-settings",enabled:d.createSettings,schema:fe}],p=new Set;for(const{key:t,enabled:n,schema:f}of y)if(n){m(`Creating ${t} collection...`);try{await s.apiFetch(`/v1/admin/sites/${o}/collections`,{method:"POST",body:JSON.stringify(f)}),r.collectionsCreated.push(t),p.add(t)}catch(h){r.errors.push(`Failed to create ${t} collection: ${h instanceof Error?h.message:String(h)}`)}a++}if(!d.addSampleContent)return m("Done"),r;if(p.has("pages"))for(const t of z){m(`Creating page "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"pages",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing page "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`pages/${t.slug}`)}catch(n){r.errors.push(`Failed to create page "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("posts"))for(const t of K){m(`Creating post "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"posts",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing post "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`posts/${t.slug}`)}catch(n){r.errors.push(`Failed to create post "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("site-settings")){m("Configuring settings...");try{const t=await s.apiFetch(`/v1/admin/sites/${o}/collections/site-settings`);a++,t.singletonContentId?(m("Saving settings draft..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/draft`,{method:"PUT",body:JSON.stringify({title:"Site Settings",slug:"site-settings",body:Se})}),a++,m("Publishing settings..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/publish`,{method:"POST"}),a++,r.contentCreated.push("site-settings")):a+=2}catch(t){r.errors.push(`Failed to populate settings: ${t instanceof Error?t.message:String(t)}`),a+=3}}return m("Done"),r}function Pe(){const[s,o]=u.useState(!1),{data:d,isLoading:g}=X(s),r=V(),x=u.useMemo(()=>[...d?.items??[]].sort((l,A)=>(l.name||l.host).localeCompare(A.name||A.host)),[d]),{user:a}=Z(),{data:m}=ee(),y=a?(m?.superAdminIds??[]).includes(a.sub):!1,p=te(),t=se(),[n,f]=u.useState(!1),[h,j]=u.useState(""),[S,c]=u.useState(""),[N,i]=u.useState(!0),[v,D]=u.useState(!0),[w,O]=u.useState(!0),[P,E]=u.useState(!0),[F,L]=u.useState(!1),[H,T]=u.useState(null),I=()=>{j(""),c(""),i(!0),D(!0),O(!0),E(!0),L(!1),T(null)},B=l=>{f(l),l||I()};if(g)return e.jsx(ae,{});const _=async()=>{if(h.trim())try{await t.mutateAsync({host:h.trim(),name:S.trim()||h.trim()});const l={createPages:v,createPosts:w,createSettings:P,addSampleContent:F};if(N&&(v||w||P)){const A=Q(l);T({completed:0,total:A,label:"Setting up collections..."});const M=await be(p,h.trim(),l,T);M.errors.length>0&&console.warn("Scaffold warnings:",M.errors)}f(!1),I()}catch{T(null)}};return x.length===0?e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"No sites available."}),e.jsxs(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]}):e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex-1 p-4 sm:p-8",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Select a site"}),y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:s,onCheckedChange:l=>o(l===!0)}),"Show archived sites"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(k,{variant:"outline",onClick:()=>r("/users"),children:[e.jsx(ne,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"All Users"})]}),e.jsxs(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Create Site"})]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:x.map(l=>e.jsx(me,{className:"cursor-pointer transition-shadow hover:shadow-md",onClick:()=>r(`/sites/${l.host}/content`),children:e.jsxs(he,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{children:l.name||l.host}),l.status==="archived"&&e.jsx(oe,{variant:"outline",children:"Archived"})]}),e.jsx(ge,{children:l.host})]})},l.host))})]})]})}function q({newHost:s,setNewHost:o,newName:d,setNewName:g,createDefaults:r,setCreateDefaults:x,createPages:a,setCreatePages:m,createPosts:y,setCreatePosts:p,createSettings:t,setCreateSettings:n,addSampleContent:f,setAddSampleContent:h,onSubmit:j,isPending:S,scaffoldProgress:c}){const N=S||!!c;return e.jsxs(ie,{children:[e.jsxs(le,{children:[e.jsx(re,{children:"Create Site"}),e.jsx(ce,{className:"sr-only",children:"Enter details for the new site"})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"host",children:"Host"}),e.jsx(Y,{id:"host",placeholder:"example.com",value:s,onChange:i=>o(i.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"name",children:"Display Name"}),e.jsx(Y,{id:"name",placeholder:"My Site",value:d,onChange:i=>g(i.target.value)})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(b,{checked:r,onCheckedChange:i=>x(i===!0)}),"Create Default Collections"]}),r&&e.jsxs("div",{className:"ml-6 mt-3 space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:a,onCheckedChange:i=>m(i===!0)}),"Pages"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:y,onCheckedChange:i=>p(i===!0)}),"Posts"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:t,onCheckedChange:i=>n(i===!0)}),"Site Settings"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(b,{checked:f,onCheckedChange:i=>h(i===!0)}),"Add Sample Content"]})]})]})]}),c&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-300",style:{width:`${c.total>0?c.completed/c.total*100:0}%`},role:"progressbar","aria-valuenow":c.completed,"aria-valuemin":0,"aria-valuemax":c.total})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.label," ","(",c.completed,"/",c.total,")"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Please wait while your site is being set up. Do not close this tab."})]}),e.jsx(de,{children:e.jsx(k,{onClick:j,disabled:!s.trim()||N,children:c?c.label:S?"Creating...":"Create"})})]})}export{Pe as SitesPage};
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as u,f as V}from"./react-vendor-C2CvUxFh.js";import{b as X,u as Z,d as ee,e as te,g as se,h as ae,H as U,D as G,i as J,B as k,P as R,U as ne,j as oe,k as ie,l as le,m as re,n as ce,L as W,I as Y,o as de}from"./index-Ce5pmRMj.js";import{C as me,a as he,b as ue,d as ge}from"./card-C9hfyHXf.js";import{C as b}from"./checkbox-DVJcwUt1.js";import"./radix-C5ZmWuuL.js";const pe={name:"pages",label:"Pages",labelSingular:"Page",slug:"pages",singleton:!1,fields:[{name:"content",label:"Content",type:"blocks",options:{}}]},xe={name:"posts",label:"Blog Posts",labelSingular:"Blog Post",slug:"/blog",singleton:!1,fields:[{name:"author",label:"Author",type:"text",options:{}},{name:"content",label:"Content",type:"blocks",options:{}}]},fe={name:"site-settings",label:"Site Settings",labelSingular:"Site Settings",slug:"site-settings",singleton:!0,fields:[{name:"siteName",label:"Site Name",type:"text",options:{}},{name:"tagline",label:"Tagline",type:"text",options:{}},{name:"footerText",label:"Footer Text",type:"text",options:{}},{name:"menuItems",label:"Menu Items",type:"array",options:{itemFields:[{name:"label",label:"Label",type:"text",options:{}},{name:"href",label:"URL",type:"text",options:{}}]}}]};function C(s,o){return{id:o,type:"paragraph",props:{textColor:"default",backgroundColor:"default",textAlignment:"left"},content:[{type:"text",text:s}],children:[]}}function $(s,o,d){return{id:d,type:"heading",props:{textColor:"default",backgroundColor:"default",textAlignment:"left",level:o},content:[{type:"text",text:s}],children:[]}}const z=[{title:"Home",slug:"home",body:{content:[$("Welcome to Headroom",1,"home-h1"),C("This is your new site powered by Headroom CMS. Edit this page to add your own content.","home-p1"),$("Getting Started",2,"home-h2"),C("Head over to the admin panel to manage your content, collections, and media.","home-p2")]}},{title:"About",slug:"about",body:{content:[$("About Us",1,"about-h1"),C("Tell your visitors about your company, team, or project. This is a great place to share your story.","about-p1")]}},{title:"Contact",slug:"contact",body:{content:[$("Contact",1,"contact-h1"),C("Get in touch with us. Replace this with your contact information or a contact form.","contact-p1")]}}],K=[{title:"Welcome to Headroom",slug:"welcome-to-headroom",body:{author:"Admin",content:[C("This is your first blog post. You can edit or delete it and start writing your own content.","post-p1"),C("Headroom makes it easy to create and manage your content with a powerful block editor, media library, and flexible collections.","post-p2")]}}],Se={siteName:"Headroom Site",tagline:"A site powered by Headroom CMS",footerText:"© 2026 Headroom Site. Built with Headroom CMS.",menuItems:[{label:"Home",href:"/"},{label:"About",href:"/about"},{label:"Blog",href:"/blog"},{label:"Contact",href:"/contact"}]};function Q(s){const d=[s.createPages,s.createPosts,s.createSettings].filter(Boolean).length;if(!s.addSampleContent)return d;let g=0;return s.createPages&&(g+=z.length*2),s.createPosts&&(g+=K.length*2),s.createSettings&&(g+=3),d+g}async function be(s,o,d,g){const r={collectionsCreated:[],contentCreated:[],errors:[]},x=Q(d);let a=0;const m=t=>{g?.({completed:a,total:x,label:t})},y=[{key:"pages",enabled:d.createPages,schema:pe},{key:"posts",enabled:d.createPosts,schema:xe},{key:"site-settings",enabled:d.createSettings,schema:fe}],p=new Set;for(const{key:t,enabled:n,schema:f}of y)if(n){m(`Creating ${t} collection...`);try{await s.apiFetch(`/v1/admin/sites/${o}/collections`,{method:"POST",body:JSON.stringify(f)}),r.collectionsCreated.push(t),p.add(t)}catch(h){r.errors.push(`Failed to create ${t} collection: ${h instanceof Error?h.message:String(h)}`)}a++}if(!d.addSampleContent)return m("Done"),r;if(p.has("pages"))for(const t of z){m(`Creating page "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"pages",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing page "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`pages/${t.slug}`)}catch(n){r.errors.push(`Failed to create page "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("posts"))for(const t of K){m(`Creating post "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"posts",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing post "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`posts/${t.slug}`)}catch(n){r.errors.push(`Failed to create post "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("site-settings")){m("Configuring settings...");try{const t=await s.apiFetch(`/v1/admin/sites/${o}/collections/site-settings`);a++,t.singletonContentId?(m("Saving settings draft..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/draft`,{method:"PUT",body:JSON.stringify({title:"Site Settings",slug:"site-settings",body:Se})}),a++,m("Publishing settings..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/publish`,{method:"POST"}),a++,r.contentCreated.push("site-settings")):a+=2}catch(t){r.errors.push(`Failed to populate settings: ${t instanceof Error?t.message:String(t)}`),a+=3}}return m("Done"),r}function Pe(){const[s,o]=u.useState(!1),{data:d,isLoading:g}=X(s),r=V(),x=u.useMemo(()=>[...d?.items??[]].sort((l,A)=>(l.name||l.host).localeCompare(A.name||A.host)),[d]),{user:a}=Z(),{data:m}=ee(),y=a?(m?.superAdminIds??[]).includes(a.sub):!1,p=te(),t=se(),[n,f]=u.useState(!1),[h,j]=u.useState(""),[S,c]=u.useState(""),[N,i]=u.useState(!0),[v,D]=u.useState(!0),[w,O]=u.useState(!0),[P,E]=u.useState(!0),[F,L]=u.useState(!1),[H,T]=u.useState(null),I=()=>{j(""),c(""),i(!0),D(!0),O(!0),E(!0),L(!1),T(null)},B=l=>{f(l),l||I()};if(g)return e.jsx(ae,{});const _=async()=>{if(h.trim())try{await t.mutateAsync({host:h.trim(),name:S.trim()||h.trim()});const l={createPages:v,createPosts:w,createSettings:P,addSampleContent:F};if(N&&(v||w||P)){const A=Q(l);T({completed:0,total:A,label:"Setting up collections..."});const M=await be(p,h.trim(),l,T);M.errors.length>0&&console.warn("Scaffold warnings:",M.errors)}f(!1),I()}catch{T(null)}};return x.length===0?e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"No sites available."}),e.jsxs(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]}):e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex-1 p-4 sm:p-8",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Select a site"}),y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:s,onCheckedChange:l=>o(l===!0)}),"Show archived sites"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(k,{variant:"outline",onClick:()=>r("/users"),children:[e.jsx(ne,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"All Users"})]}),e.jsxs(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Create Site"})]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:x.map(l=>e.jsx(me,{className:"cursor-pointer transition-shadow hover:shadow-md",onClick:()=>r(`/sites/${l.host}/content`),children:e.jsxs(he,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{children:l.name||l.host}),l.status==="archived"&&e.jsx(oe,{variant:"outline",children:"Archived"})]}),e.jsx(ge,{children:l.host})]})},l.host))})]})]})}function q({newHost:s,setNewHost:o,newName:d,setNewName:g,createDefaults:r,setCreateDefaults:x,createPages:a,setCreatePages:m,createPosts:y,setCreatePosts:p,createSettings:t,setCreateSettings:n,addSampleContent:f,setAddSampleContent:h,onSubmit:j,isPending:S,scaffoldProgress:c}){const N=S||!!c;return e.jsxs(ie,{children:[e.jsxs(le,{children:[e.jsx(re,{children:"Create Site"}),e.jsx(ce,{className:"sr-only",children:"Enter details for the new site"})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"host",children:"Host"}),e.jsx(Y,{id:"host",placeholder:"example.com",value:s,onChange:i=>o(i.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"name",children:"Display Name"}),e.jsx(Y,{id:"name",placeholder:"My Site",value:d,onChange:i=>g(i.target.value)})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(b,{checked:r,onCheckedChange:i=>x(i===!0)}),"Create Default Collections"]}),r&&e.jsxs("div",{className:"ml-6 mt-3 space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:a,onCheckedChange:i=>m(i===!0)}),"Pages"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:y,onCheckedChange:i=>p(i===!0)}),"Posts"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:t,onCheckedChange:i=>n(i===!0)}),"Site Settings"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(b,{checked:f,onCheckedChange:i=>h(i===!0)}),"Add Sample Content"]})]})]})]}),c&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-300",style:{width:`${c.total>0?c.completed/c.total*100:0}%`},role:"progressbar","aria-valuenow":c.completed,"aria-valuemin":0,"aria-valuemax":c.total})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.label," ","(",c.completed,"/",c.total,")"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Please wait while your site is being set up. Do not close this tab."})]}),e.jsx(de,{children:e.jsx(k,{onClick:j,disabled:!s.trim()||N,children:c?c.label:S?"Creating...":"Create"})})]})}export{Pe as SitesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as F,f as B,r as L,L as C}from"./react-vendor-C2CvUxFh.js";import{j as S,m as O}from"./useContent-
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as F,f as B,r as L,L as C}from"./react-vendor-C2CvUxFh.js";import{j as S,m as O}from"./useContent-Bs7nel7C.js";import{x as E,w as P,S as b,B as r,bb as M,a3 as U,W as z,D as H,i as V,T as W,k as Y,l as _,m as q,n as G,o as J,ad as K,j as Q,v as g}from"./index-Ce5pmRMj.js";import{u as X}from"./usePageTitle-C1r1-C00.js";import{C as y,a as v,b as D,c as w}from"./card-C9hfyHXf.js";import{f as Z}from"./format-C88SDH8g.js";import{a as ss}from"./MediaField-CxccCFGQ.js";import"./radix-C5ZmWuuL.js";import"./useMedia-ae3s_ajC.js";import"./select-CrRhFGIi.js";import"./media-url-DdCoIedP.js";function es({host:i,ref:t}){const c=!t.title&&!!t.contentId,{data:o}=S(i,c?t.contentId:""),d=c&&o?.content?o.content:null,u=t.title||d?.title||t.contentId,a=t.collection||d?.collection||"";return s.jsxs(C,{to:`/sites/${i}/content/${a}/${t.contentId}`,className:"flex items-center gap-3 rounded-md border p-2 transition-colors hover:bg-muted",children:[s.jsx(K,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"flex-1 truncate text-sm",children:u}),a&&s.jsx(Q,{variant:"secondary",children:a})]})}function us(){const{host:i,collection:t,id:c}=F(),o=B(),d=E(),{collections:u}=P(),{data:a,isLoading:$}=S(i,c),k=O(i,c),[T,p]=L.useState(!1),m=u.find(e=>e.name===t),f=m?.relationships??[];if(X({title:"Submission Detail",showBack:!0,backTo:`/sites/${i}/submissions/${t}`}),$)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(b,{className:"h-8 w-64"}),s.jsx(b,{className:"h-64 w-full"})]});if(!a?.content)return s.jsx("p",{className:"text-muted-foreground",children:"Submission not found."});const l=a.content,x=a.body??l.body,h=l.siteUser,j=l.relationships;function I(e,n){return n==null?"—":typeof n=="boolean"?n?"Yes":"No":Array.isArray(n)?n.join(", "):String(n)}async function R(){try{await k.mutateAsync(),g.success("Submission deleted"),o(`/sites/${i}/submissions/${t}`)}catch(e){g.error("Failed to delete",{description:e instanceof Error?e.message:void 0})}}const A=f.length>0&&j&&Object.keys(j).length>0;return s.jsxs("div",{className:"mx-auto max-w-2xl",children:[!d&&s.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[s.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>o(`/sites/${i}/submissions/${t}`),children:[s.jsx(M,{className:"mr-1.5 h-4 w-4"}),"Back"]}),s.jsx("h1",{className:"text-2xl font-semibold",children:"Submission Detail"}),s.jsx("div",{className:"ml-auto",children:s.jsxs(r,{variant:"outline",size:"sm",onClick:()=>o(`/sites/${i}/submissions/${t}/${c}/edit`),children:[s.jsx(U,{className:"mr-1.5 h-4 w-4"}),"Edit"]})})]}),s.jsxs(y,{children:[s.jsx(v,{children:s.jsx(D,{children:l.title||"Untitled"})}),s.jsxs(w,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:"ID"}),s.jsx("span",{className:"font-mono text-xs",children:l.contentId})]}),!!l.publishedAt&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:"Submitted"}),s.jsx("span",{children:Z(l.publishedAt)})]}),h&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:"Submitted by"}),s.jsx(C,{to:`/sites/${i}/settings/site-users/${h.userId}`,className:"text-primary hover:underline",children:h.name||h.email})]})]}),s.jsx(z,{}),s.jsxs("div",{className:"space-y-3",children:[m?.fields?.map(e=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:e.label||e.name}),e.type==="media"?s.jsx(ss,{field:e,value:x?.[e.name],onChange:()=>{},disabled:!0}):s.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I(e,x?.[e.name])})]},e.name)),(!m?.fields||m.fields.length===0)&&x&&s.jsx("div",{className:"space-y-3",children:Object.entries(x).map(([e,n])=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:e}),s.jsx("p",{className:"text-sm whitespace-pre-wrap",children:n==null?"—":String(n)})]},e))})]})]})]}),A&&s.jsxs(y,{className:"mt-6",children:[s.jsx(v,{children:s.jsx(D,{children:"Relationships"})}),s.jsx(w,{className:"space-y-4",children:f.map(e=>{const n=j?.[e.name]??[];return n.length===0?null:s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-sm font-medium",children:e.label}),s.jsx("div",{className:"space-y-2",children:n.map(N=>s.jsx(es,{host:i,ref:N},N.contentId))})]},e.name)})})]}),s.jsx("div",{className:"mt-6",children:s.jsxs(H,{open:T,onOpenChange:p,children:[s.jsx(V,{asChild:!0,children:s.jsxs(r,{variant:"destructive",children:[s.jsx(W,{className:"mr-2 h-4 w-4"}),"Delete Submission"]})}),s.jsxs(Y,{children:[s.jsxs(_,{children:[s.jsx(q,{children:"Delete submission?"}),s.jsx(G,{children:"This will permanently delete this submission."})]}),s.jsxs(J,{children:[s.jsx(r,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),s.jsx(r,{variant:"destructive",onClick:R,children:"Delete"})]})]})]})})]})}export{us as SubmissionDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as O,f as z,r as u}from"./react-vendor-C2CvUxFh.js";import{x as U,w as V,e as D,S as E,B as P,bb as H,L as q,bc as G,I as x,v as j}from"./index-
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as O,f as z,r as u}from"./react-vendor-C2CvUxFh.js";import{x as U,w as V,e as D,S as E,B as P,bb as H,L as q,bc as G,I as x,v as j}from"./index-Ce5pmRMj.js";import{j as J,s as K,t as Q}from"./useContent-Bs7nel7C.js";import{u as W}from"./usePageTitle-C1r1-C00.js";import{T as X}from"./textarea-6fq0R6VV.js";import{C as Y}from"./checkbox-DVJcwUt1.js";import{S as Z,a as _,b as ee,c as se,d as te}from"./select-CrRhFGIi.js";import{C as ae,a as ne,b as ie,c as oe}from"./card-C9hfyHXf.js";import{a as re}from"./MediaField-CxccCFGQ.js";import{R as ce}from"./RelationshipPicker-B3Ftmqxp.js";import"./radix-C5ZmWuuL.js";import"./useMedia-ae3s_ajC.js";import"./media-url-DdCoIedP.js";import"./core.esm-DdQHdRkd.js";import"./sortable.esm-qVEMoaTg.js";import"./ContentField-pilCbdnA.js";import"./popover-CzaQYEEP.js";import"./command-Bfmj0MEL.js";import"./useContentSearch-B3aTjuCu.js";function Fe(){const{host:i,collection:c,id:m}=O(),b=z(),R=U(),{collections:A}=V(),o=!!m,d=A.find(t=>t.name===c),v=u.useMemo(()=>d?.relationships??[],[d?.relationships]),h=v.length>0,{data:p,isLoading:T}=J(i,m??""),S=D(),C=K(i),f=Q(i,m??""),[y,$]=u.useState({}),[w,N]=u.useState({}),[k,L]=u.useState(!o);W({title:o?"Edit Submission":"New Submission",showBack:!0,backTo:o?`/sites/${i}/submissions/${c}/${m}`:`/sites/${i}/submissions/${c}`});const I=u.useCallback(async t=>{const a={};for(const[e,n]of Object.entries(t))a[e]=await Promise.all(n.map(async r=>{if(r.title)return r;try{const g=await S.apiFetch(`/v1/admin/sites/${i}/content/${r.contentId}`);return{contentId:r.contentId,collection:g.content.collection??r.collection??"",slug:g.content.slug??r.slug??"",title:g.content.title??r.contentId}}catch{return r}}));return a},[S,i]);if(u.useEffect(()=>{if(o&&p&&!k){const t=p.body;t&&$({...t});const e=p.content?.relationships;e&&Object.keys(e).length>0&&I(e).then(N),L(!0)}},[o,p,k,I]),o&&T)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(E,{className:"h-8 w-64"}),s.jsx(E,{className:"h-64 w-full"})]});function l(t,a){$(e=>({...e,[t]:a}))}function B(t){const a=y[t.name];switch(t.type){case"text":return s.jsx(x,{value:a??"",onChange:e=>l(t.name,e.target.value)});case"textarea":return s.jsx(X,{value:a??"",onChange:e=>l(t.name,e.target.value),rows:4});case"number":return s.jsx(x,{type:"number",value:a!=null?String(a):"",onChange:e=>l(t.name,e.target.value===""?void 0:Number(e.target.value))});case"boolean":return s.jsx(Y,{checked:!!a,onCheckedChange:e=>l(t.name,!!e)});case"select":{const e=t.options?.choices??[];return s.jsxs(Z,{value:a??"",onValueChange:n=>l(t.name,n),children:[s.jsx(_,{children:s.jsx(ee,{placeholder:"Select..."})}),s.jsx(se,{children:e.map(n=>s.jsx(te,{value:n,children:n},n))})]})}case"array":return s.jsx(x,{value:Array.isArray(a)?a.join(", "):a??"",onChange:e=>l(t.name,e.target.value?e.target.value.split(",").map(n=>n.trim()):[]),placeholder:"Comma-separated values"});case"media":return s.jsx(re,{field:t,value:a,onChange:()=>{},disabled:!0});default:return s.jsx(x,{value:a??"",onChange:e=>l(t.name,e.target.value)})}}async function M(){const t={};for(const[e,n]of Object.entries(y))n!==void 0&&n!==""&&(t[e]=n);const a={};if(h)for(const[e,n]of Object.entries(w))a[e]=n.map(r=>({contentId:r.contentId}));try{if(o)await f.mutateAsync({fields:t,...h?{relationships:a}:{}}),j.success("Submission updated"),b(`/sites/${i}/submissions/${c}/${m}`);else{const e=await C.mutateAsync({collection:c,fields:t,...h?{relationships:a}:{}});j.success("Submission created"),b(`/sites/${i}/submissions/${c}/${e.contentId}`)}}catch(e){const n=e instanceof Error?e.message:typeof e=="object"&&e!==null&&"message"in e?String(e.message):String(e);j.error(o?"Failed to update":"Failed to create",{description:n})}}const F=C.isPending||f.isPending;return s.jsxs("div",{className:"mx-auto max-w-2xl",children:[!R&&s.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[s.jsxs(P,{variant:"ghost",size:"sm",onClick:()=>b(o?`/sites/${i}/submissions/${c}/${m}`:`/sites/${i}/submissions/${c}`),children:[s.jsx(H,{className:"mr-1.5 h-4 w-4"}),"Back"]}),s.jsx("h1",{className:"text-2xl font-semibold",children:o?"Edit Submission":"New Submission"})]}),s.jsxs(ae,{children:[s.jsx(ne,{children:s.jsx(ie,{children:d?.label??c})}),s.jsxs(oe,{className:"space-y-4",children:[d?.fields?.map(t=>s.jsxs("div",{className:"space-y-2",children:[s.jsx(q,{htmlFor:`field-${t.name}`,children:t.label||t.name}),s.jsx("div",{id:`field-${t.name}`,children:B(t)})]},t.name)),s.jsx("div",{className:"pt-4",children:s.jsxs(P,{onClick:M,disabled:F,children:[s.jsx(G,{className:"mr-1.5 h-4 w-4"}),F?"Saving...":o?"Update":"Create"]})})]})]}),h&&s.jsx("div",{className:"mt-6",children:s.jsx(ce,{relationships:v,values:w,onChange:N,host:i})})]})}export{Fe as SubmissionEditPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as G,f as J,r as p}from"./react-vendor-C2CvUxFh.js";import{u as K}from"./useFilterParams-DYdEuWPE.js";import{w as Q,x as W,B as L,P as X,T as Z,v as R,S as ee,y as se}from"./index-
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as G,f as J,r as p}from"./react-vendor-C2CvUxFh.js";import{u as K}from"./useFilterParams-DYdEuWPE.js";import{w as Q,x as W,B as L,P as X,T as Z,v as R,S as ee,y as se}from"./index-Ce5pmRMj.js";import{d as te,c as ae}from"./useContent-Bs7nel7C.js";import{u as le}from"./usePageTitle-C1r1-C00.js";import{u as ne,F as re}from"./FilterBar-BZoa63zh.js";import{C as ie,c as oe}from"./card-C9hfyHXf.js";import{C as k}from"./checkbox-DVJcwUt1.js";import{S as ce,a as de,b as ue,c as me,d as he}from"./select-CrRhFGIi.js";import{T as fe,a as pe,b as _,c as S,d as xe,e as N}from"./table-_3bMY0_z.js";import{a as B,f as ge}from"./format-C88SDH8g.js";import{P as be}from"./Pagination-Df9nQ7Z0.js";import"./radix-C5ZmWuuL.js";import"./popover-CzaQYEEP.js";import"./command-Bfmj0MEL.js";import"./useContentSearch-B3aTjuCu.js";const je=[{value:"created_desc",label:"Newest first"},{value:"created_asc",label:"Oldest first"}];function Re(){const{host:h,collection:c}=G(),v=J(),{collections:D}=Q(),[d,l]=K([{key:"sort",defaultValue:"created_desc"},{key:"relatedTo",defaultValue:""},{key:"relField",defaultValue:""},{key:"page",defaultValue:"1"},{key:"perPage",defaultValue:"20"},{key:"after",defaultValue:""}]),g=d.sort,u=d.relatedTo,n=d.relField,r=Number(d.page)||1,w=Number(d.perPage)||20,T=p.useMemo(()=>{const e=d.after;return e?e.split(","):[]},[d.after]),[m,a]=p.useState(new Set),P=W(),f=D.find(e=>e.name===c),b=f?.relationships??[];le({title:f?.label??c??""});const{data:F}=ne(h,u||void 0),A=p.useMemo(()=>{if(!u||!n)return null;const e=b.find(t=>t.name===n);return{type:"relationship",relName:n,relLabel:e?.label??n,contentId:u,contentTitle:F??"Loading..."}},[u,n,b,F]),O=p.useCallback(()=>{l({page:"1",after:""}),a(new Set)},[l]),z=p.useMemo(()=>{const e={};return g!=="created_desc"&&(e.sort=g),u&&(e.relatedTo=u),n&&(e.relField=n),e.limit=w,e},[g,u,n,w]),q=r>1?T[r-2]:void 0,{data:x,isLoading:E}=te(h,c,z,q),$=ae(h),j=x?.items,C=f?.fields,V=p.useMemo(()=>C?C.filter(e=>["text","number","boolean","select"].includes(e.type)).slice(0,4):[],[C]),I=j?.map(e=>e.contentId)??[],M=I.length>0&&I.every(e=>m.has(e));function U(e){a(t=>{const i=new Set(t);return i.has(e)?i.delete(e):i.add(e),i})}function H(){a(M?new Set:new Set(I))}function Y(e,t){const o=e.fields?.[t];if(o==null)return"—";if(typeof o=="boolean")return o?"Yes":"No";if(typeof o=="number")return String(o);const y=String(o);return y.length>60?y.slice(0,60)+"…":y}return s.jsxs("div",{children:[!P&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:f?.label??c}),s.jsxs(L,{onClick:()=>v(`/sites/${h}/submissions/${c}/new`),children:[s.jsx(X,{className:"mr-1.5 h-4 w-4"}),"New Submission"]})]}),s.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[b.length>0&&s.jsx(re,{relationships:b,activeFilters:A?[A]:[],onFilterAdd:e=>{l({relatedTo:e.contentId,relField:e.relName,page:"1",after:""}),a(new Set)},onFilterRemove:()=>{l({relatedTo:"",relField:"",page:"1",after:""}),a(new Set)}}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[m.size>0&&s.jsxs(L,{variant:"destructive",size:"sm",onClick:async()=>{const e=[...m],i=(await $.mutateAsync(e)).filter(o=>o.status==="rejected").length;i?R.error(`${i} of ${e.length} failed to delete`):R.success(`${e.length} submission(s) deleted`),O()},disabled:$.isPending,children:[s.jsx(Z,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete (",m.size,")"]}),s.jsxs(ce,{value:g,onValueChange:e=>{l({sort:e,page:"1",after:""}),a(new Set)},children:[s.jsx(de,{className:"w-[150px]",children:s.jsx(ue,{})}),s.jsx(me,{children:je.map(e=>s.jsx(he,{value:e.value,children:e.label},e.value))})]})]})]}),E?s.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((e,t)=>s.jsx(ee,{className:"h-12 w-full"},t))}):j?.length?s.jsxs(s.Fragment,{children:[P?s.jsx("div",{className:"grid gap-3","data-testid":"submission-card-view",children:j.map(e=>s.jsx(ie,{className:se("cursor-pointer gap-0 overflow-hidden py-0 transition-shadow hover:shadow-md",m.has(e.contentId)&&"ring-2 ring-primary"),onClick:()=>v(`/sites/${h}/submissions/${c}/${e.contentId}`),children:s.jsx(oe,{className:"p-3",children:s.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"font-medium truncate",children:["Submission ",e.contentId.slice(-6)]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e.publishedAt?B(e.publishedAt):"—"}),e.siteUser&&s.jsxs("p",{className:"text-xs text-muted-foreground",children:["by ",e.siteUser.name||e.siteUser.userId]})]}),s.jsx(k,{checked:m.has(e.contentId),onCheckedChange:()=>U(e.contentId),onClick:t=>t.stopPropagation(),className:"mt-1"})]})})},e.contentId))}):s.jsxs(fe,{children:[s.jsx(pe,{children:s.jsxs(_,{children:[s.jsx(S,{className:"w-10",children:s.jsx(k,{checked:M,onCheckedChange:H,"aria-label":"Select all"})}),V.map(e=>s.jsx(S,{children:e.label||e.name},e.name)),f?.requireAuth&&s.jsx(S,{children:"Submitted by"}),s.jsx(S,{children:"Submitted"})]})}),s.jsx(xe,{children:j.map(e=>s.jsxs(_,{className:"cursor-pointer",onClick:()=>v(`/sites/${h}/submissions/${c}/${e.contentId}`),children:[s.jsx(N,{onClick:t=>t.stopPropagation(),children:s.jsx(k,{checked:m.has(e.contentId),onCheckedChange:()=>U(e.contentId),"aria-label":`Select submission ${e.contentId.slice(-6)}`})}),V.map(t=>s.jsx(N,{className:"text-muted-foreground text-sm",children:Y(e,t.name)},t.name)),f?.requireAuth&&s.jsx(N,{className:"text-muted-foreground text-sm",children:e.siteUser?e.siteUser.name||e.siteUser.userId:"—"}),s.jsx(N,{className:"text-muted-foreground",children:e.publishedAt?s.jsx("span",{title:ge(e.publishedAt),children:B(e.publishedAt)}):"—"})]},e.contentId))})]}),s.jsx(be,{page:r,hasNext:!!x?.hasMore,hasPrevious:r>1,onNext:()=>{if(x?.items.length){const e=x.items[x.items.length-1].contentId,t=[...T.slice(0,r-1),e];l({page:String(r+1),after:t.join(",")})}else l({page:String(r+1)});a(new Set)},onPrevious:()=>{const e=r-1;l(e<=1?{page:"1",after:""}:{page:String(e)}),a(new Set)},perPage:w,onPerPageChange:e=>{l({perPage:String(e),page:"1",after:""}),a(new Set)}})]}):s.jsx("p",{className:"text-muted-foreground",children:"No submissions yet."})]})}export{Re as SubmissionListPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as g}from"./react-vendor-C2CvUxFh.js";import{y as r,B as x,j as b,X as y,I as A}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as g}from"./react-vendor-C2CvUxFh.js";import{y as r,B as x,j as b,X as y,I as A}from"./index-Ce5pmRMj.js";import{x as z,y as N,z as k,B as C,E as T,F as S,G as B,H as I,J as E}from"./radix-C5ZmWuuL.js";function K({...t}){return e.jsx(z,{"data-slot":"alert-dialog",...t})}function O({...t}){return e.jsx(B,{"data-slot":"alert-dialog-trigger",...t})}function R({...t}){return e.jsx(I,{"data-slot":"alert-dialog-portal",...t})}function _({className:t,...o}){return e.jsx(E,{"data-slot":"alert-dialog-overlay",className:r("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...o})}function P({className:t,size:o="default",...s}){return e.jsxs(R,{children:[e.jsx(_,{}),e.jsx(N,{"data-slot":"alert-dialog-content","data-size":o,className:r("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg",t),...s})]})}function G({className:t,...o}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:r("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),...o})}function J({className:t,...o}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:r("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),...o})}function U({className:t,...o}){return e.jsx(k,{"data-slot":"alert-dialog-title",className:r("text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),...o})}function W({className:t,...o}){return e.jsx(C,{"data-slot":"alert-dialog-description",className:r("text-muted-foreground text-sm",t),...o})}function X({className:t,variant:o="default",size:s="default",...i}){return e.jsx(x,{variant:o,size:s,asChild:!0,children:e.jsx(S,{"data-slot":"alert-dialog-action",className:r(t),...i})})}function $({className:t,variant:o="outline",size:s="default",...i}){return e.jsx(x,{variant:o,size:s,asChild:!0,children:e.jsx(T,{"data-slot":"alert-dialog-cancel",className:r(t),...i})})}function q({tags:t,onChange:o,placeholder:s,suggestions:i}){const[d,p]=g.useState(""),[f,u]=g.useState(-1),[h,c]=g.useState(!1),w=g.useRef(null),n=d&&i?i.filter(a=>a.toLowerCase().startsWith(d.toLowerCase())&&!t.includes(a)):[];function m(a){const l=a.trim().toLowerCase();l&&!t.includes(l)&&o([...t,l]),p(""),u(-1),c(!1)}function j(a){if(a.key==="ArrowDown"&&n.length>0){a.preventDefault(),u(l=>Math.min(l+1,n.length-1));return}if(a.key==="ArrowUp"&&n.length>0){a.preventDefault(),u(l=>Math.max(l-1,0));return}if(a.key==="Enter"||a.key===","){a.preventDefault(),f>=0&&f<n.length?m(n[f]):m(d);return}if(a.key==="Escape"){c(!1),u(-1);return}a.key==="Backspace"&&!d&&t.length>0&&o(t.slice(0,-1))}function v(a){o(t.filter(l=>l!==a))}return e.jsxs("div",{className:"relative",ref:w,children:[e.jsxs("div",{className:"flex flex-wrap gap-1 rounded-md border p-2 focus-within:ring-1 focus-within:ring-ring",children:[t.map(a=>e.jsxs(b,{variant:"secondary",className:"gap-1",children:[a,e.jsx("button",{type:"button",onClick:()=>v(a),className:"ml-0.5 rounded-full hover:bg-muted",children:e.jsx(y,{className:"h-3 w-3"})})]},a)),e.jsx(A,{value:d,onChange:a=>{p(a.target.value),u(-1),c(!0)},onKeyDown:j,onFocus:()=>c(!0),onBlur:()=>{setTimeout(()=>c(!1),150)},placeholder:t.length===0?s??"Add tags...":"",className:"min-w-[80px] flex-1 border-0 p-0 shadow-none focus-visible:ring-0"})]}),h&&n.length>0&&e.jsx("div",{className:"absolute z-10 mt-1 max-h-48 w-full overflow-auto rounded-md border bg-popover p-1 shadow-md",children:n.map((a,l)=>e.jsx("button",{type:"button",className:`w-full rounded-sm px-2 py-1.5 text-left text-sm ${l===f?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,onMouseDown:D=>{D.preventDefault(),m(a)},children:a},a))})]})}export{K as A,q as T,P as a,G as b,U as c,W as d,J as e,$ as f,X as g,O as h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as b,r as x}from"./react-vendor-C2CvUxFh.js";import{u as D,a as y,b as v}from"./useTags-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as b,r as x}from"./react-vendor-C2CvUxFh.js";import{u as D,a as y,b as v}from"./useTags-B-HgMVwo.js";import{x as w,I as N,B as c,P as C,S as P,T as S,v as d,D as k,k as A,l as E,m as B,n as F,o as H}from"./index-Ce5pmRMj.js";import{T as I,a as M,b as j,c as m,d as $,e as u}from"./table-_3bMY0_z.js";import{u as L}from"./usePageTitle-C1r1-C00.js";import"./radix-C5ZmWuuL.js";function Q(){const{host:t}=b(),{data:s,isLoading:n}=D(t),o=y(t),[l,r]=x.useState(""),[T,g]=x.useState(null),f=w();L({title:"Tags"});async function p(a){a.preventDefault();const i=l.trim().toLowerCase();if(i)try{await o.mutateAsync(i),r(""),d.success(`Tag "${i}" created`)}catch(h){d.error("Failed to create tag",{description:h instanceof Error?h.message:void 0})}}return e.jsxs("div",{children:[!f&&e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsxs("h1",{className:"text-2xl font-semibold",children:["Tags",s?` (${s.length})`:""]})}),e.jsxs("form",{onSubmit:p,className:"mb-6 flex gap-2",children:[e.jsx(N,{value:l,onChange:a=>r(a.target.value),placeholder:"New tag name...",className:"max-w-xs"}),e.jsxs(c,{type:"submit",disabled:o.isPending||!l.trim(),children:[e.jsx(C,{className:"mr-2 h-4 w-4"}),"Add Tag"]})]}),n?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((a,i)=>e.jsx(P,{className:"h-12 w-full"},i))}):s?.length?e.jsxs(I,{children:[e.jsx(M,{children:e.jsxs(j,{children:[e.jsx(m,{children:"Tag"}),e.jsx(m,{children:"Published Content"}),e.jsx(m,{})]})}),e.jsx($,{children:s.map(a=>e.jsxs(j,{children:[e.jsx(u,{className:"font-medium",children:a.tag}),e.jsx(u,{className:"text-muted-foreground",children:a.count}),e.jsx(u,{children:e.jsx(c,{variant:"ghost",size:"sm",disabled:a.count>0,title:a.count>0?"Cannot delete a tag that is in use":"Delete tag",onClick:()=>g(a.tag),children:e.jsx(S,{className:"h-4 w-4"})})})]},a.tag))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No tags yet. Tags are created automatically when you publish content with tags, or you can create them manually above."}),e.jsx(R,{host:t,tag:T,onClose:()=>g(null)})]})}function R({host:t,tag:s,onClose:n}){const o=v(t);async function l(){if(s)try{await o.mutateAsync(s),d.success(`Tag "${s}" deleted`),n()}catch(r){d.error("Failed to delete tag",{description:r instanceof Error?r.message:void 0})}}return e.jsx(k,{open:!!s,onOpenChange:()=>n(),children:e.jsxs(A,{children:[e.jsxs(E,{children:[e.jsx(B,{children:"Delete tag?"}),e.jsxs(F,{children:["This will remove the tag “",s,"” from the tag list. This action cannot be undone."]})]}),e.jsxs(H,{children:[e.jsx(c,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(c,{variant:"destructive",onClick:l,children:"Delete"})]})]})})}export{Q as TagsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as p}from"./react-vendor-C2CvUxFh.js";import{u as P,p as B,d as L,q as z,r as O,s as q,H as R,I as _,S as G,j as J,B as l,t as K,D as g,i as Q,T as V,k as D,l as v,m as A,n as C,o as N,v as n}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as p}from"./react-vendor-C2CvUxFh.js";import{u as P,p as B,d as L,q as z,r as O,s as q,H as R,I as _,S as G,j as J,B as l,t as K,D as g,i as Q,T as V,k as D,l as v,m as A,n as C,o as N,v as n}from"./index-Ce5pmRMj.js";import{C as W}from"./checkbox-DVJcwUt1.js";import{T as X,a as Y,b as w,c as r,d as Z,e as c}from"./table-_3bMY0_z.js";import"./radix-C5ZmWuuL.js";function le(){const{user:S}=P(),{data:y,isLoading:T}=B(),{data:U}=L(),k=z(),u=O(),h=q(),m=y?.items??[],x=U?.superAdminIds??[],[j,F]=p.useState(""),[E,f]=p.useState(null),[d,o]=p.useState(null),b=j?m.filter(s=>s.email.toLowerCase().includes(j.toLowerCase())):m;async function M(s){try{await u.mutateAsync(s),n.success("User deleted"),f(null)}catch(a){n.error("Failed to delete user",{description:a instanceof Error?a.message:void 0})}}async function H(s){try{await h.mutateAsync(s),n.success("Two-factor authentication disabled"),o(null)}catch(a){n.error("Failed to disable 2FA",{description:a instanceof Error?a.message:void 0})}}async function I(s,a){const t=a?x.filter(i=>i!==s):[...x,s];if(t.length===0){n.error("At least one super admin is required");return}try{await k.mutateAsync({superAdminIds:t}),n.success(a?"Super admin removed":"Super admin added")}catch(i){n.error("Failed to update super admins",{description:i instanceof Error?i.message:void 0})}}return e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(R,{}),e.jsxs("div",{className:"flex-1 p-8",children:[e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsx("h1",{className:"text-2xl font-semibold",children:"All Users"})}),e.jsx("div",{className:"mb-4",children:e.jsx(_,{placeholder:"Search by email...",value:j,onChange:s=>F(s.target.value),className:"max-w-sm"})}),T?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,a)=>e.jsx(G,{className:"h-12 w-full"},a))}):b.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No users found."}):e.jsxs(X,{children:[e.jsx(Y,{children:e.jsxs(w,{children:[e.jsx(r,{children:"Email"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"2FA"}),e.jsx(r,{children:"Super Admin"}),e.jsx(r,{})]})}),e.jsx(Z,{children:b.map(s=>{const a=s.sub===S?.sub,t=x.includes(s.sub);return e.jsxs(w,{children:[e.jsxs(c,{className:"text-sm",children:[s.email,a&&e.jsx("span",{className:"text-muted-foreground ml-2",children:"(you)"})]}),e.jsx(c,{className:"text-sm capitalize",children:s.status}),e.jsx(c,{children:s.mfaEnabled?e.jsx(J,{variant:"outline",className:"border-green-500 text-green-700",children:"Enabled"}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(c,{children:e.jsx(W,{checked:t,onCheckedChange:()=>I(s.sub,t)})}),e.jsx(c,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[!a&&s.mfaEnabled&&e.jsx(l,{variant:"ghost",size:"sm",title:"Disable 2FA",onClick:()=>o(s.sub),children:e.jsx(K,{className:"h-4 w-4"})}),!a&&e.jsxs(g,{open:E===s.sub,onOpenChange:i=>f(i?s.sub:null),children:[e.jsx(Q,{asChild:!0,children:e.jsx(l,{variant:"ghost",size:"sm",className:"text-destructive",title:"Delete account",children:e.jsx(V,{className:"h-4 w-4"})})}),e.jsxs(D,{children:[e.jsxs(v,{children:[e.jsx(A,{children:"Delete User Account"}),e.jsx(C,{className:"sr-only",children:"Confirm permanent deletion of this user account"})]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This will permanently delete the account for"," ",e.jsx("strong",{children:s.email}),". They will lose access to all sites."]}),e.jsxs(N,{children:[e.jsx(l,{variant:"outline",onClick:()=>f(null),children:"Cancel"}),e.jsx(l,{variant:"destructive",onClick:()=>M(s.sub),disabled:u.isPending,children:u.isPending?"Deleting...":"Delete Account"})]})]})]})]})})]},s.sub)})})]}),e.jsx(g,{open:d!==null,onOpenChange:s=>{s||o(null)},children:e.jsxs(D,{children:[e.jsxs(v,{children:[e.jsx(A,{children:"Disable Two-Factor Authentication"}),e.jsxs(C,{children:["This will disable 2FA for"," ",e.jsx("strong",{children:m.find(s=>s.sub===d)?.email}),". They will be able to log in with just their password."]})]}),e.jsxs(N,{children:[e.jsx(l,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(l,{variant:"destructive",onClick:()=>{d&&H(d)},disabled:h.isPending,children:h.isPending?"Disabling...":"Disable 2FA"})]})]})})]})]})}export{le as UsersPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as R,f as M,r as d}from"./react-vendor-C2CvUxFh.js";import{a as U,b as q,c as K,d as V,e as Y,f as _}from"./useWebhooks-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as R,f as M,r as d}from"./react-vendor-C2CvUxFh.js";import{a as U,b as q,c as K,d as V,e as Y,f as _}from"./useWebhooks-BvZjUJkJ.js";import{S as v,x as z,L as W,I as G,j as y,B as l,a as J,aM as Q,D as X,i as Z,T as ee,k as se,l as te,m as ae,n as ne,o as re,v as i}from"./index-Ce5pmRMj.js";import{C as b,c as j,a as T,b as w}from"./card-C9hfyHXf.js";import{T as oe,a as ie,b as C,c as p,d as le,e as f}from"./table-_3bMY0_z.js";import{f as ce}from"./format-C88SDH8g.js";import{u as de}from"./usePageTitle-C1r1-C00.js";import"./radix-C5ZmWuuL.js";const he=["content.published","content.unpublished","content.deleted"];function ve(){const{host:t,id:a}=R(),n=a==="new",{data:o,isLoading:c}=U(t,n?"":a);return!n&&c?e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{className:"h-8 w-64"}),e.jsx(v,{className:"h-64 w-full"})]}):n?e.jsx(N,{host:t,isNew:!0}):o?e.jsx(N,{host:t,isNew:!1,webhook:o},o.webhookId):e.jsx("p",{className:"text-muted-foreground",children:"Webhook not found."})}function N({host:t,isNew:a,webhook:n}){const o=M(),c=q(t),h=K(t,n?.webhookId??""),D=V(t,n?.webhookId??""),S=Y(t,n?.webhookId??""),{data:u}=_(t,a?"":n?.webhookId??""),[m,E]=d.useState(n?.url??""),[x,I]=d.useState(n?.events??[]),[g,P]=d.useState(null),[B,k]=d.useState(!1),F=z();de({title:a?"New Webhook":"Edit Webhook",showBack:!0,backTo:`/sites/${t}/settings/webhooks`});function A(s){I(r=>r.includes(s)?r.filter($=>$!==s):[...r,s])}async function H(s){s.preventDefault();try{if(a){const r=await c.mutateAsync({url:m,events:x,enabled:!0});P(r.secret??null),i.success("Webhook created"),o(`/sites/${t}/settings/webhooks/${r.webhookId}`,{replace:!0})}else await h.mutateAsync({url:m,events:x,enabled:n?.enabled}),i.success("Webhook updated")}catch(r){i.error(a?"Failed to create":"Failed to update",{description:r instanceof Error?r.message:void 0})}}async function L(){try{await S.mutateAsync(),i.success("Test webhook sent")}catch(s){i.error("Test failed",{description:s instanceof Error?s.message:void 0})}}async function O(){try{await D.mutateAsync(),i.success("Webhook deleted"),o(`/sites/${t}/settings/webhooks`)}catch(s){i.error("Failed to delete",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl space-y-6",children:[!F&&e.jsx("h1",{className:"text-2xl font-semibold",children:a?"New Webhook":"Edit Webhook"}),g&&e.jsx(b,{className:"border-yellow-500",children:e.jsxs(j,{className:"pt-6",children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Webhook Secret"}),e.jsx("p",{className:"text-muted-foreground mb-2 text-sm",children:"Save this secret now. You won't see it again."}),e.jsx("code",{className:"bg-muted rounded px-2 py-1 text-sm",children:g})]})}),e.jsxs(b,{children:[e.jsx(T,{children:e.jsx(w,{children:"Webhook Settings"})}),e.jsx(j,{children:e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"url",children:"URL"}),e.jsx(G,{id:"url",type:"url",value:m,onChange:s=>E(s.target.value),required:!0,placeholder:"https://example.com/webhook"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{children:"Events"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:he.map(s=>e.jsx(y,{variant:x.includes(s)?"default":"outline",className:"cursor-pointer",onClick:()=>A(s),children:s},s))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{type:"submit",disabled:c.isPending||h.isPending,children:[(c.isPending||h.isPending)&&e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}),a?"Create":"Save"]}),!a&&e.jsxs(l,{type:"button",variant:"outline",onClick:L,children:[e.jsx(Q,{className:"mr-2 h-4 w-4"}),"Test"]}),e.jsx(l,{type:"button",variant:"outline",onClick:()=>o(`/sites/${t}/settings/webhooks`),children:"Cancel"})]})]})})]}),!a&&u?.items&&u.items.length>0&&e.jsxs(b,{children:[e.jsx(T,{children:e.jsx(w,{children:"Recent Deliveries"})}),e.jsx(j,{children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsxs(C,{children:[e.jsx(p,{children:"Event"}),e.jsx(p,{children:"Status"}),e.jsx(p,{children:"Time"})]})}),e.jsx(le,{children:u.items.map(s=>e.jsxs(C,{children:[e.jsx(f,{children:s.event}),e.jsx(f,{children:e.jsx(y,{variant:s.status==="success"?"default":"destructive",children:s.responseStatus??"Error"})}),e.jsx(f,{className:"text-muted-foreground",children:ce(s.createdAt)})]},s.deliveryId))})]})})]}),!a&&e.jsxs(X,{open:B,onOpenChange:k,children:[e.jsx(Z,{asChild:!0,children:e.jsxs(l,{variant:"destructive",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),"Delete Webhook"]})}),e.jsxs(se,{children:[e.jsxs(te,{children:[e.jsx(ae,{children:"Delete webhook?"}),e.jsx(ne,{children:"This action cannot be undone."})]}),e.jsxs(re,{children:[e.jsx(l,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),e.jsx(l,{variant:"destructive",onClick:O,children:"Delete"})]})]})]})]})}export{ve as WebhookEditPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as j,f as b}from"./react-vendor-C2CvUxFh.js";import{u}from"./useWebhooks-
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as j,f as b}from"./react-vendor-C2CvUxFh.js";import{u}from"./useWebhooks-BvZjUJkJ.js";import{x as f,B as r,P as c,S as p,j as d}from"./index-Ce5pmRMj.js";import{T as k,a as g,b as m,c as i,d as N,e as l}from"./table-_3bMY0_z.js";import{u as v}from"./usePageTitle-C1r1-C00.js";import"./radix-C5ZmWuuL.js";function I(){const{host:a}=j(),t=b(),{data:n,isLoading:x}=u(a),h=f();return v({title:"Webhooks",actions:s.jsx(r,{size:"sm",onClick:()=>t(`/sites/${a}/settings/webhooks/new`),children:s.jsx(c,{className:"h-4 w-4"})})}),s.jsxs("div",{children:[!h&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Webhooks"}),s.jsxs(r,{onClick:()=>t(`/sites/${a}/settings/webhooks/new`),children:[s.jsx(c,{className:"mr-2 h-4 w-4"}),"New Webhook"]})]}),x?s.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((e,o)=>s.jsx(p,{className:"h-12 w-full"},o))}):n?.items.length?s.jsxs(k,{children:[s.jsx(g,{children:s.jsxs(m,{children:[s.jsx(i,{children:"URL"}),s.jsx(i,{children:"Events"}),s.jsx(i,{children:"Status"})]})}),s.jsx(N,{children:n.items.map(e=>s.jsxs(m,{className:"cursor-pointer",onClick:()=>t(`/sites/${a}/settings/webhooks/${e.webhookId}`),children:[s.jsx(l,{className:"max-w-xs truncate font-mono text-sm",children:e.url}),s.jsx(l,{children:s.jsx("div",{className:"flex flex-wrap gap-1",children:e.events.map(o=>s.jsx(d,{variant:"secondary",className:"text-xs",children:o},o))})}),s.jsx(l,{children:s.jsx(d,{variant:e.enabled?"default":"secondary",children:e.enabled?"Active":"Inactive"})})]},e.webhookId))})]}):s.jsx("p",{className:"text-muted-foreground",children:"No webhooks configured."})]})}export{I as WebhooksPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./tanstack-Bs3zYPPV.js";import"./react-vendor-C2CvUxFh.js";import{y as d}from"./index-
|
|
1
|
+
import{j as r}from"./tanstack-Bs3zYPPV.js";import"./react-vendor-C2CvUxFh.js";import{y as d}from"./index-Ce5pmRMj.js";function n({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:d("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:d("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...t})}function c({className:a,...t}){return r.jsx("div",{"data-slot":"card-title",className:d("leading-none font-semibold",a),...t})}function l({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:d("text-muted-foreground text-sm",a),...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:d("px-6",a),...t})}export{n as C,i as a,c as b,u as c,l as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./tanstack-Bs3zYPPV.js";import"./react-vendor-C2CvUxFh.js";import{a2 as i,y as t}from"./index-
|
|
1
|
+
import{j as r}from"./tanstack-Bs3zYPPV.js";import"./react-vendor-C2CvUxFh.js";import{a2 as i,y as t}from"./index-Ce5pmRMj.js";import{a1 as s,a2 as o}from"./radix-C5ZmWuuL.js";function b({className:e,...a}){return r.jsx(s,{"data-slot":"checkbox",className:t("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(o,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(i,{className:"size-3.5"})})})}export{b as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as C}from"./tanstack-Bs3zYPPV.js";import{r as l,b as Re}from"./react-vendor-C2CvUxFh.js";import{X as V,Y as L,h as Ae,m as je,O as $e,j as Pe}from"./radix-C5ZmWuuL.js";import{y as z,z as Me}from"./index-BA3y7HJs.js";var pe=1,Ne=.9,De=.8,Le=.17,te=.1,re=.999,Ve=.9999,_e=.99,Oe=/[\\\/_+.#"@\[\(\{&]/,Fe=/[\\\/_+.#"@\[\(\{&]/g,ze=/[\s-]/,he=/[\s-]/g;function le(e,r,t,u,a,o,s){if(o===r.length)return a===e.length?pe:_e;var f=`${a},${o}`;if(s[f]!==void 0)return s[f];for(var p=u.charAt(o),c=t.indexOf(p,a),v=0,h,k,w,I;c>=0;)h=le(e,r,t,u,c+1,o+1,s),h>v&&(c===a?h*=pe:Oe.test(e.charAt(c-1))?(h*=De,w=e.slice(a,c-1).match(Fe),w&&a>0&&(h*=Math.pow(re,w.length))):ze.test(e.charAt(c-1))?(h*=Ne,I=e.slice(a,c-1).match(he),I&&a>0&&(h*=Math.pow(re,I.length))):(h*=Le,a>0&&(h*=Math.pow(re,c-a))),e.charAt(c)!==r.charAt(o)&&(h*=Ve)),(h<te&&t.charAt(c-1)===u.charAt(o+1)||u.charAt(o+1)===u.charAt(o)&&t.charAt(c-1)!==u.charAt(o))&&(k=le(e,r,t,u,c+1,o+2,s),k*te>h&&(h=k*te)),h>v&&(v=h),c=t.indexOf(p,c+1);return s[f]=v,v}function ve(e){return e.toLowerCase().replace(he," ")}function Ke(e,r,t){return e=t&&t.length>0?`${e+" "+t.join(" ")}`:e,le(e,r,ve(e),ve(r),0,0,{})}var qe=Symbol.for("react.lazy"),W=Re[" use ".trim().toString()];function Te(e){return typeof e=="object"&&e!==null&&"then"in e}function be(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===qe&&"_payload"in e&&Te(e._payload)}function ye(e){const r=We(e),t=l.forwardRef((u,a)=>{let{children:o,...s}=u;be(o)&&typeof W=="function"&&(o=W(o._payload));const f=l.Children.toArray(o),p=f.find(He);if(p){const c=p.props.children,v=f.map(h=>h===p?l.Children.count(c)>1?l.Children.only(null):l.isValidElement(c)?c.props.children:null:h);return C.jsx(r,{...s,ref:a,children:l.isValidElement(c)?l.cloneElement(c,void 0,v):null})}return C.jsx(r,{...s,ref:a,children:o})});return t.displayName=`${e}.Slot`,t}var vt=ye("Slot");function We(e){const r=l.forwardRef((t,u)=>{let{children:a,...o}=t;if(be(a)&&typeof W=="function"&&(a=W(a._payload)),l.isValidElement(a)){const s=Ge(a),f=Ye(o,a.props);return a.type!==l.Fragment&&(f.ref=u?V(u,s):s),l.cloneElement(a,f)}return l.Children.count(a)>1?l.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Be=Symbol("radix.slottable");function He(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Be}function Ye(e,r){const t={...r};for(const u in r){const a=e[u],o=r[u];/^on[A-Z]/.test(u)?a&&o?t[u]=(...f)=>{const p=o(...f);return a(...f),p}:a&&(t[u]=a):u==="style"?t[u]={...a,...o}:u==="className"&&(t[u]=[a,o].filter(Boolean).join(" "))}return{...e,...t}}function Ge(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning;return t?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Ue=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],A=Ue.reduce((e,r)=>{const t=ye(`Primitive.${r}`),u=l.forwardRef((a,o)=>{const{asChild:s,...f}=a,p=s?t:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),C.jsx(p,{...f,ref:o})});return u.displayName=`Primitive.${r}`,{...e,[r]:u}},{}),F='[cmdk-group=""]',ne='[cmdk-group-items=""]',Xe='[cmdk-group-heading=""]',xe='[cmdk-item=""]',ge=`${xe}:not([aria-disabled="true"])`,ae="cmdk-item-select",N="data-value",Ze=(e,r,t)=>Ke(e,r,t),we=l.createContext(void 0),K=()=>l.useContext(we),Ee=l.createContext(void 0),oe=()=>l.useContext(Ee),Se=l.createContext(void 0),ke=l.forwardRef((e,r)=>{let t=D(()=>{var n,d;return{search:"",value:(d=(n=e.value)!=null?n:e.defaultValue)!=null?d:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),u=D(()=>new Set),a=D(()=>new Map),o=D(()=>new Map),s=D(()=>new Set),f=Ce(e),{label:p,children:c,value:v,onValueChange:h,filter:k,shouldFilter:w,loop:I,disablePointerSelection:H=!1,vimBindings:j=!0,...q}=e,Y=L(),ie=L(),G=L(),$=l.useRef(null),y=ut();P(()=>{if(v!==void 0){let n=v.trim();t.current.value=n,E.emit()}},[v]),P(()=>{y(6,ce)},[]);let E=l.useMemo(()=>({subscribe:n=>(s.current.add(n),()=>s.current.delete(n)),snapshot:()=>t.current,setState:(n,d,m)=>{var i,g,b,S;if(!Object.is(t.current[n],d)){if(t.current[n]=d,n==="search")J(),X(),y(1,Z);else if(n==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let x=document.getElementById(G);x?x.focus():(i=document.getElementById(Y))==null||i.focus()}if(y(7,()=>{var x;t.current.selectedItemId=(x=M())==null?void 0:x.id,E.emit()}),m||y(5,ce),((g=f.current)==null?void 0:g.value)!==void 0){let x=d??"";(S=(b=f.current).onValueChange)==null||S.call(b,x);return}}E.emit()}},emit:()=>{s.current.forEach(n=>n())}}),[]),U=l.useMemo(()=>({value:(n,d,m)=>{var i;d!==((i=o.current.get(n))==null?void 0:i.value)&&(o.current.set(n,{value:d,keywords:m}),t.current.filtered.items.set(n,ue(d,m)),y(2,()=>{X(),E.emit()}))},item:(n,d)=>(u.current.add(n),d&&(a.current.has(d)?a.current.get(d).add(n):a.current.set(d,new Set([n]))),y(3,()=>{J(),X(),t.current.value||Z(),E.emit()}),()=>{o.current.delete(n),u.current.delete(n),t.current.filtered.items.delete(n);let m=M();y(4,()=>{J(),m?.getAttribute("id")===n&&Z(),E.emit()})}),group:n=>(a.current.has(n)||a.current.set(n,new Set),()=>{o.current.delete(n),a.current.delete(n)}),filter:()=>f.current.shouldFilter,label:p||e["aria-label"],getDisablePointerSelection:()=>f.current.disablePointerSelection,listId:Y,inputId:G,labelId:ie,listInnerRef:$}),[]);function ue(n,d){var m,i;let g=(i=(m=f.current)==null?void 0:m.filter)!=null?i:Ze;return n?g(n,t.current.search,d):0}function X(){if(!t.current.search||f.current.shouldFilter===!1)return;let n=t.current.filtered.items,d=[];t.current.filtered.groups.forEach(i=>{let g=a.current.get(i),b=0;g.forEach(S=>{let x=n.get(S);b=Math.max(x,b)}),d.push([i,b])});let m=$.current;O().sort((i,g)=>{var b,S;let x=i.getAttribute("id"),T=g.getAttribute("id");return((b=n.get(T))!=null?b:0)-((S=n.get(x))!=null?S:0)}).forEach(i=>{let g=i.closest(ne);g?g.appendChild(i.parentElement===g?i:i.closest(`${ne} > *`)):m.appendChild(i.parentElement===m?i:i.closest(`${ne} > *`))}),d.sort((i,g)=>g[1]-i[1]).forEach(i=>{var g;let b=(g=$.current)==null?void 0:g.querySelector(`${F}[${N}="${encodeURIComponent(i[0])}"]`);b?.parentElement.appendChild(b)})}function Z(){let n=O().find(m=>m.getAttribute("aria-disabled")!=="true"),d=n?.getAttribute(N);E.setState("value",d||void 0)}function J(){var n,d,m,i;if(!t.current.search||f.current.shouldFilter===!1){t.current.filtered.count=u.current.size;return}t.current.filtered.groups=new Set;let g=0;for(let b of u.current){let S=(d=(n=o.current.get(b))==null?void 0:n.value)!=null?d:"",x=(i=(m=o.current.get(b))==null?void 0:m.keywords)!=null?i:[],T=ue(S,x);t.current.filtered.items.set(b,T),T>0&&g++}for(let[b,S]of a.current)for(let x of S)if(t.current.filtered.items.get(x)>0){t.current.filtered.groups.add(b);break}t.current.filtered.count=g}function ce(){var n,d,m;let i=M();i&&(((n=i.parentElement)==null?void 0:n.firstChild)===i&&((m=(d=i.closest(F))==null?void 0:d.querySelector(Xe))==null||m.scrollIntoView({block:"nearest"})),i.scrollIntoView({block:"nearest"}))}function M(){var n;return(n=$.current)==null?void 0:n.querySelector(`${xe}[aria-selected="true"]`)}function O(){var n;return Array.from(((n=$.current)==null?void 0:n.querySelectorAll(ge))||[])}function Q(n){let d=O()[n];d&&E.setState("value",d.getAttribute(N))}function ee(n){var d;let m=M(),i=O(),g=i.findIndex(S=>S===m),b=i[g+n];(d=f.current)!=null&&d.loop&&(b=g+n<0?i[i.length-1]:g+n===i.length?i[0]:i[g+n]),b&&E.setState("value",b.getAttribute(N))}function se(n){let d=M(),m=d?.closest(F),i;for(;m&&!i;)m=n>0?ot(m,F):it(m,F),i=m?.querySelector(ge);i?E.setState("value",i.getAttribute(N)):ee(n)}let de=()=>Q(O().length-1),fe=n=>{n.preventDefault(),n.metaKey?de():n.altKey?se(1):ee(1)},me=n=>{n.preventDefault(),n.metaKey?Q(0):n.altKey?se(-1):ee(-1)};return l.createElement(A.div,{ref:r,tabIndex:-1,...q,"cmdk-root":"",onKeyDown:n=>{var d;(d=q.onKeyDown)==null||d.call(q,n);let m=n.nativeEvent.isComposing||n.keyCode===229;if(!(n.defaultPrevented||m))switch(n.key){case"n":case"j":{j&&n.ctrlKey&&fe(n);break}case"ArrowDown":{fe(n);break}case"p":case"k":{j&&n.ctrlKey&&me(n);break}case"ArrowUp":{me(n);break}case"Home":{n.preventDefault(),Q(0);break}case"End":{n.preventDefault(),de();break}case"Enter":{n.preventDefault();let i=M();if(i){let g=new Event(ae);i.dispatchEvent(g)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:st},p),B(e,n=>l.createElement(Ee.Provider,{value:E},l.createElement(we.Provider,{value:U},n))))}),Je=l.forwardRef((e,r)=>{var t,u;let a=L(),o=l.useRef(null),s=l.useContext(Se),f=K(),p=Ce(e),c=(u=(t=p.current)==null?void 0:t.forceMount)!=null?u:s?.forceMount;P(()=>{if(!c)return f.item(a,s?.id)},[c]);let v=Ie(a,o,[e.value,e.children,o],e.keywords),h=oe(),k=R(y=>y.value&&y.value===v.current),w=R(y=>c||f.filter()===!1?!0:y.search?y.filtered.items.get(a)>0:!0);l.useEffect(()=>{let y=o.current;if(!(!y||e.disabled))return y.addEventListener(ae,I),()=>y.removeEventListener(ae,I)},[w,e.onSelect,e.disabled]);function I(){var y,E;H(),(E=(y=p.current).onSelect)==null||E.call(y,v.current)}function H(){h.setState("value",v.current,!0)}if(!w)return null;let{disabled:j,value:q,onSelect:Y,forceMount:ie,keywords:G,...$}=e;return l.createElement(A.div,{ref:V(o,r),...$,id:a,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!k,"data-disabled":!!j,"data-selected":!!k,onPointerMove:j||f.getDisablePointerSelection()?void 0:H,onClick:j?void 0:I},e.children)}),Qe=l.forwardRef((e,r)=>{let{heading:t,children:u,forceMount:a,...o}=e,s=L(),f=l.useRef(null),p=l.useRef(null),c=L(),v=K(),h=R(w=>a||v.filter()===!1?!0:w.search?w.filtered.groups.has(s):!0);P(()=>v.group(s),[]),Ie(s,f,[e.value,e.heading,p]);let k=l.useMemo(()=>({id:s,forceMount:a}),[a]);return l.createElement(A.div,{ref:V(f,r),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},t&&l.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:c},t),B(e,w=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?c:void 0},l.createElement(Se.Provider,{value:k},w))))}),et=l.forwardRef((e,r)=>{let{alwaysRender:t,...u}=e,a=l.useRef(null),o=R(s=>!s.search);return!t&&!o?null:l.createElement(A.div,{ref:V(a,r),...u,"cmdk-separator":"",role:"separator"})}),tt=l.forwardRef((e,r)=>{let{onValueChange:t,...u}=e,a=e.value!=null,o=oe(),s=R(c=>c.search),f=R(c=>c.selectedItemId),p=K();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(A.input,{ref:r,...u,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":f,id:p.inputId,type:"text",value:a?e.value:s,onChange:c=>{a||o.setState("search",c.target.value),t?.(c.target.value)}})}),rt=l.forwardRef((e,r)=>{let{children:t,label:u="Suggestions",...a}=e,o=l.useRef(null),s=l.useRef(null),f=R(c=>c.selectedItemId),p=K();return l.useEffect(()=>{if(s.current&&o.current){let c=s.current,v=o.current,h,k=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let w=c.offsetHeight;v.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return k.observe(c),()=>{cancelAnimationFrame(h),k.unobserve(c)}}},[]),l.createElement(A.div,{ref:V(o,r),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":f,"aria-label":u,id:p.listId},B(e,c=>l.createElement("div",{ref:V(s,p.listInnerRef),"cmdk-list-sizer":""},c)))}),nt=l.forwardRef((e,r)=>{let{open:t,onOpenChange:u,overlayClassName:a,contentClassName:o,container:s,...f}=e;return l.createElement(Ae,{open:t,onOpenChange:u},l.createElement(je,{container:s},l.createElement($e,{"cmdk-overlay":"",className:a}),l.createElement(Pe,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(ke,{ref:r,...f}))))}),lt=l.forwardRef((e,r)=>R(t=>t.filtered.count===0)?l.createElement(A.div,{ref:r,...e,"cmdk-empty":"",role:"presentation"}):null),at=l.forwardRef((e,r)=>{let{progress:t,children:u,label:a="Loading...",...o}=e;return l.createElement(A.div,{ref:r,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},B(e,s=>l.createElement("div",{"aria-hidden":!0},s)))}),_=Object.assign(ke,{List:rt,Item:Je,Input:tt,Group:Qe,Separator:et,Dialog:nt,Empty:lt,Loading:at});function ot(e,r){let t=e.nextElementSibling;for(;t;){if(t.matches(r))return t;t=t.nextElementSibling}}function it(e,r){let t=e.previousElementSibling;for(;t;){if(t.matches(r))return t;t=t.previousElementSibling}}function Ce(e){let r=l.useRef(e);return P(()=>{r.current=e}),r}var P=typeof window>"u"?l.useEffect:l.useLayoutEffect;function D(e){let r=l.useRef();return r.current===void 0&&(r.current=e()),r}function R(e){let r=oe(),t=()=>e(r.snapshot());return l.useSyncExternalStore(r.subscribe,t,t)}function Ie(e,r,t,u=[]){let a=l.useRef(),o=K();return P(()=>{var s;let f=(()=>{var c;for(let v of t){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(c=v.current.textContent)==null?void 0:c.trim():a.current}})(),p=u.map(c=>c.trim());o.value(e,f,p),(s=r.current)==null||s.setAttribute(N,f),a.current=f}),a}var ut=()=>{let[e,r]=l.useState(),t=D(()=>new Map);return P(()=>{t.current.forEach(u=>u()),t.current=new Map},[e]),(u,a)=>{t.current.set(u,a),r({})}};function ct(e){let r=e.type;return typeof r=="function"?r(e.props):"render"in r?r.render(e.props):e}function B({asChild:e,children:r},t){return e&&l.isValidElement(r)?l.cloneElement(ct(r),{ref:r.ref},t(r.props.children)):t(r)}var st={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function gt({className:e,...r}){return C.jsx(_,{"data-slot":"command",className:z("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...r})}function ht({className:e,...r}){return C.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[C.jsx(Me,{className:"size-4 shrink-0 opacity-50"}),C.jsx(_.Input,{"data-slot":"command-input",className:z("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})}function bt({className:e,...r}){return C.jsx(_.List,{"data-slot":"command-list",className:z("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...r})}function yt({...e}){return C.jsx(_.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function xt({className:e,...r}){return C.jsx(_.Group,{"data-slot":"command-group",className:z("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...r})}function wt({className:e,...r}){return C.jsx(_.Item,{"data-slot":"command-item",className:z("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}export{gt as C,A as P,vt as S,ht as a,bt as b,yt as c,xt as d,wt as e};
|
|
1
|
+
import{j as C}from"./tanstack-Bs3zYPPV.js";import{r as l,b as Re}from"./react-vendor-C2CvUxFh.js";import{X as V,Y as L,h as Ae,m as je,O as $e,j as Pe}from"./radix-C5ZmWuuL.js";import{y as z,z as Me}from"./index-Ce5pmRMj.js";var pe=1,Ne=.9,De=.8,Le=.17,te=.1,re=.999,Ve=.9999,_e=.99,Oe=/[\\\/_+.#"@\[\(\{&]/,Fe=/[\\\/_+.#"@\[\(\{&]/g,ze=/[\s-]/,he=/[\s-]/g;function le(e,r,t,u,a,o,s){if(o===r.length)return a===e.length?pe:_e;var f=`${a},${o}`;if(s[f]!==void 0)return s[f];for(var p=u.charAt(o),c=t.indexOf(p,a),v=0,h,k,w,I;c>=0;)h=le(e,r,t,u,c+1,o+1,s),h>v&&(c===a?h*=pe:Oe.test(e.charAt(c-1))?(h*=De,w=e.slice(a,c-1).match(Fe),w&&a>0&&(h*=Math.pow(re,w.length))):ze.test(e.charAt(c-1))?(h*=Ne,I=e.slice(a,c-1).match(he),I&&a>0&&(h*=Math.pow(re,I.length))):(h*=Le,a>0&&(h*=Math.pow(re,c-a))),e.charAt(c)!==r.charAt(o)&&(h*=Ve)),(h<te&&t.charAt(c-1)===u.charAt(o+1)||u.charAt(o+1)===u.charAt(o)&&t.charAt(c-1)!==u.charAt(o))&&(k=le(e,r,t,u,c+1,o+2,s),k*te>h&&(h=k*te)),h>v&&(v=h),c=t.indexOf(p,c+1);return s[f]=v,v}function ve(e){return e.toLowerCase().replace(he," ")}function Ke(e,r,t){return e=t&&t.length>0?`${e+" "+t.join(" ")}`:e,le(e,r,ve(e),ve(r),0,0,{})}var qe=Symbol.for("react.lazy"),W=Re[" use ".trim().toString()];function Te(e){return typeof e=="object"&&e!==null&&"then"in e}function be(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===qe&&"_payload"in e&&Te(e._payload)}function ye(e){const r=We(e),t=l.forwardRef((u,a)=>{let{children:o,...s}=u;be(o)&&typeof W=="function"&&(o=W(o._payload));const f=l.Children.toArray(o),p=f.find(He);if(p){const c=p.props.children,v=f.map(h=>h===p?l.Children.count(c)>1?l.Children.only(null):l.isValidElement(c)?c.props.children:null:h);return C.jsx(r,{...s,ref:a,children:l.isValidElement(c)?l.cloneElement(c,void 0,v):null})}return C.jsx(r,{...s,ref:a,children:o})});return t.displayName=`${e}.Slot`,t}var vt=ye("Slot");function We(e){const r=l.forwardRef((t,u)=>{let{children:a,...o}=t;if(be(a)&&typeof W=="function"&&(a=W(a._payload)),l.isValidElement(a)){const s=Ge(a),f=Ye(o,a.props);return a.type!==l.Fragment&&(f.ref=u?V(u,s):s),l.cloneElement(a,f)}return l.Children.count(a)>1?l.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Be=Symbol("radix.slottable");function He(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Be}function Ye(e,r){const t={...r};for(const u in r){const a=e[u],o=r[u];/^on[A-Z]/.test(u)?a&&o?t[u]=(...f)=>{const p=o(...f);return a(...f),p}:a&&(t[u]=a):u==="style"?t[u]={...a,...o}:u==="className"&&(t[u]=[a,o].filter(Boolean).join(" "))}return{...e,...t}}function Ge(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning;return t?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Ue=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],A=Ue.reduce((e,r)=>{const t=ye(`Primitive.${r}`),u=l.forwardRef((a,o)=>{const{asChild:s,...f}=a,p=s?t:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),C.jsx(p,{...f,ref:o})});return u.displayName=`Primitive.${r}`,{...e,[r]:u}},{}),F='[cmdk-group=""]',ne='[cmdk-group-items=""]',Xe='[cmdk-group-heading=""]',xe='[cmdk-item=""]',ge=`${xe}:not([aria-disabled="true"])`,ae="cmdk-item-select",N="data-value",Ze=(e,r,t)=>Ke(e,r,t),we=l.createContext(void 0),K=()=>l.useContext(we),Ee=l.createContext(void 0),oe=()=>l.useContext(Ee),Se=l.createContext(void 0),ke=l.forwardRef((e,r)=>{let t=D(()=>{var n,d;return{search:"",value:(d=(n=e.value)!=null?n:e.defaultValue)!=null?d:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),u=D(()=>new Set),a=D(()=>new Map),o=D(()=>new Map),s=D(()=>new Set),f=Ce(e),{label:p,children:c,value:v,onValueChange:h,filter:k,shouldFilter:w,loop:I,disablePointerSelection:H=!1,vimBindings:j=!0,...q}=e,Y=L(),ie=L(),G=L(),$=l.useRef(null),y=ut();P(()=>{if(v!==void 0){let n=v.trim();t.current.value=n,E.emit()}},[v]),P(()=>{y(6,ce)},[]);let E=l.useMemo(()=>({subscribe:n=>(s.current.add(n),()=>s.current.delete(n)),snapshot:()=>t.current,setState:(n,d,m)=>{var i,g,b,S;if(!Object.is(t.current[n],d)){if(t.current[n]=d,n==="search")J(),X(),y(1,Z);else if(n==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let x=document.getElementById(G);x?x.focus():(i=document.getElementById(Y))==null||i.focus()}if(y(7,()=>{var x;t.current.selectedItemId=(x=M())==null?void 0:x.id,E.emit()}),m||y(5,ce),((g=f.current)==null?void 0:g.value)!==void 0){let x=d??"";(S=(b=f.current).onValueChange)==null||S.call(b,x);return}}E.emit()}},emit:()=>{s.current.forEach(n=>n())}}),[]),U=l.useMemo(()=>({value:(n,d,m)=>{var i;d!==((i=o.current.get(n))==null?void 0:i.value)&&(o.current.set(n,{value:d,keywords:m}),t.current.filtered.items.set(n,ue(d,m)),y(2,()=>{X(),E.emit()}))},item:(n,d)=>(u.current.add(n),d&&(a.current.has(d)?a.current.get(d).add(n):a.current.set(d,new Set([n]))),y(3,()=>{J(),X(),t.current.value||Z(),E.emit()}),()=>{o.current.delete(n),u.current.delete(n),t.current.filtered.items.delete(n);let m=M();y(4,()=>{J(),m?.getAttribute("id")===n&&Z(),E.emit()})}),group:n=>(a.current.has(n)||a.current.set(n,new Set),()=>{o.current.delete(n),a.current.delete(n)}),filter:()=>f.current.shouldFilter,label:p||e["aria-label"],getDisablePointerSelection:()=>f.current.disablePointerSelection,listId:Y,inputId:G,labelId:ie,listInnerRef:$}),[]);function ue(n,d){var m,i;let g=(i=(m=f.current)==null?void 0:m.filter)!=null?i:Ze;return n?g(n,t.current.search,d):0}function X(){if(!t.current.search||f.current.shouldFilter===!1)return;let n=t.current.filtered.items,d=[];t.current.filtered.groups.forEach(i=>{let g=a.current.get(i),b=0;g.forEach(S=>{let x=n.get(S);b=Math.max(x,b)}),d.push([i,b])});let m=$.current;O().sort((i,g)=>{var b,S;let x=i.getAttribute("id"),T=g.getAttribute("id");return((b=n.get(T))!=null?b:0)-((S=n.get(x))!=null?S:0)}).forEach(i=>{let g=i.closest(ne);g?g.appendChild(i.parentElement===g?i:i.closest(`${ne} > *`)):m.appendChild(i.parentElement===m?i:i.closest(`${ne} > *`))}),d.sort((i,g)=>g[1]-i[1]).forEach(i=>{var g;let b=(g=$.current)==null?void 0:g.querySelector(`${F}[${N}="${encodeURIComponent(i[0])}"]`);b?.parentElement.appendChild(b)})}function Z(){let n=O().find(m=>m.getAttribute("aria-disabled")!=="true"),d=n?.getAttribute(N);E.setState("value",d||void 0)}function J(){var n,d,m,i;if(!t.current.search||f.current.shouldFilter===!1){t.current.filtered.count=u.current.size;return}t.current.filtered.groups=new Set;let g=0;for(let b of u.current){let S=(d=(n=o.current.get(b))==null?void 0:n.value)!=null?d:"",x=(i=(m=o.current.get(b))==null?void 0:m.keywords)!=null?i:[],T=ue(S,x);t.current.filtered.items.set(b,T),T>0&&g++}for(let[b,S]of a.current)for(let x of S)if(t.current.filtered.items.get(x)>0){t.current.filtered.groups.add(b);break}t.current.filtered.count=g}function ce(){var n,d,m;let i=M();i&&(((n=i.parentElement)==null?void 0:n.firstChild)===i&&((m=(d=i.closest(F))==null?void 0:d.querySelector(Xe))==null||m.scrollIntoView({block:"nearest"})),i.scrollIntoView({block:"nearest"}))}function M(){var n;return(n=$.current)==null?void 0:n.querySelector(`${xe}[aria-selected="true"]`)}function O(){var n;return Array.from(((n=$.current)==null?void 0:n.querySelectorAll(ge))||[])}function Q(n){let d=O()[n];d&&E.setState("value",d.getAttribute(N))}function ee(n){var d;let m=M(),i=O(),g=i.findIndex(S=>S===m),b=i[g+n];(d=f.current)!=null&&d.loop&&(b=g+n<0?i[i.length-1]:g+n===i.length?i[0]:i[g+n]),b&&E.setState("value",b.getAttribute(N))}function se(n){let d=M(),m=d?.closest(F),i;for(;m&&!i;)m=n>0?ot(m,F):it(m,F),i=m?.querySelector(ge);i?E.setState("value",i.getAttribute(N)):ee(n)}let de=()=>Q(O().length-1),fe=n=>{n.preventDefault(),n.metaKey?de():n.altKey?se(1):ee(1)},me=n=>{n.preventDefault(),n.metaKey?Q(0):n.altKey?se(-1):ee(-1)};return l.createElement(A.div,{ref:r,tabIndex:-1,...q,"cmdk-root":"",onKeyDown:n=>{var d;(d=q.onKeyDown)==null||d.call(q,n);let m=n.nativeEvent.isComposing||n.keyCode===229;if(!(n.defaultPrevented||m))switch(n.key){case"n":case"j":{j&&n.ctrlKey&&fe(n);break}case"ArrowDown":{fe(n);break}case"p":case"k":{j&&n.ctrlKey&&me(n);break}case"ArrowUp":{me(n);break}case"Home":{n.preventDefault(),Q(0);break}case"End":{n.preventDefault(),de();break}case"Enter":{n.preventDefault();let i=M();if(i){let g=new Event(ae);i.dispatchEvent(g)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:st},p),B(e,n=>l.createElement(Ee.Provider,{value:E},l.createElement(we.Provider,{value:U},n))))}),Je=l.forwardRef((e,r)=>{var t,u;let a=L(),o=l.useRef(null),s=l.useContext(Se),f=K(),p=Ce(e),c=(u=(t=p.current)==null?void 0:t.forceMount)!=null?u:s?.forceMount;P(()=>{if(!c)return f.item(a,s?.id)},[c]);let v=Ie(a,o,[e.value,e.children,o],e.keywords),h=oe(),k=R(y=>y.value&&y.value===v.current),w=R(y=>c||f.filter()===!1?!0:y.search?y.filtered.items.get(a)>0:!0);l.useEffect(()=>{let y=o.current;if(!(!y||e.disabled))return y.addEventListener(ae,I),()=>y.removeEventListener(ae,I)},[w,e.onSelect,e.disabled]);function I(){var y,E;H(),(E=(y=p.current).onSelect)==null||E.call(y,v.current)}function H(){h.setState("value",v.current,!0)}if(!w)return null;let{disabled:j,value:q,onSelect:Y,forceMount:ie,keywords:G,...$}=e;return l.createElement(A.div,{ref:V(o,r),...$,id:a,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!k,"data-disabled":!!j,"data-selected":!!k,onPointerMove:j||f.getDisablePointerSelection()?void 0:H,onClick:j?void 0:I},e.children)}),Qe=l.forwardRef((e,r)=>{let{heading:t,children:u,forceMount:a,...o}=e,s=L(),f=l.useRef(null),p=l.useRef(null),c=L(),v=K(),h=R(w=>a||v.filter()===!1?!0:w.search?w.filtered.groups.has(s):!0);P(()=>v.group(s),[]),Ie(s,f,[e.value,e.heading,p]);let k=l.useMemo(()=>({id:s,forceMount:a}),[a]);return l.createElement(A.div,{ref:V(f,r),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},t&&l.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:c},t),B(e,w=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?c:void 0},l.createElement(Se.Provider,{value:k},w))))}),et=l.forwardRef((e,r)=>{let{alwaysRender:t,...u}=e,a=l.useRef(null),o=R(s=>!s.search);return!t&&!o?null:l.createElement(A.div,{ref:V(a,r),...u,"cmdk-separator":"",role:"separator"})}),tt=l.forwardRef((e,r)=>{let{onValueChange:t,...u}=e,a=e.value!=null,o=oe(),s=R(c=>c.search),f=R(c=>c.selectedItemId),p=K();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(A.input,{ref:r,...u,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":f,id:p.inputId,type:"text",value:a?e.value:s,onChange:c=>{a||o.setState("search",c.target.value),t?.(c.target.value)}})}),rt=l.forwardRef((e,r)=>{let{children:t,label:u="Suggestions",...a}=e,o=l.useRef(null),s=l.useRef(null),f=R(c=>c.selectedItemId),p=K();return l.useEffect(()=>{if(s.current&&o.current){let c=s.current,v=o.current,h,k=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let w=c.offsetHeight;v.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return k.observe(c),()=>{cancelAnimationFrame(h),k.unobserve(c)}}},[]),l.createElement(A.div,{ref:V(o,r),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":f,"aria-label":u,id:p.listId},B(e,c=>l.createElement("div",{ref:V(s,p.listInnerRef),"cmdk-list-sizer":""},c)))}),nt=l.forwardRef((e,r)=>{let{open:t,onOpenChange:u,overlayClassName:a,contentClassName:o,container:s,...f}=e;return l.createElement(Ae,{open:t,onOpenChange:u},l.createElement(je,{container:s},l.createElement($e,{"cmdk-overlay":"",className:a}),l.createElement(Pe,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(ke,{ref:r,...f}))))}),lt=l.forwardRef((e,r)=>R(t=>t.filtered.count===0)?l.createElement(A.div,{ref:r,...e,"cmdk-empty":"",role:"presentation"}):null),at=l.forwardRef((e,r)=>{let{progress:t,children:u,label:a="Loading...",...o}=e;return l.createElement(A.div,{ref:r,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},B(e,s=>l.createElement("div",{"aria-hidden":!0},s)))}),_=Object.assign(ke,{List:rt,Item:Je,Input:tt,Group:Qe,Separator:et,Dialog:nt,Empty:lt,Loading:at});function ot(e,r){let t=e.nextElementSibling;for(;t;){if(t.matches(r))return t;t=t.nextElementSibling}}function it(e,r){let t=e.previousElementSibling;for(;t;){if(t.matches(r))return t;t=t.previousElementSibling}}function Ce(e){let r=l.useRef(e);return P(()=>{r.current=e}),r}var P=typeof window>"u"?l.useEffect:l.useLayoutEffect;function D(e){let r=l.useRef();return r.current===void 0&&(r.current=e()),r}function R(e){let r=oe(),t=()=>e(r.snapshot());return l.useSyncExternalStore(r.subscribe,t,t)}function Ie(e,r,t,u=[]){let a=l.useRef(),o=K();return P(()=>{var s;let f=(()=>{var c;for(let v of t){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(c=v.current.textContent)==null?void 0:c.trim():a.current}})(),p=u.map(c=>c.trim());o.value(e,f,p),(s=r.current)==null||s.setAttribute(N,f),a.current=f}),a}var ut=()=>{let[e,r]=l.useState(),t=D(()=>new Map);return P(()=>{t.current.forEach(u=>u()),t.current=new Map},[e]),(u,a)=>{t.current.set(u,a),r({})}};function ct(e){let r=e.type;return typeof r=="function"?r(e.props):"render"in r?r.render(e.props):e}function B({asChild:e,children:r},t){return e&&l.isValidElement(r)?l.cloneElement(ct(r),{ref:r.ref},t(r.props.children)):t(r)}var st={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function gt({className:e,...r}){return C.jsx(_,{"data-slot":"command",className:z("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...r})}function ht({className:e,...r}){return C.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[C.jsx(Me,{className:"size-4 shrink-0 opacity-50"}),C.jsx(_.Input,{"data-slot":"command-input",className:z("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})}function bt({className:e,...r}){return C.jsx(_.List,{"data-slot":"command-list",className:z("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...r})}function yt({...e}){return C.jsx(_.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function xt({className:e,...r}){return C.jsx(_.Group,{"data-slot":"command-group",className:z("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...r})}function wt({className:e,...r}){return C.jsx(_.Item,{"data-slot":"command-item",className:z("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}export{gt as C,A as P,vt as S,ht as a,bt as b,yt as c,xt as d,wt as e};
|