headroom-cms 0.1.7 → 0.1.8
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 +9 -82
- package/admin/assets/{AdminsPage-BqfhR4Zc.js → AdminsPage-Bt_ekZen.js} +1 -1
- package/admin/assets/AllContentPage-CFqEMAl9.js +1 -0
- package/admin/assets/{ApiKeysPage-DJjOSLoR.js → ApiKeysPage-BfWCxGhC.js} +1 -1
- package/admin/assets/AuditPage-BE0XIUl2.js +1 -0
- package/admin/assets/{BlockEditor-DDsml97y.js → BlockEditor-6wqsThJ7.js} +40 -40
- package/admin/assets/{BlockTypeEditPage-Cg7BifaZ.js → BlockTypeEditPage-CuNJfZw0.js} +1 -1
- package/admin/assets/{BlockTypesPage-BDFj8TSL.js → BlockTypesPage-BIMBVxBs.js} +1 -1
- package/admin/assets/{BulkActionBar-CastJGEP.js → BulkActionBar-TRiXXLQd.js} +1 -1
- package/admin/assets/{CollectionEditPage-DGW4iMfo.js → CollectionEditPage-BqX_0cC2.js} +1 -1
- package/admin/assets/{CollectionsPage-C8XNxRda.js → CollectionsPage-ClplrxNn.js} +1 -1
- package/admin/assets/{ContentCreatePage-CX4aOzTR.js → ContentCreatePage-DfYcEH1u.js} +1 -1
- package/admin/assets/ContentEditPage-D3Rvlktk.js +2 -0
- package/admin/assets/ContentListPage-zmO8Is4d.js +1 -0
- package/admin/assets/{CustomBlockPreview-DfDOcbmR.js → CustomBlockPreview-C6HqS4xv.js} +1 -1
- package/admin/assets/{FieldBuilder-8VVLG_j0.js → FieldBuilder-36tfpSyM.js} +1 -1
- package/admin/assets/{FilterBar-JCp03kkK.js → FilterBar-DhRwTqFv.js} +1 -1
- package/admin/assets/{LoginPage-gPNC9XRN.js → LoginPage-DutieANA.js} +1 -1
- package/admin/assets/MediaField-J2TLG_fu.js +1 -0
- package/admin/assets/{MediaPage-D9763lEk.js → MediaPage-DZZKMGF4.js} +1 -1
- package/admin/assets/{RelationshipPicker-D7dFI43Q.js → RelationshipPicker-CDFs4TMW.js} +1 -1
- package/admin/assets/SiteSettingsPage-BtCC3RKc.js +1 -0
- package/admin/assets/SiteUserEditPage-ClHmp0T-.js +1 -0
- package/admin/assets/SiteUsersPage-AyJvcVM7.js +1 -0
- package/admin/assets/{SitesPage-BFIZ3Y5K.js → SitesPage-Bw_WBN6v.js} +1 -1
- package/admin/assets/SubmissionDetailPage-DS08LGxd.js +1 -0
- package/admin/assets/{SubmissionEditPage-PgowJuvq.js → SubmissionEditPage-Brf-DK2X.js} +1 -1
- package/admin/assets/{SubmissionListPage-HFDQxPhn.js → SubmissionListPage-DNMzQZHS.js} +1 -1
- package/admin/assets/{TagInput-CDkKZboX.js → TagInput-BILCaC9b.js} +1 -1
- package/admin/assets/{TagsPage-BW15-W4H.js → TagsPage-DdeZokow.js} +1 -1
- package/admin/assets/{UsersPage-C-zlDeTy.js → UsersPage-B0vLxjrg.js} +1 -1
- package/admin/assets/{WebhookEditPage-cPPALIbH.js → WebhookEditPage-SlJE4d3z.js} +1 -1
- package/admin/assets/{WebhooksPage-vkPC4m9a.js → WebhooksPage-C6lGZLpr.js} +1 -1
- package/admin/assets/{card-10FqkZPA.js → card-hXVtlM0q.js} +1 -1
- package/admin/assets/{checkbox-fC1QPb_4.js → checkbox-WGrS3sUr.js} +1 -1
- package/admin/assets/{command-BeacdV75.js → command-fvBFHye4.js} +1 -1
- package/admin/assets/{index-wYNPRVrc.js → index-Cir9tY_P.js} +5 -5
- package/admin/assets/index-DACBYsKM.css +1 -0
- package/admin/assets/{popover-BJDj8C6y.js → popover-D5_HjjUC.js} +1 -1
- package/admin/assets/{select-BV3jemT6.js → select-_uJYxzeZ.js} +1 -1
- package/admin/assets/serializeToText-DR_WnxiI.js +2 -0
- package/admin/assets/{table-WkEcC9MH.js → table-DLoIbCQ5.js} +1 -1
- package/admin/assets/{textarea-CHQ9tT69.js → textarea-vSXNxwTe.js} +1 -1
- package/admin/assets/useAdminResolver-D-LlmquD.js +1 -0
- package/admin/assets/useContent-e8beBIuq.js +1 -0
- package/admin/assets/{useContentSearch-B-_p0_QX.js → useContentSearch-DOjveB9t.js} +1 -1
- package/admin/assets/{useMedia-m6zKB__r.js → useMedia-e3sqWm_t.js} +1 -1
- package/admin/assets/{usePageTitle-Bwf-MpTD.js → usePageTitle-BNSba9_L.js} +1 -1
- package/admin/assets/useSiteUsers-BdnvuM2E.js +1 -0
- package/admin/assets/{useTags-CLPWVUB3.js → useTags-f7AVSLuj.js} +1 -1
- package/admin/assets/{useWebhooks-no0l3-mF.js → useWebhooks-BH_r8-Mo.js} +1 -1
- package/admin/index.html +2 -2
- package/admin/sw.js +1 -1
- package/dist/cdn.d.ts.map +1 -1
- package/dist/cdn.js +179 -19
- package/dist/cdn.js.map +1 -1
- package/lambda/api/bootstrap +0 -0
- package/lambda/webhook-worker/bootstrap +0 -0
- package/package.json +1 -1
- package/src/cdn.ts +184 -19
- package/admin/assets/AllContentPage-C11eeRMt.js +0 -1
- package/admin/assets/AuditPage-DJNk7IaW.js +0 -1
- package/admin/assets/ContentEditPage-Dj3RK2BF.js +0 -2
- package/admin/assets/ContentListPage-CoDanHrR.js +0 -1
- package/admin/assets/MediaField-Du7_gRse.js +0 -1
- package/admin/assets/SiteSettingsPage-Tfiex2yn.js +0 -1
- package/admin/assets/SiteUsersPage-CSV8syR3.js +0 -1
- package/admin/assets/SubmissionDetailPage-8vtUQsLd.js +0 -1
- package/admin/assets/index-Do_SK4Zl.css +0 -1
- package/admin/assets/serializeToText-BJy0Ms5I.js +0 -2
- package/admin/assets/useAdminResolver-CpZj93vH.js +0 -1
- package/admin/assets/useContent-D8yDRTTy.js +0 -1
- package/admin/assets/useSiteUsers-QbiItSH1.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as H,f as M,r as o}from"./react-vendor-C2CvUxFh.js";import{L as d,I as y,a9 as C,aA as R,S as T,aB as U,aC as V,aD as W,x as _,W as z,B as h,a as G,D as J,i as K,T as Q,k as X,l as Y,m as Z,n as ee,o as ae,v as j}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as H,f as M,r as o}from"./react-vendor-C2CvUxFh.js";import{L as d,I as y,a9 as C,aA as R,S as T,aB as U,aC as V,aD as W,x as _,W as z,B as h,a as G,D as J,i as K,T as Q,k as X,l as Y,m as Z,n as ee,o as ae,v as j}from"./index-Cir9tY_P.js";import{I as se,F as te}from"./FieldBuilder-36tfpSyM.js";import{i as le}from"./format-C88SDH8g.js";import{T as ie}from"./textarea-vSXNxwTe.js";import{C as ne,a as re,b as oe,c as ce}from"./card-hXVtlM0q.js";import{C as de,a as me,b as pe}from"./collapsible-B414SspL.js";import{C as ue}from"./CustomBlockPreview-C6HqS4xv.js";import{u as B}from"./useDebouncedValue-C-cQUcLG.js";import{u as xe}from"./usePageTitle-BNSba9_L.js";import"./radix-C1kb_NqW.js";import"./core.esm-B_kcYf6n.js";import"./sortable.esm-QyXA6fio.js";import"./select-_uJYxzeZ.js";import"./checkbox-WGrS3sUr.js";function he({fields:s,previewTemplate:t,previewData:a,onPreviewDataChange:r,blockTypeName:c,blockTypeLabel:m,blockTypeIcon:b}){const i=B(t,300),f=B(a,300);return e.jsxs("div",{className:"space-y-4",children:[s.map(n=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:n.label}),e.jsx(y,{value:String(a[n.name]??""),onChange:v=>r({...a,[n.name]:v.target.value}),placeholder:`Sample ${n.label}...`})]},n.name)),e.jsx(C,{}),e.jsx("div",{className:"rounded-md border p-4",children:e.jsx(ue,{blockType:{name:c,label:m,icon:b,fields:s,previewTemplate:i},props:f})})]})}function Le(){const{host:s,name:t}=H(),a=t==="new",{data:r,isLoading:c}=R(s,a?"":t);return!a&&c?e.jsxs("div",{className:"space-y-4",children:[e.jsx(T,{className:"h-8 w-64"}),e.jsx(T,{className:"h-64 w-full"})]}):a?e.jsx(N,{host:s,isNew:!0}):r?e.jsx(N,{host:s,isNew:!1,blockType:r},r.name):e.jsx("p",{className:"text-muted-foreground",children:"Block type not found."})}function N({host:s,isNew:t,blockType:a}){const r=M(),c=U(s),m=V(s,a?.name??""),b=W(s,a?.name??""),[i,f]=o.useState(a?.name??""),[n,v]=o.useState(a?.label??""),[g,D]=o.useState(a?.icon??""),[S,P]=o.useState(!t),F=new Set((a?.fields??[]).map(l=>l.name).filter(Boolean)),[p,L]=o.useState(a?.fields??[]),[u,I]=o.useState(a?.previewTemplate??""),[x,E]=o.useState(a?.previewData??{}),[O,k]=o.useState(!1),$=_();xe({title:t?"New Block Type":a?.label??i,showBack:!0,backTo:`/sites/${s}/settings/block-types`});async function q(l){l.preventDefault();try{t?(await c.mutateAsync({name:i,label:n,icon:g,fields:p,previewTemplate:u||void 0,previewData:Object.keys(x).length>0?x:void 0}),j.success("Block type created"),r(`/sites/${s}/settings/block-types/${i}`)):(await m.mutateAsync({label:n,icon:g,fields:p,previewTemplate:u||void 0,previewData:Object.keys(x).length>0?x:void 0}),j.success("Block type updated"))}catch(w){j.error(t?"Failed to create":"Failed to update",{description:w instanceof Error?w.message:void 0})}}async function A(){try{await b.mutateAsync(),j.success("Block type deleted"),r(`/sites/${s}/settings/block-types`)}catch(l){j.error("Failed to delete",{description:l instanceof Error?l.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!$&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:t?"New Block Type":`Edit: ${a?.label??i}`}),e.jsxs(ne,{children:[e.jsx(re,{children:e.jsx(oe,{children:"Block Type Settings"})}),e.jsx(ce,{children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"name",children:"Name"}),e.jsx(se,{id:"name",value:i,onChange:f,onBlur:()=>{i&&!S&&v(le(i))},readOnly:!t,placeholder:"e.g. hero_banner",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"label",children:"Label"}),e.jsx(y,{id:"label",value:n,onChange:l=>{v(l.target.value),P(!0)},required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"icon",children:"Icon"}),e.jsx(y,{id:"icon",value:g,onChange:l=>D(l.target.value)})]}),e.jsx(C,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Block Fields"}),e.jsx(te,{fields:p,onChange:L,existingFieldNames:F})]}),e.jsx(C,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"preview-template",children:"Preview Template (Liquid + Tailwind)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Use Liquid syntax to render a preview. Block field values are available as template variables."}),e.jsx(ie,{id:"preview-template",value:u,onChange:l=>I(l.target.value),rows:6,placeholder:'<div class="p-4">{{ title }}</div>',className:"font-mono text-sm"})]}),(u||p.length>0)&&e.jsxs(de,{children:[e.jsxs(me,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(z,{className:"h-4 w-4 transition-transform [[data-state=open]>&]:rotate-90"}),"Preview"]}),e.jsx(pe,{className:"mt-2",children:e.jsx(he,{fields:p,previewTemplate:u,previewData:x,onPreviewDataChange:E,blockTypeName:i,blockTypeLabel:n,blockTypeIcon:g})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{type:"submit",disabled:c.isPending||m.isPending,children:[(c.isPending||m.isPending)&&e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}),t?"Create":"Save"]}),e.jsx(h,{type:"button",variant:"outline",onClick:()=>r(`/sites/${s}/settings/block-types`),children:"Cancel"})]})]})})]}),!t&&e.jsx("div",{className:"mt-6",children:e.jsxs(J,{open:O,onOpenChange:k,children:[e.jsx(K,{asChild:!0,children:e.jsxs(h,{variant:"destructive",children:[e.jsx(Q,{className:"mr-2 h-4 w-4"}),"Delete Block Type"]})}),e.jsxs(X,{children:[e.jsxs(Y,{children:[e.jsx(Z,{children:"Delete block type?"}),e.jsx(ee,{children:"This will permanently delete this block type."})]}),e.jsxs(ae,{children:[e.jsx(h,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),e.jsx(h,{variant:"destructive",onClick:A,children:"Delete"})]})]})]})})]})}export{Le as BlockTypeEditPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as h,f as j}from"./react-vendor-C2CvUxFh.js";import{az as p,x as u,B as c,P as o,S as f}from"./index-
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as h,f as j}from"./react-vendor-C2CvUxFh.js";import{az as p,x as u,B as c,P as o,S as f}from"./index-Cir9tY_P.js";import{T as N,a as b,b as r,c as a,d as g,e as i}from"./table-DLoIbCQ5.js";import{u as k}from"./usePageTitle-BNSba9_L.js";import"./radix-C1kb_NqW.js";function C(){const{host:l}=h(),n=j(),{data:t,isLoading:m}=p(l),d=u();return k({title:"Block Types",actions:s.jsx(c,{size:"sm",onClick:()=>n(`/sites/${l}/settings/block-types/new`),children:s.jsx(o,{className:"h-4 w-4"})})}),s.jsxs("div",{children:[!d&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Block Types"}),s.jsxs(c,{onClick:()=>n(`/sites/${l}/settings/block-types/new`),children:[s.jsx(o,{className:"mr-2 h-4 w-4"}),"New Block Type"]})]}),m?s.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((e,x)=>s.jsx(f,{className:"h-12 w-full"},x))}):t?.items.length?s.jsxs(N,{children:[s.jsx(b,{children:s.jsxs(r,{children:[s.jsx(a,{children:"Name"}),s.jsx(a,{children:"Label"}),s.jsx(a,{children:"Icon"}),s.jsx(a,{children:"Fields"})]})}),s.jsx(g,{children:t.items.map(e=>s.jsxs(r,{className:"cursor-pointer",onClick:()=>n(`/sites/${l}/settings/block-types/${e.name}`),children:[s.jsx(i,{className:"font-mono text-sm",children:e.name}),s.jsx(i,{children:e.label}),s.jsx(i,{children:e.icon}),s.jsx(i,{className:"text-muted-foreground",children:e.fields?.length??0})]},e.name))})]}):s.jsx("p",{className:"text-muted-foreground",children:"No block types defined."})]})}export{C as BlockTypesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as m}from"./react-vendor-C2CvUxFh.js";import{B as a,a as t,X as x,D as h,k as j,l as p,m as u,n as D,o as b}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as m}from"./react-vendor-C2CvUxFh.js";import{B as a,a as t,X as x,D as h,k as j,l as p,m as u,n as D,o as b}from"./index-Cir9tY_P.js";function k({selectedCount:i,onPublish:n,onUnpublish:r,onDelete:o,onClear:c,isPending:s}){const[d,l]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-md border bg-muted/50 px-4 py-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:[i," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{size:"sm",variant:"outline",onClick:n,disabled:s,children:[s&&e.jsx(t,{className:"mr-1 h-3 w-3 animate-spin"}),"Publish"]}),e.jsx(a,{size:"sm",variant:"outline",onClick:r,disabled:s,children:"Unpublish"}),e.jsx(a,{size:"sm",variant:"destructive",onClick:()=>l(!0),disabled:s,children:"Delete"})]}),e.jsx(a,{size:"sm",variant:"ghost",onClick:c,className:"ml-auto",disabled:s,children:e.jsx(x,{className:"h-4 w-4"})})]}),e.jsx(h,{open:d,onOpenChange:l,children:e.jsxs(j,{children:[e.jsxs(p,{children:[e.jsxs(u,{children:["Delete ",i," item",i!==1?"s":"","?"]}),e.jsx(D,{children:"This action cannot be undone. The selected content items will be permanently deleted."})]}),e.jsxs(b,{children:[e.jsx(a,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(a,{variant:"destructive",onClick:async()=>{l(!1),await o()},disabled:s,children:[s&&e.jsx(t,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})})]})}export{k as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as i,u as fe,f as Ce}from"./react-vendor-C2CvUxFh.js";import{R as ve,W as Se,y as Q,as as Ne,B as C,T as ee,I as E,P as ye,at as V,au as ke,S as z,x as Pe,w as De,av as Le,aw as Ee,ax as Te,L as h,ay as we,a9 as G,a as Fe,D as Ie,i as Be,k as Ae,l as Re,m as Oe,n as Me,o as qe,v as L}from"./index-wYNPRVrc.js";import{I as se,F as Ue}from"./FieldBuilder-8VVLG_j0.js";import{i as ae,c as $e}from"./format-C88SDH8g.js";import{C as O}from"./checkbox-fC1QPb_4.js";import{C as W,a as Y,b as K,c as X}from"./card-10FqkZPA.js";import{u as _e}from"./usePageTitle-Bwf-MpTD.js";import{S as M,a as q,b as U,c as $,d as f}from"./select-BV3jemT6.js";import{C as He,u as Ve,a as ze,P as Ge,D as We,c as Ye}from"./core.esm-B_kcYf6n.js";import{u as Ke,S as Xe,v as Ze,a as Je}from"./sortable.esm-QyXA6fio.js";import{C as Qe,a as es,b as ss}from"./collapsible-B414SspL.js";import{P as as,a as ts,b as ls}from"./popover-BJDj8C6y.js";import"./radix-C1kb_NqW.js";import"./textarea-CHQ9tT69.js";function ns({id:a,relationship:s,onChange:t,onRemove:u,collections:x,readOnlyName:g,defaultExpanded:j}){const[o,k]=i.useState(j??!1),[m,P]=i.useState(!!s.label),{attributes:v,listeners:c,setNodeRef:r,transform:d,transition:S}=Ke({id:a}),y={transform:He.Transform.toString(d),transition:S};function p(n){t({...s,...n})}const T=x.find(n=>n.name===s.targetCollection)?.label??s.targetCollection;return e.jsx("div",{ref:r,style:y,className:"rounded-md border bg-card",children:e.jsxs(Qe,{open:o,onOpenChange:k,children:[e.jsxs("div",{className:"flex items-center gap-2 p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...v,...c,children:e.jsx(ve,{className:"h-4 w-4"})}),e.jsx(es,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex items-center",children:e.jsx(Se,{className:Q("h-4 w-4 transition-transform",o&&"rotate-90")})})}),e.jsx("span",{className:"min-w-[80px] text-sm font-mono",children:s.name||"unnamed"}),e.jsx(Ne,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:T}),e.jsx("span",{className:"flex-1 truncate text-sm text-muted-foreground",children:s.label}),e.jsx(C,{type:"button",variant:"ghost",size:"sm",onClick:u,className:"text-destructive",children:e.jsx(ee,{className:"h-3 w-3"})})]}),e.jsx(ss,{children:e.jsxs("div",{className:"space-y-3 border-t p-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),e.jsx(se,{value:s.name,onChange:n=>p({name:n}),onBlur:()=>{s.name&&!m&&p({label:ae(s.name)})},readOnly:g,className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Label"}),e.jsx(E,{value:s.label,onChange:n=>{p({label:n.target.value}),P(!0)},className:"h-8 text-sm"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Target Collection"}),e.jsxs(M,{value:s.targetCollection,onValueChange:n=>p({targetCollection:n}),children:[e.jsx(q,{className:"h-8 text-sm",children:e.jsx(U,{placeholder:"Select collection..."})}),e.jsx($,{children:x.map(n=>e.jsx(f,{value:n.name,children:n.label},n.name))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:`${a}-multiple`,checked:s.multiple,onCheckedChange:n=>p({multiple:!!n})}),e.jsx("label",{htmlFor:`${a}-multiple`,className:"text-sm",children:"Allow multiple"})]})]})})]})})}function is({relationships:a,onChange:s,collections:t,existingRelNames:u}){const x=Ve(ze(Ge)),g=a.map((c,r)=>`rel-${r}`),[j,o]=i.useState(null);function k(){o(a.length),s([...a,{name:"",label:"",targetCollection:"",multiple:!1}])}function m(c,r){const d=[...a];d[c]=r,s(d)}function P(c){s(a.filter((r,d)=>d!==c))}function v(c){const{active:r,over:d}=c;if(d&&r.id!==d.id){const S=g.indexOf(String(r.id)),y=g.indexOf(String(d.id));s(Je(a,S,y))}}return e.jsx(We,{sensors:x,collisionDetection:Ye,onDragEnd:v,children:e.jsx(Xe,{items:g,strategy:Ze,children:e.jsxs("div",{className:"space-y-2",children:[a.map((c,r)=>e.jsx(ns,{id:`rel-${r}`,relationship:c,onChange:d=>m(r,d),onRemove:()=>P(r),collections:t,readOnlyName:!!(u?.has(c.name)&&c.name),defaultExpanded:r===j},`rel-${r}`)),e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:k,children:[e.jsx(ye,{className:"mr-2 h-3 w-3"})," Add Relationship"]})]})})})}const Z=["Newspaper","FileText","BookOpen","PenLine","Edit","Image","Camera","Video","Music","Mic","ShoppingCart","Store","Package","Tag","Gift","Users","User","UserPlus","Contact","Building","Calendar","Clock","Timer","CalendarDays","CalendarCheck","Star","Heart","ThumbsUp","Award","Trophy","Map","MapPin","Globe","Compass","Navigation","MessageSquare","Mail","Send","Phone","Bell","Folder","FolderOpen","Archive","Database","HardDrive","Settings","Wrench","Cog","Sliders","SlidersHorizontal","BarChart","PieChart","TrendingUp","Activity","LineChart","Code","Terminal","Braces","Bug","Puzzle","Home","Layout","Grid","List","Layers","Lightbulb","Zap","Flame","Sun","Moon","Link","ExternalLink","Share","Download","Upload","Lock","Unlock","Shield","Key","Eye"];function rs({value:a,onChange:s}){const[t,u]=i.useState(!1),[x,g]=i.useState(""),j=x?Z.filter(o=>o.toLowerCase().includes(x.toLowerCase())):Z;return e.jsxs(as,{open:t,onOpenChange:u,children:[e.jsx(ts,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:"gap-2 w-full justify-start",children:[e.jsx(V,{name:a||"FileText",className:"h-4 w-4"}),e.jsx("span",{className:"truncate",children:a||"Select icon..."})]})}),e.jsxs(ls,{className:"w-72 p-2",align:"start",children:[e.jsx(E,{placeholder:"Search icons...",value:x,onChange:o=>g(o.target.value),className:"mb-2",autoFocus:!0}),e.jsxs("div",{className:"grid grid-cols-6 gap-1 max-h-48 overflow-y-auto",children:[j.map(o=>e.jsx("button",{type:"button",title:o,className:Q("flex items-center justify-center rounded-md p-2 hover:bg-accent transition-colors",a===o&&"bg-accent ring-1 ring-primary"),onClick:()=>{s(o),u(!1),g("")},children:e.jsx(V,{name:o,className:"h-4 w-4"})},o)),j.length===0&&e.jsx("p",{className:"col-span-6 text-center text-sm text-muted-foreground py-4",children:"No matching icons"})]})]})]})}const os=["text","textarea","number","boolean","select","array"],cs=["url","email","date","content","blocks"];function ks(){const{host:a,name:s}=fe(),t=s==="new",{data:u,isLoading:x}=ke(a,t?"":s);return!t&&x?e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{className:"h-8 w-64"}),e.jsx(z,{className:"h-64 w-full"})]}):t?e.jsx(J,{host:a,isNew:!0}):u?e.jsx(J,{host:a,isNew:!1,collection:u},u.name):e.jsx("p",{className:"text-muted-foreground",children:"Collection not found."})}function J({host:a,isNew:s,collection:t}){const u=Ce(),x=Pe(),{collections:g}=De(),j=Le(a),o=Ee(a,t?.name??""),k=Te(a,t?.name??""),[m,P]=i.useState(t?.name??""),[v,c]=i.useState(t?.label??""),[r,d]=i.useState(t?.labelSingular??""),[S,y]=i.useState(t?.slug??""),[p,T]=i.useState(t?.singleton??!1),[n,te]=i.useState(t?.mode??"content"),[F,le]=i.useState(t?.requireAuth??!1),b=n==="submission",[ne,ie]=i.useState(!s),[re,oe]=i.useState(!s),[ce,de]=i.useState(!s),ue=new Set((t?.fields??[]).map(l=>l.name).filter(Boolean)),I=[{name:"blocks",label:"Blocks",type:"blocks",options:{}}],[D,w]=i.useState(t?.fields??(s&&!p?I:[])),[B,me]=i.useState(t?.relationships??[]),xe=new Set((t?.relationships??[]).map(l=>l.name).filter(Boolean)),[A,he]=i.useState(t?.mobileNavPriority??0),[R,ge]=i.useState(t?.icon??""),[je,_]=i.useState(!1);_e({title:s?"New Collection":t?.label??m,showBack:!0,backTo:`/sites/${a}/settings/collections`});function pe(){if(!m)return;const l=ae(m);ne||c(l),re||d($e(l)),ce||y(m.replace(/_/g,"-"))}async function H(l){l?.preventDefault();try{s?(await j.mutateAsync({name:m,label:v,labelSingular:r,slug:S,singleton:b?!1:p,fields:D,relationships:B,mobileNavPriority:A,icon:R,mode:n,requireAuth:b?F:void 0}),L.success("Collection created"),u(`/sites/${a}/settings/collections/${m}`)):(await o.mutateAsync({label:v,labelSingular:r,slug:b?void 0:S,singleton:b?!1:p,fields:D,relationships:B,mobileNavPriority:A,icon:R,mode:n,requireAuth:b?F:void 0}),L.success("Collection updated"))}catch(N){L.error(s?"Failed to create":"Failed to update",{description:N instanceof Error?N.message:void 0})}}async function be(){try{await k.mutateAsync(),L.success("Collection deleted"),u(`/sites/${a}/settings/collections`)}catch(l){L.error("Failed to delete",{description:l instanceof Error?l.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!x&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:s?"New Collection":`Edit: ${t?.label??m}`}),e.jsxs(W,{children:[e.jsx(Y,{children:e.jsx(K,{children:"Collection Settings"})}),e.jsx(X,{children:e.jsxs("form",{onSubmit:H,className:"space-y-4","aria-label":"Collection settings",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"name",children:"Name"}),e.jsx(se,{id:"name",value:m,onChange:P,onBlur:pe,readOnly:!s,placeholder:"e.g. blog_posts",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"mode",children:"Mode"}),e.jsxs(M,{value:n,onValueChange:l=>{te(l),l==="submission"&&s&&(T(!1),w(D.filter(N=>os.includes(N.type)))),l==="content"&&s&&D.length===0&&w(I)},disabled:!s,children:[e.jsx(q,{id:"mode",children:e.jsx(U,{})}),e.jsxs($,{children:[e.jsx(f,{value:"content",children:"Content"}),e.jsx(f,{value:"submission",children:"Submissions"})]})]}),!s&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mode cannot be changed after creation."})]}),b&&e.jsx("div",{className:"rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Submission Collection"}),e.jsxs("p",{className:"mt-1",children:["Submissions are created via the API:"," ",e.jsxs("code",{className:"rounded bg-blue-100 px-1 dark:bg-blue-900",children:["POST /v1/","{site}","/submit/",m||"{collection}"]})]})]})]})}),b&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:"requireAuth",checked:F,onCheckedChange:l=>le(!!l)}),e.jsx(h,{htmlFor:"requireAuth",children:"Require authentication (site users must be logged in to submit)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"label",children:"Label"}),e.jsx(E,{id:"label",value:v,onChange:l=>{c(l.target.value),ie(!0)},required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"label-singular",children:"Label Singular"}),e.jsx(E,{id:"label-singular",value:r,onChange:l=>{d(l.target.value),oe(!0)},required:!0})]}),!b&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"slug",children:"Slug"}),e.jsx(E,{id:"slug",value:S,onChange:l=>{y(l.target.value),de(!0)},required:!0})]}),!b&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:"singleton",checked:p,onCheckedChange:l=>{const N=!!l;T(N),s&&w(N?[]:I)},disabled:!s}),e.jsx(h,{htmlFor:"singleton",children:"Singleton (single entry, no list)"})]}),e.jsx(G,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Fields"}),e.jsx(Ue,{fields:D,onChange:w,excludeTypes:b?cs:void 0,existingFieldNames:ue})]}),e.jsx(G,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Relationships"}),e.jsx(is,{relationships:B,onChange:me,collections:g,existingRelNames:xe})]})]})})]}),e.jsxs(W,{className:"mt-6",children:[e.jsx(Y,{children:e.jsx(K,{children:"Navigation"})}),e.jsxs(X,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Icon"}),e.jsx(rs,{value:R,onChange:ge})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"mobileNavPriority",children:"Bottom Nav Priority"}),e.jsxs(M,{value:String(A),onValueChange:l=>he(Number(l)),children:[e.jsx(q,{id:"mobileNavPriority",children:e.jsx(U,{})}),e.jsxs($,{children:[e.jsx(f,{value:"0",children:"0 - Hidden"}),e.jsx(f,{value:"1",children:"1"}),e.jsx(f,{value:"2",children:"2"}),e.jsx(f,{value:"3",children:"3"}),e.jsx(f,{value:"4",children:"4"}),e.jsx(f,{value:"5",children:"5 - Highest"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Collections with priority > 0 appear in the mobile bottom navigation bar."})]})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(C,{type:"button",variant:"outline",onClick:()=>u(`/sites/${a}/settings/collections`),children:"Cancel"}),e.jsxs(C,{onClick:H,disabled:j.isPending||o.isPending,children:[(j.isPending||o.isPending)&&e.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Create":"Save"]})]}),!s&&e.jsx("div",{className:"mt-6",children:e.jsxs(Ie,{open:je,onOpenChange:_,children:[e.jsx(Be,{asChild:!0,children:e.jsxs(C,{variant:"destructive",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),"Delete Collection"]})}),e.jsxs(Ae,{children:[e.jsxs(Re,{children:[e.jsx(Oe,{children:"Delete collection?"}),e.jsx(Me,{children:"This will permanently delete the collection and all its content."})]}),e.jsxs(qe,{children:[e.jsx(C,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(C,{variant:"destructive",onClick:be,children:"Delete"})]})]})]})})]})}export{ks as CollectionEditPage};
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as i,u as fe,f as Ce}from"./react-vendor-C2CvUxFh.js";import{R as ve,W as Se,y as Q,as as Ne,B as C,T as ee,I as E,P as ye,at as V,au as ke,S as z,x as Pe,w as De,av as Le,aw as Ee,ax as Te,L as h,ay as we,a9 as G,a as Fe,D as Ie,i as Be,k as Ae,l as Re,m as Oe,n as Me,o as qe,v as L}from"./index-Cir9tY_P.js";import{I as se,F as Ue}from"./FieldBuilder-36tfpSyM.js";import{i as ae,c as $e}from"./format-C88SDH8g.js";import{C as O}from"./checkbox-WGrS3sUr.js";import{C as W,a as Y,b as K,c as X}from"./card-hXVtlM0q.js";import{u as _e}from"./usePageTitle-BNSba9_L.js";import{S as M,a as q,b as U,c as $,d as f}from"./select-_uJYxzeZ.js";import{C as He,u as Ve,a as ze,P as Ge,D as We,c as Ye}from"./core.esm-B_kcYf6n.js";import{u as Ke,S as Xe,v as Ze,a as Je}from"./sortable.esm-QyXA6fio.js";import{C as Qe,a as es,b as ss}from"./collapsible-B414SspL.js";import{P as as,a as ts,b as ls}from"./popover-D5_HjjUC.js";import"./radix-C1kb_NqW.js";import"./textarea-vSXNxwTe.js";function ns({id:a,relationship:s,onChange:t,onRemove:u,collections:x,readOnlyName:g,defaultExpanded:j}){const[o,k]=i.useState(j??!1),[m,P]=i.useState(!!s.label),{attributes:v,listeners:c,setNodeRef:r,transform:d,transition:S}=Ke({id:a}),y={transform:He.Transform.toString(d),transition:S};function p(n){t({...s,...n})}const T=x.find(n=>n.name===s.targetCollection)?.label??s.targetCollection;return e.jsx("div",{ref:r,style:y,className:"rounded-md border bg-card",children:e.jsxs(Qe,{open:o,onOpenChange:k,children:[e.jsxs("div",{className:"flex items-center gap-2 p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...v,...c,children:e.jsx(ve,{className:"h-4 w-4"})}),e.jsx(es,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex items-center",children:e.jsx(Se,{className:Q("h-4 w-4 transition-transform",o&&"rotate-90")})})}),e.jsx("span",{className:"min-w-[80px] text-sm font-mono",children:s.name||"unnamed"}),e.jsx(Ne,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:T}),e.jsx("span",{className:"flex-1 truncate text-sm text-muted-foreground",children:s.label}),e.jsx(C,{type:"button",variant:"ghost",size:"sm",onClick:u,className:"text-destructive",children:e.jsx(ee,{className:"h-3 w-3"})})]}),e.jsx(ss,{children:e.jsxs("div",{className:"space-y-3 border-t p-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),e.jsx(se,{value:s.name,onChange:n=>p({name:n}),onBlur:()=>{s.name&&!m&&p({label:ae(s.name)})},readOnly:g,className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Label"}),e.jsx(E,{value:s.label,onChange:n=>{p({label:n.target.value}),P(!0)},className:"h-8 text-sm"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Target Collection"}),e.jsxs(M,{value:s.targetCollection,onValueChange:n=>p({targetCollection:n}),children:[e.jsx(q,{className:"h-8 text-sm",children:e.jsx(U,{placeholder:"Select collection..."})}),e.jsx($,{children:x.map(n=>e.jsx(f,{value:n.name,children:n.label},n.name))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:`${a}-multiple`,checked:s.multiple,onCheckedChange:n=>p({multiple:!!n})}),e.jsx("label",{htmlFor:`${a}-multiple`,className:"text-sm",children:"Allow multiple"})]})]})})]})})}function is({relationships:a,onChange:s,collections:t,existingRelNames:u}){const x=Ve(ze(Ge)),g=a.map((c,r)=>`rel-${r}`),[j,o]=i.useState(null);function k(){o(a.length),s([...a,{name:"",label:"",targetCollection:"",multiple:!1}])}function m(c,r){const d=[...a];d[c]=r,s(d)}function P(c){s(a.filter((r,d)=>d!==c))}function v(c){const{active:r,over:d}=c;if(d&&r.id!==d.id){const S=g.indexOf(String(r.id)),y=g.indexOf(String(d.id));s(Je(a,S,y))}}return e.jsx(We,{sensors:x,collisionDetection:Ye,onDragEnd:v,children:e.jsx(Xe,{items:g,strategy:Ze,children:e.jsxs("div",{className:"space-y-2",children:[a.map((c,r)=>e.jsx(ns,{id:`rel-${r}`,relationship:c,onChange:d=>m(r,d),onRemove:()=>P(r),collections:t,readOnlyName:!!(u?.has(c.name)&&c.name),defaultExpanded:r===j},`rel-${r}`)),e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:k,children:[e.jsx(ye,{className:"mr-2 h-3 w-3"})," Add Relationship"]})]})})})}const Z=["Newspaper","FileText","BookOpen","PenLine","Edit","Image","Camera","Video","Music","Mic","ShoppingCart","Store","Package","Tag","Gift","Users","User","UserPlus","Contact","Building","Calendar","Clock","Timer","CalendarDays","CalendarCheck","Star","Heart","ThumbsUp","Award","Trophy","Map","MapPin","Globe","Compass","Navigation","MessageSquare","Mail","Send","Phone","Bell","Folder","FolderOpen","Archive","Database","HardDrive","Settings","Wrench","Cog","Sliders","SlidersHorizontal","BarChart","PieChart","TrendingUp","Activity","LineChart","Code","Terminal","Braces","Bug","Puzzle","Home","Layout","Grid","List","Layers","Lightbulb","Zap","Flame","Sun","Moon","Link","ExternalLink","Share","Download","Upload","Lock","Unlock","Shield","Key","Eye"];function rs({value:a,onChange:s}){const[t,u]=i.useState(!1),[x,g]=i.useState(""),j=x?Z.filter(o=>o.toLowerCase().includes(x.toLowerCase())):Z;return e.jsxs(as,{open:t,onOpenChange:u,children:[e.jsx(ts,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:"gap-2 w-full justify-start",children:[e.jsx(V,{name:a||"FileText",className:"h-4 w-4"}),e.jsx("span",{className:"truncate",children:a||"Select icon..."})]})}),e.jsxs(ls,{className:"w-72 p-2",align:"start",children:[e.jsx(E,{placeholder:"Search icons...",value:x,onChange:o=>g(o.target.value),className:"mb-2",autoFocus:!0}),e.jsxs("div",{className:"grid grid-cols-6 gap-1 max-h-48 overflow-y-auto",children:[j.map(o=>e.jsx("button",{type:"button",title:o,className:Q("flex items-center justify-center rounded-md p-2 hover:bg-accent transition-colors",a===o&&"bg-accent ring-1 ring-primary"),onClick:()=>{s(o),u(!1),g("")},children:e.jsx(V,{name:o,className:"h-4 w-4"})},o)),j.length===0&&e.jsx("p",{className:"col-span-6 text-center text-sm text-muted-foreground py-4",children:"No matching icons"})]})]})]})}const os=["text","textarea","number","boolean","select","array"],cs=["url","email","date","content","blocks"];function ks(){const{host:a,name:s}=fe(),t=s==="new",{data:u,isLoading:x}=ke(a,t?"":s);return!t&&x?e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{className:"h-8 w-64"}),e.jsx(z,{className:"h-64 w-full"})]}):t?e.jsx(J,{host:a,isNew:!0}):u?e.jsx(J,{host:a,isNew:!1,collection:u},u.name):e.jsx("p",{className:"text-muted-foreground",children:"Collection not found."})}function J({host:a,isNew:s,collection:t}){const u=Ce(),x=Pe(),{collections:g}=De(),j=Le(a),o=Ee(a,t?.name??""),k=Te(a,t?.name??""),[m,P]=i.useState(t?.name??""),[v,c]=i.useState(t?.label??""),[r,d]=i.useState(t?.labelSingular??""),[S,y]=i.useState(t?.slug??""),[p,T]=i.useState(t?.singleton??!1),[n,te]=i.useState(t?.mode??"content"),[F,le]=i.useState(t?.requireAuth??!1),b=n==="submission",[ne,ie]=i.useState(!s),[re,oe]=i.useState(!s),[ce,de]=i.useState(!s),ue=new Set((t?.fields??[]).map(l=>l.name).filter(Boolean)),I=[{name:"blocks",label:"Blocks",type:"blocks",options:{}}],[D,w]=i.useState(t?.fields??(s&&!p?I:[])),[B,me]=i.useState(t?.relationships??[]),xe=new Set((t?.relationships??[]).map(l=>l.name).filter(Boolean)),[A,he]=i.useState(t?.mobileNavPriority??0),[R,ge]=i.useState(t?.icon??""),[je,_]=i.useState(!1);_e({title:s?"New Collection":t?.label??m,showBack:!0,backTo:`/sites/${a}/settings/collections`});function pe(){if(!m)return;const l=ae(m);ne||c(l),re||d($e(l)),ce||y(m.replace(/_/g,"-"))}async function H(l){l?.preventDefault();try{s?(await j.mutateAsync({name:m,label:v,labelSingular:r,slug:S,singleton:b?!1:p,fields:D,relationships:B,mobileNavPriority:A,icon:R,mode:n,requireAuth:b?F:void 0}),L.success("Collection created"),u(`/sites/${a}/settings/collections/${m}`)):(await o.mutateAsync({label:v,labelSingular:r,slug:b?void 0:S,singleton:b?!1:p,fields:D,relationships:B,mobileNavPriority:A,icon:R,mode:n,requireAuth:b?F:void 0}),L.success("Collection updated"))}catch(N){L.error(s?"Failed to create":"Failed to update",{description:N instanceof Error?N.message:void 0})}}async function be(){try{await k.mutateAsync(),L.success("Collection deleted"),u(`/sites/${a}/settings/collections`)}catch(l){L.error("Failed to delete",{description:l instanceof Error?l.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!x&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:s?"New Collection":`Edit: ${t?.label??m}`}),e.jsxs(W,{children:[e.jsx(Y,{children:e.jsx(K,{children:"Collection Settings"})}),e.jsx(X,{children:e.jsxs("form",{onSubmit:H,className:"space-y-4","aria-label":"Collection settings",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"name",children:"Name"}),e.jsx(se,{id:"name",value:m,onChange:P,onBlur:pe,readOnly:!s,placeholder:"e.g. blog_posts",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"mode",children:"Mode"}),e.jsxs(M,{value:n,onValueChange:l=>{te(l),l==="submission"&&s&&(T(!1),w(D.filter(N=>os.includes(N.type)))),l==="content"&&s&&D.length===0&&w(I)},disabled:!s,children:[e.jsx(q,{id:"mode",children:e.jsx(U,{})}),e.jsxs($,{children:[e.jsx(f,{value:"content",children:"Content"}),e.jsx(f,{value:"submission",children:"Submissions"})]})]}),!s&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mode cannot be changed after creation."})]}),b&&e.jsx("div",{className:"rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Submission Collection"}),e.jsxs("p",{className:"mt-1",children:["Submissions are created via the API:"," ",e.jsxs("code",{className:"rounded bg-blue-100 px-1 dark:bg-blue-900",children:["POST /v1/","{site}","/submit/",m||"{collection}"]})]})]})]})}),b&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:"requireAuth",checked:F,onCheckedChange:l=>le(!!l)}),e.jsx(h,{htmlFor:"requireAuth",children:"Require authentication (site users must be logged in to submit)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"label",children:"Label"}),e.jsx(E,{id:"label",value:v,onChange:l=>{c(l.target.value),ie(!0)},required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"label-singular",children:"Label Singular"}),e.jsx(E,{id:"label-singular",value:r,onChange:l=>{d(l.target.value),oe(!0)},required:!0})]}),!b&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"slug",children:"Slug"}),e.jsx(E,{id:"slug",value:S,onChange:l=>{y(l.target.value),de(!0)},required:!0})]}),!b&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:"singleton",checked:p,onCheckedChange:l=>{const N=!!l;T(N),s&&w(N?[]:I)},disabled:!s}),e.jsx(h,{htmlFor:"singleton",children:"Singleton (single entry, no list)"})]}),e.jsx(G,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Fields"}),e.jsx(Ue,{fields:D,onChange:w,excludeTypes:b?cs:void 0,existingFieldNames:ue})]}),e.jsx(G,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Relationships"}),e.jsx(is,{relationships:B,onChange:me,collections:g,existingRelNames:xe})]})]})})]}),e.jsxs(W,{className:"mt-6",children:[e.jsx(Y,{children:e.jsx(K,{children:"Navigation"})}),e.jsxs(X,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Icon"}),e.jsx(rs,{value:R,onChange:ge})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"mobileNavPriority",children:"Bottom Nav Priority"}),e.jsxs(M,{value:String(A),onValueChange:l=>he(Number(l)),children:[e.jsx(q,{id:"mobileNavPriority",children:e.jsx(U,{})}),e.jsxs($,{children:[e.jsx(f,{value:"0",children:"0 - Hidden"}),e.jsx(f,{value:"1",children:"1"}),e.jsx(f,{value:"2",children:"2"}),e.jsx(f,{value:"3",children:"3"}),e.jsx(f,{value:"4",children:"4"}),e.jsx(f,{value:"5",children:"5 - Highest"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Collections with priority > 0 appear in the mobile bottom navigation bar."})]})]})]}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(C,{type:"button",variant:"outline",onClick:()=>u(`/sites/${a}/settings/collections`),children:"Cancel"}),e.jsxs(C,{onClick:H,disabled:j.isPending||o.isPending,children:[(j.isPending||o.isPending)&&e.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Create":"Save"]})]}),!s&&e.jsx("div",{className:"mt-6",children:e.jsxs(Ie,{open:je,onOpenChange:_,children:[e.jsx(Be,{asChild:!0,children:e.jsxs(C,{variant:"destructive",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),"Delete Collection"]})}),e.jsxs(Ae,{children:[e.jsxs(Re,{children:[e.jsx(Oe,{children:"Delete collection?"}),e.jsx(Me,{children:"This will permanently delete the collection and all its content."})]}),e.jsxs(qe,{children:[e.jsx(C,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(C,{variant:"destructive",onClick:be,children:"Delete"})]})]})]})})]})}export{ks as CollectionEditPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as j,f as u}from"./react-vendor-C2CvUxFh.js";import{ar as f,x as g,B as o,P as c,S as b,j as r}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as j,f as u}from"./react-vendor-C2CvUxFh.js";import{ar as f,x as g,B as o,P as c,S as b,j as r}from"./index-Cir9tY_P.js";import{T as p,a as N,b as d,c as i,d as C,e as n}from"./table-DLoIbCQ5.js";import{u as T}from"./usePageTitle-BNSba9_L.js";import"./radix-C1kb_NqW.js";function $(){const{host:l}=j(),a=u(),{data:t,isLoading:m}=f(l),x=g();return T({title:"Collections",actions:e.jsx(o,{size:"sm",onClick:()=>a(`/sites/${l}/settings/collections/new`),children:e.jsx(c,{className:"h-4 w-4"})})}),e.jsxs("div",{children:[!x&&e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Collections"}),e.jsxs(o,{onClick:()=>a(`/sites/${l}/settings/collections/new`),children:[e.jsx(c,{className:"mr-2 h-4 w-4"}),"New Collection"]})]}),m?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,h)=>e.jsx(b,{className:"h-12 w-full"},h))}):t?.items.length?e.jsxs(p,{children:[e.jsx(N,{children:e.jsxs(d,{children:[e.jsx(i,{children:"Name"}),e.jsx(i,{children:"Label"}),e.jsx(i,{children:"Type"}),e.jsx(i,{children:"Fields"})]})}),e.jsx(C,{children:t.items.map(s=>e.jsxs(d,{className:"cursor-pointer",onClick:()=>a(`/sites/${l}/settings/collections/${s.name}`),children:[e.jsx(n,{className:"font-mono text-sm",children:s.name}),e.jsx(n,{children:s.label}),e.jsx(n,{children:s.singleton?e.jsx(r,{variant:"secondary",children:"Singleton"}):e.jsx(r,{variant:"outline",children:"Collection"})}),e.jsx(n,{className:"text-muted-foreground",children:s.fields?.length??0})]},s.name))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No collections defined."})]})}export{$ as CollectionsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as E,f as P,r as i,m as I,N as T}from"./react-vendor-C2CvUxFh.js";import{w as F,x as k,L as g,I as h,B as f,a as A,v as p,C as B}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as E,f as P,r as i,m as I,N as T}from"./react-vendor-C2CvUxFh.js";import{w as F,x as k,L as g,I as h,B as f,a as A,v as p,C as B}from"./index-Cir9tY_P.js";import{e as L}from"./useContent-e8beBIuq.js";import{C as D,a as H,b as M,c as q}from"./card-hXVtlM0q.js";import{u as R}from"./usePageTitle-BNSba9_L.js";import{s as z}from"./format-C88SDH8g.js";import"./radix-C1kb_NqW.js";function X(){const{host:a,collection:s}=E(),c=P(),{collections:C}=F(),o=L(a),[l,j]=i.useState(""),[u,d]=i.useState(""),[v,b]=i.useState(!1),[m,x]=i.useState(null),N=k(),[S]=I(),r=C.find(t=>t.name===s),$=S.get("from")==="recent"?`/sites/${a}/content`:`/sites/${a}/content/${s}`;if(R({title:`New ${r?.labelSingular??s}`,showBack:!0,backTo:$}),r?.singleton){const t=r.singletonContentId?`/sites/${a}/content/${s}/${r.singletonContentId}`:`/sites/${a}/content/${s}`;return e.jsx(T,{to:t,replace:!0})}function y(t){j(t),v||d(z(t))}async function w(t){t.preventDefault(),x(null);try{const n=await o.mutateAsync({collection:s,title:l,slug:u||void 0});p.success("Content created"),c(`/sites/${a}/content/${s}/${n.contentId}`)}catch(n){n instanceof B&&n.status===409?x("A content item with this slug already exists. Choose a different slug."):p.error("Failed to create content",{description:n instanceof Error?n.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!N&&e.jsxs("h1",{className:"mb-6 text-2xl font-semibold",children:["New ",r?.labelSingular??s]}),e.jsxs(D,{children:[e.jsx(H,{children:e.jsx(M,{children:"Details"})}),e.jsx(q,{children:e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"title",children:"Title"}),e.jsx(h,{id:"title",value:l,onChange:t=>y(t.target.value),required:!0,autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"slug",children:"Slug"}),e.jsx(h,{id:"slug",value:u,onChange:t=>{d(t.target.value),b(!0)}})]}),m&&e.jsx("p",{className:"text-sm text-destructive",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(f,{type:"submit",disabled:!l||o.isPending,children:[o.isPending&&e.jsx(A,{className:"mr-2 h-4 w-4 animate-spin"}),"Create"]}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>c(-1),children:"Cancel"})]})]})})]})]})}export{X as ContentCreatePage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlockEditor-6wqsThJ7.js","assets/tanstack-Bs3zYPPV.js","assets/react-vendor-C2CvUxFh.js","assets/index-Cir9tY_P.js","assets/radix-C1kb_NqW.js","assets/index-DACBYsKM.css","assets/command-fvBFHye4.js","assets/MediaField-J2TLG_fu.js","assets/useMedia-e3sqWm_t.js","assets/select-_uJYxzeZ.js","assets/card-hXVtlM0q.js","assets/media-url-DIg_vSyf.js","assets/CustomBlockPreview-C6HqS4xv.js","assets/RelationshipPicker-CDFs4TMW.js","assets/core.esm-B_kcYf6n.js","assets/sortable.esm-QyXA6fio.js","assets/popover-D5_HjjUC.js","assets/useContentSearch-DOjveB9t.js","assets/useDebouncedValue-C-cQUcLG.js","assets/useContent-e8beBIuq.js","assets/useAdminResolver-D-LlmquD.js","assets/usePageTitle-BNSba9_L.js","assets/serializeToText-DR_WnxiI.js","assets/format-C88SDH8g.js","assets/textarea-vSXNxwTe.js","assets/TagInput-BILCaC9b.js","assets/collapsible-B414SspL.js","assets/useTags-f7AVSLuj.js","assets/checkbox-WGrS3sUr.js","assets/contentStatus-BmaiYVOm.js","assets/BlockEditor-Cp_wZ2xN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as c,u as Qs,f as Zs,m as et,L as st}from"./react-vendor-C2CvUxFh.js";import{f as tt,g as is,h as at,i as ls,j as nt,k as it,l as lt,m as rt,n as ct,o as ot,p as dt,q as ut,r as rs}from"./useContent-e8beBIuq.js";import{C as ye,v as S,E as ht,y as cs,F as mt,G as xt,J as pt,K as ft,S as F,M as os,N as ds,O as oe,Q as de,I as ue,B as f,P as gt,R as jt,T as us,V as bt,x as hs,_ as vt,L as X,e as yt,w as Nt,W as ms,X as Ge,Y as Ct,Z as Ye,$ as St,a0 as We,a1 as wt,j as kt,a as _,a2 as Xe,a3 as Qe,a4 as Dt,a5 as Ze,a6 as je,a7 as Pt,a8 as At,D as Ne,k as Ce,l as Se,m as we,n as ke,o as De,a9 as Tt,i as Lt}from"./index-Cir9tY_P.js";import{u as It}from"./useAdminResolver-D-LlmquD.js";import{u as Ft}from"./usePageTitle-BNSba9_L.js";import{s as Q,T as Rt,d as Ot}from"./serializeToText-DR_WnxiI.js";import{S as xs,a as ps,b as fs,c as gs,d as ce,e as Vt,f as Et,g as Bt}from"./select-_uJYxzeZ.js";import{f as U,a as be}from"./format-C88SDH8g.js";import{T as js}from"./textarea-vSXNxwTe.js";import{C as z,c as H,a as es,b as ss}from"./card-hXVtlM0q.js";import{T as $t,A as _t,a as Mt,b as Ut,c as zt,d as Ht,e as Jt,f as Kt,g as qt}from"./TagInput-BILCaC9b.js";import{C as bs,a as vs,b as ys}from"./collapsible-B414SspL.js";import{u as Gt}from"./useTags-f7AVSLuj.js";import{M as Yt,a as Wt}from"./MediaField-J2TLG_fu.js";import{m as Xt}from"./media-url-DIg_vSyf.js";import{C as Qt,R as Zt}from"./RelationshipPicker-CDFs4TMW.js";import{C as ea}from"./checkbox-WGrS3sUr.js";import{u as sa,a as ta,P as aa,D as na,c as ia,C as la}from"./core.esm-B_kcYf6n.js";import{S as ra,v as ca,a as oa,u as da}from"./sortable.esm-QyXA6fio.js";import{g as ua,a as ha,b as ma}from"./contentStatus-BmaiYVOm.js";const xa=3e3,pa="__HEADROOM_API_URL__".replace(/\/+$/,"");function fa(s,i,n,t){const l=tt(s,i),r=c.useRef(null),u=c.useRef(n?JSON.stringify(n):""),x=c.useRef(void 0),[g,o]=c.useState(null),[v,w]=c.useState(null),h=c.useRef(!1),p=c.useCallback(d=>{JSON.stringify(d)!==u.current&&(r.current=d,clearTimeout(x.current),x.current=window.setTimeout(()=>{if(r.current){const k=r.current,j=JSON.stringify(k);r.current=null,l.mutate(k,{onSuccess:b=>{if(h.current){h.current=!1;return}u.current=j,o(Date.now()),b?.blockId&&w(b.blockId)},onError:b=>{b instanceof ye&&b.code==="SLUG_TAKEN"?t?.():b instanceof ye&&b.status===400&&S.error("Auto-save failed",{description:b.message})}})}},xa))},[l,t]),m=c.useCallback(async d=>{if(clearTimeout(x.current),r.current){const y={...r.current};d?.createVersion&&(y.createVersion=!0);const k=JSON.stringify(r.current);r.current=null;const j=await l.mutateAsync(y);u.current=k,o(Date.now()),j?.blockId&&w(j.blockId)}else if(d?.createVersion&&u.current){const k={...JSON.parse(u.current),createVersion:!0},j=await l.mutateAsync(k);o(Date.now()),j?.blockId&&w(j.blockId)}},[l]),P=c.useCallback(()=>{clearTimeout(x.current),r.current=null},[]),D=c.useCallback(d=>{u.current=JSON.stringify(d)},[]),A=c.useCallback(()=>{clearTimeout(x.current),r.current=null,h.current=!0,w(null)},[]);return c.useEffect(()=>()=>{if(clearTimeout(x.current),r.current){const d=JSON.stringify(r.current),y=ht(),k=`${pa}/v1/admin/sites/${s}/content/${i}/draft`;fetch(k,{method:"PUT",body:d,headers:{"Content-Type":"application/json",...y?{Authorization:`Bearer ${y}`}:{}},keepalive:!0}).catch(()=>{}),r.current=null}},[s,i]),{schedule:p,flush:m,cancel:P,resetBaseline:D,discard:A,isSaving:l.isPending,lastSavedAt:g,lastSavedBlockId:v}}function ga({lines:s}){return e.jsx("div",{className:"font-mono text-sm leading-relaxed",children:s.map((i,n)=>e.jsx("div",{style:{paddingLeft:`${i.indent*1.5}rem`},className:cs("min-h-[1.5em]",i.type==="label"&&"text-muted-foreground font-semibold mt-1",i.type==="heading"&&"font-bold",i.type==="empty"&&"h-2"),children:i.text},n))})}function Pe(s){switch(s.kind){case"draft":return"Draft";case"published":return"Published";case"history":return U(s.createdAt)}}function he(s){switch(s.kind){case"draft":return"draft";case"published":return"published";case"history":return`history:${s.blockId}`}}function ts({value:s,onChange:i,isPublished:n,versions:t,exclude:l,size:r}){const u=l?he(l):null;function x(g){if(g==="draft")i({kind:"draft"});else if(g==="published")i({kind:"published"});else if(g.startsWith("history:")){const o=g.slice(8),v=t.find(w=>w.blockId===o);v&&i({kind:"history",blockId:v.blockId,createdAt:v.createdAt,title:v.title})}}return e.jsxs(xs,{value:he(s),onValueChange:x,children:[e.jsx(ps,{size:r,children:e.jsx(fs,{children:Pe(s)})}),e.jsxs(gs,{position:"popper",children:[u!=="draft"&&e.jsx(ce,{value:"draft",children:"Draft"}),n&&u!=="published"&&e.jsx(ce,{value:"published",children:"Published"}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Vt,{}),e.jsxs(Et,{children:[e.jsx(Bt,{children:"Version History"}),t.map(g=>{const o=`history:${g.blockId}`;return o===u?null:e.jsx(ce,{value:o,children:U(g.createdAt)},o)})]})]})]})]})}function as({ref:s,host:i,contentId:n,collectionFields:t,isSingleton:l,draftBody:r,draftMetadata:u,collectionRelationships:x,draftRelationships:g}){const o=s?.kind==="published",v=s?.kind==="history",w=v?s.blockId:null,{data:h,isLoading:p}=is(i,n,o),{data:m,isLoading:P}=at(i,n,v?w:null),D=c.useMemo(()=>(x??[]).map(y=>({name:y.name,label:y.label})),[x]);function A(y){if(D.length!==0)return{defs:D,values:y??{}}}const d=c.useMemo(()=>{if(!s)return[];if(s.kind==="draft")return r?Q(t,r,l?void 0:u,A(g)):[];if(s.kind==="published"){if(!h)return[];const j=l?void 0:{title:h.title,slug:h.slug,snippet:h.snippet,tags:h.tags},b=h.relationships;return Q(t,h.fields??{},j,A(b))}if(!m)return[];const y=l?void 0:{title:m.title,slug:m.slug,snippet:m.snippet,tags:m.tags},k=m.relationships;return Q(t,m.body??{},y,A(k))},[s,r,u,g,h,m,t,l,D]);return s?s.kind==="draft"?{lines:d,isLoading:!1,hasData:!!r}:s.kind==="published"?{lines:d,isLoading:p,hasData:!!h}:{lines:d,isLoading:P,hasData:!!m}:{lines:[],isLoading:!1,hasData:!1}}function ja({open:s,onOpenChange:i,host:n,contentId:t,collectionFields:l,isSingleton:r,isPublished:u,draftBody:x,draftMetadata:g,initialVersion:o,collectionRelationships:v,draftRelationships:w}){const[h,p]=c.useState(o??{kind:"published"}),[m,P]=c.useState({kind:"draft"}),[D,A]=c.useState(s),[d,y]=c.useState(o);if((s!==D||o!==d)&&(A(s),y(o),s)){const L=o??{kind:"published"};p(L),P(L.kind==="draft"?{kind:"published"}:{kind:"draft"})}he(h)===he(m)&&(h.kind!=="draft"?P({kind:"draft"}):u&&P({kind:"published"}));const{data:k}=ls(n,t),j=k?.items??[],b={host:n,contentId:t,collectionFields:l,isSingleton:r,draftBody:x,draftMetadata:g,collectionRelationships:v,draftRelationships:w},T=as({ref:s?h:null,...b}),N=as({ref:s?m:null,...b}),J=T.isLoading;return e.jsx(mt,{open:s,onOpenChange:i,children:e.jsxs(xt,{className:"w-[calc(100vw-2rem)] sm:max-w-2xl overflow-y-auto pt-[env(safe-area-inset-top,0px)] pr-[env(safe-area-inset-right,0px)]",children:[e.jsx(pt,{children:e.jsxs(ft,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground text-sm font-normal",children:"Viewing"}),e.jsx(ts,{value:h,onChange:p,isPublished:u,versions:j,size:"sm"})]})}),J&&e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(F,{className:"h-6 w-48"}),e.jsx(F,{className:"h-4 w-full"}),e.jsx(F,{className:"h-4 w-full"}),e.jsx(F,{className:"h-4 w-2/3"})]}),!J&&!T.hasData&&e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"No data available for this version."}),!J&&T.hasData&&e.jsx("div",{className:"p-4",children:e.jsxs(os,{defaultValue:"changes",children:[e.jsxs(ds,{variant:"line",className:"mb-4",children:[e.jsx(oe,{value:"content",children:"Content"}),e.jsx(oe,{value:"changes",children:"Changes"})]}),e.jsx(de,{value:"content",children:e.jsx(ga,{lines:T.lines})}),e.jsxs(de,{value:"changes",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Compare with"}),e.jsx(ts,{value:m,onChange:P,isPublished:u,versions:j,exclude:h,size:"sm"})]}),N.isLoading?e.jsxs("div",{className:"space-y-4",children:[e.jsx(F,{className:"h-4 w-full"}),e.jsx(F,{className:"h-4 w-full"}),e.jsx(F,{className:"h-4 w-2/3"})]}):N.hasData?e.jsx(Rt,{left:N.lines,right:T.lines,leftLabel:Pe(m),rightLabel:Pe(h)}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No data available for comparison."})]})]})})]})})}function ve({field:s,value:i,onChange:n}){const t=s.options;return e.jsx(ue,{value:i??"",onChange:l=>n(l.target.value),placeholder:t?.placeholder,maxLength:t?.maxLength,required:!!t?.required,type:s.type==="url"?"url":s.type==="email"?"email":"text"})}function ba({field:s,value:i,onChange:n}){const t=s.options;return e.jsx(js,{value:i??"",onChange:l=>n(l.target.value),placeholder:t?.placeholder,maxLength:t?.maxLength,required:!!t?.required,rows:4})}function va({field:s,value:i,onChange:n}){const t=s.options;return e.jsx(ue,{type:"number",value:i??"",onChange:l=>n(l.target.value===""?void 0:Number(l.target.value)),min:t?.min,max:t?.max,step:t?.step,required:!!t?.required})}function ya({field:s,value:i,onChange:n}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ea,{id:`field-${s.name}`,checked:!!i,onCheckedChange:t=>n(!!t)}),e.jsx("label",{htmlFor:`field-${s.name}`,className:"text-sm text-muted-foreground",children:s.label})]})}function Na({field:s,value:i,onChange:n}){const l=s.options?.choices??[];return e.jsxs(xs,{value:i??"",onValueChange:r=>n(r),children:[e.jsx(ps,{children:e.jsx(fs,{placeholder:"Select..."})}),e.jsx(gs,{children:l.map(r=>e.jsx(ce,{value:r,children:r},r))})]})}function Ca({field:s,value:i,onChange:n}){const t=sa(ta(aa)),l=i??[],u=s.options?.itemFields??[],x=l.map((h,p)=>`item-${p}`);function g(){n([...l,{}])}function o(h){n(l.filter((p,m)=>m!==h))}function v(h,p){const m=[...l];m[h]=p,n(m)}function w(h){const{active:p,over:m}=h;if(m&&p.id!==m.id){const P=x.indexOf(String(p.id)),D=x.indexOf(String(m.id));n(oa(l,P,D))}}return e.jsx(na,{sensors:t,collisionDetection:ia,onDragEnd:w,children:e.jsx(ra,{items:x,strategy:ca,children:e.jsxs("div",{className:"space-y-3",children:[l.map((h,p)=>e.jsx(Sa,{id:`item-${p}`,itemFields:u,item:h,onUpdate:m=>v(p,m),onRemove:()=>o(p)},`item-${p}`)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(gt,{className:"mr-2 h-3 w-3"})," Add Item"]})]})})})}function Sa({id:s,itemFields:i,item:n,onUpdate:t,onRemove:l}){const{attributes:r,listeners:u,setNodeRef:x,transform:g,transition:o}=da({id:s}),v={transform:la.Transform.toString(g),transition:o};return e.jsx(z,{ref:x,style:v,children:e.jsxs(H,{className:"flex gap-2 p-3",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...r,...u,children:e.jsx(jt,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1",children:e.jsx(Ae,{fields:i,values:n,onChange:t})}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",onClick:l,className:"text-destructive",children:e.jsx(us,{className:"h-3 w-3"})})]})})}const wa=c.lazy(()=>vt(()=>import("./BlockEditor-6wqsThJ7.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]))),ka=2,ns=c.createContext(0);function Da({value:s,onChange:i,compact:n=!0}){const t=c.useContext(ns),r=bt()?.blockTypes??[],u=hs();return t>=ka?e.jsx("div",{className:"rounded-md border border-muted p-4 text-sm text-muted-foreground",children:"Maximum nesting depth reached. Cannot embed another block editor here."}):e.jsx(ns.Provider,{value:t+1,children:e.jsx("div",{className:u?"":"rounded-md border",children:e.jsx(c.Suspense,{fallback:e.jsx(F,{className:"h-48"}),children:e.jsx(wa,{initialBlocks:s??[],onChange:i,blockTypes:r,compact:n})})})})}function Pa({field:s,value:i,onChange:n}){const l=s.options?.fields??[],r=i&&typeof i=="object"&&!Array.isArray(i)?i:{};return e.jsx(z,{children:e.jsx(H,{className:"p-3",children:e.jsx(Ae,{fields:l,values:r,onChange:u=>n(u)})})})}function Ae({fields:s,values:i,onChange:n}){function t(l,r){n({...i,[l]:r})}return e.jsx("div",{className:"space-y-4",children:s.map(l=>e.jsxs("div",{className:"space-y-2",children:[l.type!=="boolean"&&e.jsx(X,{children:l.label}),Aa(l,i[l.name],r=>t(l.name,r))]},l.name))})}function Aa(s,i,n){switch(s.type){case"text":case"url":case"email":return e.jsx(ve,{field:s,value:i,onChange:n});case"textarea":return e.jsx(ba,{field:s,value:i,onChange:n});case"number":return e.jsx(va,{field:s,value:i,onChange:n});case"boolean":return e.jsx(ya,{field:s,value:i,onChange:n});case"select":return e.jsx(Na,{field:s,value:i,onChange:n});case"media":return e.jsx(Yt,{field:s,value:i,onChange:n});case"content":return e.jsx(Qt,{field:s,value:i,onChange:n});case"blocks":return e.jsx(Da,{field:s,value:i,onChange:n});case"array":return e.jsx(Ca,{field:s,value:i,onChange:n});case"container":return e.jsx(Pa,{field:s,value:i,onChange:n});case"date":return e.jsx(ve,{field:{...s,type:"text"},value:i,onChange:n});default:return e.jsx(ve,{field:s,value:i,onChange:n})}}function Ta(){const{host:s,collection:i,id:n}=Qs(),{data:t,isLoading:l}=nt(s,n);return l?e.jsxs("div",{className:"space-y-4",children:[e.jsx(F,{className:"h-8 w-64"}),e.jsx(F,{className:"h-64 w-full"})]}):t?.content?e.jsx(La,{host:s,collection:i,contentId:n,content:t.content,draft:t.draft,publishedBlockId:t.publishedBlockId}):e.jsx("p",{className:"text-muted-foreground",children:"Content not found."})}function La({host:s,collection:i,contentId:n,content:t,draft:l,publishedBlockId:r}){const u=Zs(),x=yt(),{collections:g}=Nt(),o=it(s,n),v=lt(s,n),w=rt(s,n),h=ct(s,n),p=ot(s,n),m=dt(s,n),P=l?{title:l.title??t.title,slug:l.slug??t.slug??"",snippet:l.snippet??t.snippet??"",tags:l.tags??t.tags??[],cover:l.cover??t.cover??null,body:l.body??{},relationships:l.relationships??{}}:void 0,[D,A]=c.useState(null),d=fa(s,n,P,()=>{A("This slug is already in use by another item in this collection")}),{data:y}=Gt(s),k=y?.map(a=>a.tag),j=g.find(a=>a.name===i),b=c.useMemo(()=>j?.fields??[],[j?.fields]),T=c.useMemo(()=>j?.relationships??[],[j?.relationships]),N=j?.singleton??!1,J=hs(),[L,Te]=c.useState(l?.title??t.title),[E,Le]=c.useState(l?.slug??t.slug??""),[B,Ie]=c.useState(l?.snippet??t.snippet??""),Fe=l?.autoSnippet??"",[K,Re]=c.useState(l?.tags??t.tags??[]),[R,Oe]=c.useState(l?.cover??t.cover??null),[q,Ve]=c.useState(l?.body??{}),[G,Ee]=c.useState(l?.relationships??{}),[Ns,Cs]=c.useState(0),[Ss,ws]=c.useState(!1),[ks,Z]=c.useState(!1),[Ds,Y]=c.useState(!1),[Ps,ee]=c.useState(null),[me,se]=c.useState(!1),[As,te]=c.useState(!1),[Ts,ae]=c.useState(!1),[ne,Be]=c.useState(""),[Ls,xe]=c.useState(!1),[pe,$e]=c.useState(""),_e=ut(s,n),M=c.useCallback(()=>({title:L,slug:E,snippet:B,tags:K,cover:R,body:q,relationships:G}),[L,E,B,K,R,q,G]);function Is(a){Te(a),d.schedule({...M(),title:a})}function Fs(a){Le(a),A(null),d.schedule({...M(),slug:a})}function Rs(a){Ie(a),d.schedule({...M(),snippet:a})}function Os(a){Re(a),d.schedule({...M(),tags:a})}function Me(a){Oe(a),d.schedule({...M(),cover:a})}function Vs(a){Ve(a),d.schedule({...M(),body:a})}function Es(a){Ee(a),d.schedule({...M(),relationships:a})}const Bs=d.lastSavedBlockId??l?.blockId,O=ua(t.publishedAt,t.lastPublishedAt,r,Bs,t.scheduledAt,t.scheduledFailed),ie=ha(O),le=ma(O),{data:$}=is(s,n,!!t.publishedAt),V=c.useMemo(()=>{if(!me||!$)return null;const a=N?void 0:{title:$.title,slug:$.slug,snippet:$.snippet,tags:$.tags},C=T.map(I=>({name:I.name,label:I.label})),W=$.relationships,Je=C.length>0?{defs:C,values:W??{}}:void 0,qs=Q(b,$.fields??{},a,Je),Gs=N?void 0:{title:L,slug:E,snippet:B,tags:K},Ys=C.length>0?{defs:C,values:G}:void 0,Ws=Q(b,q,Gs,Ys),Xs=Ot(qs,Ws,{comparator:(I,ge)=>I.text===ge.text&&I.indent===ge.indent&&I.type===ge.type});let Ke=0,qe=0;for(const I of Xs)I.added?Ke+=I.count??0:I.removed&&(qe+=I.count??0);return{added:Ke,removed:qe}},[me,$,b,T,N,L,E,B,K,q,G]),[$s]=et(),_s=$s.get("from")==="recent"?`/sites/${s}/content`:`/sites/${s}/content/${i}`;Ft({title:N?j?.label??i:L||"Untitled",showBack:!N,backTo:N?void 0:_s,badge:{label:ie.label,variant:ie.variant}});function Ue(){if(t.publishedAt&&t.slug&&E!==t.slug){te(!0);return}O==="published-changes"?se(!0):re()}async function re(){try{d.cancel(),await d.flush({createVersion:!0}),await o.mutateAsync(void 0),d.discard(),S.success("Content published")}catch(a){if(a instanceof ye&&a.code==="SLUG_TAKEN"){A("This slug is already in use by another item in this collection"),S.error("Slug already in use",{description:"Please choose a different slug before publishing."});return}S.error("Failed to publish",{description:a instanceof Error?a.message:void 0})}}async function Ms(){try{await v.mutateAsync(),Y(!1),S.success("Content unpublished")}catch(a){S.error("Failed to unpublish",{description:a instanceof Error?a.message:void 0})}}async function Us(){try{d.discard();const a=await x.apiFetch(`/v1/admin/sites/${s}/content/${n}/published`);await _e.mutateAsync();const C={title:a.title??"",slug:a.slug??"",snippet:a.snippet??"",tags:a.tags??[],cover:a.cover??null,body:a.fields??{},relationships:a.relationships??{}};Te(C.title),Le(C.slug),Ie(C.snippet),Re(C.tags),Oe(C.cover),Ve(C.body),Ee(C.relationships),Cs(W=>W+1),d.resetBaseline(C),S.success("Changes discarded")}catch(a){S.error("Failed to discard changes",{description:a instanceof Error?a.message:void 0})}}async function zs(){try{await w.mutateAsync(),S.success("Content deleted"),u(`/sites/${s}/content/${i}`)}catch(a){S.error("Failed to delete",{description:a instanceof Error?a.message:void 0})}}async function Hs(){if(ne)try{d.cancel(),await d.flush({createVersion:!0});const a=new Date(ne).getTime();await p.mutateAsync(a),ae(!1),Be(""),S.success("Content scheduled for publishing")}catch(a){S.error("Failed to schedule",{description:a instanceof Error?a.message:void 0})}}async function Js(){try{await m.mutateAsync(),S.success("Schedule cancelled")}catch(a){S.error("Failed to cancel schedule",{description:a instanceof Error?a.message:void 0})}}async function Ks(){if(pe)try{const a=new Date(pe).getTime();await h.mutateAsync(a),xe(!1),S.success("Publish date updated")}catch(a){S.error("Failed to update publish date",{description:a instanceof Error?a.message:void 0})}}function fe(a){const C=new Date(a),W=C.getTimezoneOffset();return new Date(C.getTime()-W*6e4).toISOString().slice(0,16)}const ze=e.jsx("div",{className:"space-y-6",children:b.length>0?e.jsx(Ae,{fields:b,values:q,onChange:Vs},Ns):e.jsx(z,{children:e.jsx(H,{className:"py-8 text-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No fields defined for this collection."," ",e.jsx(st,{to:`/sites/${s}/settings/collections/${i}`,className:"underline",children:"Configure fields"})]})})})}),He=e.jsxs("div",{className:"space-y-6",children:[!N&&e.jsx(z,{children:e.jsxs(H,{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"title",children:"Title"}),e.jsx(ue,{id:"title",value:L,onChange:a=>Is(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"slug",children:"Slug"}),e.jsx(ue,{id:"slug",value:E,onChange:a=>Fs(a.target.value),className:D?"border-destructive":""}),D&&e.jsx("p",{className:"text-sm text-destructive",children:D})]}),e.jsxs(bs,{defaultOpen:!!B,children:[e.jsxs(vs,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(ms,{className:"h-4 w-4 transition-transform [[data-state=open]>&]:rotate-90"}),"Snippet",e.jsx("span",{className:"text-xs text-muted-foreground",children:"(auto-generated if empty)"})]}),e.jsxs(ys,{className:"mt-2 space-y-2",children:[e.jsx(js,{id:"snippet",value:B,onChange:a=>Rs(a.target.value),rows:3,placeholder:"Brief summary of this content..."}),!B&&Fe&&e.jsxs("p",{className:"text-xs italic text-muted-foreground",children:["Auto-generated: ",Fe]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:"Cover Image"}),R?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>Z(!0),children:[e.jsx("img",{src:Xt(R.url),alt:R.alt??R.filename??"",className:"h-10 w-10 rounded object-cover bg-muted"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:R.filename??R.alt??R.id}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",onClick:a=>{a.stopPropagation(),Me(null)},children:e.jsx(Ge,{className:"h-3 w-3"})})]}):e.jsxs(f,{type:"button",variant:"outline",className:"w-full",onClick:()=>Z(!0),children:[e.jsx(Ct,{className:"mr-2 h-4 w-4"}),"Select Image"]}),e.jsx(Wt,{open:ks,onClose:()=>Z(!1),onSelect:a=>{Me({id:a.mediaId,url:a.url,width:a.width??0,height:a.height??0,alt:a.alt,caption:a.caption,filename:a.filename}),Z(!1)},allowedTypes:["image/*"]})]})]})}),!N&&e.jsxs(z,{children:[e.jsx(es,{children:e.jsx(ss,{children:"Tags"})}),e.jsx(H,{children:e.jsx($t,{tags:K,onChange:Os,suggestions:k})})]}),T.length>0&&e.jsx(Zt,{relationships:T,values:G,onChange:Es,host:s}),e.jsxs(z,{children:[e.jsx(es,{children:e.jsx(ss,{children:"Info"})}),e.jsxs(H,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Collection"}),e.jsx("span",{children:t.collection})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"ID"}),e.jsx("span",{className:"font-mono text-xs",children:t.contentId})]}),t.publishedAt?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"Published"}),Ls?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"datetime-local",value:pe,onChange:a=>$e(a.target.value),className:"text-xs border rounded px-1 py-0.5",max:fe(Date.now())}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:Ks,disabled:h.isPending,children:e.jsx(Ye,{className:"h-3 w-3"})}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>xe(!1),children:e.jsx(Ge,{className:"h-3 w-3"})})]}):e.jsxs("span",{className:"cursor-pointer hover:underline",title:U(t.publishedAt),onClick:()=>{$e(fe(t.publishedAt)),xe(!0)},children:[be(t.publishedAt),e.jsx(St,{className:"inline ml-1 h-3 w-3 text-muted-foreground"})]})]}),t.lastPublishedAt&&t.lastPublishedAt!==t.publishedAt&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last published"}),e.jsx("span",{title:U(t.lastPublishedAt),children:be(t.lastPublishedAt)})]})]}):t.lastPublishedAt?e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last published"}),e.jsx("span",{title:U(t.lastPublishedAt),children:be(t.lastPublishedAt)})]}):null,O==="scheduled"&&t.scheduledAt&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"Scheduled for"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(We,{className:"h-3 w-3"}),U(t.scheduledAt)]})]}),O==="schedule-failed"&&e.jsx("div",{className:"text-destructive text-xs",children:"Scheduled publishing failed after multiple attempts."}),t.publishedAt&&e.jsxs(f,{variant:"outline",size:"sm",className:"w-full mt-2",onClick:()=>{ee({kind:"published"}),Y(!0)},children:[e.jsx(wt,{className:"mr-2 h-4 w-4"}),"View published"]})]})]}),e.jsx(Ra,{host:s,contentId:n,onViewVersion:a=>{ee({kind:"history",blockId:a.blockId,createdAt:a.createdAt,title:a.title}),Y(!0)}}),!N&&e.jsx(Fa,{deleteOpen:Ss,setDeleteOpen:ws,onDelete:zs,host:s,contentId:n})]});return e.jsxs("div",{className:"mx-auto max-w-6xl",children:[!J&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 md:mb-6 md:flex-nowrap md:gap-3 md:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 md:gap-3",children:[e.jsx("h1",{className:"truncate text-xl font-semibold md:text-2xl",children:N?j?.label??i:L||"Untitled"}),e.jsx(kt,{variant:ie.variant,children:ie.label}),d.isSaving&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(_,{className:"h-3 w-3 animate-spin"}),"Saving..."]}),!d.isSaving&&d.lastSavedAt&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ye,{className:"h-3 w-3"}),"Saved"]})]}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(f,{variant:"outline",onClick:()=>d.flush({createVersion:!0}),disabled:d.isSaving,children:[d.isSaving&&e.jsx(_,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Draft"]}),O==="scheduled"&&e.jsxs(e.Fragment,{children:[e.jsxs(f,{variant:"outline",onClick:Js,disabled:m.isPending,children:[m.isPending&&e.jsx(_,{className:"mr-2 h-4 w-4 animate-spin"}),"Cancel Schedule"]}),e.jsxs(f,{onClick:()=>void re(),disabled:o.isPending,children:[o.isPending&&e.jsx(_,{className:"mr-2 h-4 w-4 animate-spin"}),"Publish Now"]})]}),O!=="scheduled"&&le&&e.jsxs("div",{className:"flex",children:[e.jsxs(f,{onClick:Ue,disabled:o.isPending,className:"rounded-r-none",children:[o.isPending&&e.jsx(_,{className:"mr-2 h-4 w-4 animate-spin"}),le]}),!t.publishedAt&&e.jsxs(Xe,{children:[e.jsx(Qe,{asChild:!0,children:e.jsx(f,{className:"rounded-l-none border-l px-2",disabled:o.isPending,children:e.jsx(Dt,{className:"h-4 w-4"})})}),e.jsx(Ze,{align:"end",children:e.jsxs(je,{onClick:()=>ae(!0),children:[e.jsx(We,{className:"mr-2 h-4 w-4"}),"Schedule for later"]})})]})]}),t.publishedAt&&e.jsxs(Xe,{children:[e.jsx(Qe,{asChild:!0,children:e.jsx(f,{variant:"outline",size:"icon",children:e.jsx(Pt,{className:"h-4 w-4"})})}),e.jsxs(Ze,{align:"end",children:[O==="published-changes"&&e.jsxs(je,{onClick:Us,disabled:_e.isPending,children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),"Discard Changes"]}),e.jsx(je,{onClick:Ms,className:"text-destructive focus:text-destructive",children:"Unpublish"})]})]})]})]}),J?e.jsxs(os,{defaultValue:"content",children:[e.jsxs("div",{className:"mb-2 flex items-center",children:[e.jsxs(ds,{variant:"line",children:[e.jsx(oe,{value:"content",children:"Content"}),e.jsx(oe,{value:"info",children:"Info"})]}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>d.flush({createVersion:!0}),disabled:d.isSaving,children:[d.isSaving&&e.jsx(_,{className:"mr-1 h-3 w-3 animate-spin"}),"Save"]}),O!=="scheduled"&&le&&e.jsxs(f,{size:"sm",onClick:Ue,disabled:o.isPending,children:[o.isPending&&e.jsx(_,{className:"mr-1 h-3 w-3 animate-spin"}),le]})]})]}),e.jsx(de,{value:"content",className:"mt-0",children:ze}),e.jsx(de,{value:"info",className:"mt-0",children:He})]}):e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx("div",{className:"lg:col-span-2",children:ze}),e.jsx("div",{children:He})]}),e.jsx(ja,{open:Ds,onOpenChange:a=>{Y(a),a||ee(null)},host:s,contentId:n,collectionFields:b,isSingleton:N,isPublished:!!t.publishedAt,draftBody:q,draftMetadata:N?void 0:{title:L,slug:E,snippet:B,tags:K},initialVersion:Ps,collectionRelationships:T,draftRelationships:G}),e.jsx(_t,{open:me,onOpenChange:se,children:e.jsxs(Mt,{children:[e.jsxs(Ut,{children:[e.jsx(zt,{children:"Publish changes?"}),e.jsx(Ht,{children:V?e.jsxs(e.Fragment,{children:[V.added>0&&e.jsxs("span",{className:"text-green-600",children:["+",V.added," added"]}),V.added>0&&V.removed>0&&", ",V.removed>0&&e.jsxs("span",{className:"text-red-600",children:["-",V.removed," removed"]}),V.added===0&&V.removed===0&&e.jsx("span",{children:"No visible changes detected."})]}):"This will update the published version with your current changes."})]}),e.jsx("div",{className:"mb-2",children:e.jsx(f,{variant:"link",className:"p-0 h-auto text-sm",onClick:()=>{se(!1),ee({kind:"draft"}),Y(!0)},children:"View full diff"})}),e.jsxs(Jt,{children:[e.jsx(Kt,{children:"Cancel"}),e.jsx(qt,{onClick:()=>{se(!1),re()},children:"Publish Update"})]})]})}),e.jsx(Ne,{open:As,onOpenChange:te,children:e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(we,{children:"Slug change detected"}),e.jsxs(ke,{children:["You are changing the slug from “",t.slug,"” to “",E,"”. This may break external bookmarks and SEO links."]})]}),e.jsx(Ia,{host:s,contentId:n}),e.jsxs(De,{children:[e.jsx(f,{variant:"outline",onClick:()=>te(!1),children:"Cancel"}),e.jsx(f,{onClick:()=>{te(!1),re()},children:"Publish Anyway"})]})]})}),e.jsx(Ne,{open:Ts,onOpenChange:ae,children:e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(we,{children:"Schedule publishing"}),e.jsx(ke,{children:"Choose a date and time to automatically publish this content. Times are rounded to the nearest 15-minute interval."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{htmlFor:"schedule-date",children:"Publish at"}),e.jsx("input",{id:"schedule-date",type:"datetime-local",value:ne,onChange:a=>Be(a.target.value),min:fe(Date.now()+1200*1e3),className:"w-full rounded-md border px-3 py-2 text-sm",step:"900"})]}),e.jsxs(De,{children:[e.jsx(f,{variant:"outline",onClick:()=>ae(!1),children:"Cancel"}),e.jsxs(f,{onClick:Hs,disabled:!ne||p.isPending,children:[p.isPending&&e.jsx(_,{className:"mr-2 h-4 w-4 animate-spin"}),"Schedule"]})]})]})})]})}function Ia({host:s,contentId:i}){const{data:n}=rs(s,i,!0);return!n||n.count===0?null:e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-50 p-3 text-sm dark:bg-yellow-950/30",children:[e.jsxs("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:["This content is referenced by ",n.count," other"," ",n.count===1?"item":"items",":"]}),e.jsxs("ul",{className:"mt-1 list-disc pl-5 text-yellow-700 dark:text-yellow-300",children:[n.items.slice(0,5).map(t=>e.jsxs("li",{children:[t.title," (",t.collection,")"]},`${t.contentId}-${t.fieldName}`)),n.items.length>5&&e.jsxs("li",{children:["and ",n.items.length-5," more..."]})]})]})}function Fa({deleteOpen:s,setDeleteOpen:i,onDelete:n,host:t,contentId:l}){const{data:r}=rs(t,l,s);return e.jsxs(e.Fragment,{children:[e.jsx(Tt,{}),e.jsxs(Ne,{open:s,onOpenChange:i,children:[e.jsx(Lt,{asChild:!0,children:e.jsxs(f,{variant:"destructive",className:"w-full",children:[e.jsx(us,{className:"mr-2 h-4 w-4"}),"Delete"]})}),e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(we,{children:"Delete content?"}),e.jsx(ke,{children:"This action cannot be undone. The content will be permanently deleted."})]}),r&&r.count>0&&e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-50 p-3 text-sm dark:bg-yellow-950/30",children:[e.jsxs("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:["This content is referenced by ",r.count," other"," ",r.count===1?"item":"items",":"]}),e.jsxs("ul",{className:"mt-1 list-disc pl-5 text-yellow-700 dark:text-yellow-300",children:[r.items.slice(0,5).map(u=>e.jsxs("li",{children:[u.title," (",u.collection,")"]},`${u.contentId}-${u.fieldName}`)),r.items.length>5&&e.jsxs("li",{children:["and ",r.items.length-5," more..."]})]})]}),e.jsxs(De,{children:[e.jsx(f,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(f,{variant:"destructive",onClick:n,children:"Delete"})]})]})]})]})}function Ra({host:s,contentId:i,onViewVersion:n}){const{data:t}=ls(s,i),[l,r]=c.useState(!1),u=t?.items??[],x=u.map(o=>o.createdBy).filter(Boolean),{resolve:g}=It(x);return u.length===0?null:e.jsx(z,{children:e.jsx(H,{className:"pt-4",children:e.jsxs(bs,{open:l,onOpenChange:r,children:[e.jsxs(vs,{className:"flex w-full items-center gap-2 text-sm font-medium",children:[e.jsx(ms,{className:cs("h-4 w-4 transition",l&&"rotate-90")}),"Version History (",u.length,")"]}),e.jsx(ys,{className:"mt-2",children:e.jsx("div",{className:"space-y-1",children:u.map((o,v)=>e.jsxs("button",{className:"py-1 text-sm hover:bg-muted rounded px-1 -mx-1 transition-colors w-full text-left",onClick:()=>n(o),children:[e.jsx("span",{children:U(o.createdAt)}),o.createdBy&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:g(o.createdBy)}),o.title&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:o.title})]},`${o.createdAt}-${v}`))})})]})})})}const tn=Object.freeze(Object.defineProperty({__proto__:null,ContentEditPage:Ta},Symbol.toStringTag,{value:"Module"}));export{tn as C,Ae as F};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as Ce,f as Se,r as v}from"./react-vendor-C2CvUxFh.js";import{w as we,x as ke,B as F,P as re,v as b,z as ce,I as ie,X as V,A as ye,L as M,j as y,S as Te,a as _e,y as Ae}from"./index-Cir9tY_P.js";import{d as Ie,e as Pe,a as $e,b as Fe,c as Ve}from"./useContent-e8beBIuq.js";import{u as Be}from"./useTags-f7AVSLuj.js";import{u as De}from"./useDebouncedValue-C-cQUcLG.js";import{u as Le}from"./usePageTitle-BNSba9_L.js";import{u as Ue}from"./useFilterParams-DYdEuWPE.js";import{m as de}from"./media-url-DIg_vSyf.js";import{u as qe,F as Me}from"./FilterBar-DhRwTqFv.js";import{C as Re,c as ze}from"./card-hXVtlM0q.js";import{C as X}from"./checkbox-WGrS3sUr.js";import{P as Oe,a as Ee,b as He}from"./popover-D5_HjjUC.js";import{S as N,a as C,b as S,c as w,d}from"./select-_uJYxzeZ.js";import{T as Xe,a as Ze,b as oe,c as B,d as Ge,e as D}from"./table-DLoIbCQ5.js";import{a as R,f as ue}from"./format-C88SDH8g.js";import{g as he,a as xe}from"./contentStatus-BmaiYVOm.js";import{B as Qe}from"./BulkActionBar-TRiXXLQd.js";import"./radix-C1kb_NqW.js";import"./command-fvBFHye4.js";import"./useContentSearch-DOjveB9t.js";const z=3,me=[{value:"updated_desc",label:"Last updated"},{value:"updated_asc",label:"Oldest updated"},{value:"title_asc",label:"Title A–Z",requiresCollection:!0},{value:"title_desc",label:"Title Z–A",requiresCollection:!0},{value:"created_desc",label:"Newest created"},{value:"created_asc",label:"Oldest created"}],Z=[{value:"all",label:"All statuses"},{value:"draft",label:"Draft"},{value:"published",label:"Published"},{value:"changed",label:"Changed"},{value:"unpublished",label:"Unpublished"},{value:"scheduled",label:"Scheduled"}];function gs(){const{host:c,collection:t}=Ce(),T=Se(),{collections:je}=we(),[h,n]=Ue([{key:"q",defaultValue:""},{key:"search",defaultValue:"prefix"},{key:"tag",defaultValue:""},{key:"status",defaultValue:""},{key:"sort",defaultValue:"updated_desc"},{key:"relatedTo",defaultValue:""},{key:"relField",defaultValue:""}]),A=h.search,x=h.tag||void 0,m=h.status||void 0,_=h.sort,g=h.relatedTo,p=h.relField,[I,P]=v.useState(h.q),[fe,G]=v.useState(),[o,k]=v.useState(new Set),O=ke(),j=je.find(e=>e.name===t),L=j?.relationships??[],{data:Q}=qe(c,g||void 0),J=v.useMemo(()=>{if(!g||!p)return null;const e=L.find(r=>r.name===p);return{type:"relationship",relName:p,relLabel:e?.label??p,contentId:g,contentTitle:Q??"Loading..."}},[g,p,L,Q]);Le({title:j?.label??t??"",actions:j?.singleton?void 0:s.jsx(F,{size:"sm",onClick:()=>T(`/sites/${c}/content/${t}/new`),children:s.jsx(re,{className:"h-4 w-4"})})});const u=De(I,300);v.useEffect(()=>{u!==h.q&&n({q:u})},[u,h.q,n]);const a=v.useCallback(()=>G(void 0),[]),ge=v.useMemo(()=>{const e={};return u&&(e.q=u,e.search=A),x&&(e.tag=x),m&&(e.status=m),_!=="updated_desc"&&(e.sort=_),g&&(e.relatedTo=g),p&&(e.relField=p),e},[u,A,x,m,_,g,p]),{data:$,isLoading:pe}=Ie(c,t,ge,fe),E=Pe(c),K=$e(c),W=Fe(c),Y=Ve(c),{data:ee}=Be(c),U=v.useMemo(()=>ee?.map(e=>e.tag)??[],[ee]);if(j?.singleton&&$?.items.length===1)return T(`/sites/${c}/content/${t}/${$.items[0].contentId}`,{replace:!0}),null;const q=$?.items,H=q?.map(e=>e.contentId)??[],se=H.length>0&&H.every(e=>o.has(e));function le(e){k(r=>{const l=new Set(r);return l.has(e)?l.delete(e):l.add(e),l})}function ve(){k(se?new Set:new Set(H))}const ae=!!(u||x||m||g),te=!!u,ne=[A!=="prefix"?1:0,x?1:0,m?1:0,_!=="updated_desc"?1:0].reduce((e,r)=>e+r,0),be=K.isPending||W.isPending||Y.isPending;async function Ne(){try{const e=await E.mutateAsync({collection:t,title:j?.label??t});b.success("Singleton content recreated"),T(`/sites/${c}/content/${t}/${e.contentId}`)}catch(e){b.error("Failed to recreate singleton",{description:e instanceof Error?e.message:void 0})}}return s.jsxs("div",{children:[!O&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:j?.label??t}),!j?.singleton&&s.jsxs(F,{onClick:()=>T(`/sites/${c}/content/${t}/new`),children:[s.jsx(re,{className:"mr-2 h-4 w-4"}),"New"]})]}),o.size>0?s.jsx(Qe,{selectedCount:o.size,onPublish:async()=>{const e=[...o],l=(await K.mutateAsync(e)).filter(i=>i.status==="rejected").length;l?b.error(`${l} of ${e.length} failed to publish`):b.success(`${e.length} item(s) published`),k(new Set)},onUnpublish:async()=>{const e=[...o],l=(await W.mutateAsync(e)).filter(i=>i.status==="rejected").length;l?b.error(`${l} of ${e.length} failed to unpublish`):b.success(`${e.length} item(s) unpublished`),k(new Set)},onDelete:async()=>{const e=[...o],l=(await Y.mutateAsync(e)).filter(i=>i.status==="rejected").length;l?b.error(`${l} of ${e.length} failed to delete`):b.success(`${e.length} item(s) deleted`),k(new Set)},onClear:()=>k(new Set),isPending:be}):O?s.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ce,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(ie,{placeholder:"Search...",value:I,onChange:e=>{P(e.target.value),a()},className:"pl-8 pr-8"}),I&&s.jsx("button",{onClick:()=>{P(""),a()},className:"absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",children:s.jsx(V,{className:"h-4 w-4"})})]}),s.jsxs(Oe,{children:[s.jsx(Ee,{asChild:!0,children:s.jsxs(F,{variant:"outline",size:"icon",className:"relative shrink-0","aria-label":"Filters",children:[s.jsx(ye,{className:"h-4 w-4"}),ne>0&&s.jsx("span",{className:"absolute -right-1 -top-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-[10px] text-primary-foreground",children:ne})]})}),s.jsxs(He,{className:"w-64 space-y-3",align:"end",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(M,{className:"text-xs font-medium",children:"Search Mode"}),s.jsxs(N,{value:A,onValueChange:e=>{n({search:e}),a()},children:[s.jsx(C,{children:s.jsx(S,{})}),s.jsxs(w,{children:[s.jsx(d,{value:"prefix",children:"Starts with"}),s.jsx(d,{value:"full",children:"Contains"})]})]})]}),U.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(M,{className:"text-xs font-medium",children:"Tag"}),s.jsxs(N,{value:x??"__all__",onValueChange:e=>{n({tag:e==="__all__"?"":e}),a()},children:[s.jsx(C,{children:s.jsx(S,{})}),s.jsxs(w,{children:[s.jsx(d,{value:"__all__",children:"All tags"}),U.map(e=>s.jsx(d,{value:e,children:e},e))]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(M,{className:"text-xs font-medium",children:"Status"}),s.jsxs(N,{value:m??"all",onValueChange:e=>{n({status:e==="all"?"":e}),a()},children:[s.jsx(C,{children:s.jsx(S,{})}),s.jsx(w,{children:Z.map(e=>s.jsx(d,{value:e.value??"all",children:e.label},e.value??"all"))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(M,{className:"text-xs font-medium",children:"Sort"}),s.jsxs(N,{value:_,onValueChange:e=>{n({sort:e}),a()},disabled:te,children:[s.jsx(C,{children:s.jsx(S,{})}),s.jsx(w,{children:me.map(e=>s.jsx(d,{value:e.value,disabled:e.requiresCollection&&!t,children:e.label},e.value))})]})]})]})]})]}):s.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(ce,{className:"absolute left-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(ie,{placeholder:"Search titles...",value:I,onChange:e=>{P(e.target.value),a()},className:"w-56 pl-8 pr-8"}),I&&s.jsx("button",{onClick:()=>{P(""),a()},className:"absolute right-2 text-muted-foreground hover:text-foreground",children:s.jsx(V,{className:"h-4 w-4"})})]}),s.jsxs(N,{value:A,onValueChange:e=>{n({search:e}),a()},children:[s.jsx(C,{className:"w-[130px]",children:s.jsx(S,{})}),s.jsxs(w,{children:[s.jsx(d,{value:"prefix",children:"Starts with"}),s.jsx(d,{value:"full",children:"Contains"})]})]}),U.length>0&&s.jsxs(N,{value:x??"__all__",onValueChange:e=>{n({tag:e==="__all__"?"":e}),a()},children:[s.jsx(C,{className:"w-[140px]",children:s.jsx(S,{placeholder:"Tag"})}),s.jsxs(w,{children:[s.jsx(d,{value:"__all__",children:"All tags"}),U.map(e=>s.jsx(d,{value:e,children:e},e))]})]}),s.jsxs(N,{value:m??"all",onValueChange:e=>{n({status:e==="all"?"":e}),a()},children:[s.jsx(C,{className:"w-[150px]",children:s.jsx(S,{})}),s.jsx(w,{children:Z.map(e=>s.jsx(d,{value:e.value??"all",children:e.label},e.value??"all"))})]}),s.jsx("div",{className:"ml-auto",children:s.jsxs(N,{value:_,onValueChange:e=>{n({sort:e}),a()},disabled:te,children:[s.jsx(C,{className:"w-[170px]",children:s.jsx(S,{})}),s.jsx(w,{children:me.map(e=>s.jsx(d,{value:e.value,disabled:e.requiresCollection&&!t,children:e.label},e.value))})]})})]}),L.length>0&&s.jsx("div",{className:"mb-3",children:s.jsx(Me,{relationships:L,activeFilters:J?[J]:[],onFilterAdd:e=>{n({relatedTo:e.contentId,relField:e.relName}),a()},onFilterRemove:()=>{n({relatedTo:"",relField:""}),a()}})}),ae&&o.size===0&&s.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[u&&s.jsxs(y,{variant:"secondary",className:"gap-1",children:["Search: ",u,s.jsx("button",{onClick:()=>{P(""),a()},children:s.jsx(V,{className:"h-3 w-3"})})]}),x&&s.jsxs(y,{variant:"secondary",className:"gap-1",children:["Tag: ",x,s.jsx("button",{onClick:()=>{n({tag:""}),a()},children:s.jsx(V,{className:"h-3 w-3"})})]}),m&&s.jsxs(y,{variant:"secondary",className:"gap-1",children:["Status: ",Z.find(e=>e.value===m)?.label,s.jsx("button",{onClick:()=>{n({status:""}),a()},children:s.jsx(V,{className:"h-3 w-3"})})]})]}),pe?s.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((e,r)=>s.jsx(Te,{className:"h-12 w-full"},r))}):q?.length?s.jsxs(s.Fragment,{children:[O?s.jsx("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"content-card-view",children:q.map(e=>{const r=he(e.publishedAt,e.lastPublishedAt,e.publishedBlockId,e.lastDraftBlockId,e.scheduledAt,e.scheduledFailed),l=xe(r),i=e.tags??[];return s.jsx(Re,{className:Ae("cursor-pointer gap-0 overflow-hidden py-0 transition-shadow hover:shadow-md",o.has(e.contentId)&&"ring-2 ring-primary"),onClick:()=>T(`/sites/${c}/content/${t}/${e.contentId}`),children:s.jsxs(ze,{className:"p-3",children:[s.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.cover?.url&&s.jsx("img",{src:de(e.cover.url),alt:e.cover.alt??"",className:"h-12 w-12 rounded object-cover flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",children:e.draftTitle||e.title||"Untitled"}),s.jsx(y,{variant:l.variant,className:"shrink-0",children:l.label})]}),(e.draftSlug||e.slug)&&s.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:["/",e.draftSlug||e.slug]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e.lastDraftAt?R(e.lastDraftAt):"—"})]}),s.jsx(X,{checked:o.has(e.contentId),onCheckedChange:()=>le(e.contentId),onClick:f=>f.stopPropagation(),className:"mt-1"})]}),i.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:i.slice(0,z).map(f=>s.jsx(y,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:f},f))})]})},e.contentId)})}):s.jsxs(Xe,{children:[s.jsx(Ze,{children:s.jsxs(oe,{children:[s.jsx(B,{className:"w-10",children:s.jsx(X,{checked:se,onCheckedChange:ve,"aria-label":"Select all"})}),s.jsx(B,{children:"Title"}),s.jsx(B,{children:"Slug"}),s.jsx(B,{children:"Status"}),s.jsx(B,{children:"Updated"})]})}),s.jsx(Ge,{children:q.map(e=>{const r=he(e.publishedAt,e.lastPublishedAt,e.publishedBlockId,e.lastDraftBlockId),l=xe(r),i=e.tags??[];return s.jsxs(oe,{className:"cursor-pointer",onClick:()=>T(`/sites/${c}/content/${t}/${e.contentId}`),children:[s.jsx(D,{onClick:f=>f.stopPropagation(),children:s.jsx(X,{checked:o.has(e.contentId),onCheckedChange:()=>le(e.contentId),"aria-label":`Select ${e.draftTitle||e.title||"Untitled"}`})}),s.jsx(D,{className:"font-medium",children:s.jsxs("div",{className:"flex items-center gap-3",children:[e.cover?.url&&s.jsx("img",{src:de(e.cover.url),alt:e.cover.alt??"",className:"h-8 w-8 rounded object-cover flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{children:e.draftTitle||e.title||"Untitled"}),i.length>0&&s.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-1",children:[i.slice(0,z).map(f=>s.jsx(y,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal text-muted-foreground",children:f},f)),i.length>z&&s.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",i.length-z," more"]})]})]})]})}),s.jsx(D,{className:"text-muted-foreground text-sm",children:e.draftSlug||e.slug||"—"}),s.jsx(D,{children:s.jsx(y,{variant:l.variant,children:l.label})}),s.jsx(D,{className:"text-muted-foreground",children:e.scheduledAt&&!e.publishedAt?s.jsxs("span",{title:ue(e.scheduledAt),children:["Scheduled ",R(e.scheduledAt)]}):e.publishedAt?s.jsx("span",{title:ue(e.publishedAt),children:R(e.publishedAt)}):e.lastDraftAt?R(e.lastDraftAt):"—"})]},e.contentId)})})]}),$?.hasMore&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(F,{variant:"outline",onClick:()=>G($.cursor??void 0),children:"Load More"})})]}):j?.singleton?s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-muted-foreground",children:"Singleton content is missing. Click below to recreate it."}),s.jsxs(F,{onClick:Ne,disabled:E.isPending,children:[E.isPending&&s.jsx(_e,{className:"mr-2 h-4 w-4 animate-spin"}),"Recreate ",j.label]})]}):s.jsx("p",{className:"text-muted-foreground",children:ae?"No content matches the current filters.":"No content yet."})]})}export{gs as ContentListPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as Qt}from"./index-
|
|
1
|
+
import{_ as Qt}from"./index-Cir9tY_P.js";import{j as q}from"./tanstack-Bs3zYPPV.js";import{r as ie}from"./react-vendor-C2CvUxFh.js";class z{constructor(e,n,r,s,i){this.kind=e,this.input=n,this.begin=r,this.end=s,this.file=i}getText(){return this.input.slice(this.begin,this.end)}getPosition(){let[e,n]=[1,1];for(let r=0;r<this.begin;r++)this.input[r]===`
|
|
2
2
|
`?(e++,n=1):n++;return[e,n]}size(){return this.end-this.begin}}class J{liquidMethodMissing(e,n){}}const Gt=Object.prototype.toString,He=String.prototype.toLowerCase,Re=Object.hasOwnProperty;function f(t){return typeof t=="string"}function T(t){return typeof t=="function"}function Xt(t){return t&&T(t.then)}function he(t){return t&&T(t.next)&&T(t.throw)&&T(t.return)}function Kt(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function u(t){return t=p(t),f(t)?t:O(t)?"":_(t)?t.map(e=>u(e)).join(""):String(t)}function se(t){return t=p(t),_(t)?t:f(t)&&t.length>0?[t]:tn(t)?Array.from(t):me(t)?Object.keys(t).map(e=>[e,t[e]]):[]}function v(t){return t=p(t),O(t)?[]:_(t)?t:[t]}function p(t){return t instanceof J&&T(t.valueOf)?t.valueOf():t}function Se(t){return+p(t)||0}function ge(t){return typeof t=="number"}function wt(t){return t&&T(t.toLiquid)?wt(t.toLiquid()):t}function O(t){return t==null}function en(t){return t===void 0}function _(t){return Gt.call(t)==="[object Array]"}function bt(t){return t&&ge(t.length)}function tn(t){return me(t)&&Symbol.iterator in t}function We(t,e){t=t||{};for(const n in t)if(Re.call(t,n)&&e(t[n],n,t)===!1)break;return t}function xt(t){return t[t.length-1]}function me(t){const e=typeof t;return t!==null&&(e==="object"||e==="function")}function Tt(t,e,n=1){const r=[];for(let s=t;s<e;s+=n)r.push(s);return r}function re(t,e,n=" "){return vt(t,e,n,(r,s)=>s+r)}function nn(t,e,n=" "){return vt(t,e,n,(r,s)=>r+s)}function vt(t,e,n,r){t=String(t);let s=e-t.length;for(;s-- >0;)t=r(t,n);return t}function _t(t){return t}function rn(t){return[...t].some(n=>n>="a"&&n<="z")?t.toUpperCase():t.toLowerCase()}function sn(t,e){return t.length>e?t.slice(0,e-3)+"...":t}function Ye(t,e){return t==null&&e==null?0:t==null?1:e==null||(t=He.call(t),e=He.call(e),t<e)?-1:t>e?1:0}function ye(t){return function(...e){return t.call(this,...e.map(p))}}function D(t){return function(...e){return t.call(this,...e.map(Se))}}function Ee(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function*oe(t){const e=new Set;for(const n of t){const r=JSON.stringify(n);e.has(r)||(e.add(r),yield n)}}const Je="__liquidClass__";class Z extends Error{constructor(e,n){super(typeof e=="string"?e:e.message),this.context="",typeof e!="string"&&Object.defineProperty(this,"originalError",{value:e,enumerable:!1}),Object.defineProperty(this,"token",{value:n,enumerable:!1}),Object.defineProperty(this,Je,{value:"LiquidError",enumerable:!1})}update(){Object.defineProperty(this,"context",{value:fn(this.token),enumerable:!1}),this.message=dn(this.message,this.token),this.stack=this.message+`
|
|
3
3
|
`+this.context+`
|
|
4
4
|
`+this.stack,this.originalError&&(this.stack+=`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as j}from"./react-vendor-C2CvUxFh.js";import{C as O,u as z,a as A,P as D,D as P,c as q}from"./core.esm-B_kcYf6n.js";import{u as V,S as $,v as _,a as G}from"./sortable.esm-QyXA6fio.js";import{I as m,y as k,V as U,L as i,R as W,W as Y,B as E,T as H,P as J}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as j}from"./react-vendor-C2CvUxFh.js";import{C as O,u as z,a as A,P as D,D as P,c as q}from"./core.esm-B_kcYf6n.js";import{u as V,S as $,v as _,a as G}from"./sortable.esm-QyXA6fio.js";import{I as m,y as k,V as U,L as i,R as W,W as Y,B as E,T as H,P as J}from"./index-Cir9tY_P.js";import{S as I,a as L,b as B,c as M,d as R}from"./select-_uJYxzeZ.js";import{d as w,i as K}from"./format-C88SDH8g.js";import{C as Q,a as X,b as Z}from"./collapsible-B414SspL.js";import{C}from"./checkbox-WGrS3sUr.js";import{T as ee}from"./textarea-vSXNxwTe.js";function se({value:t,onChange:a,onBlur:u,readOnly:p,className:l,...s}){const[n,h]=j.useState(!1),x=j.useRef(void 0);j.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const g=j.useCallback(v=>{const N=v.target.value,f=w(N,"leading");a(f),N!==f&&N.length>0?(h(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>h(!1),2e3)):h(!1)},[a]),y=j.useCallback(()=>{const v=w(t,"all");v!==t&&a(v),u?.()},[t,a,u]);return e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{value:t,onChange:g,onBlur:y,disabled:p,"aria-invalid":n||void 0,autoComplete:"off","data-1p-ignore":!0,"data-lpignore":"true",className:k("font-mono",l),...s}),n&&e.jsx("p",{className:"text-xs text-destructive",children:"Must start with a letter. Only lowercase letters, numbers, hyphens, and underscores."})]})}function ae({type:t,options:a,onChange:u}){const p=U();function l(s,n){u({...a,[s]:n})}return e.jsxs("div",{className:"space-y-3",children:[!["boolean","blocks","array","container"].includes(t)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{id:"opt-required",checked:!!a.required,onCheckedChange:s=>l("required",!!s)}),e.jsx(i,{htmlFor:"opt-required",className:"text-sm",children:"Required"})]}),["text","textarea"].includes(t)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Placeholder"}),e.jsx(m,{value:a.placeholder??"",onChange:s=>l("placeholder",s.target.value),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Max Length"}),e.jsx(m,{type:"number",value:a.maxLength??"",onChange:s=>l("maxLength",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]})]}),t==="number"&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Min"}),e.jsx(m,{type:"number",value:a.min??"",onChange:s=>l("min",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Max"}),e.jsx(m,{type:"number",value:a.max??"",onChange:s=>l("max",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Step"}),e.jsx(m,{type:"number",value:a.step??"",onChange:s=>l("step",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]})]}),t==="select"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Choices (one per line)"}),e.jsx(ee,{value:(a.choices??[]).join(`
|
|
2
2
|
`),onChange:s=>l("choices",s.target.value.split(`
|
|
3
3
|
`).map(n=>n.trim()).filter(Boolean)),rows:4,className:"text-sm"})]}),t==="media"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Allowed Types (e.g., image/*, video/*)"}),e.jsx(m,{value:(a.allowedTypes??[]).join(", "),onChange:s=>l("allowedTypes",s.target.value.split(",").map(n=>n.trim()).filter(Boolean)),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Folder"}),e.jsx(m,{value:a.folder??"",onChange:s=>l("folder",s.target.value||void 0),placeholder:"e.g., submissions/photos",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Accept (MIME filter)"}),e.jsx(m,{value:a.accept??"",onChange:s=>l("accept",s.target.value||void 0),placeholder:"e.g., image/*",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Max Size (bytes)"}),e.jsx(m,{type:"number",value:a.maxSize??"",onChange:s=>l("maxSize",s.target.value?Number(s.target.value):void 0),placeholder:"5242880 (5MB)",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{id:"opt-media-multiple",checked:!!a.multiple,onCheckedChange:s=>l("multiple",!!s)}),e.jsx(i,{htmlFor:"opt-media-multiple",className:"text-sm",children:"Allow multiple"})]})]}),t==="content"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Allowed Collections"}),p&&p.collections.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:p.collections.map(s=>{const n=a.collections??[],h=n.includes(s.name);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(C,{id:`col-${s.name}`,checked:h,onCheckedChange:x=>{x?l("collections",[...n,s.name]):l("collections",n.filter(g=>g!==s.name))}}),e.jsx(i,{htmlFor:`col-${s.name}`,className:"text-xs font-normal",children:s.label||s.name})]},s.name)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave all unchecked to allow any collection"})]}):e.jsx(m,{value:(a.collections??[]).join(", "),onChange:s=>l("collections",s.target.value.split(",").map(n=>n.trim()).filter(Boolean)),placeholder:"Comma-separated, leave empty for all",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{id:"opt-multiple",checked:!!a.multiple,onCheckedChange:s=>l("multiple",!!s)}),e.jsx(i,{htmlFor:"opt-multiple",className:"text-sm",children:"Allow multiple"})]})]}),t==="container"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Fields"}),e.jsx(T,{fields:a.fields??[],onChange:s=>l("fields",s),excludeTypes:["container","blocks"]})]}),t==="array"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(i,{className:"text-xs",children:"Item Fields"}),e.jsx(T,{fields:a.itemFields??[],onChange:s=>l("itemFields",s),excludeTypes:["array","container"]})]})]})}const S=[{value:"text",label:"Text"},{value:"textarea",label:"Textarea"},{value:"number",label:"Number"},{value:"boolean",label:"Boolean"},{value:"select",label:"Select"},{value:"url",label:"URL"},{value:"email",label:"Email"},{value:"date",label:"Date"},{value:"media",label:"Media"},{value:"content",label:"Content"},{value:"blocks",label:"Blocks"},{value:"array",label:"Array"},{value:"container",label:"Container"}];function le({id:t,field:a,onChange:u,onRemove:p,excludeTypes:l,readOnlyName:s,defaultExpanded:n}){const[h,x]=j.useState(n??!1),[g,y]=j.useState(!!a.label),{attributes:v,listeners:N,setNodeRef:f,transform:F,transition:r}=V({id:t}),o=l?S.filter(c=>!l.includes(c.value)):S,d={transform:O.Transform.toString(F),transition:r};function b(c){u({...a,...c})}return e.jsx("div",{ref:f,style:d,className:"rounded-md border bg-card",children:e.jsxs(Q,{open:h,onOpenChange:x,children:[e.jsxs("div",{className:"flex items-center gap-2 p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...v,...N,children:e.jsx(W,{className:"h-4 w-4"})}),e.jsx(X,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex items-center",children:e.jsx(Y,{className:k("h-4 w-4 transition-transform",h&&"rotate-90")})})}),e.jsx("span",{className:"min-w-[80px] text-sm font-mono",children:a.name||"unnamed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a.type}),e.jsx("span",{className:"flex-1 truncate text-sm text-muted-foreground",children:a.label}),e.jsx(E,{type:"button",variant:"ghost",size:"sm",onClick:p,className:"text-destructive",children:e.jsx(H,{className:"h-3 w-3"})})]}),e.jsx(Z,{children:e.jsxs("div",{className:"space-y-3 border-t p-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),e.jsx(se,{value:a.name,onChange:c=>b({name:c}),onBlur:()=>{a.name&&!g&&b({label:K(a.name)})},readOnly:s,className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Label"}),e.jsx(m,{value:a.label,onChange:c=>{b({label:c.target.value}),y(!0)},className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Type"}),e.jsxs(I,{value:a.type,onValueChange:c=>b({type:c,options:{}}),children:[e.jsx(L,{className:"h-8 text-sm",children:e.jsx(B,{})}),e.jsx(M,{children:o.map(c=>e.jsx(R,{value:c.value,children:c.label},c.value))})]})]})]}),e.jsx(ae,{type:a.type,options:a.options??{},onChange:c=>b({options:c})})]})})]})})}function T({fields:t,onChange:a,excludeTypes:u,existingFieldNames:p}){const l=z(A(D)),s=t.map((r,o)=>`field-${o}`),[n,h]=j.useState("text"),[x,g]=j.useState(null),y=u?S.filter(r=>!u.includes(r.value)):S;function v(){g(t.length),a([...t,{name:"",label:"",type:n,options:{}}])}function N(r,o){const d=[...t];d[r]=o,a(d)}function f(r){a(t.filter((o,d)=>d!==r))}function F(r){const{active:o,over:d}=r;if(d&&o.id!==d.id){const b=s.indexOf(String(o.id)),c=s.indexOf(String(d.id));a(G(t,b,c))}}return e.jsx(P,{sensors:l,collisionDetection:q,onDragEnd:F,children:e.jsx($,{items:s,strategy:_,children:e.jsxs("div",{className:"space-y-2",children:[t.map((r,o)=>e.jsx(le,{id:`field-${o}`,field:r,onChange:d=>N(o,d),onRemove:()=>f(o),excludeTypes:u,readOnlyName:!!(p?.has(r.name)&&r.name),defaultExpanded:o===x},`field-${o}`)),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(I,{value:n,onValueChange:h,children:[e.jsx(L,{className:"h-8 w-[130px] text-sm",children:e.jsx(B,{})}),e.jsx(M,{children:y.map(r=>e.jsx(R,{value:r.value,children:r.label},r.value))})]}),e.jsxs(E,{type:"button",variant:"outline",size:"sm",onClick:v,children:[e.jsx(J,{className:"mr-2 h-3 w-3"})," Add Field"]})]})]})})})}export{T as F,se as I};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as N,j as e}from"./tanstack-Bs3zYPPV.js";import{u as v,r as h}from"./react-vendor-C2CvUxFh.js";import{e as w,j as x,X as y,a2 as S,a3 as F,B as p,
|
|
1
|
+
import{u as N,j as e}from"./tanstack-Bs3zYPPV.js";import{u as v,r as h}from"./react-vendor-C2CvUxFh.js";import{e as w,j as x,X as y,a2 as S,a3 as F,B as p,b2 as j,a5 as R,a6 as I,aa as P}from"./index-Cir9tY_P.js";import{P as T,a as L,b as D}from"./popover-D5_HjjUC.js";import{C as B,a as M,b as $,c as k,d as q,e as E}from"./command-fvBFHye4.js";import{u as Q}from"./useContentSearch-DOjveB9t.js";import{u as z}from"./useDebouncedValue-C-cQUcLG.js";function J({relationships:s,activeFilters:a,onFilterAdd:o,onFilterRemove:i}){const{host:u}=v(),[l,c]=h.useState(null),[d,r]=h.useState(""),n=z(d,300);if(s.length===0)return null;const f=new Set(a.map(t=>t.relName)),m=s.filter(t=>!f.has(t.name));function g(t){c(t),r("")}function C(t){l&&(o({type:"relationship",relName:l.name,relLabel:l.label,contentId:t.contentId,contentTitle:t.title}),c(null),r(""))}function b(){c(null),r("")}return e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"filter-bar",children:[a.map(t=>e.jsxs(x,{variant:"secondary",className:"gap-1 pl-2",children:[t.relLabel,": ",t.contentTitle,e.jsx("button",{onClick:()=>i(t.relName),className:"ml-0.5 hover:text-foreground","aria-label":`Remove ${t.relLabel} filter`,children:e.jsx(y,{className:"h-3 w-3"})})]},t.relName)),m.length>0&&(l?e.jsx(A,{host:u,rel:l,query:d,debouncedQuery:n,onQueryChange:r,onSelect:C,onClose:b}):e.jsxs(S,{children:[e.jsx(F,{asChild:!0,children:e.jsxs(p,{variant:"outline",size:"sm","data-testid":"add-filter-button",children:[e.jsx(j,{className:"mr-1.5 h-3.5 w-3.5"}),"Add filter"]})}),e.jsx(R,{align:"start",children:m.map(t=>e.jsx(I,{onSelect:()=>g(t),children:t.label},t.name))})]}))]})}function A({host:s,rel:a,query:o,debouncedQuery:i,onQueryChange:u,onSelect:l,onClose:c}){const{data:d,isLoading:r}=Q(s,i,[a.targetCollection],"published");return e.jsxs(T,{open:!0,onOpenChange:n=>{n||c()},children:[e.jsx(L,{asChild:!0,children:e.jsxs(p,{variant:"outline",size:"sm",children:[e.jsx(j,{className:"mr-1.5 h-3.5 w-3.5"}),a.label,"..."]})}),e.jsx(D,{className:"w-80 p-0",align:"start",children:e.jsxs(B,{shouldFilter:!1,children:[e.jsx(M,{placeholder:`Search ${a.label.toLowerCase()}...`,value:o,onValueChange:u,autoFocus:!0}),e.jsx($,{children:r?e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}):e.jsxs(e.Fragment,{children:[e.jsx(k,{children:"No published content found."}),e.jsx(q,{heading:i.length===0?"Recent":void 0,children:d?.items.map(n=>e.jsxs(E,{value:n.contentId,onSelect:()=>l({contentId:n.contentId,collection:n.collection,slug:n.slug??"",title:n.title}),children:[e.jsx(P,{className:"h-4 w-4"}),e.jsx("span",{className:"flex-1 truncate",children:n.title}),e.jsx(x,{variant:"outline",className:"text-xs",children:n.collection})]},n.contentId))})]})})]})})]})}function W(s,a){const o=w();return N({queryKey:["sites",s,"content-detail",a,"filter-title"],queryFn:async()=>(await o.apiFetch(`/v1/admin/sites/${s}/content/${a}`)).content?.title||"Untitled",enabled:!!s&&!!a,staleTime:6e4})}export{J as F,W as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as o,N as Y}from"./react-vendor-C2CvUxFh.js";import{u as z,L as c,I as d,B as m,a as x,f as _,c as G}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as o,N as Y}from"./react-vendor-C2CvUxFh.js";import{u as z,L as c,I as d,B as m,a as x,f as _,c as G}from"./index-Cir9tY_P.js";import{C as J,a as X,b as Z,c as $}from"./card-hXVtlM0q.js";import"./radix-C1kb_NqW.js";function oe(){const{status:T,login:D,completeNewPassword:L,respondToMfaChallenge:O}=z(),[g,W]=o.useState(""),[j,I]=o.useState(""),[N,q]=o.useState(""),[v,E]=o.useState(""),[i,a]=o.useState(""),[n,r]=o.useState(!1),[l,y]=o.useState(null),[u,f]=o.useState("login"),[h,C]=o.useState(""),[S,P]=o.useState(""),[w,b]=o.useState(""),[F,R]=o.useState("");if(T==="authenticated")return e.jsx(Y,{to:"/sites",replace:!0});async function M(t){t.preventDefault(),a(""),r(!0);try{const s=await D(g,j);s.challenge==="NEW_PASSWORD_REQUIRED"&&s.cognitoUser?y({type:"NEW_PASSWORD_REQUIRED",user:s.cognitoUser}):s.challenge==="SOFTWARE_TOKEN_MFA"&&s.cognitoUser&&y({type:"SOFTWARE_TOKEN_MFA",user:s.cognitoUser})}catch(s){a(s instanceof Error?s.message:"Login failed")}finally{r(!1)}}async function U(t){if(t.preventDefault(),!!l){a(""),r(!0);try{await L(l.user,N)}catch(s){a(s instanceof Error?s.message:"Password change failed")}finally{r(!1)}}}async function k(t){if(t.preventDefault(),!!l){a(""),r(!0);try{await O(l.user,v)}catch(s){s&&typeof s=="object"&&"name"in s&&s.name==="NotAuthorizedException"?(a("Your session has expired. Please sign in again."),y(null),E("")):a(s instanceof Error?s.message:"Invalid code")}finally{r(!1)}}}async function B(t){t.preventDefault(),a(""),r(!0);try{await _(h),f("forgot-confirm")}catch(s){(s&&typeof s=="object"&&"name"in s?s.name:"")==="LimitExceededException"?a("Too many attempts. Please try again later."):f("forgot-confirm")}finally{r(!1)}}async function K(){a(""),r(!0);try{await _(h)}catch{}finally{r(!1)}}async function Q(t){if(t.preventDefault(),a(""),w.length<12){a("Password must be at least 12 characters.");return}if(w!==F){a("Passwords do not match.");return}r(!0);try{await G(h,S,w),f("forgot-success")}catch(s){const p=s&&typeof s=="object"&&"name"in s?s.name:"";a(p==="CodeMismatchException"?"Invalid verification code.":p==="ExpiredCodeException"?"Verification code has expired. Please request a new one.":p==="InvalidPasswordException"?"New password does not meet requirements (min 12 chars, uppercase, lowercase, number, symbol).":p==="LimitExceededException"?"Too many attempts. Please try again later.":s instanceof Error?s.message:"Password reset failed")}finally{r(!1)}}function A(){f("login"),a(""),P(""),b(""),R("")}function V(){return u==="forgot-email"?e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter your email and we'll send a code to reset your password."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"forgot-email",children:"Email"}),e.jsx(d,{id:"forgot-email",type:"email",value:h,onChange:t=>C(t.target.value),required:!0,autoFocus:!0,autoComplete:"email"})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Send Reset Code"]}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground w-full text-center text-sm underline",onClick:A,children:"Back to sign in"})]}):u==="forgot-confirm"?e.jsxs("form",{onSubmit:Q,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter the code sent to your email and choose a new password."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"reset-code",children:"Verification Code"}),e.jsx(d,{id:"reset-code",type:"text",value:S,onChange:t=>P(t.target.value),required:!0,autoFocus:!0,autoComplete:"one-time-code"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"reset-password",children:"New Password"}),e.jsx(d,{id:"reset-password",type:"password",value:w,onChange:t=>b(t.target.value),required:!0,autoComplete:"new-password"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"reset-confirm-password",children:"Confirm Password"}),e.jsx(d,{id:"reset-confirm-password",type:"password",value:F,onChange:t=>R(t.target.value),required:!0,autoComplete:"new-password"})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Reset Password"]}),e.jsxs("p",{className:"text-muted-foreground text-center text-sm",children:["Didn't receive a code?"," ",e.jsx("button",{type:"button",className:"text-foreground underline",onClick:K,disabled:n,children:"Resend code"})]})]}):u==="forgot-success"?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your password has been reset successfully."}),e.jsx(m,{className:"w-full",onClick:A,children:"Sign In"})]}):l?.type==="SOFTWARE_TOKEN_MFA"?e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter the 6-digit code from your authenticator app."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"mfa-code",children:"Authentication Code"}),e.jsx(d,{id:"mfa-code",type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:v,onChange:t=>E(t.target.value),required:!0,autoFocus:!0,autoComplete:"one-time-code"})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Verify"]})]}):l?.type==="NEW_PASSWORD_REQUIRED"?e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Please set a new password to continue."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"new-password",children:"New Password"}),e.jsx(d,{id:"new-password",type:"password",value:N,onChange:t=>q(t.target.value),required:!0,minLength:12,autoFocus:!0})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Set Password"]})]}):e.jsxs("form",{onSubmit:M,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"email",children:"Email"}),e.jsx(d,{id:"email",type:"email",value:g,onChange:t=>W(t.target.value),required:!0,autoFocus:!0,autoComplete:"email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"password",children:"Password"}),e.jsx(d,{id:"password",type:"password",value:j,onChange:t=>I(t.target.value),required:!0,autoComplete:"current-password"})]}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground text-sm underline",onClick:()=>{f("forgot-email"),C(g),a("")},children:"Forgot password?"}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Sign In"]})]})}function H(){return u==="forgot-email"||u==="forgot-confirm"?"Reset Password":u==="forgot-success"?"Password Reset":l?.type==="SOFTWARE_TOKEN_MFA"?"Two-Factor Authentication":l?.type==="NEW_PASSWORD_REQUIRED"?"Set New Password":"Sign in to Headroom"}return e.jsx("div",{className:"flex h-dvh items-center justify-center",children:e.jsxs(J,{className:"w-full max-w-sm",children:[e.jsx(X,{children:e.jsx(Z,{className:"text-center text-xl",children:H()})}),e.jsx($,{children:V()})]})})}export{oe as LoginPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as F,r as f}from"./react-vendor-C2CvUxFh.js";import{D as R,k as $,l as q,m as B,n as E,I,B as g,a as k,ai as O,Y as L,ae as D,v as V,X as H,L as M}from"./index-Cir9tY_P.js";import{h as X,i as Y,d as G,m as J,n as K}from"./useMedia-e3sqWm_t.js";import{S as Q,a as Z,b as ee,c as ae,d as _}from"./select-_uJYxzeZ.js";import{C as se}from"./card-hXVtlM0q.js";import{m as P}from"./media-url-DIg_vSyf.js";function te({open:i,onSelect:l,onClose:r,allowedTypes:n}){const{host:c}=F(),[d,m]=f.useState(""),[u,j]=f.useState("__all__"),t=f.useRef(null),N=X(c),o=Y(c),{data:v}=G(c),h=v?.items??[],y=u==="__all__"?void 0:u==="__unfiled__"?"":u,{data:w,fetchNextPage:s,hasNextPage:C,isFetchingNextPage:b}=J(c,{folderId:y}),[S,T]=f.useState(!1),U=(w?.pages.flatMap(a=>a.items)??[]).filter(a=>n&&!n.some(x=>x.endsWith("/*")?a.mimeType.startsWith(x.slice(0,-1)):a.mimeType===x)?!1:d?a.filename.toLowerCase().includes(d.toLowerCase())||a.alt?.toLowerCase().includes(d.toLowerCase()):!0);async function A(a){T(!0);try{const{uploadUrl:p,mediaId:x}=await N.mutateAsync({filename:a.name,contentType:a.type,size:a.size});await fetch(p,{method:"PUT",body:a,headers:{"Content-Type":a.type}});const z=await o.mutateAsync({mediaId:x,filename:a.name});l(z),r()}catch(p){V.error("Upload failed",{description:p instanceof Error?p.message:void 0})}finally{T(!1)}}function W(a){return a.startsWith("image/")}return e.jsx(R,{open:i,onOpenChange:()=>r(),children:e.jsxs($,{className:"max-w-3xl",children:[e.jsxs(q,{children:[e.jsx(B,{children:"Select Media"}),e.jsx(E,{className:"sr-only",children:"Browse and select media files"})]}),e.jsxs("div",{className:"mb-4 flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(I,{placeholder:"Search by filename...",value:d,onChange:a=>m(a.target.value),className:"max-w-xs"}),h.length>0&&e.jsxs(Q,{value:u,onValueChange:j,children:[e.jsx(Z,{className:"w-[150px]",children:e.jsx(ee,{})}),e.jsxs(ae,{children:[e.jsx(_,{value:"__all__",children:"All folders"}),h.map(a=>e.jsx(_,{value:a.folderId,children:a.name},a.folderId)),e.jsx(_,{value:"__unfiled__",children:"Unfiled"})]})]})]}),e.jsxs("div",{children:[e.jsx("input",{ref:t,type:"file",className:"hidden",accept:n?.join(",")??void 0,onChange:a=>a.target.files?.[0]&&A(a.target.files[0])}),e.jsxs(g,{variant:"outline",onClick:()=>t.current?.click(),disabled:S,children:[S?e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(O,{className:"mr-2 h-4 w-4"}),"Upload New"]})]})]}),e.jsx("div",{className:"grid max-h-96 grid-cols-4 gap-3 overflow-y-auto",children:U.map(a=>e.jsxs(se,{className:"cursor-pointer overflow-hidden hover:ring-2 hover:ring-primary",onClick:()=>{l(a),r()},children:[e.jsx("div",{className:"flex aspect-square items-center justify-center bg-muted",children:W(a.mimeType)?e.jsx("img",{src:P(a.urls?.thumb_md??a.url),alt:a.alt??a.filename,className:"h-full w-full object-cover"}):e.jsxs("div",{className:"flex flex-col items-center gap-1 p-2",children:[a.mimeType.startsWith("image/")?e.jsx(L,{className:"h-8 w-8 text-muted-foreground"}):e.jsx(D,{className:"h-8 w-8 text-muted-foreground"}),e.jsx("span",{className:"max-w-full truncate text-xs text-muted-foreground",children:a.filename})]})}),e.jsx("div",{className:"p-1.5",children:e.jsx("p",{className:"truncate text-xs",children:a.filename})})]},a.mediaId))}),U.length===0&&e.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No media found."}),C&&e.jsxs(g,{variant:"ghost",className:"mt-2 w-full",onClick:()=>s(),disabled:b,children:[b?e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Load More"]})]})})}function le(i){if(!i)return null;if(typeof i=="string")return{id:i,url:""};const l=i,r=l.id??l.mediaId??"";return r?{id:r,url:l.url??"",mimeType:l.mimeType,width:l.width,height:l.height,alt:l.alt,caption:l.caption,filename:l.filename}:null}function ie(i){return i?i.startsWith("image/"):!0}function pe({field:i,value:l,onChange:r,disabled:n}){const{host:c}=F(),[d,m]=f.useState(!1),j=i.options?.allowedTypes,t=le(l),N=t?.id??"",{data:o}=K(c,N),v=t?.mimeType??o?.mimeType,h=ie(v),y=s=>{t&&r({...t,alt:s})},w=s=>{t&&r({...t,caption:s})};return e.jsxs("div",{children:[t?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>!n&&m(!0),children:[h&&o?.url?e.jsx("img",{src:P(o.urls?.thumb_sm??o.url),alt:t.alt??o?.filename??"",className:"h-10 w-10 rounded object-cover bg-muted"}):e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded bg-muted","aria-label":"File",children:e.jsx(D,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("span",{className:"flex-1 truncate text-sm",children:t.filename??o?.filename??"Loading..."}),!n&&e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:s=>{s.stopPropagation(),r("")},children:e.jsx(H,{className:"h-3 w-3"})})]}),!n&&h&&e.jsxs("div",{className:"grid grid-cols-1 gap-3 pl-1 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{htmlFor:`${t.id}-alt`,className:"text-xs font-normal text-muted-foreground",children:"Alt text"}),e.jsx(I,{id:`${t.id}-alt`,type:"text","aria-label":"Alt text",value:t.alt??"",onChange:s=>y(s.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{htmlFor:`${t.id}-caption`,className:"text-xs font-normal text-muted-foreground",children:"Caption"}),e.jsx(I,{id:`${t.id}-caption`,type:"text","aria-label":"Caption",value:t.caption??"",onChange:s=>w(s.target.value)})]})]})]}):e.jsxs(g,{type:"button",variant:"outline",onClick:()=>m(!0),disabled:n,children:[e.jsx(L,{className:"mr-2 h-4 w-4"}),"Select Media"]}),!n&&e.jsx(te,{open:d,onClose:()=>m(!1),onSelect:s=>{const C={id:s.mediaId,url:s.url,mimeType:s.mimeType,width:s.width,height:s.height,alt:s.alt??"",caption:s.caption??"",filename:s.filename};r(C),m(!1)},allowedTypes:j})]})}export{pe as M,te as a};
|