@chaibuilder/pages 0.13.4 → 0.14.0

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.
Files changed (76) hide show
  1. package/dist/{2AITGKQY-DpAgk_u8.cjs → 2AITGKQY-BLi5HVHf.cjs} +1 -1
  2. package/dist/{2AITGKQY-Dx_Cte-P.js → 2AITGKQY-iyhQ7kgG.js} +5 -5
  3. package/dist/{NCMVHL6D-B6lv7Umq.cjs → NCMVHL6D-CKYg8-AM.cjs} +1 -1
  4. package/dist/{NCMVHL6D-CT2qHOTS.js → NCMVHL6D-PLvSyK5P.js} +2 -2
  5. package/dist/{ZDWCUMSJ-C1vrgsti.cjs → ZDWCUMSJ-BJZ_Yi-4.cjs} +1 -1
  6. package/dist/{ZDWCUMSJ-W9xywtZH.js → ZDWCUMSJ-CuLkdxY-.js} +1 -1
  7. package/dist/add-new-language-page--ah9yzN3.cjs +1 -0
  8. package/dist/add-new-language-page-WM_Ve2vH.js +390 -0
  9. package/dist/add-new-page-Bs_NXM9x.js +30 -0
  10. package/dist/add-new-page-CnUo6xzd.cjs +1 -0
  11. package/dist/confetti.module-BuUnQuWk.cjs +2 -0
  12. package/dist/confetti.module-DCmCkDyV.js +409 -0
  13. package/dist/delete-page-Cf88UkqJ.cjs +1 -0
  14. package/dist/delete-page-D8xhYESu.js +38 -0
  15. package/dist/digital-asset-manager-BAFTqxsM.js +976 -0
  16. package/dist/digital-asset-manager-D_lcprwY.cjs +1 -0
  17. package/dist/duplicate-page-BX1gOez-.cjs +1 -0
  18. package/dist/duplicate-page-CqXTGmWt.js +120 -0
  19. package/dist/dynamic-page-selector-0TiUnfUg.js +86 -0
  20. package/dist/dynamic-page-selector-9JIQrcq5.cjs +1 -0
  21. package/dist/get-seo-defaults-9zHebckY.js +65 -0
  22. package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
  23. package/dist/image-compression-DZ9WMmyn.cjs +1 -0
  24. package/dist/image-compression-DsZ1oqpb.js +37 -0
  25. package/dist/index-D7kegQ3M.js +5153 -0
  26. package/dist/index-LU0FTfeN.cjs +5 -0
  27. package/dist/index.cjs +1 -1
  28. package/dist/index.d.ts +4 -22
  29. package/dist/index.js +20 -21
  30. package/dist/json-diff-viewer-Be-PVOZN.cjs +8 -0
  31. package/dist/json-diff-viewer-C2GK_BDh.js +258 -0
  32. package/dist/lang-panel-CPFS1ssC.js +218 -0
  33. package/dist/lang-panel-CePltxo2.cjs +1 -0
  34. package/dist/mark-as-template-DeB23sWR.cjs +1 -0
  35. package/dist/mark-as-template-jdwcgRIB.js +146 -0
  36. package/dist/nested-path-selector-content-D_iF9Sm3.cjs +1 -0
  37. package/dist/nested-path-selector-content-DvIL_EoN.js +87 -0
  38. package/dist/no-language-page-content-DUM4KxWu.js +35 -0
  39. package/dist/no-language-page-content-Dsm2H3pc.cjs +1 -0
  40. package/dist/page-creator-BjuYmKfc.js +796 -0
  41. package/dist/page-creator-DG0LwvL1.cjs +1 -0
  42. package/dist/page-lock-request-B9WPmFcd.cjs +1 -0
  43. package/dist/page-lock-request-BceB1S-X.js +64 -0
  44. package/dist/page-locked-by-dialog-2MULM3jh.cjs +1 -0
  45. package/dist/page-locked-by-dialog-BEWfFLSc.js +63 -0
  46. package/dist/page-manager-new-BONZN4c5.cjs +1 -0
  47. package/dist/page-manager-new-DV6A9WFv.js +354 -0
  48. package/dist/page-manager-search-and-filter-3h4URMP_.cjs +1 -0
  49. package/dist/page-manager-search-and-filter-DIiowi9F.js +197 -0
  50. package/dist/page-revisions-content-BIxeZeND.js +446 -0
  51. package/dist/page-revisions-content-CQbt25XX.cjs +1 -0
  52. package/dist/publish-pages-content-CdKHrfys.js +178 -0
  53. package/dist/publish-pages-content-im9dPOBM.cjs +1 -0
  54. package/dist/save-to-lib-DGII9CEP.js +476 -0
  55. package/dist/save-to-lib-DOh-850u.cjs +1 -0
  56. package/dist/seo-panel-2VdpoGSg.cjs +1 -0
  57. package/dist/seo-panel-Bxo4f-a_.js +667 -0
  58. package/dist/shared-json-ld-C1OewNgp.cjs +1 -0
  59. package/dist/shared-json-ld-gbnBFljN.js +337 -0
  60. package/dist/slug-input-BmcGmc_i.js +87 -0
  61. package/dist/slug-input-CfuQV97Z.cjs +1 -0
  62. package/dist/theme-panel-footer-D3SwHqGR.js +25 -0
  63. package/dist/theme-panel-footer-FrY4U8zn.cjs +1 -0
  64. package/dist/translation-warning-modal-DalBhNQy.js +26 -0
  65. package/dist/translation-warning-modal-Kctu12rQ.cjs +1 -0
  66. package/dist/unmark-as-template-CihtTMOb.cjs +1 -0
  67. package/dist/unmark-as-template-UwmCCn0u.js +38 -0
  68. package/dist/unpublish-page-CNwIU6AS.js +26 -0
  69. package/dist/unpublish-page-DzLtZcNw.cjs +1 -0
  70. package/dist/use-page-expand-manager-B7JtHdg5.cjs +1 -0
  71. package/dist/use-page-expand-manager-BCFQnVkT.js +85 -0
  72. package/package.json +1 -1
  73. package/dist/index-C4j31Yhz.js +0 -11471
  74. package/dist/index-DnjETHks.cjs +0 -6
  75. package/dist/page-revisions-content-Gx-Qf_91.cjs +0 -8
  76. package/dist/page-revisions-content-_-Nd4U11.js +0 -712
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),T=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),w=require("lodash-es"),m=require("lucide-react"),p=require("react"),L=require("sonner"),u=require("./index-LU0FTfeN.cjs"),J=require("@tanstack/react-query"),S=()=>{const n=u.useApiUrl(),d=u.useFetch();return J.useQuery({queryKey:[u.ACTIONS.GET_APP_SHARED_JSONLD],queryFn:async()=>await d(n,{action:u.ACTIONS.GET_APP_SHARED_JSONLD})||[],placeholderData:[],staleTime:60*60*1e3,retry:2})};function P(){const{data:n}=u.useCurrentPage(),d=w.get(n,"metadata",{})||{},[o,j]=p.useState(w.get(d,"sharedJsonLD",[])||[]),[x,h]=p.useState({show:!1,data:null}),{mutateAsync:y}=u.useUpdateActivePageMetadata(),[a,r]=p.useState(null),{data:i,isLoading:g}=S(),{mutateAsync:f}=u.useUpdateAppSharedJsonLD(),{selectedLang:b}=T.useLanguages(),l=async t=>{await y({...d,sharedJsonLD:t}),j(t),r(null)},v=async t=>{r(t);let c=[...o];w.includes(o,t)?c=c.filter(N=>N!==t):c=[...c||[],t],await l(c)},A=async t=>{r(t);try{const c=i==null?void 0:i.filter(N=>N.id!==t);await f(c),j(c),r(null)}catch{r(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"})]}),!b&&e.jsxs(s.Tooltip,{delayDuration:0,children:[e.jsx(s.TooltipTrigger,{type:"button",disabled:g,className:"rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",onClick:t=>{t.stopPropagation(),h({show:!0,data:null})},children:g?e.jsx(m.Loader,{className:"h-4 w-4 animate-spin"}):e.jsx(m.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:[(!i||(i==null?void 0:i.length)===0)&&!g&&e.jsx("div",{className:"flex items-center justify-center px-2 py-4 text-xs",children:"No shared JSON-LD found"}),i==null?void 0:i.map(t=>{const c=u.parseJSONWithPlaceholders(t.content),N=c.isValid?c.parsed:"",C=w.includes(o,t.id),D=!b;return e.jsxs(s.Card,{className:`relative border-gray-300 p-0 shadow-none transition-all ${a===t.id?"pointer-events-none":""}`,children:[a===t.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(m.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:[D&&e.jsx(s.Switch,{checked:C,onCheckedChange:()=>v(t.id)}),e.jsxs("div",{children:[e.jsx(s.CardTitle,{className:"flex items-center gap-2 text-sm leading-none",children:t.name}),(t==null?void 0:t.description)&&e.jsx("p",{className:"mt-1 text-xs leading-none text-muted-foreground",children:t==null?void 0:t.description})]})]}),D&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 p-0",onClick:()=>h({show:!0,data:t}),children:e.jsx(m.Edit,{className:"h-4 w-4"})}),e.jsxs(s.AlertDialog,{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(m.Trash,{className:"h-4 w-4"})}),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:t.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(t.id),className:"bg-red-500 text-white hover:bg-red-600",children:"Delete"})]})]})]})]})]})}),e.jsx(s.CardContent,{className:"px-2 pb-2",children:D?e.jsx(s.Textarea,{id:t.id,rows:1,readOnly:!0,value:JSON.stringify(N,null,2),className:"no-scrollbar cursor-text overflow-hidden rounded-md border-none bg-gray-100/80 text-xs"}):e.jsxs("div",{className:"flex h-20 w-full flex-col items-center justify-center rounded-lg border bg-gray-100",children:[e.jsx("div",{className:"max-w-xl text-center text-xs text-gray-500",children:"Not available in selected language, but available in default language."}),e.jsx(s.Button,{size:"sm",variant:"outline",className:"mt-2",onClick:()=>{},children:"Copy & Edit from default language"})]})})]})})]}),g&&e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx(m.Loader,{className:"h-5 w-5 animate-spin"})})]}),e.jsx(O,{data:x==null?void 0:x.data,show:x==null?void 0:x.show,onClose:()=>{h({show:!1,data:null})}})]})}const O=({data:n,show:d,onClose:o})=>e.jsx(s.Dialog,{open:d,onOpenChange:()=>o(),children:d&&e.jsx(F,{data:n,show:d,onClose:o})}),F=({data:n,show:d,onClose:o})=>{const[j,x]=p.useState("edit"),[h,y]=p.useState(""),[a,r]=p.useState({name:"",content:"",description:"",enabledByDefaultForNewPages:!1}),{data:i}=S(),{mutateAsync:g,isPending:f}=u.useUpdateAppSharedJsonLD();p.useEffect(()=>{x("edit"),r({name:"",description:"",content:"",enabledByDefaultForNewPages:!1}),n&&r({name:n.name,description:n.description,content:n.content,enabledByDefaultForNewPages:n.enabledByDefaultForNewPages})},[n,d]),p.useEffect(()=>{const l=u.parseJSONWithPlaceholders(a.content);y(l.isValid?JSON.stringify(l.parsed,null,2):"")},[a.content]);const b=async()=>{if(!a.name||!a.content){L.toast.error("Please enter a name and content");return}const l={id:n?n.id:crypto.randomUUID(),name:a.name,description:a.description,content:a.content};n?await g([...(i||[]).map(v=>v.id===n.id?l:v)]):await g([...i||[],l]),o()};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:[e.jsxs("div",{children:[e.jsx(s.Label,{htmlFor:"new-name",children:"Schema Name"}),e.jsx(s.Input,{id:"new-name",value:a.name,onChange:l=>r({...a,name:l.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:a.description||"",onChange:l=>r({...a,description:l.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:j,onValueChange:x,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(m.Code,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]}),e.jsxs(s.TabsTrigger,{value:"preview",className:"flex items-center gap-1",disabled:!h,children:[e.jsx(m.Eye,{className:"h-4 w-4"}),e.jsx("span",{children:"Preview"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:j==="edit"&&e.jsx(s.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>r({...a,content:h}),disabled:!h,children:"Format"})})]}),e.jsxs(s.TabsContent,{value:"edit",children:[e.jsx(s.Textarea,{id:"new-content",value:a.content||"{}",onChange:l=>r({...a,content:l.target.value}),className:"font-mono text-sm",placeholder:"Enter JSON-LD markup...",rows:10}),!h&&a.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:h||"{}",className:"bg-muted font-mono text-sm",placeholder:"{}",rows:10,readOnly:!0})})]})]}),n&&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:"Apply to All Existing Pages"}),e.jsx("div",{className:"text-xs text-blue-700",children:"This will add this JSON-LD schema to all existing pages on your site a"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{size:"sm",variant:"outline",onClick:()=>{},children:"Apply to all"}),e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>{},children:"Remove to all"})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Switch,{id:"new-enabled",checked:a.enabledByDefaultForNewPages,onCheckedChange:l=>r({...a,enabledByDefaultForNewPages:l})}),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 gap-2",children:[e.jsx(s.Button,{disabled:f,variant:"outline",type:"button",size:"sm",onClick:()=>o(),children:"Cancel"}),e.jsx(s.Button,{disabled:f||!h,type:"button",size:"sm",onClick:b,children:f?e.jsxs(e.Fragment,{children:[e.jsx(m.Loader,{className:"h-4 w-4 animate-spin"})," ",n?"Updating":"Adding"]}):n?"Update Schema":"Add Schema"})]})]})]})]})};exports.default=P;
@@ -0,0 +1,337 @@
1
+ import { jsxs as a, jsx as e, Fragment as I } from "react/jsx-runtime";
2
+ import { useLanguages as _ } from "@chaibuilder/sdk";
3
+ import { Tooltip as H, TooltipTrigger as M, TooltipContent as R, ScrollArea as V, Card as q, CardHeader as G, Switch as k, CardTitle as W, Button as p, AlertDialog as K, AlertDialogTrigger as Q, AlertDialogContent as $, AlertDialogHeader as X, AlertDialogTitle as Y, AlertDialogDescription as Z, AlertDialogFooter as ee, AlertDialogCancel as ae, AlertDialogAction as te, CardContent as ne, Textarea as S, Dialog as le, DialogContent as se, DialogHeader as ie, DialogTitle as re, Label as b, Input as C, Tabs as ce, TabsList as de, TabsTrigger as T, TabsContent as L } from "@chaibuilder/sdk/ui";
4
+ import { get as J, includes as P } from "lodash-es";
5
+ import { Loader as y, Plus as oe, Edit as he, Trash as me, Code as ue, Eye as pe } from "lucide-react";
6
+ import { useState as g, useEffect as O } from "react";
7
+ import { toast as ge } from "sonner";
8
+ import { ai as fe, aj as xe, A as F, ak as Ne, al as ve, am as j, an as E } from "./index-D7kegQ3M.js";
9
+ import { useQuery as we } from "@tanstack/react-query";
10
+ const U = () => {
11
+ const l = fe(), d = xe();
12
+ return we({
13
+ queryKey: [F.GET_APP_SHARED_JSONLD],
14
+ queryFn: async () => await d(l, { action: F.GET_APP_SHARED_JSONLD }) || [],
15
+ placeholderData: [],
16
+ staleTime: 60 * 60 * 1e3,
17
+ retry: 2
18
+ });
19
+ };
20
+ function Fe() {
21
+ const { data: l } = Ne(), d = J(l, "metadata", {}) || {}, [o, f] = g(J(d, "sharedJsonLD", []) || []), [m, h] = g({ show: !1, data: null }), { mutateAsync: D } = ve(), [n, i] = g(null), { data: r, isLoading: u } = U(), { mutateAsync: x } = j(), { selectedLang: v } = _(), s = async (t) => {
22
+ await D({ ...d, sharedJsonLD: t }), f(t), i(null);
23
+ }, w = async (t) => {
24
+ i(t);
25
+ let c = [...o];
26
+ P(o, t) ? c = c.filter((N) => N !== t) : c = [...c || [], t], await s(c);
27
+ }, z = async (t) => {
28
+ i(t);
29
+ try {
30
+ const c = r == null ? void 0 : r.filter((N) => N.id !== t);
31
+ await x(c), f(c), i(null);
32
+ } catch {
33
+ i(null);
34
+ }
35
+ };
36
+ return /* @__PURE__ */ a("div", { className: "rounded border bg-muted p-2", children: [
37
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between pb-2", children: [
38
+ /* @__PURE__ */ a("div", { children: [
39
+ /* @__PURE__ */ e("div", { className: "text-xs font-medium", children: "Shared JSON-LD Templates" }),
40
+ /* @__PURE__ */ e("div", { className: "w-full text-xs text-gray-500", children: "Manage reusable JSON-LD schemas that can be applied across multiple pages" })
41
+ ] }),
42
+ !v && /* @__PURE__ */ a(H, { delayDuration: 0, children: [
43
+ /* @__PURE__ */ e(
44
+ M,
45
+ {
46
+ type: "button",
47
+ disabled: u,
48
+ className: "rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/80",
49
+ onClick: (t) => {
50
+ t.stopPropagation(), h({ show: !0, data: null });
51
+ },
52
+ children: u ? /* @__PURE__ */ e(y, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(oe, { className: "h-4 w-4" })
53
+ }
54
+ ),
55
+ /* @__PURE__ */ e(R, { children: "Add new schema" })
56
+ ] })
57
+ ] }),
58
+ /* @__PURE__ */ a(V, { className: "max-h-96 overflow-y-auto", children: [
59
+ /* @__PURE__ */ a("div", { className: "space-y-2", children: [
60
+ (!r || (r == null ? void 0 : r.length) === 0) && !u && /* @__PURE__ */ e("div", { className: "flex items-center justify-center px-2 py-4 text-xs", children: "No shared JSON-LD found" }),
61
+ r == null ? void 0 : r.map((t) => {
62
+ const c = E(t.content), N = c.isValid ? c.parsed : "", B = P(o, t.id), A = !v;
63
+ return /* @__PURE__ */ a(
64
+ q,
65
+ {
66
+ className: `relative border-gray-300 p-0 shadow-none transition-all ${n === t.id ? "pointer-events-none" : ""}`,
67
+ children: [
68
+ n === t.id && /* @__PURE__ */ e("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-50 flex items-center justify-center rounded-xl bg-white/80", children: /* @__PURE__ */ e(y, { className: "h-5 w-5 animate-spin text-primary" }) }),
69
+ /* @__PURE__ */ e(G, { className: "p-2", children: /* @__PURE__ */ a("div", { className: "flex items-center justify-between", children: [
70
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-3", children: [
71
+ A && /* @__PURE__ */ e(k, { checked: B, onCheckedChange: () => w(t.id) }),
72
+ /* @__PURE__ */ a("div", { children: [
73
+ /* @__PURE__ */ e(W, { className: "flex items-center gap-2 text-sm leading-none", children: t.name }),
74
+ (t == null ? void 0 : t.description) && /* @__PURE__ */ e("p", { className: "mt-1 text-xs leading-none text-muted-foreground", children: t == null ? void 0 : t.description })
75
+ ] })
76
+ ] }),
77
+ A && /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
78
+ /* @__PURE__ */ e(
79
+ p,
80
+ {
81
+ type: "button",
82
+ variant: "ghost",
83
+ size: "icon",
84
+ className: "h-5 w-5 p-0",
85
+ onClick: () => h({ show: !0, data: t }),
86
+ children: /* @__PURE__ */ e(he, { className: "h-4 w-4" })
87
+ }
88
+ ),
89
+ /* @__PURE__ */ a(K, { children: [
90
+ /* @__PURE__ */ e(Q, { className: "flex h-5 w-5 items-center justify-center rounded-md text-red-500 hover:bg-red-100 hover:text-red-800", children: /* @__PURE__ */ e(me, { className: "h-4 w-4" }) }),
91
+ /* @__PURE__ */ a($, { children: [
92
+ /* @__PURE__ */ a(X, { children: [
93
+ /* @__PURE__ */ e(Y, { children: "Delete Schema" }),
94
+ /* @__PURE__ */ a(Z, { children: [
95
+ "Are you sure you want to delete ",
96
+ /* @__PURE__ */ e("span", { className: "font-medium", children: t.name }),
97
+ "? This action cannot be undone."
98
+ ] })
99
+ ] }),
100
+ /* @__PURE__ */ a(ee, { children: [
101
+ /* @__PURE__ */ e(ae, { type: "button", children: "Cancel" }),
102
+ /* @__PURE__ */ e(
103
+ te,
104
+ {
105
+ type: "button",
106
+ onClick: () => z(t.id),
107
+ className: "bg-red-500 text-white hover:bg-red-600",
108
+ children: "Delete"
109
+ }
110
+ )
111
+ ] })
112
+ ] })
113
+ ] })
114
+ ] })
115
+ ] }) }),
116
+ /* @__PURE__ */ e(ne, { className: "px-2 pb-2", children: A ? /* @__PURE__ */ e(
117
+ S,
118
+ {
119
+ id: t.id,
120
+ rows: 1,
121
+ readOnly: !0,
122
+ value: JSON.stringify(N, null, 2),
123
+ className: "no-scrollbar cursor-text overflow-hidden rounded-md border-none bg-gray-100/80 text-xs"
124
+ }
125
+ ) : /* @__PURE__ */ a("div", { className: "flex h-20 w-full flex-col items-center justify-center rounded-lg border bg-gray-100", children: [
126
+ /* @__PURE__ */ e("div", { className: "max-w-xl text-center text-xs text-gray-500", children: "Not available in selected language, but available in default language." }),
127
+ /* @__PURE__ */ e(
128
+ p,
129
+ {
130
+ size: "sm",
131
+ variant: "outline",
132
+ className: "mt-2",
133
+ onClick: () => {
134
+ },
135
+ children: "Copy & Edit from default language"
136
+ }
137
+ )
138
+ ] }) })
139
+ ]
140
+ }
141
+ );
142
+ })
143
+ ] }),
144
+ u && /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e(y, { className: "h-5 w-5 animate-spin" }) })
145
+ ] }),
146
+ /* @__PURE__ */ e(
147
+ be,
148
+ {
149
+ data: m == null ? void 0 : m.data,
150
+ show: m == null ? void 0 : m.show,
151
+ onClose: () => {
152
+ h({ show: !1, data: null });
153
+ }
154
+ }
155
+ )
156
+ ] });
157
+ }
158
+ const be = ({
159
+ data: l,
160
+ show: d,
161
+ onClose: o
162
+ }) => /* @__PURE__ */ e(le, { open: d, onOpenChange: () => o(), children: d && /* @__PURE__ */ e(ye, { data: l, show: d, onClose: o }) }), ye = ({
163
+ data: l,
164
+ show: d,
165
+ onClose: o
166
+ }) => {
167
+ const [f, m] = g("edit"), [h, D] = g(""), [n, i] = g({
168
+ name: "",
169
+ content: "",
170
+ description: "",
171
+ enabledByDefaultForNewPages: !1
172
+ }), { data: r } = U(), { mutateAsync: u, isPending: x } = j();
173
+ O(() => {
174
+ m("edit"), i({ name: "", description: "", content: "", enabledByDefaultForNewPages: !1 }), l && i({
175
+ name: l.name,
176
+ description: l.description,
177
+ content: l.content,
178
+ enabledByDefaultForNewPages: l.enabledByDefaultForNewPages
179
+ });
180
+ }, [l, d]), O(() => {
181
+ const s = E(n.content);
182
+ D(s.isValid ? JSON.stringify(s.parsed, null, 2) : "");
183
+ }, [n.content]);
184
+ const v = async () => {
185
+ if (!n.name || !n.content) {
186
+ ge.error("Please enter a name and content");
187
+ return;
188
+ }
189
+ const s = {
190
+ id: l ? l.id : crypto.randomUUID(),
191
+ name: n.name,
192
+ description: n.description,
193
+ content: n.content
194
+ };
195
+ l ? await u([
196
+ ...(r || []).map((w) => w.id === l.id ? s : w)
197
+ ]) : await u([...r || [], s]), o();
198
+ };
199
+ return /* @__PURE__ */ a(se, { className: "flex max-w-xl flex-col overflow-y-auto", children: [
200
+ /* @__PURE__ */ e(ie, { children: /* @__PURE__ */ e(re, { children: "Add New Shared JSON-LD Schema" }) }),
201
+ /* @__PURE__ */ a("div", { className: "flex max-h-[75vh] flex-col space-y-2 overflow-y-auto", children: [
202
+ /* @__PURE__ */ a("div", { children: [
203
+ /* @__PURE__ */ e(b, { htmlFor: "new-name", children: "Schema Name" }),
204
+ /* @__PURE__ */ e(
205
+ C,
206
+ {
207
+ id: "new-name",
208
+ value: n.name,
209
+ onChange: (s) => i({ ...n, name: s.target.value }),
210
+ placeholder: "e.g., Product Schema",
211
+ className: "text-xs"
212
+ }
213
+ )
214
+ ] }),
215
+ /* @__PURE__ */ a("div", { children: [
216
+ /* @__PURE__ */ e(b, { htmlFor: "new-description", children: "Description" }),
217
+ /* @__PURE__ */ e(
218
+ C,
219
+ {
220
+ id: "new-description",
221
+ value: n.description || "",
222
+ onChange: (s) => i({ ...n, description: s.target.value }),
223
+ placeholder: "Brief description of this schema"
224
+ }
225
+ )
226
+ ] }),
227
+ /* @__PURE__ */ a("div", { children: [
228
+ /* @__PURE__ */ e(b, { htmlFor: "new-content", children: "JSON-LD Content" }),
229
+ /* @__PURE__ */ a(ce, { value: f, onValueChange: m, className: "w-full", children: [
230
+ /* @__PURE__ */ a("div", { className: "mb-2 flex w-full items-center justify-between", children: [
231
+ /* @__PURE__ */ a(de, { className: "w-max", children: [
232
+ /* @__PURE__ */ a(T, { value: "edit", className: "flex items-center gap-1", children: [
233
+ /* @__PURE__ */ e(ue, { className: "h-4 w-4" }),
234
+ /* @__PURE__ */ e("span", { children: "Edit" })
235
+ ] }),
236
+ /* @__PURE__ */ a(T, { value: "preview", className: "flex items-center gap-1", disabled: !h, children: [
237
+ /* @__PURE__ */ e(pe, { className: "h-4 w-4" }),
238
+ /* @__PURE__ */ e("span", { children: "Preview" })
239
+ ] })
240
+ ] }),
241
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: f === "edit" && /* @__PURE__ */ e(
242
+ p,
243
+ {
244
+ type: "button",
245
+ variant: "outline",
246
+ size: "sm",
247
+ onClick: () => i({ ...n, content: h }),
248
+ disabled: !h,
249
+ children: "Format"
250
+ }
251
+ ) })
252
+ ] }),
253
+ /* @__PURE__ */ a(L, { value: "edit", children: [
254
+ /* @__PURE__ */ e(
255
+ S,
256
+ {
257
+ id: "new-content",
258
+ value: n.content || "{}",
259
+ onChange: (s) => i({ ...n, content: s.target.value }),
260
+ className: "font-mono text-sm",
261
+ placeholder: "Enter JSON-LD markup...",
262
+ rows: 10
263
+ }
264
+ ),
265
+ !h && n.content ? /* @__PURE__ */ e("p", { className: "pt-px text-xs text-red-500", children: "Invalid JSON-LD" }) : /* @__PURE__ */ e("p", {})
266
+ ] }),
267
+ /* @__PURE__ */ e(L, { value: "preview", children: /* @__PURE__ */ e(
268
+ S,
269
+ {
270
+ id: "new-content",
271
+ value: h || "{}",
272
+ className: "bg-muted font-mono text-sm",
273
+ placeholder: "{}",
274
+ rows: 10,
275
+ readOnly: !0
276
+ }
277
+ ) })
278
+ ] })
279
+ ] }),
280
+ l && /* @__PURE__ */ a("div", { className: "flex items-center justify-between rounded-lg border border-blue-300 bg-blue-500/10 p-2", children: [
281
+ /* @__PURE__ */ a("div", { children: [
282
+ /* @__PURE__ */ e("div", { className: "text-sm font-medium text-blue-900", children: "Apply to All Existing Pages" }),
283
+ /* @__PURE__ */ e("div", { className: "text-xs text-blue-700", children: "This will add this JSON-LD schema to all existing pages on your site a" })
284
+ ] }),
285
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
286
+ /* @__PURE__ */ e(
287
+ p,
288
+ {
289
+ size: "sm",
290
+ variant: "outline",
291
+ onClick: () => {
292
+ },
293
+ children: "Apply to all"
294
+ }
295
+ ),
296
+ /* @__PURE__ */ e(
297
+ p,
298
+ {
299
+ size: "sm",
300
+ variant: "ghost",
301
+ onClick: () => {
302
+ },
303
+ children: "Remove to all"
304
+ }
305
+ )
306
+ ] })
307
+ ] }),
308
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between pt-2", children: [
309
+ /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
310
+ /* @__PURE__ */ e(
311
+ k,
312
+ {
313
+ id: "new-enabled",
314
+ checked: n.enabledByDefaultForNewPages,
315
+ onCheckedChange: (s) => i({ ...n, enabledByDefaultForNewPages: s })
316
+ }
317
+ ),
318
+ /* @__PURE__ */ a(b, { htmlFor: "new-enabled", children: [
319
+ /* @__PURE__ */ e("div", { children: "Enabled by default for new pages" }),
320
+ /* @__PURE__ */ e("div", { className: "text-xs font-light text-muted-foreground", children: "New pages will automatically include this schema" })
321
+ ] })
322
+ ] }),
323
+ /* @__PURE__ */ a("div", { className: "flex gap-2", children: [
324
+ /* @__PURE__ */ e(p, { disabled: x, variant: "outline", type: "button", size: "sm", onClick: () => o(), children: "Cancel" }),
325
+ /* @__PURE__ */ e(p, { disabled: x || !h, type: "button", size: "sm", onClick: v, children: x ? /* @__PURE__ */ a(I, { children: [
326
+ /* @__PURE__ */ e(y, { className: "h-4 w-4 animate-spin" }),
327
+ " ",
328
+ l ? "Updating" : "Adding"
329
+ ] }) : l ? "Update Schema" : "Add Schema" })
330
+ ] })
331
+ ] })
332
+ ] })
333
+ ] });
334
+ };
335
+ export {
336
+ Fe as default
337
+ };
@@ -0,0 +1,87 @@
1
+ import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
+ import { L as d } from "./index-D7kegQ3M.js";
3
+ import { Input as v } from "@chaibuilder/sdk/ui";
4
+ import { useState as x, useEffect as C } from "react";
5
+ const y = (e) => {
6
+ if (!e) return { base: e, extension: null };
7
+ const n = e.lastIndexOf(".");
8
+ if (n <= 0) return { base: e, extension: null };
9
+ const t = e.substring(n);
10
+ return { base: e.substring(0, n), extension: t };
11
+ }, g = (e) => {
12
+ if (!e) return e;
13
+ const { base: n } = y(e);
14
+ return n;
15
+ };
16
+ function w(e, n) {
17
+ const t = (e || "").split("/").filter(Boolean);
18
+ let s = "", r = !0;
19
+ if (n.slug === "/") {
20
+ const a = t.pop() || "";
21
+ if (d[a])
22
+ r = !0;
23
+ else {
24
+ s = a;
25
+ const l = t.pop() || "";
26
+ r = !!d[l];
27
+ }
28
+ } else if (n.parent)
29
+ t.length && (s = t.pop() || "");
30
+ else if (t.length) {
31
+ s = t.pop() || "";
32
+ const a = t.pop() || "";
33
+ r = !!d[a];
34
+ }
35
+ return { initSlug: s, prefix: r };
36
+ }
37
+ const E = (e) => e && g(e), z = (e, n) => {
38
+ const t = g(e || "");
39
+ return !t || t === "/" ? `/${n}` : `${t}/${n}`;
40
+ };
41
+ function D({
42
+ value: e,
43
+ onChange: n,
44
+ placeholder: t,
45
+ parentSlug: s,
46
+ onValidationChange: r,
47
+ disabled: a = !1,
48
+ fullSlug: l
49
+ }) {
50
+ const [h, u] = x(e), [c, f] = x(null);
51
+ C(() => {
52
+ u(e);
53
+ }, [e]);
54
+ const N = (b) => {
55
+ const p = b.target.value.replace(/\//g, "").replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-_.]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").toLowerCase(), m = (p.match(/\./g) || []).length, S = m <= 1;
56
+ m > 1 ? f("Invalid slug. Only one dot (.) is allowed in the slug") : f(null), r && r(S), u(p), n(p);
57
+ };
58
+ return /* @__PURE__ */ i("div", { children: [
59
+ s && /* @__PURE__ */ o("div", { className: "mb-1 flex items-center", children: /* @__PURE__ */ i("span", { className: "text-xs text-gray-500", children: [
60
+ "Parent: ",
61
+ /* @__PURE__ */ o("span", { className: "font-mono text-gray-900", children: E(s) })
62
+ ] }) }),
63
+ /* @__PURE__ */ i("div", { className: "relative", children: [
64
+ /* @__PURE__ */ o(
65
+ v,
66
+ {
67
+ disabled: a,
68
+ value: h,
69
+ onChange: N,
70
+ placeholder: t,
71
+ className: c ? "border-red-500" : ""
72
+ }
73
+ ),
74
+ c && /* @__PURE__ */ o("div", { className: "mt-1 text-xs text-red-500", children: c })
75
+ ] }),
76
+ l && l !== "undefined" && /* @__PURE__ */ o("div", { className: "mt-1 flex items-center", children: /* @__PURE__ */ i("span", { className: "text-xs text-gray-500", children: [
77
+ "Complete Slug: ",
78
+ /* @__PURE__ */ o("span", { className: "font-mono text-gray-900", children: l })
79
+ ] }) })
80
+ ] });
81
+ }
82
+ export {
83
+ D as S,
84
+ z as c,
85
+ w as p,
86
+ g as r
87
+ };
@@ -0,0 +1 @@
1
+ "use strict";const s=require("react/jsx-runtime"),u=require("./index-LU0FTfeN.cjs"),b=require("@chaibuilder/sdk/ui"),d=require("react"),j=e=>{if(!e)return{base:e,extension:null};const n=e.lastIndexOf(".");if(n<=0)return{base:e,extension:null};const t=e.substring(n);return{base:e.substring(0,n),extension:t}},x=e=>{if(!e)return e;const{base:n}=j(e);return n};function E(e,n){const t=(e||"").split("/").filter(Boolean);let r="",a=!0;if(n.slug==="/"){const i=t.pop()||"";if(u.LANGUAGES[i])a=!0;else{r=i;const l=t.pop()||"";a=!!u.LANGUAGES[l]}}else if(n.parent)t.length&&(r=t.pop()||"");else if(t.length){r=t.pop()||"";const i=t.pop()||"";a=!!u.LANGUAGES[i]}return{initSlug:r,prefix:a}}const v=e=>e&&x(e),C=(e,n)=>{const t=x(e||"");return!t||t==="/"?`/${n}`:`${t}/${n}`};function A({value:e,onChange:n,placeholder:t,parentSlug:r,onValidationChange:a,disabled:i=!1,fullSlug:l}){const[g,p]=d.useState(e),[o,f]=d.useState(null);d.useEffect(()=>{p(e)},[e]);const h=S=>{const c=S.target.value.replace(/\//g,"").replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-_.]/g,"-").replace(/-+/g,"-").replace(/^-+/,"").toLowerCase(),m=(c.match(/\./g)||[]).length,N=m<=1;m>1?f("Invalid slug. Only one dot (.) is allowed in the slug"):f(null),a&&a(N),p(c),n(c)};return s.jsxs("div",{children:[r&&s.jsx("div",{className:"mb-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Parent: ",s.jsx("span",{className:"font-mono text-gray-900",children:v(r)})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(b.Input,{disabled:i,value:g,onChange:h,placeholder:t,className:o?"border-red-500":""}),o&&s.jsx("div",{className:"mt-1 text-xs text-red-500",children:o})]}),l&&l!=="undefined"&&s.jsx("div",{className:"mt-1 flex items-center",children:s.jsxs("span",{className:"text-xs text-gray-500",children:["Complete Slug: ",s.jsx("span",{className:"font-mono text-gray-900",children:l})]})})]})}exports.SlugInput=A;exports.combineParentChildSlugs=C;exports.parseSlugForEdit=E;exports.removeSlugExtension=x;
@@ -0,0 +1,25 @@
1
+ import { jsxs as h, jsx as n } from "react/jsx-runtime";
2
+ import { u as l, a as m, t as r } from "./index-D7kegQ3M.js";
3
+ import { useTheme as d } from "@chaibuilder/sdk";
4
+ import { Button as a } from "@chaibuilder/sdk/ui";
5
+ const P = () => {
6
+ const [e] = d(), { mutate: o, isPending: s } = l(), { mutateAsync: t, isPending: i } = m();
7
+ return /* @__PURE__ */ h("div", { className: "flex items-center justify-center gap-x-3 border-t bg-white py-3", children: [
8
+ /* @__PURE__ */ n(a, { size: "sm", variant: "outline", disabled: s || i, onClick: () => {
9
+ t({ settings: { theme: e } });
10
+ }, children: "Save draft" }),
11
+ /* @__PURE__ */ n(a, { size: "sm", disabled: s || i, onClick: async () => {
12
+ await t({ settings: { theme: e } }), o(
13
+ { ids: ["THEME"] },
14
+ {
15
+ onSuccess: () => {
16
+ r("BOTTOM_RIGHT");
17
+ }
18
+ }
19
+ );
20
+ }, children: "Publish" })
21
+ ] });
22
+ };
23
+ export {
24
+ P as default
25
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-LU0FTfeN.cjs"),d=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),l=()=>{const[t]=d.useTheme(),{mutate:o,isPending:i}=s.usePublishPages(),{mutateAsync:n,isPending:u}=s.useUpdateWebsiteSettings(),r=()=>{n({settings:{theme:t}})},c=async()=>{await n({settings:{theme:t}}),o({ids:["THEME"]},{onSuccess:()=>{s.throwConfetti("BOTTOM_RIGHT")}})};return e.jsxs("div",{className:"flex items-center justify-center gap-x-3 border-t bg-white py-3",children:[e.jsx(a.Button,{size:"sm",variant:"outline",disabled:i||u,onClick:r,children:"Save draft"}),e.jsx(a.Button,{size:"sm",disabled:i||u,onClick:c,children:"Publish"})]})};exports.default=l;
@@ -0,0 +1,26 @@
1
+ import { jsx as n, jsxs as e } from "react/jsx-runtime";
2
+ import { Dialog as s, DialogContent as d, DialogHeader as h, DialogTitle as u, DialogDescription as g, DialogFooter as m, Button as i } from "@chaibuilder/sdk/ui";
3
+ const f = ({
4
+ isOpen: l,
5
+ onClose: o,
6
+ onContinue: t,
7
+ isPending: a = !1,
8
+ title: r = "Translation Warning",
9
+ description: c = "Some blocks need translations before publishing. Do you want to continue anyway?"
10
+ }) => /* @__PURE__ */ n(s, { open: l, onOpenChange: o, children: l && /* @__PURE__ */ e(d, { className: "sm:max-w-[425px]", children: [
11
+ /* @__PURE__ */ e(h, { children: [
12
+ /* @__PURE__ */ n(u, { children: r }),
13
+ /* @__PURE__ */ n(g, { children: c })
14
+ ] }),
15
+ /* @__PURE__ */ e(m, { className: "flex gap-2", children: [
16
+ /* @__PURE__ */ n(i, { variant: "outline", onClick: () => {
17
+ o();
18
+ }, disabled: a, children: "Cancel" }),
19
+ /* @__PURE__ */ n(i, { onClick: () => {
20
+ t();
21
+ }, disabled: a, children: a ? "Publishing..." : "Continue Anyway" })
22
+ ] })
23
+ ] }) });
24
+ export {
25
+ f as default
26
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),e=require("@chaibuilder/sdk/ui"),d=({isOpen:l,onClose:i,onContinue:o,isPending:a=!1,title:t="Translation Warning",description:s="Some blocks need translations before publishing. Do you want to continue anyway?"})=>{const r=()=>{i()},c=()=>{o()};return n.jsx(e.Dialog,{open:l,onOpenChange:i,children:l&&n.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[n.jsxs(e.DialogHeader,{children:[n.jsx(e.DialogTitle,{children:t}),n.jsx(e.DialogDescription,{children:s})]}),n.jsxs(e.DialogFooter,{className:"flex gap-2",children:[n.jsx(e.Button,{variant:"outline",onClick:r,disabled:a,children:"Cancel"}),n.jsx(e.Button,{onClick:c,disabled:a,children:a?"Publishing...":"Continue Anyway"})]})]})})};exports.default=d;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-LU0FTfeN.cjs"),t=require("@chaibuilder/sdk/ui"),u=require("react"),d=({page:i,onClose:a})=>{const[s,n]=u.useState(!1),r=c.useUnmarkAsTemplate(),o=()=>{n(!0),r.mutate(i,{onSuccess:()=>{n(!1),a()},onError:()=>{n(!1)}})};return e.jsx(t.Dialog,{open:!0,onOpenChange:a,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Unmark as template"}),e.jsx(t.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:"Are you sure you want to unmark this page as a template?"})]}),e.jsxs(t.DialogFooter,{className:s?"pointer-events-none opacity-75":"",children:[e.jsx(t.Button,{variant:"outline",onClick:l=>{l.stopPropagation(),a()},children:"Cancel"}),e.jsx(t.Button,{variant:"default",disabled:s,onClick:o,children:"Unmark as template"})]})]})})};exports.default=d;
@@ -0,0 +1,38 @@
1
+ import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
+ import { o as c } from "./index-D7kegQ3M.js";
3
+ import { Dialog as m, DialogContent as p, DialogHeader as d, DialogTitle as u, DialogDescription as h, DialogFooter as g, Button as r } from "@chaibuilder/sdk/ui";
4
+ import { useState as f } from "react";
5
+ const T = ({ page: i, onClose: a }) => {
6
+ const [o, t] = f(!1), s = c();
7
+ return /* @__PURE__ */ e(m, { open: !0, onOpenChange: a, children: /* @__PURE__ */ n(p, { children: [
8
+ /* @__PURE__ */ n(d, { children: [
9
+ /* @__PURE__ */ e(u, { children: "Unmark as template" }),
10
+ /* @__PURE__ */ e(h, { className: "space-y-1 py-4 text-xs text-slate-500", children: "Are you sure you want to unmark this page as a template?" })
11
+ ] }),
12
+ /* @__PURE__ */ n(g, { className: o ? "pointer-events-none opacity-75" : "", children: [
13
+ /* @__PURE__ */ e(
14
+ r,
15
+ {
16
+ variant: "outline",
17
+ onClick: (l) => {
18
+ l.stopPropagation(), a();
19
+ },
20
+ children: "Cancel"
21
+ }
22
+ ),
23
+ /* @__PURE__ */ e(r, { variant: "default", disabled: o, onClick: () => {
24
+ t(!0), s.mutate(i, {
25
+ onSuccess: () => {
26
+ t(!1), a();
27
+ },
28
+ onError: () => {
29
+ t(!1);
30
+ }
31
+ });
32
+ }, children: "Unmark as template" })
33
+ ] })
34
+ ] }) });
35
+ };
36
+ export {
37
+ T as default
38
+ };
@@ -0,0 +1,26 @@
1
+ import { jsx as n, jsxs as l } from "react/jsx-runtime";
2
+ import { l as d, C as r } from "./index-D7kegQ3M.js";
3
+ import { Dialog as h, DialogContent as a, DialogHeader as u, DialogTitle as m, DialogDescription as U, DialogFooter as D, Button as e } from "@chaibuilder/sdk/ui";
4
+ const f = ({ page: i, onClose: o }) => {
5
+ const { mutate: s, isPending: t } = d(), c = async () => {
6
+ s(i, { onSuccess: o });
7
+ };
8
+ return /* @__PURE__ */ n(h, { open: !!i, onOpenChange: o, children: /* @__PURE__ */ l(a, { children: [
9
+ /* @__PURE__ */ l(u, { children: [
10
+ /* @__PURE__ */ n(m, { children: "Confirm action" }),
11
+ /* @__PURE__ */ l(U, { children: [
12
+ r.UNPUBLISH_MSG,
13
+ " ",
14
+ /* @__PURE__ */ n("b", { children: (i == null ? void 0 : i.name) ?? (i == null ? void 0 : i.slug) }),
15
+ "?"
16
+ ] })
17
+ ] }),
18
+ /* @__PURE__ */ l(D, { children: [
19
+ /* @__PURE__ */ n(e, { variant: "outline", onClick: o, children: "Cancel" }),
20
+ /* @__PURE__ */ n(e, { variant: "destructive", disabled: t, onClick: c, children: t ? r.UPDATING : r.UNPUBLISH })
21
+ ] })
22
+ ] }) });
23
+ };
24
+ export {
25
+ f as default
26
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("./index-LU0FTfeN.cjs"),e=require("@chaibuilder/sdk/ui"),o=({page:i,onClose:t})=>{const{mutate:r,isPending:l}=s.useUnpublishPage(),c=async()=>{r(i,{onSuccess:t})};return n.jsx(e.Dialog,{open:!!i,onOpenChange:t,children:n.jsxs(e.DialogContent,{children:[n.jsxs(e.DialogHeader,{children:[n.jsx(e.DialogTitle,{children:"Confirm action"}),n.jsxs(e.DialogDescription,{children:[s.CONTENT.UNPUBLISH_MSG," ",n.jsx("b",{children:(i==null?void 0:i.name)??(i==null?void 0:i.slug)}),"?"]})]}),n.jsxs(e.DialogFooter,{children:[n.jsx(e.Button,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(e.Button,{variant:"destructive",disabled:l,onClick:c,children:l?s.CONTENT.UPDATING:s.CONTENT.UNPUBLISH})]})]})})};exports.default=o;
@@ -0,0 +1 @@
1
+ "use strict";const m=require("jotai"),p=require("react"),n=require("lodash-es"),y=require("./index-LU0FTfeN.cjs"),A=y.atomWithStorage("expandedPagesState",[]),E=s=>n.flatMap(s,e=>[e,...e.children?E(e.children):[]]),S=(s,e)=>{const t=(a,i=[])=>{for(const r of a){const o=[...i,r.id];if(r.id===e)return o;if(r.children&&r.children.length>0){const d=t(r.children,o);if(d)return d}}return null};return t(s)||[]},P=(s,e)=>{if(!e)return[];const t=E(s),a=n.find(t,i=>i.id===e);if(a){if(a.parent)return[...P(s,a.parent),e];const i=S(s,e);if(!n.isEmpty(i))return i}return[e]},C=s=>{const e=new Set,t=(a,i=[])=>{a.forEach(r=>{const o=[...i,r.id];r.shouldExpandOnSearch&&o.forEach(d=>e.add(d)),r.children&&!n.isEmpty(r.children)&&t(r.children,o)})};return t(s),Array.from(e)},b=s=>{const[e,t]=m.useAtom(A),a=s?n.includes(e,s):!1,i=p.useCallback(()=>{t(c=>a?n.filter(c,l=>l!==s):[...c,s])},[t,a,s]),r=p.useCallback((c,l)=>{if(!l||n.isEmpty(c))return;const h=E(c),u=P(h,l);if(!Array.isArray(u)||n.isEmpty(u))return;const f=u.slice(0,-1);n.isEmpty(f)||t(g=>n.uniq([...g,...f]))},[t]),o=p.useCallback(c=>{if(n.isEmpty(c))return;const l=C(c);n.isEmpty(l)||t(h=>n.union(h,l))},[t]),d=p.useCallback(c=>{if(n.isEmpty(c))return;const l=n.flatMap(c,h=>{const u=f=>[f.id,...f.children?n.flatMap(f.children,u):[]];return u(h)});t(l)},[t]),x=p.useCallback(()=>{t([])},[t]);return{isExpanded:a,toggleExpanded:i,updateForSelectedPage:r,expandedPages:e,expandPagesOnSearch:o,setExpandedPages:t,expandAll:d,collapseAll:x}};exports.usePageExpandManager=b;