@chaibuilder/sdk 0.1.4 → 0.1.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.
Files changed (78) hide show
  1. package/dist/{AddBlocks-b6a12d50.js → AddBlocks-671fde09.js} +20 -19
  2. package/dist/AddBlocks-862cf7e0.cjs +3 -0
  3. package/dist/{BrandingOptions-1190723a.js → BrandingOptions-520c438d.js} +11 -9
  4. package/dist/BrandingOptions-8bbdd54f.cjs +1 -0
  5. package/dist/{CanvasArea-f5d27245.cjs → CanvasArea-86eef07f.cjs} +2 -2
  6. package/dist/{CanvasArea-15458836.js → CanvasArea-d912e63e.js} +226 -224
  7. package/dist/{Class-e34b2337.js → Class-1fb4c0c4.js} +110 -169
  8. package/dist/Class-6c695ccb.cjs +1 -0
  9. package/dist/Layers-ae78b10e.cjs +1 -0
  10. package/dist/{Layers-ff4ef9c0.js → Layers-db65053b.js} +12 -10
  11. package/dist/MODIFIERS-70fef873.cjs +1 -0
  12. package/dist/MODIFIERS-c2e02614.js +67 -0
  13. package/dist/{MarkAsGlobalBlock-dea26aa7.js → MarkAsGlobalBlock-a1274d49.js} +10 -8
  14. package/dist/MarkAsGlobalBlock-d5b40fdb.cjs +1 -0
  15. package/dist/PagesPanel-41ebbdd1.cjs +1 -0
  16. package/dist/{PagesPanel-3e9163c4.js → PagesPanel-48cb686f.js} +12 -10
  17. package/dist/ProjectPanel-08a229f3.cjs +1 -0
  18. package/dist/{ProjectPanel-17c5f131.js → ProjectPanel-920b0f75.js} +9 -10
  19. package/dist/Settings-0c125f1b.cjs +1 -0
  20. package/dist/{Settings-6f2e86a9.js → Settings-9ccc4a65.js} +7 -5
  21. package/dist/{SidePanels-96e64da9.js → SidePanels-9684bfe2.js} +8 -6
  22. package/dist/SidePanels-ef33ed66.cjs +1 -0
  23. package/dist/{Topbar-08d10607.js → Topbar-2f40d770.js} +7 -5
  24. package/dist/Topbar-84eadc0e.cjs +1 -0
  25. package/dist/add-page-modal-7fc782b9.cjs +1 -0
  26. package/dist/add-page-modal-fb7d069a.js +93 -0
  27. package/dist/core.cjs +1 -1
  28. package/dist/core.d.ts +13 -11
  29. package/dist/core.js +63 -61
  30. package/dist/delete-page-modal-15e71ba4.cjs +1 -0
  31. package/dist/{delete-page-modal-fa7b4272.js → delete-page-modal-cc906461.js} +9 -8
  32. package/dist/html-to-json-01cc5fe0.cjs +1 -0
  33. package/dist/{html-to-json-9304dbda.js → html-to-json-d20aafdd.js} +2 -2
  34. package/dist/index-1217461b.cjs +2 -0
  35. package/dist/index-32519c31.js +4909 -0
  36. package/dist/lib.cjs +1 -1
  37. package/dist/lib.js +4 -4
  38. package/dist/page-viewer-15b9eb5f.cjs +1 -0
  39. package/dist/{page-viewer-f1452439.js → page-viewer-77998a4d.js} +21 -18
  40. package/dist/{project-general-setting-0d7715b8.cjs → project-general-setting-a8be43b9.cjs} +1 -1
  41. package/dist/{project-general-setting-e5d14fa6.js → project-general-setting-e66f4966.js} +7 -5
  42. package/dist/render.cjs +2 -2
  43. package/dist/render.d.ts +9 -3
  44. package/dist/render.js +154 -134
  45. package/dist/single-page-detail-116281ae.cjs +1 -0
  46. package/dist/{single-page-detail-74f88ed2.js → single-page-detail-a0332ab5.js} +39 -38
  47. package/dist/style.css +1 -1
  48. package/dist/useChangePage-6a7c7374.js +12 -0
  49. package/dist/useChangePage-f22cea36.cjs +1 -0
  50. package/dist/usePageActions-5e28a006.cjs +1 -0
  51. package/dist/usePageActions-d6e1d325.js +38 -0
  52. package/package.json +3 -2
  53. package/dist/AddBlocks-1f683caa.cjs +0 -3
  54. package/dist/BrandingOptions-02e4ebcf.cjs +0 -1
  55. package/dist/CONTROLS-031e1de3.cjs +0 -1
  56. package/dist/CONTROLS-442caee5.js +0 -6
  57. package/dist/Class-7d6aadbc.cjs +0 -1
  58. package/dist/Layers-06fa708d.cjs +0 -1
  59. package/dist/MarkAsGlobalBlock-fa0e0543.cjs +0 -1
  60. package/dist/PagesPanel-b08e1357.cjs +0 -1
  61. package/dist/ProjectPanel-f0b94e3f.cjs +0 -1
  62. package/dist/Settings-739cff3b.cjs +0 -1
  63. package/dist/SidePanels-ce4d41d5.cjs +0 -1
  64. package/dist/Topbar-b97472fc.cjs +0 -1
  65. package/dist/add-page-modal-3275cfb2.cjs +0 -1
  66. package/dist/add-page-modal-bcd9249e.js +0 -93
  67. package/dist/delete-page-modal-420a17e3.cjs +0 -1
  68. package/dist/html-to-json-9c9961da.cjs +0 -1
  69. package/dist/index-133d90a5.cjs +0 -2
  70. package/dist/index-3f65447f.js +0 -4754
  71. package/dist/page-viewer-139bfb2a.cjs +0 -1
  72. package/dist/single-page-detail-54d7feca.cjs +0 -1
  73. package/dist/useMutation-7d536740.cjs +0 -1
  74. package/dist/useMutation-97876a40.js +0 -126
  75. package/dist/usePageActions-ac9ad321.cjs +0 -1
  76. package/dist/usePageActions-de3b7515.js +0 -37
  77. package/dist/useProjectActions-3b1dbb5e.js +0 -18
  78. package/dist/useProjectActions-41af0f70.cjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),n=require("react"),u=require("@radix-ui/react-icons"),o=require("./popover-7cb9079b.cjs"),c=require("./index-133d90a5.cjs");require("@radix-ui/react-popover");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("i18next");require("react-i18next");require("flagged");require("react-dnd");require("lodash");require("@minoru/react-dnd-treeview");require("./useBuilderProp-5e57d0c8.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-7d6aadbc.cjs");require("redux-undo");require("@react-hookz/web");require("@chaibuilder/blocks");require("./CONTROLS-031e1de3.cjs");const j=n.lazy(()=>Promise.resolve().then(()=>require("./single-page-detail-54d7feca.cjs"))),m=({pageData:r})=>{const[s,t]=n.useState("CLOSE");return e.jsxRuntimeExports.jsxs(o.Popover,{open:s==="OPEN"||s==="ALERT"||s==="PENDING",onOpenChange:i=>{t(s==="PENDING"?"ALERT":i?"OPEN":"CLOSE")},children:[e.jsxRuntimeExports.jsx(o.PopoverTrigger,{asChild:!0,onClick:i=>{i.stopPropagation(),t("OPEN")},children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:s==="OPEN"||s==="ALERT"||s==="PENDING"?e.jsxRuntimeExports.jsx(u.ChevronRightIcon,{}):e.jsxRuntimeExports.jsx("div",{className:"hidden hover:text-blue-600 group-hover:flex",children:e.jsxRuntimeExports.jsx(u.GearIcon,{})})})}),e.jsxRuntimeExports.jsx(o.PopoverContent,{side:"right",align:"start",alignOffset:-35,className:"h-screen w-96",children:e.jsxRuntimeExports.jsx(n.Suspense,{fallback:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full animate-pulse flex-col gap-y-3",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-6 w-1/2"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"})]}),children:e.jsxRuntimeExports.jsx(j,{pageData:r,open:s,setOpen:t})})})]})},p=r=>{const[s]=["123"],{data:t}=c.useProject(),i={},x=(t==null?void 0:t.homepage)===r.uuid,l=s===r.uuid,a=()=>i(r);return t?e.jsxRuntimeExports.jsxs("button",{className:`group relative flex w-full cursor-pointer items-center justify-between px-2.5 py-2 ${l?"bg-blue-200 ":""}`,onClick:a,type:"button",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1.5",children:[x?e.jsxRuntimeExports.jsx(u.HomeIcon,{}):e.jsxRuntimeExports.jsx(u.FileTextIcon,{})," ",r.name]}),e.jsxRuntimeExports.jsx(m,{pageData:r})]}):null},d=({pages:r,isLoading:s})=>s?e.jsxRuntimeExports.jsxs("div",{className:"flex animate-pulse flex-col gap-y-1 px-2.5 pt-2",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"})]}):r.length===0?e.jsxRuntimeExports.jsx("div",{className:"px-2.5 pb-2 pt-4",children:"No pages"}):e.jsxRuntimeExports.jsx("div",{className:"-mb-2",children:n.Children.toArray(r.map(t=>e.jsxRuntimeExports.jsx(p,{...t})))});exports.default=d;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-5c3ac4f7.cjs"),q=require("react"),c=require("lodash"),H=require("@radix-ui/react-icons"),w=require("./useBuilderProp-5e57d0c8.cjs"),L=require("./scroll-area-088530b9.cjs"),d=require("@chaibuilder/blocks"),z=require("sonner"),p=require("./form-6eac0287.cjs"),N=require("./index-133d90a5.cjs"),b=require("./useProjectActions-41af0f70.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("@radix-ui/react-scroll-area");require("@rjsf/core");require("@rjsf/validator-ajv8");require("./link-86c532b5.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("./ImagesPanel-addb2bf9.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("i18next");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-7d6aadbc.cjs");require("redux-undo");require("@react-hookz/web");require("./CONTROLS-031e1de3.cjs");require("./useMutation-7d536740.cjs");const _=q.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-420a17e3.cjs"))),B=q.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-4f50caa7.cjs"))),h=n=>{if(!c.isString(n)||!(n.includes("/[")&&n.includes("]")))return!1;const i=/^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/,g=/^[a-zA-Z0-9_-]+$/;let e=!0;return n.split("/").forEach(u=>{e&&(u.includes("[[")&&u.includes("]]")?e=/^\[\[\.{3}[a-zA-Z0-9_-]+\]\]$/.test(u):u.includes("[")&&u.includes("]")?e=i.test(u):e=g.test(u))}),e},P=n=>n&&c.isEmpty(n.seoData)?{...n,seoData:{title:"",description:"",image:""}}:n,G=(n,o)=>{const i=!c.isEqual(c.omit(n,["seoData"]),c.omit(o,["seoData"])),g=!c.isEqual(P(o).seoData,P(n).seoData);return i||g},Y=({open:n,setOpen:o,pageData:i})=>{const g=N.useQueryClient(),{data:e}=N.useProject(),u=b.useUpdateProject(),m=b.useUpdateProject("Homepage updated successfully."),[s,y]=q.useState(P(i)),[a,A]=q.useState({isHomePage:(e==null?void 0:e.homepage)===i.uuid}),E=G(s,i);q.useEffect(()=>{const l=!c.isEqual(P(i),s),r=(e==null?void 0:e.homepage)!==i.uuid&&a.isHomePage;o(l||r?"PENDING":"OPEN")},[e,i,s,a,o]);const j=()=>{if(E){if(i.type==="DYNAMIC"&&!h((s==null?void 0:s.slug)||"")){n==="ALERT"&&o("PENDING");return}u.mutate(s,{onSuccess:()=>{g.invalidateQueries({refetchType:"active",queryKey:["pages",e==null?void 0:e.uuid]}),o("CLOSE"),z.toast.success("Page updated successfully.")}})}a.isHomePage&&(e==null?void 0:e.homepage)!==i.uuid&&m.mutate({...e,homepage:i==null?void 0:i.uuid},{onSuccess:()=>o("CLOSE")})},S=({formData:l},r)=>{y(f=>{var C,R;if(!r)return f;const x={[r]:l[r]};return r==="page_name"?x.slug=c.kebabCase((C=l[r])==null?void 0:C.replace(/\d/g,"")):r==="slug"?x.slug=(R=l[r])==null?void 0:R.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_"):r==="seo_data"&&(x.seo_data={title:l[r].title||"",description:l[r].description||"",image:l[r].image||""}),{...f,...x}})},I=({formData:l},r)=>{A(f=>{const x={[r]:l[r]};return{...f,...x}})},T={page_name:d.SingleLineText({title:"Page Name",default:s.name}),slug:d.SingleLineText({title:"Page Slug",default:s.slug})},v={seo_data:d.Model({title:"",description:"",default:{title:"",description:"",image:""},properties:{title:d.SingleLineText({title:"Meta Title",default:s.name}),description:d.MultilineText({title:"Meta Description",default:s.slug}),image:d.Image({title:"Social Media Image",default:""})}})},M={isHomePage:d.Checkbox({title:"Set as homepage",default:a.isHomePage})};return t.jsxRuntimeExports.jsxs(L.ScrollArea,{className:"flex h-full select-none flex-col",children:[t.jsxRuntimeExports.jsx(B,{open:n==="ALERT",title:"Do yo want to save changes?",onCancel:()=>o("CLOSE"),onConfirm:j,disabled:m.isPending||u.isPending}),t.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 px-2.5 py-1",children:t.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:"Page Details"})}),t.jsxRuntimeExports.jsx("div",{className:"px-2.5 pt-2",children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-2",children:[t.jsxRuntimeExports.jsx(p.Form,{title:"Basic Details",formData:s,properties:T,onChange:S,disabled:u.isPending||m.isPending}),t.jsxRuntimeExports.jsx("div",{className:"h-2 w-full"}),t.jsxRuntimeExports.jsx(p.Form,{title:"SEO Details",formData:s,properties:v,onChange:S,disabled:u.isPending||m.isPending}),(e==null?void 0:e.homepage)!==i.uuid&&i.type==="STATIC"?t.jsxRuntimeExports.jsx(p.Form,{formData:a,properties:M,onChange:I,disabled:u.isPending||m.isPending}):i.type==="STATIC"&&t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1 px-1 pt-2 text-xs font-medium text-gray-500",children:[t.jsxRuntimeExports.jsx(H.HomeIcon,{})," This is homepage"," "]}),s.type==="DYNAMIC"&&!h((s==null?void 0:s.slug)||"")&&t.jsxRuntimeExports.jsxs("small",{className:"px-1 text-red-400",children:["Add dynamic ID in page slug Eg: ",t.jsxRuntimeExports.jsx("i",{className:"underline",children:"some-url/[some-id]"})]}),t.jsxRuntimeExports.jsxs("div",{className:"my-2 flex w-full items-center justify-between gap-x-2 px-1",children:[t.jsxRuntimeExports.jsx(w.Button,{className:"w-full",type:"submit",onClick:j,disabled:(e==null?void 0:e.homepage)!==i.uuid&&a.isHomePage?!1:c.isEmpty(s.name)||c.isEmpty(s.slug)||!E||u.isPending||m.isPending||s.type==="DYNAMIC"&&!h((s==null?void 0:s.slug)||""),children:"Save"}),t.jsxRuntimeExports.jsx(_,{pageData:i,projectData:e})]})]})})]})};exports.default=Y;
