@chaibuilder/pages 0.15.3 → 0.15.5
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/dist/{2AITGKQY-o6FgGSqg.cjs → 2AITGKQY-D4uLyw6-.cjs} +1 -1
- package/dist/{2AITGKQY-DhC0sF1x.js → 2AITGKQY-DYwNjBFe.js} +2 -2
- package/dist/{NCMVHL6D-BPM6RHYa.cjs → NCMVHL6D-C-L7-X3f.cjs} +1 -1
- package/dist/{NCMVHL6D-D7HU3akD.js → NCMVHL6D-DVB60g_2.js} +2 -2
- package/dist/{ZDWCUMSJ-NVCxv9uE.cjs → ZDWCUMSJ-BORULBXb.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Cr1v3giV.js → ZDWCUMSJ-Dp6ML_tn.js} +1 -1
- package/dist/{add-new-language-page-D3PSLiUv.cjs → add-new-language-page-D4VPifNs.cjs} +1 -1
- package/dist/{add-new-language-page-8q4Ku3eg.js → add-new-language-page-DENCjC_f.js} +2 -2
- package/dist/{add-new-page-YpzILOYq.cjs → add-new-page-BuK6We-q.cjs} +1 -1
- package/dist/{add-new-page-BpvpSM4X.js → add-new-page-CD-9ppdS.js} +1 -1
- package/dist/{delete-page-w64MO7db.cjs → delete-page-B-TP6nJ7.cjs} +1 -1
- package/dist/{delete-page-CXRJjJ4o.js → delete-page-CatRlDfx.js} +1 -1
- package/dist/digital-asset-manager-DL2nAqUC.cjs +1 -0
- package/dist/digital-asset-manager-KakxBkBC.js +917 -0
- package/dist/{duplicate-page-DB_c7V2t.cjs → duplicate-page-D4Oiy71Q.cjs} +1 -1
- package/dist/{duplicate-page-CSQs2MOp.js → duplicate-page-DEmh0df0.js} +2 -2
- package/dist/{dynamic-page-selector-DTk4oull.js → dynamic-page-selector-8g1-84iW.js} +1 -1
- package/dist/{dynamic-page-selector-CF9nb6i_.cjs → dynamic-page-selector-Cz6zWaKo.cjs} +1 -1
- package/dist/index-Blg1T7nL.cjs +5 -0
- package/dist/{index-BuXZJnGo.js → index-zaGKeGBW.js} +850 -765
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -6
- package/dist/{json-diff-viewer-oyxMD3Hc.js → json-diff-viewer-BF0qFBif.js} +1 -1
- package/dist/{json-diff-viewer-zBoPBSd3.cjs → json-diff-viewer-c3ft4c4A.cjs} +1 -1
- package/dist/{lang-panel-B_HcsPPo.js → lang-panel-D1FKTNui.js} +2 -2
- package/dist/{lang-panel-D2YUMeJZ.cjs → lang-panel-ExS97Zgk.cjs} +1 -1
- package/dist/{mark-as-template-C4wH4UKf.cjs → mark-as-template-CcnkROAU.cjs} +1 -1
- package/dist/{mark-as-template-CPEPYXg7.js → mark-as-template-v-I05xcZ.js} +1 -1
- package/dist/{no-language-page-content-CVyOpT9h.js → no-language-page-content-Bm5CcsUo.js} +1 -1
- package/dist/{no-language-page-content-ECt0SxFX.cjs → no-language-page-content-Ddz2hnYs.cjs} +1 -1
- package/dist/{page-creator-y6kl3nw5.js → page-creator-Crc5BzeB.js} +2 -2
- package/dist/{page-creator-BG2hc82u.cjs → page-creator-CsZpQ7Gy.cjs} +1 -1
- package/dist/{page-lock-request-fGZbOFTp.cjs → page-lock-request-Dx6OrOwM.cjs} +1 -1
- package/dist/{page-lock-request-DC62b588.js → page-lock-request-WKfG7Sd3.js} +1 -1
- package/dist/{page-locked-by-dialog-BIC-c0Jl.cjs → page-locked-by-dialog-BvdAXZPw.cjs} +1 -1
- package/dist/{page-locked-by-dialog-D-vXaoga.js → page-locked-by-dialog-jy3lYV3l.js} +1 -1
- package/dist/{page-manager-new-Cto2r7Va.js → page-manager-new-CNHlSwfe.js} +66 -66
- package/dist/page-manager-new-CUlpwqpH.cjs +1 -0
- package/dist/{page-manager-search-and-filter-sVnGlF46.js → page-manager-search-and-filter-CuAn82Db.js} +1 -1
- package/dist/{page-manager-search-and-filter-z2b4sgvb.cjs → page-manager-search-and-filter-eFsGtm5W.cjs} +1 -1
- package/dist/{page-revisions-content-BaTqBnko.js → page-revisions-content-PRgwV04S.js} +2 -2
- package/dist/{page-revisions-content-Tb3T6zvU.cjs → page-revisions-content-dSFvGFEO.cjs} +1 -1
- package/dist/{publish-pages-content-C9CgEWo0.js → publish-pages-content-C24iBibw.js} +2 -2
- package/dist/{publish-pages-content-BGkEZ3GK.cjs → publish-pages-content-akIgltlm.cjs} +1 -1
- package/dist/{save-to-lib-DNK4GPNw.cjs → save-to-lib-C3H1ZPb-.cjs} +1 -1
- package/dist/{save-to-lib-DGtyTG6H.js → save-to-lib-DSPvtFSd.js} +1 -1
- package/dist/{seo-panel-CrK7z4bR.cjs → seo-panel-Ce6aTIyt.cjs} +1 -1
- package/dist/{seo-panel-DESVAQM5.js → seo-panel-rZ8s88c0.js} +17 -17
- package/dist/server.cjs +1 -1
- package/dist/server.js +96 -96
- package/dist/shared-json-ld-DMYOwp6B.js +565 -0
- package/dist/shared-json-ld-hCiviuBf.cjs +1 -0
- package/dist/{slug-input-DMYhARDW.cjs → slug-input-BN8eQgxP.cjs} +1 -1
- package/dist/{slug-input-DfAsMPg8.js → slug-input-Dhzaobv6.js} +1 -1
- package/dist/{theme-panel-footer-Bj2yHtxO.cjs → theme-panel-footer-0GrdOHO_.cjs} +1 -1
- package/dist/{theme-panel-footer-RrxiDGoD.js → theme-panel-footer-BzEy5bsg.js} +1 -1
- package/dist/{unmark-as-template-C8hTjRVk.cjs → unmark-as-template-DXEs6foh.cjs} +1 -1
- package/dist/{unmark-as-template-BjetSrYF.js → unmark-as-template-Dsiyocm9.js} +1 -1
- package/dist/{unpublish-page-gtGfNOAq.cjs → unpublish-page-c1mqQEa_.cjs} +1 -1
- package/dist/{unpublish-page-BTPEVAkv.js → unpublish-page-yGyz2jiw.js} +1 -1
- package/dist/{web-preview-DNgPjdgZ.js → web-preview-BEyjKFDL.js} +1 -1
- package/dist/{web-preview-BcULgiw_.cjs → web-preview-TTKtpSUi.cjs} +1 -1
- package/package.json +2 -3
- package/dist/digital-asset-manager-B2m5T22s.js +0 -1001
- package/dist/digital-asset-manager-BGyKKd_6.cjs +0 -1
- package/dist/index-Cds1vIhw.cjs +0 -5
- package/dist/page-manager-new-CUfjlMed.cjs +0 -1
- package/dist/shared-json-ld-BMfQzOWc.js +0 -650
- package/dist/shared-json-ld-_ozYsSHn.cjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@chaibuilder/sdk"),q=require("@tanstack/react-query"),u=require("./index-Cds1vIhw.cjs"),s=require("@chaibuilder/sdk/ui"),I=require("lodash-es"),p=require("lucide-react"),o=require("react"),F=require("sonner"),z=()=>{const t=u.useApiUrl(),h=u.useFetch();return q.useQuery({queryKey:[u.ACTIONS.GET_GLOBAL_JSONLD_ITEMS],queryFn:async()=>h(t,{action:u.ACTIONS.GET_GLOBAL_JSONLD_ITEMS})})},U=({show:t,onClose:h,initialData:n})=>e.jsx(s.Dialog,{open:t,onOpenChange:()=>h(),children:t&&e.jsx(_,{show:t,onClose:h,initialData:n})}),_=({show:t,onClose:h,initialData:n})=>{const[S,N]=o.useState("edit"),[v,i]=o.useState(""),[l,b]=o.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[w,g]=o.useState(!1),{data:j}=u.useCurrentPage(),{mutateAsync:m,isPending:c}=u.useAddGlobalSchema(),{mutateAsync:y}=u.useTogglePageGlobalSchema(),O=q.useQueryClient();o.useEffect(()=>{N("edit"),b(n?{name:n.name,description:n.description,content:JSON.stringify(n.jsonld,null,2),enabledByDefaultForNewPages:!1}:{name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),g(!1)},[t,n]),o.useEffect(()=>{const d=u.parseJSONWithPlaceholders(l.content);i(d.isValid?JSON.stringify(d.parsed,null,2):"")},[l.content]);const T=async()=>{if(!l.name||!l.content){F.toast.error("Please enter a name and content");return}const d=u.parseJSONWithPlaceholders(l.content);if(!d.isValid){F.toast.error("Invalid JSON-LD content");return}const P={name:l.name,jsonld:d.parsed,addToExistingPages:w,addToNewPages:l.enabledByDefaultForNewPages,description:l.description};n!=null&&n.primaryPageId&&(P.primaryPage=n.primaryPageId);const C=await m(P);j!=null&&j.id&&(C!=null&&C.id)&&!(n!=null&&n.primaryPageId)&&(await y({schemaId:C.id,pageId:j.id,enabled:!0}),O.invalidateQueries({queryKey:[u.ACTIONS.GET_LANGUAGE_PAGES,j.id]})),h()};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Add New Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[(n==null?void 0:n.languageCode)&&e.jsxs(s.Alert,{className:"border-blue-200 bg-blue-50",children:[e.jsx(p.Info,{className:"h-4 w-4 text-blue-600"}),e.jsxs(s.AlertDescription,{className:"text-sm text-blue-800",children:["You are creating a ",e.jsx("span",{className:"font-semibold",children:n.languageCode})," language version of this schema. This will be linked to the default language schema."]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(s.Input,{id:"new-name",value:l.name,onChange:d=>b({...l,name:d.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-description",children:"Description"}),e.jsx(s.Input,{id:"new-description",value:l.description||"",onChange:d=>b({...l,description:d.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-content",children:"JSON-LD Content"}),e.jsxs(s.Tabs,{value:S,onValueChange:N,className:"w-full",children:[e.jsxs("div",{className:"mb-2 flex w-full items-center justify-between",children:[e.jsxs(s.TabsList,{className:"w-max",children:[e.jsxs(s.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[e.jsx(p.Code,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]}),e.jsxs(s.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!v,children:[e.jsx(p.Eye,{className:"h-4 w-4"}),e.jsx("span",{children:"Preview"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:S==="edit"&&e.jsx(s.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>b({...l,content:v}),disabled:!v,children:"Format"})})]}),e.jsxs(s.TabsContent,{value:"edit",children:[e.jsx(s.Textarea,{id:"new-content",value:l.content||"{}",onChange:d=>b({...l,content:d.target.value}),className:"font-mono text-sm",placeholder:"Enter JSON-LD markup...",rows:10}),!v&&l.content?e.jsx("p",{className:"pt-px text-xs text-red-500",children:"Invalid JSON-LD"}):e.jsx("p",{})]}),e.jsx(s.TabsContent,{value:"preview",children:e.jsx(s.Textarea,{id:"new-content",value:v||"{}",className:"bg-muted font-mono text-sm",placeholder:"{}",rows:10,readOnly:!0})})]})]}),!(n!=null&&n.primaryPageId)&&e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Switch,{id:"add-to-all-existing",checked:w,onCheckedChange:d=>g(d)}),e.jsxs(s.Label,{htmlFor:"add-to-all-existing",children:[e.jsx("div",{children:"Add to all existing pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"This schema will be added to all existing pages on your site"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Switch,{id:"new-enabled",checked:l.enabledByDefaultForNewPages,onCheckedChange:d=>b({...l,enabledByDefaultForNewPages:d})}),e.jsxs(s.Label,{htmlFor:"new-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(s.Button,{disabled:c,variant:"outline",type:"button",size:"sm",onClick:()=>h(),children:"Cancel"}),e.jsx(s.Button,{disabled:c||!v,type:"button",size:"sm",onClick:T,children:c?e.jsxs(e.Fragment,{children:[e.jsx(p.Loader,{className:"h-4 w-4 animate-spin"})," Adding"]}):e.jsxs(e.Fragment,{children:["Add Schema",(n==null?void 0:n.languageCode)&&` (${n.languageCode})`]})})]})]})]})]})},H=({id:t,onClose:h})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:()=>h(),children:t&&e.jsx(V,{id:t,onClose:h})}),V=({id:t,onClose:h})=>{const[n,S]=o.useState("edit"),[N,v]=o.useState(""),[i,l]=o.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),[b,w]=o.useState(!1),[g,j]=o.useState(!1),[m,c]=o.useState(!1),{data:y}=z(),{mutateAsync:O,isPending:T}=u.useUpdateGlobalSchema(),{mutateAsync:d}=u.useApplySchemaToAllPages(),{mutateAsync:P}=u.useRemoveSchemaFromAllPages();o.useEffect(()=>{var x,L;if(S("edit"),t&&y){const A=y.find(a=>a.id===t);A&&(l({name:A.name,description:((x=A.metadata)==null?void 0:x.description)||"",content:JSON.stringify(A.jsonld,null,2),enabledByDefaultForNewPages:((L=A.metadata)==null?void 0:L.addToNewPages)||!1}),c(!!A.primaryPage))}},[t,y]),o.useEffect(()=>{const x=u.parseJSONWithPlaceholders(i.content);v(x.isValid?JSON.stringify(x.parsed,null,2):"")},[i.content]);const C=async()=>{if(!i.name||!i.content){F.toast.error("Please enter a name and content");return}const x=u.parseJSONWithPlaceholders(i.content);if(!x.isValid){F.toast.error("Invalid JSON-LD content");return}const L={id:t,name:i.name,jsonld:x.parsed,addToNewPages:i.enabledByDefaultForNewPages,description:i.description};await O(L),h()},J=async()=>{try{await d(t)}finally{w(!1)}},E=async()=>{try{await P(t)}finally{j(!1)}};return e.jsxs(s.DialogContent,{className:"flex max-w-xl flex-col overflow-y-auto",children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:"Edit Shared JSON-LD Schema"})}),e.jsxs("div",{className:"flex max-h-[75vh] flex-col space-y-2 overflow-y-auto",children:[e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-name",children:"Schema Name"}),e.jsx(s.Input,{id:"edit-name",value:i.name,onChange:x=>l({...i,name:x.target.value}),placeholder:"e.g., Product Schema",className:"text-xs"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-description",children:"Description"}),e.jsx(s.Input,{id:"edit-description",value:i.description||"",onChange:x=>l({...i,description:x.target.value}),placeholder:"Brief description of this schema"})]}),e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"edit-content",children:"JSON-LD Content"}),e.jsxs(s.Tabs,{value:n,onValueChange:S,className:"w-full",children:[e.jsxs("div",{className:"mb-2 flex w-full items-center justify-between",children:[e.jsxs(s.TabsList,{className:"w-max",children:[e.jsxs(s.TabsTrigger,{value:"edit",className:"flex items-center gap-1",children:[e.jsx(p.Code,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]}),e.jsxs(s.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!N,children:[e.jsx(p.Eye,{className:"h-4 w-4"}),e.jsx("span",{children:"Preview"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:n==="edit"&&e.jsx(s.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>l({...i,content:N}),disabled:!N,children:"Format"})})]}),e.jsxs(s.TabsContent,{value:"edit",children:[e.jsx(s.Textarea,{id:"edit-content",value:i.content||"{}",onChange:x=>l({...i,content:x.target.value}),className:"font-mono text-sm",placeholder:"Enter JSON-LD markup...",rows:10}),!N&&i.content?e.jsx("p",{className:"pt-px text-xs text-red-500",children:"Invalid JSON-LD"}):e.jsx("p",{})]}),e.jsx(s.TabsContent,{value:"preview",children:e.jsx(s.Textarea,{id:"edit-content-preview",value:N||"{}",className:"bg-muted font-mono text-sm",placeholder:"{}",rows:10,readOnly:!0})})]})]}),!m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-blue-900",children:"Manage Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"Add or remove this schema from all existing pages on your site"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{size:"sm",variant:"outline",onClick:()=>w(!0),children:"Add to all existing"}),e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>j(!0),children:"Remove from all"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Switch,{id:"edit-enabled",checked:i.enabledByDefaultForNewPages,onCheckedChange:x=>l({...i,enabledByDefaultForNewPages:x})}),e.jsxs(s.Label,{htmlFor:"edit-enabled",children:[e.jsx("div",{children:"Enabled by default for new pages"}),e.jsx("div",{className:"text-xs font-light text-muted-foreground",children:"New pages will automatically include this schema"})]})]})]}),e.jsxs("div",{className:`flex items-center justify-between ${m?"pt-2":""}`,children:[m&&e.jsx("div",{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(s.Button,{disabled:T,variant:"outline",type:"button",size:"sm",onClick:()=>h(),children:"Cancel"}),e.jsx(s.Button,{disabled:T||!N,type:"button",size:"sm",onClick:C,children:T?e.jsxs(e.Fragment,{children:[e.jsx(p.Loader,{className:"h-4 w-4 animate-spin"})," Updating"]}):"Update Schema"})]})]})]}),e.jsx(s.AlertDialog,{open:b,onOpenChange:w,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Add to All Existing Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will add the schema ",e.jsx("span",{className:"font-medium",children:i.name})," to all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:J,children:"Add to All"})]})]})}),e.jsx(s.AlertDialog,{open:g,onOpenChange:j,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Remove from All Pages?"}),e.jsxs(s.AlertDialogDescription,{children:["This will remove the schema ",e.jsx("span",{className:"font-medium",children:i.name})," from all existing pages on your site. This action cannot be undone automatically."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:E,className:"bg-red-500 hover:bg-red-600",children:"Remove from All"})]})]})})]})};function Q(){const[t,h]=o.useState(!1),[n,S]=o.useState(void 0),[N,v]=o.useState(null),[i,l]=o.useState(null),[b,w]=o.useState(null),{data:g,isLoading:j}=z(),{selectedLang:m}=M.useLanguages(),{data:c}=u.useCurrentPage(),{data:y}=u.useLanguagePages(),{mutateAsync:O}=u.useDeleteGlobalSchema(),{mutateAsync:T}=u.useTogglePageGlobalSchema(),d=o.useMemo(()=>y==null?void 0:y.find(a=>!a.primaryPage&&a.lang===""),[y]),P=o.useMemo(()=>(d==null?void 0:d.globalJsonLds)||[],[d]),C=o.useMemo(()=>g?I.filter(g,r=>r.primaryPage===null&&r.lang==="").map(r=>{const f=m?I.find(g,D=>D.primaryPage===r.id&&D.lang===m):null;return{defaultSchema:r,languageVersion:f,displayItem:f||r,hasLanguageVersion:!!f}}):[],[g,m]),[J,E]=o.useState([]),x=J.length>0?J:(c==null?void 0:c.globalJsonLds)||[];o.useEffect(()=>{c!=null&&c.globalJsonLds&&E(c.globalJsonLds)},[c==null?void 0:c.globalJsonLds]);const L=async a=>{if(!(c!=null&&c.id))return;w(a);const r=x.includes(a),f=r?x.filter(D=>D!==a):[...x,a];E(f);try{await T({schemaId:a,pageId:c.id,enabled:!r})}catch{E(c.globalJsonLds)}finally{w(null)}},A=async a=>{w(a);try{await O(a)}finally{w(null)}};return e.jsxs("div",{className:"rounded border bg-muted p-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium",children:"Shared JSON-LD Templates"}),e.jsx("div",{className:"w-full text-xs text-gray-500",children:"Manage reusable JSON-LD schemas that can be applied across multiple pages"})]}),!m&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:j,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:a=>{a.stopPropagation(),h(!0)},children:j?e.jsx(p.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(p.Plus,{className:"h-4 w-4"})}),e.jsx(s.TooltipContent,{children:"Add new schema"})]})]}),e.jsxs(s.ScrollArea,{className:"max-h-96 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[(!g||(g==null?void 0:g.length)===0)&&!j&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),C.map(({defaultSchema:a,displayItem:r,hasLanguageVersion:f})=>{var B,G;const D=x.includes(r.id),k=P.includes(a.id),R=f&&m?k:D;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${b===r.id?"pointer-events-none":""}`,children:[b===r.id&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80",children:e.jsx(p.Loader,{className:"h-5 w-5 animate-spin text-primary"})}),e.jsx(s.CardHeader,{className:"p-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(f||!m)&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("div",{children:e.jsx(s.Switch,{checked:R,onCheckedChange:()=>L(a.id),disabled:!!(f&&m)})})}),f&&m&&e.jsx(s.TooltipContent,{children:"Using the default language state"})]}),e.jsxs("div",{children:[e.jsxs(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:[r.name,f&&m&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",m,")"]})]}),((B=r==null?void 0:r.metadata)==null?void 0:B.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:(G=r==null?void 0:r.metadata)==null?void 0:G.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>l(r.id),children:e.jsx(p.Eye,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"View schema"})]}),(f||!m)&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>v(r.id),children:e.jsx(p.Edit,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Edit schema"})]}),e.jsxs(s.AlertDialog,{children:[e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.AlertDialogTrigger,{className:"flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800",children:e.jsx(p.Trash,{className:"h-4 w-4"})})}),e.jsx(s.TooltipContent,{children:"Delete schema"})]}),e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Schema"}),e.jsxs(s.AlertDialogDescription,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium",children:r.name}),"? This action cannot be undone."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{type:"button",children:"Cancel"}),e.jsx(s.AlertDialogAction,{type:"button",onClick:()=>A(r.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})]})}),!f&&m&&e.jsx(s.CardContent,{className:"px-2 pb-2",children:e.jsxs("div",{className:"flex w-full flex-col items-center justify-center rounded-lg border bg-gray-100 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"max-w-xl text-center text-xs text-gray-500",children:["Not available in '",m,"' language. Default language JSONLD will be used."]}),k&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700",children:"Enabled in default"})]}),e.jsx(s.Button,{type:"button",size:"sm",variant:"outline",className:"mt-2",onClick:()=>{S({name:a.name,description:a.description||"",jsonld:a.jsonld,languageCode:m,primaryPageId:a.id}),h(!0)},children:"Copy & Edit from default language"})]})})]},a.id)})]}),j&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(p.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(U,{show:t,onClose:()=>{h(!1),S(void 0)},initialData:n}),e.jsx(H,{id:N,onClose:()=>v(null)}),e.jsx(W,{schema:g==null?void 0:g.find(a=>a.id===i),onClose:()=>l(null)})]})}const W=({schema:t,onClose:h})=>e.jsx(s.Dialog,{open:!!t,onOpenChange:h,children:e.jsxs(s.DialogContent,{className:"max-w-2xl",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[t==null?void 0:t.name,(t==null?void 0:t.lang)&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.lang,")"]})]})}),e.jsxs("div",{className:"space-y-3",children:[(t==null?void 0:t.description)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Description"}),e.jsx("div",{className:"text-sm",children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"JSON-LD Schema"}),e.jsx(s.Textarea,{value:JSON.stringify(t==null?void 0:t.jsonld,null,2),readOnly:!0,className:"font-mono text-xs",rows:15})]})]})]})});exports.default=Q;
|