convex-cms 0.0.9-alpha.3 → 0.0.9-alpha.6
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/admin/src/embed/index.tsx +57 -67
- package/admin/src/embed/pages/Entry.tsx +4 -5
- package/admin/src/embed/pages/NewEntry.tsx +2 -1
- package/admin/src/embed/types.ts +0 -1
- package/admin-dist/nitro.json +1 -1
- package/admin-dist/public/assets/{CmsEmptyState-BM4e6N83.js → CmsEmptyState-la_kLGHv.js} +1 -1
- package/admin-dist/public/assets/{CmsPageHeader-uor3DPIk.js → CmsPageHeader-Cf0SafVG.js} +1 -1
- package/admin-dist/public/assets/{CmsStatusBadge-D8N18LJx.js → CmsStatusBadge-BovugIHH.js} +1 -1
- package/admin-dist/public/assets/{CmsSurface-BEcY-WpI.js → CmsSurface-Dp1TegU4.js} +1 -1
- package/admin-dist/public/assets/{CmsToolbar-DE-bu3W8.js → CmsToolbar-B1zdfMu0.js} +1 -1
- package/admin-dist/public/assets/{ContentEntryEditor-BdkIMCUk.js → ContentEntryEditor-CB--8SC3.js} +1 -1
- package/admin-dist/public/assets/{TaxonomyFilter-a1-O9DPs.js → TaxonomyFilter-fmZxxbdA.js} +1 -1
- package/admin-dist/public/assets/{_contentTypeId-XIkYOLyY.js → _contentTypeId-vT09P77i.js} +1 -1
- package/admin-dist/public/assets/{_entryId-DyP15QpI.js → _entryId-Dhq6ybYt.js} +1 -1
- package/admin-dist/public/assets/{alert-DHBQuuib.js → alert-DfdkD-ZZ.js} +1 -1
- package/admin-dist/public/assets/{badge-BOhWFWzb.js → badge-Cmc3T9vs.js} +1 -1
- package/admin-dist/public/assets/{circle-check-big-DjTNapen.js → circle-check-big-B8AJAcBi.js} +1 -1
- package/admin-dist/public/assets/{command-BIc5_8gL.js → command-BsmkQ6_j.js} +1 -1
- package/admin-dist/public/assets/{content-C3N8Ugra.js → content-DdQ1u7T4.js} +1 -1
- package/admin-dist/public/assets/{content-types-D0wh1eUF.js → content-types-QYcwm0Sy.js} +1 -1
- package/admin-dist/public/assets/{index-B-g3F_ri.js → index-kxLB3e43.js} +1 -1
- package/admin-dist/public/assets/main-BrFRroF1.js +107 -0
- package/admin-dist/public/assets/{media-8uh1MwDi.js → media-Cx9IyZvU.js} +1 -1
- package/admin-dist/public/assets/{new._contentTypeId-S96rFbgY.js → new._contentTypeId-2HsDwzy_.js} +1 -1
- package/admin-dist/public/assets/{pencil-DgaZav4e.js → pencil-PaJhpDeC.js} +1 -1
- package/admin-dist/public/assets/{refresh-cw-BBut4hAU.js → refresh-cw-D_KNzBUN.js} +1 -1
- package/admin-dist/public/assets/{rotate-ccw-DVCkojZZ.js → rotate-ccw-I3wzW1RQ.js} +1 -1
- package/admin-dist/public/assets/{scroll-area-DPC4uXzf.js → scroll-area-t72-FBB4.js} +1 -1
- package/admin-dist/public/assets/{search-CSyHHglh.js → search-BsuImjd-.js} +1 -1
- package/admin-dist/public/assets/{settings-cEqPsoJ0.js → settings-DB6TvceQ.js} +1 -1
- package/admin-dist/public/assets/{switch-O2BviO8Q.js → switch-DWN_fx2n.js} +1 -1
- package/admin-dist/public/assets/{tabs-p1MWhOqY.js → tabs-BG0vukFH.js} +1 -1
- package/admin-dist/public/assets/{tanstack-adapter-CDrxoPZD.js → tanstack-adapter-DHsy8Fjs.js} +1 -1
- package/admin-dist/public/assets/{taxonomies-DJ9UbjXW.js → taxonomies-WG8YV2pR.js} +1 -1
- package/admin-dist/public/assets/{trash-RnpP6lXF.js → trash-C3Lt5m9d.js} +1 -1
- package/admin-dist/public/assets/{useBreadcrumbLabel-zbIWXlkc.js → useBreadcrumbLabel-BC8wl3jQ.js} +1 -1
- package/admin-dist/public/assets/{usePermissions-4CTlK-vU.js → usePermissions-BM1Vv1YJ.js} +1 -1
- package/admin-dist/server/_libs/convex-helpers.mjs +37 -0
- package/admin-dist/server/_libs/convex.mjs +1357 -168
- package/admin-dist/server/_ssr/{CmsEmptyState-BA0Lc5xs.mjs → CmsEmptyState-NKmyUWD9.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsPageHeader-PMyecILZ.mjs → CmsPageHeader-CngxPIOg.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsStatusBadge-CInuN2bZ.mjs → CmsStatusBadge-D4fiHjJD.mjs} +2 -2
- package/admin-dist/server/_ssr/{CmsSurface-CH1PIfcS.mjs → CmsSurface-DN9I2iuX.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsToolbar-IuhSA7gR.mjs → CmsToolbar-ux-veU96.mjs} +1 -1
- package/admin-dist/server/_ssr/{ContentEntryEditor-Bzhir4fQ.mjs → ContentEntryEditor-BiY9bJr9.mjs} +9 -9
- package/admin-dist/server/_ssr/{TaxonomyFilter-r4izSMBh.mjs → TaxonomyFilter-BdtKJie2.mjs} +3 -3
- package/admin-dist/server/_ssr/{_contentTypeId-BWEbjqxY.mjs → _contentTypeId-CRo5WQVu.mjs} +12 -11
- package/admin-dist/server/_ssr/{_entryId-B5xoXoJf.mjs → _entryId-FnG3uc_Y.mjs} +12 -11
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-BbSNqRIw.mjs +4 -0
- package/admin-dist/server/_ssr/{badge-DXrjBRqZ.mjs → badge-D3SGS0Jp.mjs} +1 -1
- package/admin-dist/server/_ssr/{command-Cj90OdCX.mjs → command-2t7uTBKt.mjs} +1 -1
- package/admin-dist/server/_ssr/{content-DKRI-YqL.mjs → content-CCsSzXeb.mjs} +10 -9
- package/admin-dist/server/_ssr/{content-types-BzgRcS8K.mjs → content-types-CuVG3uSt.mjs} +7 -6
- package/admin-dist/server/_ssr/{index-BPf6_agY.mjs → index-CLwCLoco.mjs} +5 -4
- package/admin-dist/server/_ssr/index.mjs +2 -2
- package/admin-dist/server/_ssr/{media-MpjxOZL8.mjs → media-D3duVWkk.mjs} +11 -10
- package/admin-dist/server/_ssr/{new._contentTypeId-DSb4qR9j.mjs → new._contentTypeId-6uKYdgGO.mjs} +11 -10
- package/admin-dist/server/_ssr/router-D9Zk56-q.mjs +7979 -0
- package/admin-dist/server/_ssr/{scroll-area-JwVD_6MZ.mjs → scroll-area-vbjKsfFu.mjs} +1 -1
- package/admin-dist/server/_ssr/{settings-KVJNe0GM.mjs → settings-D7-vwjqD.mjs} +9 -8
- package/admin-dist/server/_ssr/{switch-DvREvRv4.mjs → switch-CbKuV4Qh.mjs} +1 -1
- package/admin-dist/server/_ssr/{tabs-B0h57pFf.mjs → tabs-C_IfqLiu.mjs} +2 -2
- package/admin-dist/server/_ssr/{tanstack-adapter-gmM64LnW.mjs → tanstack-adapter-yhyAcBi-.mjs} +1 -1
- package/admin-dist/server/_ssr/{taxonomies-BbBNx260.mjs → taxonomies-C15s_nvM.mjs} +9 -8
- package/admin-dist/server/_ssr/{trash-JAzYGh7A.mjs → trash-BPIjmAUh.mjs} +9 -8
- package/admin-dist/server/_ssr/{useBreadcrumbLabel-BWIujj97.mjs → useBreadcrumbLabel-BC7plG0L.mjs} +1 -1
- package/admin-dist/server/_ssr/{usePermissions-CcLDCSwa.mjs → usePermissions-DJ8a7bZU.mjs} +1 -1
- package/admin-dist/server/index.mjs +157 -157
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +6 -15
- package/dist/client/index.js.map +1 -1
- package/package.json +6 -1
- package/admin-dist/public/assets/main-BapBJgQD.js +0 -102
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-CBTan6ii.mjs +0 -4
- package/admin-dist/server/_ssr/router-Dk9ikPNc.mjs +0 -3055
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as W,r as t,m as q,a as I,j as e,n as R,L as f,I as A,o as Z,g as _,C as N,u as M,P as L,p as X,i as U,q as Y,s as ee,h as P,T as V,t as H,k as se}from"./main-BapBJgQD.js";import{C as G}from"./CmsEmptyState-BM4e6N83.js";import{P as J}from"./pencil-DgaZav4e.js";import{C as ae}from"./CmsPageHeader-uor3DPIk.js";import{C as B}from"./CmsSurface-BEcY-WpI.js";import{B as Q}from"./badge-BOhWFWzb.js";import{S as te}from"./scroll-area-DPC4uXzf.js";import{u as re}from"./tanstack-adapter-CDrxoPZD.js";const ie=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],ne=W("folder-tree",ie);function le({taxonomy:i,onSave:c,onCancel:d}){const x=!!i,[l,C]=t.useState({name:i?.name??"",displayName:i?.displayName??"",description:i?.description??"",isHierarchical:i?.isHierarchical??!1,allowInlineCreation:i?.allowInlineCreation??!0,isActive:i?.isActive??!0,icon:i?.icon??"",sortOrder:i?.sortOrder??0}),[g,r]=t.useState({}),[u,p]=t.useState(!1),[O,m]=t.useState(null),[y,S]=t.useState(!1),w=q(),k=I(w.createTaxonomy),z=I(w.updateTaxonomy);t.useEffect(()=>{i&&C({name:i.name,displayName:i.displayName,description:i.description??"",isHierarchical:i.isHierarchical,allowInlineCreation:i.allowInlineCreation,isActive:i.isActive,icon:i.icon??"",sortOrder:i.sortOrder??0})},[i]);const h=t.useCallback((s,T)=>{C(E=>({...E,[s]:T})),r(E=>{const{[s]:n,...a}=E;return a})},[]),b=t.useCallback(s=>s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),F=t.useCallback(s=>{h("displayName",s),!x&&!y&&h("name",b(s))},[h,x,y,b]),v=t.useCallback(()=>{const s={};return l.name.trim()?/^[a-z][a-z0-9-]*$/.test(l.name)||(s.name="Slug must start with a letter and contain only lowercase letters, numbers, and hyphens"):s.name="Slug is required",l.displayName.trim()||(s.displayName="Display name is required"),r(s),Object.keys(s).length===0},[l]),o=t.useCallback(async s=>{if(s.preventDefault(),!!v()){p(!0),m(null);try{x&&i?await z({id:i._id,displayName:l.displayName,description:l.description||void 0,allowInlineCreation:l.allowInlineCreation,icon:l.icon||void 0,sortOrder:l.sortOrder,isActive:l.isActive}):await k({name:l.name,displayName:l.displayName,description:l.description||void 0,isHierarchical:l.isHierarchical,allowInlineCreation:l.allowInlineCreation,icon:l.icon||void 0,sortOrder:l.sortOrder}),c()}catch(T){const E=T instanceof Error?T.message:"Failed to save taxonomy";m(E)}finally{p(!1)}}},[v,x,i,l,k,z,c]);return e.jsx(R,{open:!0,onOpenChange:s=>!s&&!u&&d(),title:x?"Edit Taxonomy":"Create Taxonomy",size:"lg",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:d,disabled:u,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:o,loading:u,children:x?"Save Changes":"Create Taxonomy"})]}),children:e.jsxs("form",{onSubmit:o,className:"space-y-4",children:[O&&e.jsx("div",{className:"diff-removed rounded-lg border px-3 py-2 text-sm",children:O}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"displayName",children:["Display Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"displayName",value:l.displayName,onChange:s=>F(s.target.value),placeholder:"e.g., Categories, Tags",disabled:u,className:g.displayName?"border-destructive":""}),g.displayName&&e.jsx("p",{className:"text-xs text-destructive",children:g.displayName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"name",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"name",value:l.name,onChange:s=>{h("name",s.target.value.toLowerCase()),S(!0)},placeholder:"e.g., categories, tags",disabled:u||x,className:g.name?"border-destructive":""}),g.name&&e.jsx("p",{className:"text-xs text-destructive",children:g.name}),x&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"description",children:"Description"}),e.jsx(Z,{id:"description",value:l.description,onChange:s=>h("description",s.target.value),placeholder:"Optional description",rows:2,disabled:u})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"icon",children:"Icon"}),e.jsx(A,{id:"icon",value:l.icon,onChange:s=>h("icon",s.target.value),placeholder:"e.g., 🏷️ or folder",disabled:u}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emoji or icon name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"sortOrder",children:"Sort Order"}),e.jsx(A,{id:"sortOrder",type:"number",value:l.sortOrder,onChange:s=>h("sortOrder",parseInt(s.target.value)||0),disabled:u})]})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"isHierarchical",checked:l.isHierarchical,onCheckedChange:s=>h("isHierarchical",s),disabled:u||x}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isHierarchical",className:"cursor-pointer font-medium",children:"Hierarchical"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terms can have parent-child relationships (like categories)"}),x&&e.jsx("p",{className:"text-xs text-warning",children:"Hierarchy type cannot be changed after creation"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"allowInlineCreation",checked:l.allowInlineCreation,onCheckedChange:s=>h("allowInlineCreation",s),disabled:u}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"allowInlineCreation",className:"cursor-pointer font-medium",children:"Allow inline creation"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Users can create new terms while editing content"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"isActive",checked:l.isActive,onCheckedChange:s=>h("isActive",s),disabled:u}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isActive",className:"cursor-pointer font-medium",children:"Active"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Inactive taxonomies are hidden from content editors"})]})]})]})]})})}function oe({taxonomyId:i,isHierarchical:c,allowInlineCreation:d}){const x=q(),[l,C]=t.useState(new Set),[g,r]=t.useState(null),[u,p]=t.useState(!1),[O,m]=t.useState(),[y,S]=t.useState(null),[w,k]=t.useState(null),z=c?M(x.getTermsHierarchy,{taxonomyId:i}):M(x.listTerms,{taxonomyId:i}),h=I(x.deleteTerm),b=c?z:z?.page,F=b===void 0,v=t.useCallback(n=>{C(a=>{const j=new Set(a);return j.has(n)?j.delete(n):j.add(n),j})},[]),o=t.useCallback(n=>{m(n),r(null),p(!0)},[]),s=t.useCallback(n=>{r(n),p(!0)},[]),T=t.useCallback(async n=>{k(null);try{await h({id:n,cascade:!0}),S(null)}catch(a){const j=a instanceof Error?a.message:"Failed to delete term";k(j)}},[h]),E=(n,a=0)=>{const j=n.children&&n.children.length>0,D=l.has(n._id);return e.jsxs("div",{className:"border-b border-border/50 last:border-0",children:[e.jsxs("div",{className:P("group flex items-center gap-2 py-2 pr-2 transition-colors hover:bg-muted/50",a>0&&"border-l-2 border-muted"),style:{paddingLeft:`${a*24+8}px`},children:[c&&e.jsx("button",{type:"button",onClick:()=>v(n._id),disabled:!j,className:P("flex size-5 items-center justify-center rounded transition-colors",j?"text-muted-foreground hover:bg-muted hover:text-foreground":"invisible"),"aria-expanded":D,children:j&&(D?e.jsx(Y,{className:"size-4"}):e.jsx(ee,{className:"size-4"}))}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.color&&e.jsx("span",{className:"size-3 shrink-0 rounded-full",style:{backgroundColor:n.color}}),n.icon&&e.jsx("span",{className:"shrink-0 text-sm",children:n.icon}),e.jsx("span",{className:"truncate font-medium text-foreground",children:n.name}),e.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:["(",n.slug,")"]}),e.jsxs("span",{className:"ml-auto shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[n.usageCount," ",n.usageCount===1?"use":"uses"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[c&&d&&e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>o(n._id),title:"Add child term",className:"size-7 p-0",children:e.jsx(L,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>s(n),title:"Edit term",className:"size-7 p-0",children:e.jsx(J,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>S(n._id),title:"Delete term",className:"size-7 p-0 text-destructive hover:text-destructive",children:e.jsx(V,{className:"size-3.5"})})]})]}),c&&j&&D&&e.jsx("div",{children:n.children.map($=>E($,a+1))})]},n._id)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Terms"}),e.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>o(),children:[e.jsx(L,{className:"size-3.5"}),"Add Term"]})]}),w&&e.jsxs("div",{className:"diff-removed flex items-center justify-between rounded-lg border px-3 py-2 text-sm",children:[w,e.jsx("button",{type:"button",onClick:()=>k(null),className:"text-diff-removed hover:text-diff-removed-foreground",children:"×"})]}),e.jsx("div",{className:"rounded-lg border bg-card",children:F?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"})}):!b||b.length===0?e.jsx(G,{icon:e.jsx(X,{className:"size-8"}),title:"No terms yet",description:"Add your first term to start organizing content.",action:d?{label:"Add your first term",onClick:()=>o(),variant:"secondary"}:void 0}):e.jsx("div",{className:"divide-y divide-border/50",children:b.map(n=>E(n))})}),u&&e.jsx(ce,{taxonomyId:i,term:g,parentId:O,isHierarchical:c,onSave:()=>{p(!1),r(null),m(void 0)},onCancel:()=>{p(!1),r(null),m(void 0)}}),e.jsx(U,{open:!!y,onOpenChange:n=>!n&&S(null),title:"Delete Term",description:c?"Are you sure you want to delete this term? All child terms will also be deleted.":"Are you sure you want to delete this term?",confirmLabel:"Delete",variant:"danger",onConfirm:()=>y&&T(y)})]})}function ce({taxonomyId:i,term:c,parentId:d,isHierarchical:x,onSave:l,onCancel:C}){const g=!!c,[r,u]=t.useState({name:c?.name??"",slug:c?.slug??"",description:c?.description??"",color:c?.color??"",icon:c?.icon??"",sortOrder:c?.sortOrder??0}),[p,O]=t.useState({}),[m,y]=t.useState(!1),[S,w]=t.useState(null),[k,z]=t.useState(!1),h=q(),b=I(h.createTerm),F=I(h.updateTerm),v=t.useCallback((a,j)=>{u(D=>({...D,[a]:j})),O(D=>{const{[a]:$,...K}=D;return K})},[]),o=t.useCallback(a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),s=t.useCallback(a=>{v("name",a),!g&&!k&&v("slug",o(a))},[v,g,k,o]),T=t.useCallback(()=>{const a={};return r.name.trim()||(a.name="Name is required"),r.slug.trim()?/^[a-z0-9-]+$/.test(r.slug)||(a.slug="Slug must contain only lowercase letters, numbers, and hyphens"):a.slug="Slug is required",O(a),Object.keys(a).length===0},[r]),E=t.useCallback(async a=>{if(a.preventDefault(),!!T()){y(!0),w(null);try{g&&c?await F({id:c._id,name:r.name,slug:r.slug,description:r.description||void 0,color:r.color||void 0,icon:r.icon||void 0,sortOrder:r.sortOrder}):await b({taxonomyId:i,name:r.name,slug:r.slug,description:r.description||void 0,parentId:d,color:r.color||void 0,icon:r.icon||void 0,sortOrder:r.sortOrder}),l()}catch(j){const D=j instanceof Error?j.message:"Failed to save term";w(D)}finally{y(!1)}}},[T,g,c,r,i,d,b,F,l]),n=g?"Edit Term":d?"Create Child Term":"Create Term";return e.jsx(R,{open:!0,onOpenChange:a=>!a&&!m&&C(),title:n,size:"md",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:C,disabled:m,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:E,loading:m,children:g?"Save Changes":"Create Term"})]}),children:e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[S&&e.jsx("div",{className:"diff-removed rounded-lg border px-3 py-2 text-sm",children:S}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termName",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"termName",value:r.name,onChange:a=>s(a.target.value),placeholder:"e.g., Technology",disabled:m,className:p.name?"border-destructive":""}),p.name&&e.jsx("p",{className:"text-xs text-destructive",children:p.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termSlug",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"termSlug",value:r.slug,onChange:a=>{v("slug",a.target.value.toLowerCase()),z(!0)},placeholder:"e.g., technology",disabled:m,className:p.slug?"border-destructive":""}),p.slug&&e.jsx("p",{className:"text-xs text-destructive",children:p.slug})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termDescription",children:"Description"}),e.jsx(Z,{id:"termDescription",value:r.description,onChange:a=>v("description",a.target.value),placeholder:"Optional description",rows:2,disabled:m})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termColor",children:"Color"}),e.jsx(A,{id:"termColor",type:"color",value:r.color||"#6b7280",onChange:a=>v("color",a.target.value),disabled:m,className:"h-9 p-1"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termIcon",children:"Icon"}),e.jsx(A,{id:"termIcon",value:r.icon,onChange:a=>v("icon",a.target.value),placeholder:"e.g., 💻",disabled:m})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termSortOrder",children:"Sort Order"}),e.jsx(A,{id:"termSortOrder",type:"number",value:r.sortOrder,onChange:a=>v("sortOrder",parseInt(a.target.value)||0),disabled:m})]})]})]})})}function de({api:i,navigation:c}){const[d,x]=t.useState(null),[l,C]=t.useState(!1),[g,r]=t.useState(null),[u,p]=t.useState(null),[O,m]=t.useState(null),y=M(i.listTaxonomies,{isActive:void 0,includeDeleted:!1}),S=I(i.deleteTaxonomy),w=y?.page??[],k=y===void 0,z=t.useCallback(()=>{r(null),C(!0)},[]),h=t.useCallback(o=>{r(o),C(!0)},[]),b=t.useCallback(async o=>{m(null);try{await S({id:o}),p(null),d?._id===o&&x(null)}catch(s){const T=s instanceof Error?s.message:"Failed to delete taxonomy";m(T)}},[S,d]),F=t.useCallback(()=>{C(!1),r(null)},[]),v=o=>o.isHierarchical?e.jsx(ne,{className:"size-5"}):e.jsx(H,{className:"size-5"});return e.jsxs("div",{className:"flex h-[calc(100vh-4rem)] flex-col p-6",children:[e.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[e.jsx(ae,{title:"Taxonomies",description:"Manage tags, categories, and other classification systems"}),e.jsxs(N,{onClick:z,children:[e.jsx(L,{className:"size-4"}),"Create Taxonomy"]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 gap-6",children:[e.jsx(B,{elevation:"base",className:"w-80 shrink-0 overflow-hidden",children:k?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Loading taxonomies..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center",children:[e.jsx(H,{className:"mb-3 size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No taxonomies created yet."}),e.jsx(N,{variant:"secondary",className:"mt-4",onClick:z,children:"Create your first taxonomy"})]}):e.jsx(te,{className:"h-full",children:e.jsx("div",{className:"divide-y",children:w.map(o=>e.jsxs("div",{className:P("group flex cursor-pointer items-center gap-3 p-3 transition-colors hover:bg-muted/50",d?._id===o._id&&"bg-primary/5",!o.isActive&&"opacity-60"),onClick:()=>x(o),children:[e.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:v(o)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.displayName}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.name})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Q,{variant:"secondary",className:"text-xs font-normal",children:o.isHierarchical?"Hierarchical":"Flat"}),!o.isActive&&e.jsx(Q,{variant:"outline",className:"text-xs font-normal",children:"Inactive"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:s=>{s.stopPropagation(),h(o)},title:"Edit taxonomy",children:e.jsx(J,{className:"size-4"})}),e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:s=>{s.stopPropagation(),p(o._id)},title:"Delete taxonomy",className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:e.jsx(V,{className:"size-4"})})]})]},o._id))})})}),e.jsx(B,{elevation:"base",className:"min-w-0 flex-1 overflow-hidden",children:d?e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between border-b p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground",children:v(d)}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:d.displayName}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]})]}),e.jsx(N,{variant:"secondary",onClick:()=>h(d),children:"Edit Taxonomy"})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(oe,{taxonomyId:d._id,isHierarchical:d.isHierarchical,allowInlineCreation:d.allowInlineCreation})})]}):e.jsx(G,{icon:e.jsx(H,{className:"size-6"}),title:"Select a taxonomy",description:"Select a taxonomy to view and manage its terms",className:"h-full"})})]}),l&&e.jsx(le,{taxonomy:g,onSave:F,onCancel:()=>{C(!1),r(null)}}),e.jsx(U,{open:u!==null,onOpenChange:o=>{o||(p(null),m(null))},title:"Delete Taxonomy",description:"Are you sure you want to delete this taxonomy? All associated terms will also be deleted.",confirmLabel:"Delete",onConfirm:()=>u&&b(u),variant:"danger",error:O})]})}function fe(){const i=re();return e.jsx(de,{api:se.admin,navigation:i})}export{fe as component};
|
|
1
|
+
import{l as W,r as t,m as q,a as I,j as e,n as R,L as f,I as A,o as Z,g as _,C as N,u as M,P as L,p as X,i as U,q as Y,s as ee,h as P,T as V,t as H,k as se}from"./main-BrFRroF1.js";import{C as G}from"./CmsEmptyState-la_kLGHv.js";import{P as J}from"./pencil-PaJhpDeC.js";import{C as ae}from"./CmsPageHeader-Cf0SafVG.js";import{C as B}from"./CmsSurface-Dp1TegU4.js";import{B as Q}from"./badge-Cmc3T9vs.js";import{S as te}from"./scroll-area-t72-FBB4.js";import{u as re}from"./tanstack-adapter-DHsy8Fjs.js";const ie=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],ne=W("folder-tree",ie);function le({taxonomy:i,onSave:c,onCancel:d}){const x=!!i,[l,C]=t.useState({name:i?.name??"",displayName:i?.displayName??"",description:i?.description??"",isHierarchical:i?.isHierarchical??!1,allowInlineCreation:i?.allowInlineCreation??!0,isActive:i?.isActive??!0,icon:i?.icon??"",sortOrder:i?.sortOrder??0}),[g,r]=t.useState({}),[u,p]=t.useState(!1),[O,m]=t.useState(null),[y,S]=t.useState(!1),w=q(),k=I(w.createTaxonomy),z=I(w.updateTaxonomy);t.useEffect(()=>{i&&C({name:i.name,displayName:i.displayName,description:i.description??"",isHierarchical:i.isHierarchical,allowInlineCreation:i.allowInlineCreation,isActive:i.isActive,icon:i.icon??"",sortOrder:i.sortOrder??0})},[i]);const h=t.useCallback((s,T)=>{C(E=>({...E,[s]:T})),r(E=>{const{[s]:n,...a}=E;return a})},[]),b=t.useCallback(s=>s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),F=t.useCallback(s=>{h("displayName",s),!x&&!y&&h("name",b(s))},[h,x,y,b]),v=t.useCallback(()=>{const s={};return l.name.trim()?/^[a-z][a-z0-9-]*$/.test(l.name)||(s.name="Slug must start with a letter and contain only lowercase letters, numbers, and hyphens"):s.name="Slug is required",l.displayName.trim()||(s.displayName="Display name is required"),r(s),Object.keys(s).length===0},[l]),o=t.useCallback(async s=>{if(s.preventDefault(),!!v()){p(!0),m(null);try{x&&i?await z({id:i._id,displayName:l.displayName,description:l.description||void 0,allowInlineCreation:l.allowInlineCreation,icon:l.icon||void 0,sortOrder:l.sortOrder,isActive:l.isActive}):await k({name:l.name,displayName:l.displayName,description:l.description||void 0,isHierarchical:l.isHierarchical,allowInlineCreation:l.allowInlineCreation,icon:l.icon||void 0,sortOrder:l.sortOrder}),c()}catch(T){const E=T instanceof Error?T.message:"Failed to save taxonomy";m(E)}finally{p(!1)}}},[v,x,i,l,k,z,c]);return e.jsx(R,{open:!0,onOpenChange:s=>!s&&!u&&d(),title:x?"Edit Taxonomy":"Create Taxonomy",size:"lg",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:d,disabled:u,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:o,loading:u,children:x?"Save Changes":"Create Taxonomy"})]}),children:e.jsxs("form",{onSubmit:o,className:"space-y-4",children:[O&&e.jsx("div",{className:"diff-removed rounded-lg border px-3 py-2 text-sm",children:O}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"displayName",children:["Display Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"displayName",value:l.displayName,onChange:s=>F(s.target.value),placeholder:"e.g., Categories, Tags",disabled:u,className:g.displayName?"border-destructive":""}),g.displayName&&e.jsx("p",{className:"text-xs text-destructive",children:g.displayName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"name",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"name",value:l.name,onChange:s=>{h("name",s.target.value.toLowerCase()),S(!0)},placeholder:"e.g., categories, tags",disabled:u||x,className:g.name?"border-destructive":""}),g.name&&e.jsx("p",{className:"text-xs text-destructive",children:g.name}),x&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"description",children:"Description"}),e.jsx(Z,{id:"description",value:l.description,onChange:s=>h("description",s.target.value),placeholder:"Optional description",rows:2,disabled:u})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"icon",children:"Icon"}),e.jsx(A,{id:"icon",value:l.icon,onChange:s=>h("icon",s.target.value),placeholder:"e.g., 🏷️ or folder",disabled:u}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emoji or icon name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"sortOrder",children:"Sort Order"}),e.jsx(A,{id:"sortOrder",type:"number",value:l.sortOrder,onChange:s=>h("sortOrder",parseInt(s.target.value)||0),disabled:u})]})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"isHierarchical",checked:l.isHierarchical,onCheckedChange:s=>h("isHierarchical",s),disabled:u||x}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isHierarchical",className:"cursor-pointer font-medium",children:"Hierarchical"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terms can have parent-child relationships (like categories)"}),x&&e.jsx("p",{className:"text-xs text-warning",children:"Hierarchy type cannot be changed after creation"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"allowInlineCreation",checked:l.allowInlineCreation,onCheckedChange:s=>h("allowInlineCreation",s),disabled:u}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"allowInlineCreation",className:"cursor-pointer font-medium",children:"Allow inline creation"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Users can create new terms while editing content"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{id:"isActive",checked:l.isActive,onCheckedChange:s=>h("isActive",s),disabled:u}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isActive",className:"cursor-pointer font-medium",children:"Active"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Inactive taxonomies are hidden from content editors"})]})]})]})]})})}function oe({taxonomyId:i,isHierarchical:c,allowInlineCreation:d}){const x=q(),[l,C]=t.useState(new Set),[g,r]=t.useState(null),[u,p]=t.useState(!1),[O,m]=t.useState(),[y,S]=t.useState(null),[w,k]=t.useState(null),z=c?M(x.getTermsHierarchy,{taxonomyId:i}):M(x.listTerms,{taxonomyId:i}),h=I(x.deleteTerm),b=c?z:z?.page,F=b===void 0,v=t.useCallback(n=>{C(a=>{const j=new Set(a);return j.has(n)?j.delete(n):j.add(n),j})},[]),o=t.useCallback(n=>{m(n),r(null),p(!0)},[]),s=t.useCallback(n=>{r(n),p(!0)},[]),T=t.useCallback(async n=>{k(null);try{await h({id:n,cascade:!0}),S(null)}catch(a){const j=a instanceof Error?a.message:"Failed to delete term";k(j)}},[h]),E=(n,a=0)=>{const j=n.children&&n.children.length>0,D=l.has(n._id);return e.jsxs("div",{className:"border-b border-border/50 last:border-0",children:[e.jsxs("div",{className:P("group flex items-center gap-2 py-2 pr-2 transition-colors hover:bg-muted/50",a>0&&"border-l-2 border-muted"),style:{paddingLeft:`${a*24+8}px`},children:[c&&e.jsx("button",{type:"button",onClick:()=>v(n._id),disabled:!j,className:P("flex size-5 items-center justify-center rounded transition-colors",j?"text-muted-foreground hover:bg-muted hover:text-foreground":"invisible"),"aria-expanded":D,children:j&&(D?e.jsx(Y,{className:"size-4"}):e.jsx(ee,{className:"size-4"}))}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.color&&e.jsx("span",{className:"size-3 shrink-0 rounded-full",style:{backgroundColor:n.color}}),n.icon&&e.jsx("span",{className:"shrink-0 text-sm",children:n.icon}),e.jsx("span",{className:"truncate font-medium text-foreground",children:n.name}),e.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:["(",n.slug,")"]}),e.jsxs("span",{className:"ml-auto shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[n.usageCount," ",n.usageCount===1?"use":"uses"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[c&&d&&e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>o(n._id),title:"Add child term",className:"size-7 p-0",children:e.jsx(L,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>s(n),title:"Edit term",className:"size-7 p-0",children:e.jsx(J,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>S(n._id),title:"Delete term",className:"size-7 p-0 text-destructive hover:text-destructive",children:e.jsx(V,{className:"size-3.5"})})]})]}),c&&j&&D&&e.jsx("div",{children:n.children.map($=>E($,a+1))})]},n._id)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Terms"}),e.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>o(),children:[e.jsx(L,{className:"size-3.5"}),"Add Term"]})]}),w&&e.jsxs("div",{className:"diff-removed flex items-center justify-between rounded-lg border px-3 py-2 text-sm",children:[w,e.jsx("button",{type:"button",onClick:()=>k(null),className:"text-diff-removed hover:text-diff-removed-foreground",children:"×"})]}),e.jsx("div",{className:"rounded-lg border bg-card",children:F?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"})}):!b||b.length===0?e.jsx(G,{icon:e.jsx(X,{className:"size-8"}),title:"No terms yet",description:"Add your first term to start organizing content.",action:d?{label:"Add your first term",onClick:()=>o(),variant:"secondary"}:void 0}):e.jsx("div",{className:"divide-y divide-border/50",children:b.map(n=>E(n))})}),u&&e.jsx(ce,{taxonomyId:i,term:g,parentId:O,isHierarchical:c,onSave:()=>{p(!1),r(null),m(void 0)},onCancel:()=>{p(!1),r(null),m(void 0)}}),e.jsx(U,{open:!!y,onOpenChange:n=>!n&&S(null),title:"Delete Term",description:c?"Are you sure you want to delete this term? All child terms will also be deleted.":"Are you sure you want to delete this term?",confirmLabel:"Delete",variant:"danger",onConfirm:()=>y&&T(y)})]})}function ce({taxonomyId:i,term:c,parentId:d,isHierarchical:x,onSave:l,onCancel:C}){const g=!!c,[r,u]=t.useState({name:c?.name??"",slug:c?.slug??"",description:c?.description??"",color:c?.color??"",icon:c?.icon??"",sortOrder:c?.sortOrder??0}),[p,O]=t.useState({}),[m,y]=t.useState(!1),[S,w]=t.useState(null),[k,z]=t.useState(!1),h=q(),b=I(h.createTerm),F=I(h.updateTerm),v=t.useCallback((a,j)=>{u(D=>({...D,[a]:j})),O(D=>{const{[a]:$,...K}=D;return K})},[]),o=t.useCallback(a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),s=t.useCallback(a=>{v("name",a),!g&&!k&&v("slug",o(a))},[v,g,k,o]),T=t.useCallback(()=>{const a={};return r.name.trim()||(a.name="Name is required"),r.slug.trim()?/^[a-z0-9-]+$/.test(r.slug)||(a.slug="Slug must contain only lowercase letters, numbers, and hyphens"):a.slug="Slug is required",O(a),Object.keys(a).length===0},[r]),E=t.useCallback(async a=>{if(a.preventDefault(),!!T()){y(!0),w(null);try{g&&c?await F({id:c._id,name:r.name,slug:r.slug,description:r.description||void 0,color:r.color||void 0,icon:r.icon||void 0,sortOrder:r.sortOrder}):await b({taxonomyId:i,name:r.name,slug:r.slug,description:r.description||void 0,parentId:d,color:r.color||void 0,icon:r.icon||void 0,sortOrder:r.sortOrder}),l()}catch(j){const D=j instanceof Error?j.message:"Failed to save term";w(D)}finally{y(!1)}}},[T,g,c,r,i,d,b,F,l]),n=g?"Edit Term":d?"Create Child Term":"Create Term";return e.jsx(R,{open:!0,onOpenChange:a=>!a&&!m&&C(),title:n,size:"md",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:C,disabled:m,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:E,loading:m,children:g?"Save Changes":"Create Term"})]}),children:e.jsxs("form",{onSubmit:E,className:"space-y-4",children:[S&&e.jsx("div",{className:"diff-removed rounded-lg border px-3 py-2 text-sm",children:S}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termName",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"termName",value:r.name,onChange:a=>s(a.target.value),placeholder:"e.g., Technology",disabled:m,className:p.name?"border-destructive":""}),p.name&&e.jsx("p",{className:"text-xs text-destructive",children:p.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termSlug",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{id:"termSlug",value:r.slug,onChange:a=>{v("slug",a.target.value.toLowerCase()),z(!0)},placeholder:"e.g., technology",disabled:m,className:p.slug?"border-destructive":""}),p.slug&&e.jsx("p",{className:"text-xs text-destructive",children:p.slug})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termDescription",children:"Description"}),e.jsx(Z,{id:"termDescription",value:r.description,onChange:a=>v("description",a.target.value),placeholder:"Optional description",rows:2,disabled:m})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termColor",children:"Color"}),e.jsx(A,{id:"termColor",type:"color",value:r.color||"#6b7280",onChange:a=>v("color",a.target.value),disabled:m,className:"h-9 p-1"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termIcon",children:"Icon"}),e.jsx(A,{id:"termIcon",value:r.icon,onChange:a=>v("icon",a.target.value),placeholder:"e.g., 💻",disabled:m})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termSortOrder",children:"Sort Order"}),e.jsx(A,{id:"termSortOrder",type:"number",value:r.sortOrder,onChange:a=>v("sortOrder",parseInt(a.target.value)||0),disabled:m})]})]})]})})}function de({api:i,navigation:c}){const[d,x]=t.useState(null),[l,C]=t.useState(!1),[g,r]=t.useState(null),[u,p]=t.useState(null),[O,m]=t.useState(null),y=M(i.listTaxonomies,{isActive:void 0,includeDeleted:!1}),S=I(i.deleteTaxonomy),w=y?.page??[],k=y===void 0,z=t.useCallback(()=>{r(null),C(!0)},[]),h=t.useCallback(o=>{r(o),C(!0)},[]),b=t.useCallback(async o=>{m(null);try{await S({id:o}),p(null),d?._id===o&&x(null)}catch(s){const T=s instanceof Error?s.message:"Failed to delete taxonomy";m(T)}},[S,d]),F=t.useCallback(()=>{C(!1),r(null)},[]),v=o=>o.isHierarchical?e.jsx(ne,{className:"size-5"}):e.jsx(H,{className:"size-5"});return e.jsxs("div",{className:"flex h-[calc(100vh-4rem)] flex-col p-6",children:[e.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[e.jsx(ae,{title:"Taxonomies",description:"Manage tags, categories, and other classification systems"}),e.jsxs(N,{onClick:z,children:[e.jsx(L,{className:"size-4"}),"Create Taxonomy"]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 gap-6",children:[e.jsx(B,{elevation:"base",className:"w-80 shrink-0 overflow-hidden",children:k?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Loading taxonomies..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center",children:[e.jsx(H,{className:"mb-3 size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No taxonomies created yet."}),e.jsx(N,{variant:"secondary",className:"mt-4",onClick:z,children:"Create your first taxonomy"})]}):e.jsx(te,{className:"h-full",children:e.jsx("div",{className:"divide-y",children:w.map(o=>e.jsxs("div",{className:P("group flex cursor-pointer items-center gap-3 p-3 transition-colors hover:bg-muted/50",d?._id===o._id&&"bg-primary/5",!o.isActive&&"opacity-60"),onClick:()=>x(o),children:[e.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:v(o)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.displayName}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.name})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Q,{variant:"secondary",className:"text-xs font-normal",children:o.isHierarchical?"Hierarchical":"Flat"}),!o.isActive&&e.jsx(Q,{variant:"outline",className:"text-xs font-normal",children:"Inactive"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:s=>{s.stopPropagation(),h(o)},title:"Edit taxonomy",children:e.jsx(J,{className:"size-4"})}),e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:s=>{s.stopPropagation(),p(o._id)},title:"Delete taxonomy",className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:e.jsx(V,{className:"size-4"})})]})]},o._id))})})}),e.jsx(B,{elevation:"base",className:"min-w-0 flex-1 overflow-hidden",children:d?e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between border-b p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground",children:v(d)}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:d.displayName}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]})]}),e.jsx(N,{variant:"secondary",onClick:()=>h(d),children:"Edit Taxonomy"})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(oe,{taxonomyId:d._id,isHierarchical:d.isHierarchical,allowInlineCreation:d.allowInlineCreation})})]}):e.jsx(G,{icon:e.jsx(H,{className:"size-6"}),title:"Select a taxonomy",description:"Select a taxonomy to view and manage its terms",className:"h-full"})})]}),l&&e.jsx(le,{taxonomy:g,onSave:F,onCancel:()=>{C(!1),r(null)}}),e.jsx(U,{open:u!==null,onOpenChange:o=>{o||(p(null),m(null))},title:"Delete Taxonomy",description:"Are you sure you want to delete this taxonomy? All associated terms will also be deleted.",confirmLabel:"Delete",onConfirm:()=>u&&b(u),variant:"danger",error:O})]})}function fe(){const i=re();return e.jsx(de,{api:se.admin,navigation:i})}export{fe as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,u as m,a as E,j as e,C as c,T as D,I as Y,S as Z,b as ee,c as se,d as te,e as I,f as A,X as R,g as _,h as ae,i as ne,k as re}from"./main-
|
|
1
|
+
import{r as a,u as m,a as E,j as e,C as c,T as D,I as Y,S as Z,b as ee,c as se,d as te,e as I,f as A,X as R,g as _,h as ae,i as ne,k as re}from"./main-BrFRroF1.js";import{C as le}from"./CmsPageHeader-Cf0SafVG.js";import{C as oe}from"./CmsToolbar-B1zdfMu0.js";import{C as ie}from"./CmsEmptyState-la_kLGHv.js";import{C as Q}from"./CmsSurface-Dp1TegU4.js";import{B as ce}from"./badge-Cmc3T9vs.js";import{A as L,a as B}from"./alert-DfdkD-ZZ.js";import{S as de}from"./search-BsuImjd-.js";import{R as M}from"./rotate-ccw-I3wzW1RQ.js";import{u as me}from"./tanstack-adapter-DHsy8Fjs.js";function xe({api:l,navigation:ue}){const[g,F]=a.useState(""),[j,O]=a.useState(""),[r,i]=a.useState(new Set),[y,x]=a.useState(null),[N,C]=a.useState(!1),[P,u]=a.useState(!1),[b,v]=a.useState(!1),[S,h]=a.useState(null),T=m(l.listTrash,{contentTypeId:g||void 0,search:j||void 0,paginationOpts:{numItems:50,cursor:null}}),U=m(l.getTrashConfig,{}),V=m(l.getTrashStats,{}),H=m(l.listContentTypes,{})?.page??[],w=E(l.bulkRestore),k=E(l.emptyTrash),o=T?.page??[],X=T===void 0,p=U,f=V,$=a.useCallback((s,t)=>{i(n=>{const d=new Set(n);return t?d.add(s):d.delete(s),d})},[]),q=a.useCallback(()=>{r.size===o.length?i(new Set):i(new Set(o.map(s=>s._id)))},[r.size,o]),z=a.useCallback(async s=>{C(!0),x(null);try{await w({ids:s}),i(t=>{const n=new Set(t);return s.forEach(d=>n.delete(d)),n})}catch(t){const n=t instanceof Error?t.message:"Failed to restore";x(n)}finally{C(!1)}},[w]),G=a.useCallback(async()=>{v(!0),h(null);try{await k({}),u(!1),i(new Set)}catch(s){const t=s instanceof Error?s.message:"Failed to empty trash";h(t)}finally{v(!1)}},[k]),J=s=>new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),K=s=>{if(!p?.retentionDays)return null;const t=s+p.retentionDays*24*60*60*1e3,n=Math.ceil((t-Date.now())/(1440*60*1e3));return Math.max(0,n)},W=s=>{if(s.title)return s.title;if(s.name)return s.name;if(s.data){const t=s.data.title||s.data.name;if(t&&typeof t=="string")return t}return s.slug||s._id};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(le,{title:"Trash",description:`Deleted items are kept for ${p?.retentionDays??30} days before permanent deletion`}),o.length>0&&e.jsxs(c,{variant:"danger",onClick:()=>u(!0),children:[e.jsx(D,{className:"size-4"}),"Empty Trash"]})]}),f&&e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs(Q,{elevation:"base",className:"p-4",children:[e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:f.totalCount??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Items in Trash"})]}),e.jsxs(Q,{elevation:"base",className:"p-4",children:[e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:f.expiredCount??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Expired"})]})]}),e.jsx(oe,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(de,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Y,{type:"text",placeholder:"Search deleted items...",value:j,onChange:s=>O(s.target.value),className:"w-64 pl-9"})]}),e.jsxs(Z,{value:g||"all",onValueChange:s=>F(s==="all"?"":s),children:[e.jsx(ee,{className:"w-48",children:e.jsx(se,{placeholder:"All Content Types"})}),e.jsxs(te,{children:[e.jsx(I,{value:"all",children:"All Content Types"}),H.map(s=>e.jsx(I,{value:s._id,children:s.displayName},s._id))]})]})]})}),y&&e.jsxs(L,{variant:"destructive",children:[e.jsx(A,{className:"size-4"}),e.jsxs(B,{className:"flex items-center justify-between",children:[y,e.jsx(c,{variant:"ghost",size:"icon-sm",onClick:()=>x(null),children:e.jsx(R,{className:"size-4"})})]})]}),S&&e.jsxs(L,{variant:"destructive",children:[e.jsx(A,{className:"size-4"}),e.jsxs(B,{className:"flex items-center justify-between",children:[S,e.jsx(c,{variant:"ghost",size:"icon-sm",onClick:()=>h(null),children:e.jsx(R,{className:"size-4"})})]})]}),r.size>0&&e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-primary/20 bg-primary/5 p-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[r.size," ",r.size===1?"item":"items"," ","selected"]}),e.jsxs(c,{variant:"primary",size:"sm",onClick:()=>z(Array.from(r)),loading:N,children:[e.jsx(M,{className:"size-4"}),"Restore Selected"]}),e.jsx(c,{variant:"secondary",size:"sm",onClick:()=>i(new Set),children:"Clear Selection"})]}),X?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading trash..."})]}):o.length===0?e.jsx(ie,{icon:e.jsx(D,{className:"size-6"}),title:"Trash is empty",description:"Deleted items will appear here"}):e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"w-10 p-3 text-left",children:e.jsx(_,{checked:r.size===o.length&&o.length>0,onCheckedChange:q})}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Type"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Deleted"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Expires In"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:o.map(s=>{const t=K(s.deletedAt);return e.jsxs("tr",{className:ae("border-b last:border-0 transition-colors hover:bg-muted/50",r.has(s._id)&&"bg-primary/5"),children:[e.jsx("td",{className:"p-3",children:e.jsx(_,{checked:r.has(s._id),onCheckedChange:n=>$(s._id,n)})}),e.jsxs("td",{className:"p-3",children:[e.jsx("span",{className:"font-medium text-foreground",children:W(s)}),s.slug&&e.jsx("span",{className:"block text-xs text-muted-foreground",children:s.slug})]}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:s.contentTypeName||"Unknown"}),e.jsxs("td",{className:"p-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:J(s.deletedAt)}),s.deletedBy&&e.jsxs("span",{className:"block text-xs text-muted-foreground",children:["by ",s.deletedBy]})]}),e.jsx("td",{className:"p-3",children:t!==null&&e.jsxs(ce,{variant:t<=3?"destructive":"secondary",className:"font-normal",children:[t," ",t===1?"day":"days"]})}),e.jsx("td",{className:"p-3",children:e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>z([s._id]),loading:N,children:[e.jsx(M,{className:"size-4"}),"Restore"]})})]},s._id)})})]})}),e.jsx(ne,{open:P,onOpenChange:u,title:"Empty Trash",description:"This will permanently delete all items in the trash. This action cannot be undone.",confirmLabel:b?"Deleting...":"Empty Trash",onConfirm:G,variant:"danger",loading:b})]})}function Te(){const l=me();return e.jsx(xe,{api:re.admin,navigation:l})}export{Te as component};
|
package/admin-dist/public/assets/{useBreadcrumbLabel-zbIWXlkc.js → useBreadcrumbLabel-BC8wl3jQ.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aN as u,r as c}from"./main-
|
|
1
|
+
import{aN as u,r as c}from"./main-BrFRroF1.js";function a(r,e){const{setOverride:s,clearOverride:t}=u();c.useEffect(()=>(e&&s(r,e),()=>{t(r)}),[r,e,s,t])}export{a as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{an as c,r as o,ao as i,ap as u,aq as d}from"./main-
|
|
1
|
+
import{an as c,r as o,ao as i,ap as u,aq as d}from"./main-BrFRroF1.js";function C(){const{role:n}=c();return o.useMemo(()=>{const r=!!n,t=(e,s,a)=>n?d(n,{resource:e,action:s,scope:a}):!1;return{role:n,hasRole:r,check:t,canAccess:e=>n?u(n,e):!1,canCreate:e=>t(e,"create"),canRead:(e,s)=>t(e,"read",s),canUpdate:(e,s)=>t(e,"update",s),canDelete:(e,s)=>t(e,"delete",s),canPublish:e=>t("contentEntries","publish",e),canUnpublish:e=>t("contentEntries","unpublish",e),canManageSettings:()=>t("settings","manage"),canManageContentTypes:()=>t("contentTypes","create")||t("contentTypes","update")||t("contentTypes","delete"),getPermissions:e=>n?i(n,e):[],isAdmin:n==="admin",isEditor:n==="admin"||n==="editor",isAuthor:n==="admin"||n==="editor"||n==="author"}},[n])}export{C as u};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { v } from "./convex.mjs";
|
|
2
|
+
function omit(obj, keys) {
|
|
3
|
+
return Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k)));
|
|
4
|
+
}
|
|
5
|
+
v.string();
|
|
6
|
+
v.float64();
|
|
7
|
+
v.float64();
|
|
8
|
+
v.boolean();
|
|
9
|
+
v.int64();
|
|
10
|
+
v.int64();
|
|
11
|
+
v.any();
|
|
12
|
+
v.null();
|
|
13
|
+
v.bytes();
|
|
14
|
+
const systemFields = (tableName) => ({
|
|
15
|
+
_id: v.id(tableName),
|
|
16
|
+
_creationTime: v.number()
|
|
17
|
+
});
|
|
18
|
+
const doc = (schema, tableName) => {
|
|
19
|
+
function addSystemFields(validator) {
|
|
20
|
+
if (validator.kind === "object") {
|
|
21
|
+
return v.object({
|
|
22
|
+
...validator.fields,
|
|
23
|
+
...systemFields(tableName)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (validator.kind !== "union") {
|
|
27
|
+
throw new Error("Only object and union validators are supported for documents");
|
|
28
|
+
}
|
|
29
|
+
return v.union(...validator.members.map(addSystemFields));
|
|
30
|
+
}
|
|
31
|
+
return addSystemFields(schema.tables[tableName].validator);
|
|
32
|
+
};
|
|
33
|
+
v.optional(v.any());
|
|
34
|
+
export {
|
|
35
|
+
doc as d,
|
|
36
|
+
omit as o
|
|
37
|
+
};
|