@@ -1 +0,0 @@
1
- "use strict";var M=(i,t,e)=>{if(!t.has(i))throw TypeError("Cannot "+e)};var s=(i,t,e)=>(M(i,t,"read from private field"),e?e.call(i):t.get(i)),c=(i,t,e)=>{if(t.has(i))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(i):t.set(i,e)},l=(i,t,e,r)=>(M(i,t,"write to private field"),r?r.call(i,e):t.set(i,e),e);var p=(i,t,e)=>(M(i,t,"access private method"),e);const w=require("react"),b=require("./index-133d90a5.cjs");function j(i){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const e in i)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:()=>i[e]})}}return t.default=i,Object.freeze(t)}const v=j(w);var a,n,o,u,f,y,O,S,x,k=(x=class extends b.Subscribable{constructor(t,e){super();c(this,f);c(this,O);c(this,a,void 0);c(this,n,void 0);c(this,o,void 0);c(this,u,void 0);l(this,n,void 0),l(this,a,t),this.setOptions(e),this.bindMethods(),p(this,f,y).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const e=this.options;this.options=s(this,a).defaultMutationOptions(t),b.shallowEqualObjects(e,this.options)||s(this,a).getMutationCache().notify({type:"observerOptionsUpdated",mutation:s(this,o),observer:this}),(r=s(this,o))==null||r.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=s(this,o))==null||t.removeObserver(this)}onMutationUpdate(t){p(this,f,y).call(this),p(this,O,S).call(this,t)}getCurrentResult(){return s(this,n)}reset(){l(this,o,void 0),p(this,f,y).call(this),p(this,O,S).call(this)}mutate(t,e){var r;return l(this,u,e),(r=s(this,o))==null||r.removeObserver(this),l(this,o,s(this,a).getMutationCache().build(s(this,a),this.options)),s(this,o).addObserver(this),s(this,o).execute(t)}},a=new WeakMap,n=new WeakMap,o=new WeakMap,u=new WeakMap,f=new WeakSet,y=function(){var e;const t=((e=s(this,o))==null?void 0:e.state)??b.getDefaultState();l(this,n,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},O=new WeakSet,S=function(t){b.notifyManager.batch(()=>{var e,r,h,m,d,g,C,E;s(this,u)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((r=(e=s(this,u)).onSuccess)==null||r.call(e,t.data,s(this,n).variables,s(this,n).context),(m=(h=s(this,u)).onSettled)==null||m.call(h,t.data,null,s(this,n).variables,s(this,n).context)):(t==null?void 0:t.type)==="error"&&((g=(d=s(this,u)).onError)==null||g.call(d,t.error,s(this,n).variables,s(this,n).context),(E=(C=s(this,u)).onSettled)==null||E.call(C,void 0,t.error,s(this,n).variables,s(this,n).context))),this.listeners.forEach(R=>{R(s(this,n))})})},x);function q(i,t){const e=b.useQueryClient(t),[r]=v.useState(()=>new k(e,i));v.useEffect(()=>{r.setOptions(i)},[r,i]);const h=v.useSyncExternalStore(v.useCallback(d=>r.subscribe(b.notifyManager.batchCalls(d)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),m=v.useCallback((d,g)=>{r.mutate(d,g).catch(D)},[r]);if(h.error&&b.shouldThrowError(r.options.throwOnError,[h.error]))throw h.error;return{...h,mutate:m,mutateAsync:h.mutate}}function D(){}exports.useMutation=q;
@@ -1,126 +0,0 @@
1
- var g = (r, t, e) => {
2
- if (!t.has(r))
3
- throw TypeError("Cannot " + e);
4
- };
5
- var s = (r, t, e) => (g(r, t, "read from private field"), e ? e.call(r) : t.get(r)), l = (r, t, e) => {
6
- if (t.has(r))
7
- throw TypeError("Cannot add the same private member more than once");
8
- t instanceof WeakSet ? t.add(r) : t.set(r, e);
9
- }, c = (r, t, e, i) => (g(r, t, "write to private field"), i ? i.call(r, e) : t.set(r, e), e);
10
- var d = (r, t, e) => (g(r, t, "access private method"), e);
11
- import * as f from "react";
12
- import { Z as w, _ as U, $ as k, a0 as E, X as L, a1 as j } from "./index-3f65447f.js";
13
- var n, h, o, u, p, M, v, y, x, q = (x = class extends w {
14
- constructor(t, e) {
15
- super();
16
- l(this, p);
17
- l(this, v);
18
- l(this, n, void 0);
19
- l(this, h, void 0);
20
- l(this, o, void 0);
21
- l(this, u, void 0);
22
- c(this, h, void 0), c(this, n, t), this.setOptions(e), this.bindMethods(), d(this, p, M).call(this);
23
- }
24
- bindMethods() {
25
- this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
26
- }
27
- setOptions(t) {
28
- var i;
29
- const e = this.options;
30
- this.options = s(this, n).defaultMutationOptions(t), U(e, this.options) || s(this, n).getMutationCache().notify({
31
- type: "observerOptionsUpdated",
32
- mutation: s(this, o),
33
- observer: this
34
- }), (i = s(this, o)) == null || i.setOptions(this.options);
35
- }
36
- onUnsubscribe() {
37
- var t;
38
- this.hasListeners() || (t = s(this, o)) == null || t.removeObserver(this);
39
- }
40
- onMutationUpdate(t) {
41
- d(this, p, M).call(this), d(this, v, y).call(this, t);
42
- }
43
- getCurrentResult() {
44
- return s(this, h);
45
- }
46
- reset() {
47
- c(this, o, void 0), d(this, p, M).call(this), d(this, v, y).call(this);
48
- }
49
- mutate(t, e) {
50
- var i;
51
- return c(this, u, e), (i = s(this, o)) == null || i.removeObserver(this), c(this, o, s(this, n).getMutationCache().build(s(this, n), this.options)), s(this, o).addObserver(this), s(this, o).execute(t);
52
- }
53
- }, n = new WeakMap(), h = new WeakMap(), o = new WeakMap(), u = new WeakMap(), p = new WeakSet(), M = function() {
54
- var e;
55
- const t = ((e = s(this, o)) == null ? void 0 : e.state) ?? k();
56
- c(this, h, {
57
- ...t,
58
- isPending: t.status === "pending",
59
- isSuccess: t.status === "success",
60
- isError: t.status === "error",
61
- isIdle: t.status === "idle",
62
- mutate: this.mutate,
63
- reset: this.reset
64
- });
65
- }, v = new WeakSet(), y = function(t) {
66
- E.batch(() => {
67
- var e, i, a, m, b, O, C, S;
68
- s(this, u) && this.hasListeners() && ((t == null ? void 0 : t.type) === "success" ? ((i = (e = s(this, u)).onSuccess) == null || i.call(
69
- e,
70
- t.data,
71
- s(this, h).variables,
72
- s(this, h).context
73
- ), (m = (a = s(this, u)).onSettled) == null || m.call(
74
- a,
75
- t.data,
76
- null,
77
- s(this, h).variables,
78
- s(this, h).context
79
- )) : (t == null ? void 0 : t.type) === "error" && ((O = (b = s(this, u)).onError) == null || O.call(
80
- b,
81
- t.error,
82
- s(this, h).variables,
83
- s(this, h).context
84
- ), (S = (C = s(this, u)).onSettled) == null || S.call(
85
- C,
86
- void 0,
87
- t.error,
88
- s(this, h).variables,
89
- s(this, h).context
90
- ))), this.listeners.forEach((R) => {
91
- R(s(this, h));
92
- });
93
- });
94
- }, x);
95
- function P(r, t) {
96
- const e = L(t), [i] = f.useState(
97
- () => new q(
98
- e,
99
- r
100
- )
101
- );
102
- f.useEffect(() => {
103
- i.setOptions(r);
104
- }, [i, r]);
105
- const a = f.useSyncExternalStore(
106
- f.useCallback(
107
- (b) => i.subscribe(E.batchCalls(b)),
108
- [i]
109
- ),
110
- () => i.getCurrentResult(),
111
- () => i.getCurrentResult()
112
- ), m = f.useCallback(
113
- (b, O) => {
114
- i.mutate(b, O).catch(A);
115
- },
116
- [i]
117
- );
118
- if (a.error && j(i.options.throwOnError, [a.error]))
119
- throw a.error;
120
- return { ...a, mutate: m, mutateAsync: a.mutate };
121
- }
122
- function A() {
123
- }
124
- export {
125
- P as u
126
- };
@@ -1 +0,0 @@
1
- "use strict";const t=require("./index-133d90a5.cjs"),i=require("./useMutation-7d536740.cjs"),a=require("sonner");require("react-i18next");const c=require("./useBuilderProp-5e57d0c8.cjs"),o=()=>{const[u]=["SAVED"],[e,s]=t.useCurrentPage(),n=t.useBuilderReset();return r=>u==="UNSAVED"?(c.toast({variant:"destructive",title:"Please save unsaved changes"}),!1):e===r.uuid?!1:(n(),setTimeout(()=>{s(r.uuid)},100),!0)},d=()=>{const u=t.useQueryClient(),e=o();return i.useMutation({mutationFn:async s=>fetch("/pages",{method:"POST",body:JSON.stringify(s)}).then(n=>n.json()),onSuccess:s=>{u.invalidateQueries({queryKey:["pages"]}),e({uuid:s.uuid,slug:s.slug}),a.toast.success("Page added successfully.")}})},g=()=>{const u=t.useQueryClient();return i.useMutation({mutationFn:async e=>fetch(`/page?uuid=${e.uuid}`,{method:"DELETE",body:JSON.stringify(e)}),onSuccess:()=>{a.toast.success("Page deleted successfully."),u.invalidateQueries({queryKey:["pages"]})}})};exports.useAddPage=d;exports.useDeletePage=g;
@@ -1,37 +0,0 @@
1
- import { a2 as o, a3 as c, X as r } from "./index-3f65447f.js";
2
- import { u as n } from "./useMutation-97876a40.js";
3
- import { toast as i } from "sonner";
4
- import "react-i18next";
5
- import { t as d } from "./useBuilderProp-81a14920.js";
6
- const g = () => {
7
- const [t] = ["SAVED"], [e, s] = o(), u = c();
8
- return (a) => t === "UNSAVED" ? (d({ variant: "destructive", title: "Please save unsaved changes" }), !1) : e === a.uuid ? !1 : (u(), setTimeout(() => {
9
- s(a.uuid);
10
- }, 100), !0);
11
- }, h = () => {
12
- const t = r(), e = g();
13
- return n({
14
- mutationFn: async (s) => fetch("/pages", {
15
- method: "POST",
16
- body: JSON.stringify(s)
17
- }).then((u) => u.json()),
18
- onSuccess: (s) => {
19
- t.invalidateQueries({ queryKey: ["pages"] }), e({ uuid: s.uuid, slug: s.slug }), i.success("Page added successfully.");
20
- }
21
- });
22
- }, S = () => {
23
- const t = r();
24
- return n({
25
- mutationFn: async (e) => fetch(`/page?uuid=${e.uuid}`, {
26
- method: "DELETE",
27
- body: JSON.stringify(e)
28
- }),
29
- onSuccess: () => {
30
- i.success("Page deleted successfully."), t.invalidateQueries({ queryKey: ["pages"] });
31
- }
32
- });
33
- };
34
- export {
35
- S as a,
36
- h as u
37
- };
@@ -1,18 +0,0 @@
1
- import { X as r, Y as u } from "./index-3f65447f.js";
2
- import { u as a } from "./useMutation-97876a40.js";
3
- import { toast as c } from "sonner";
4
- const m = (e = "Project updated successfully.") => {
5
- const t = r(), s = u();
6
- return a({
7
- mutationFn: async (o) => await fetch(`${s}/project`, {
8
- method: "PUT",
9
- body: JSON.stringify(o)
10
- }),
11
- onSuccess: () => {
12
- t.invalidateQueries({ queryKey: ["project"] }), c.success(e);
13
- }
14
- });
15
- };
16
- export {
17
- m as u
18
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("./index-133d90a5.cjs"),c=require("./useMutation-7d536740.cjs"),o=require("sonner"),n=(t="Project updated successfully.")=>{const s=e.useQueryClient(),r=e.useApiBaseUrl();return c.useMutation({mutationFn:async u=>await fetch(`${r}/project`,{method:"PUT",body:JSON.stringify(u)}),onSuccess:()=>{s.invalidateQueries({queryKey:["project"]}),o.toast.success(t)}})};exports.useUpdateProject=n;