@chaibuilder/sdk 0.1.1 → 0.1.3

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 (82) hide show
  1. package/dist/AddBlocks-0916e841.cjs +3 -0
  2. package/dist/AddBlocks-c195f577.js +258 -0
  3. package/dist/{BrandingOptions-77957074.cjs → BrandingOptions-742992b6.cjs} +1 -1
  4. package/dist/{BrandingOptions-86dc389a.js → BrandingOptions-766c19c6.js} +27 -27
  5. package/dist/{CanvasArea-29d479f2.js → CanvasArea-25800a3e.js} +19 -18
  6. package/dist/CanvasArea-e855c4a2.cjs +60 -0
  7. package/dist/Class-7d6aadbc.cjs +1 -0
  8. package/dist/{Class-e6b07b79.js → Class-e34b2337.js} +9 -9
  9. package/dist/{ImagesPanel-6595528d.js → ImagesPanel-8ccab6d9.js} +1 -1
  10. package/dist/{ImagesPanel-5cde797f.cjs → ImagesPanel-addb2bf9.cjs} +1 -1
  11. package/dist/{Layers-3a270af5.cjs → Layers-a2169d0b.cjs} +1 -1
  12. package/dist/{Layers-81832d92.js → Layers-f7e792f6.js} +3 -3
  13. package/dist/{MarkAsGlobalBlock-f2186631.cjs → MarkAsGlobalBlock-6187e6fd.cjs} +1 -1
  14. package/dist/{MarkAsGlobalBlock-a1b5646c.js → MarkAsGlobalBlock-6bac1842.js} +2 -2
  15. package/dist/PagesPanel-0827c264.js +46 -0
  16. package/dist/PagesPanel-5698953d.cjs +1 -0
  17. package/dist/ProjectPanel-a3cb7396.cjs +1 -0
  18. package/dist/ProjectPanel-e577029a.js +66 -0
  19. package/dist/{Settings-a8cea8ee.js → Settings-b214f859.js} +25 -24
  20. package/dist/Settings-bee21026.cjs +1 -0
  21. package/dist/{SidePanels-1dcabe54.js → SidePanels-03fa10e8.js} +20 -18
  22. package/dist/SidePanels-934159a4.cjs +1 -0
  23. package/dist/{Topbar-ce65bdce.js → Topbar-9bc8c9cf.js} +2 -2
  24. package/dist/{Topbar-00cfceeb.cjs → Topbar-c083cc2a.cjs} +1 -1
  25. package/dist/UnsplashImages-68492dc9.cjs +1 -0
  26. package/dist/{UnsplashImages-43ec34a9.js → UnsplashImages-afaa7706.js} +19 -28
  27. package/dist/add-page-modal-63858244.js +92 -0
  28. package/dist/add-page-modal-cb367c9d.cjs +1 -0
  29. package/dist/alert-dialog-4ce6ed22.cjs +1 -0
  30. package/dist/alert-dialog-ee98f47e.js +64 -0
  31. package/dist/confirm-alert-4f50caa7.cjs +1 -0
  32. package/dist/confirm-alert-f2a47cc7.js +36 -0
  33. package/dist/core.cjs +1 -1
  34. package/dist/core.d.ts +20 -12
  35. package/dist/core.js +53 -52
  36. package/dist/delete-page-modal-1e3914e3.cjs +1 -0
  37. package/dist/delete-page-modal-def9012d.js +64 -0
  38. package/dist/dropdown-menu-84b2439e.cjs +1 -0
  39. package/dist/dropdown-menu-ae3ed09b.js +164 -0
  40. package/dist/form-5d5c5c9e.js +125 -0
  41. package/dist/form-6eac0287.cjs +1 -0
  42. package/dist/{html-to-json-fecbbe16.js → html-to-json-9304dbda.js} +47 -47
  43. package/dist/html-to-json-9c9961da.cjs +1 -0
  44. package/dist/index-207f2cbf.cjs +2 -0
  45. package/dist/index-390f7bef.js +4749 -0
  46. package/dist/index-824a7bd0.js +188 -0
  47. package/dist/index-ebd86d7f.cjs +2 -0
  48. package/dist/input-42acea7e.cjs +1 -0
  49. package/dist/input-a0ea2bc7.js +19 -0
  50. package/dist/lib.cjs +1 -1
  51. package/dist/lib.js +3 -3
  52. package/dist/link-86c532b5.cjs +1 -0
  53. package/dist/{link-0bfd8606.js → link-f80a947d.js} +52 -68
  54. package/dist/mockServiceWorker.js +292 -0
  55. package/dist/page-viewer-41cbb548.js +88 -0
  56. package/dist/page-viewer-83ce2c70.cjs +1 -0
  57. package/dist/project-general-setting-0262fe62.js +65 -0
  58. package/dist/project-general-setting-2c8bed74.cjs +1 -0
  59. package/dist/project-seo-setting-01536592.js +67 -0
  60. package/dist/project-seo-setting-e3924578.cjs +1 -0
  61. package/dist/single-page-detail-924d57fc.js +206 -0
  62. package/dist/single-page-detail-cfeae896.cjs +1 -0
  63. package/dist/ui.cjs +1 -1
  64. package/dist/ui.js +124 -122
  65. package/dist/usePageActions-3bed2330.cjs +1 -0
  66. package/dist/usePageActions-f86f6f65.js +36 -0
  67. package/dist/useProjectActions-1de05f63.js +17 -0
  68. package/dist/useProjectActions-5092ed79.cjs +1 -0
  69. package/package.json +14 -1
  70. package/dist/AddBlocks-52d9b4d7.cjs +0 -3
  71. package/dist/AddBlocks-e047b93d.js +0 -260
  72. package/dist/CanvasArea-9ce217a4.cjs +0 -60
  73. package/dist/Class-0801d193.cjs +0 -1
  74. package/dist/Settings-6a3f0f70.cjs +0 -1
  75. package/dist/SidePanels-7fe6bebe.cjs +0 -1
  76. package/dist/UnsplashImages-1b2310ad.cjs +0 -1
  77. package/dist/dropdown-menu-a9b096f9.cjs +0 -1
  78. package/dist/dropdown-menu-d912a52e.js +0 -223
  79. package/dist/html-to-json-d8ac554d.cjs +0 -1
  80. package/dist/index-32d7b6e5.js +0 -2657
  81. package/dist/index-506fb888.cjs +0 -2
  82. package/dist/link-158970ee.cjs +0 -1
package/dist/ui.js CHANGED
@@ -1,29 +1,30 @@
1
1
  import { T as Fe, t as He } from "./toggle-00c9d11e.js";
2
- import { A as Ve, g as Ee, h as Be, b as Oe, f as qe, d as $e, c as Je, e as Ke, a as Qe, D as Ue, n as We, l as Xe, s as Ye, m as Ze, p as et, t as tt, x as at, o as ot, q as st, r as rt, u as nt, v as dt, w as it, k as lt, H as mt, j as ct, i as pt, S as ut } from "./dropdown-menu-d912a52e.js";
3
- import { B as xt, S as gt, a as bt, d as ht, f as yt, g as Nt, T as wt, e as Ct, b as St, r as vt, t as jt, h as Mt } from "./useBuilderProp-81a14920.js";
4
- import { A as Dt, c as kt, a as Rt, b as It } from "./accordion-c0176dc5.js";
5
- import { A as At, b as Pt, a as Lt, C as Gt, g as Ft, f as Ht, d as zt, c as Vt, e as Et, T as Bt } from "./textarea-0750bcd2.js";
2
+ import { D as Ve, f as Ee, d as Be, k as Oe, e as $e, h as qe, l as Je, p as Ke, g as Qe, i as Ue, j as We, m as Xe, n as Ye, o as Ze, c as et, H as tt, b as at, a as ot, S as st } from "./dropdown-menu-ae3ed09b.js";
3
+ import { B as nt, S as dt, a as it, d as lt, f as mt, g as ct, T as pt, e as ut, b as ft, r as xt, t as gt, h as bt } from "./useBuilderProp-81a14920.js";
4
+ import { A as yt, c as Nt, a as wt, b as Ct } from "./accordion-c0176dc5.js";
5
+ import { A as vt, b as jt, a as Mt, C as Tt, g as Dt, f as kt, d as Rt, c as It, e as _t, T as At } from "./textarea-0750bcd2.js";
6
6
  import { j as a } from "./jsx-runtime-944c88e2.js";
7
7
  import { cva as c } from "class-variance-authority";
8
8
  import { c as r } from "./utils-ac68b2c8.js";
9
+ import { A as Lt, g as Gt, h as Ft, b as Ht, f as zt, d as Vt, c as Et, e as Bt, a as Ot } from "./alert-dialog-ee98f47e.js";
9
10
  import { D as g, a as b } from "./dialog-3d4e82ed.js";
10
- import { f as qt, d as $t, c as Jt, e as Kt, b as Qt } from "./dialog-3d4e82ed.js";
11
- import { a as Wt, b as Xt, I as Yt, L as Zt, R as ea } from "./link-0bfd8606.js";
12
- import { L as aa } from "./label-e770a087.js";
13
- import { S as sa, a as ra } from "./scroll-area-9f64a082.js";
14
- import { T as da, c as ia, a as la, b as ma } from "./tabs-85caa1e8.js";
15
- import { P as pa, b as ua, a as fa } from "./popover-f7addcf4.js";
11
+ import { f as qt, d as Jt, c as Kt, e as Qt, b as Ut } from "./dialog-3d4e82ed.js";
12
+ import { I as Xt } from "./input-a0ea2bc7.js";
13
+ import { L as Zt } from "./label-e770a087.js";
14
+ import { S as ta, a as aa } from "./scroll-area-9f64a082.js";
15
+ import { T as sa, c as ra, a as na, b as da } from "./tabs-85caa1e8.js";
16
+ import { P as la, b as ma, a as ca } from "./popover-f7addcf4.js";
16
17
  import * as n from "react";
17
18
  import { ChevronRightIcon as h, CheckIcon as y, DotFilledIcon as N, Cross2Icon as w, MagnifyingGlassIcon as C } from "@radix-ui/react-icons";
18
19
  import * as s from "@radix-ui/react-menubar";
19
- import { S as ga, d as ba, a as ha, f as ya, e as Na, g as wa, c as Ca, b as Sa } from "./select-7fddd7c3.js";
20
+ import { S as ua, d as fa, a as xa, f as ga, e as ba, g as ha, c as ya, b as Na } from "./select-7fddd7c3.js";
20
21
  import * as d from "@radix-ui/react-dialog";
21
- import { S as ja } from "./separator-a80d065b.js";
22
+ import { S as Ca } from "./separator-a80d065b.js";
22
23
  import { Command as i } from "cmdk";
23
- import { C as Ta, d as Da, b as ka, i as Ra, c as Ia, f as _a, j as Aa, n as Pa, e as La, g as Ga, h as Fa, k as Ha, l as za, m as Va, a as Ea } from "./context-menu-e1c240ce.js";
24
+ import { C as va, d as ja, b as Ma, i as Ta, c as Da, f as ka, j as Ra, n as Ia, e as _a, g as Aa, h as Pa, k as La, l as Ga, m as Fa, a as Ha } from "./context-menu-e1c240ce.js";
25
+ import { I as Va, a as Ea, L as Ba, R as Oa } from "./link-f80a947d.js";
24
26
  import "@radix-ui/react-toggle";
25
27
  import "@radix-ui/react-switch";
26
- import "@radix-ui/react-alert-dialog";
27
28
  import "@radix-ui/react-hover-card";
28
29
  import "@radix-ui/react-dropdown-menu";
29
30
  import "@radix-ui/react-slot";
@@ -34,11 +35,7 @@ import "lodash";
34
35
  import "@radix-ui/react-accordion";
35
36
  import "clsx";
36
37
  import "tailwind-merge";
37
- import "react-icons-picker";
38
- import "react-dom";
39
- import "./ImagesPanel-6595528d.js";
40
- import "react-quill";
41
- import "react-i18next";
38
+ import "@radix-ui/react-alert-dialog";
42
39
  import "@radix-ui/react-label";
43
40
  import "@radix-ui/react-scroll-area";
44
41
  import "@radix-ui/react-tabs";
@@ -46,6 +43,11 @@ import "@radix-ui/react-popover";
46
43
  import "@radix-ui/react-select";
47
44
  import "@radix-ui/react-separator";
48
45
  import "@radix-ui/react-context-menu";
46
+ import "react-icons-picker";
47
+ import "react-dom";
48
+ import "./ImagesPanel-8ccab6d9.js";
49
+ import "react-quill";
50
+ import "react-i18next";
49
51
  const S = c(
50
52
  "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
51
53
  {
@@ -273,7 +275,7 @@ const B = n.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ a.jsx(
273
275
  B.displayName = i.List.displayName;
274
276
  const O = n.forwardRef((e, t) => /* @__PURE__ */ a.jsx(i.Empty, { ref: t, className: "py-6 text-center text-sm", ...e }));
275
277
  O.displayName = i.Empty.displayName;
276
- const q = n.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ a.jsx(
278
+ const $ = n.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ a.jsx(
277
279
  i.Group,
278
280
  {
279
281
  ref: o,
@@ -284,9 +286,9 @@ const q = n.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ a.jsx(
284
286
  ...t
285
287
  }
286
288
  ));
287
- q.displayName = i.Group.displayName;
288
- const $ = n.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ a.jsx(i.Separator, { ref: o, className: r("-mx-1 h-px bg-border", e), ...t }));
289
- $.displayName = i.Separator.displayName;
289
+ $.displayName = i.Group.displayName;
290
+ const q = n.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ a.jsx(i.Separator, { ref: o, className: r("-mx-1 h-px bg-border", e), ...t }));
291
+ q.displayName = i.Separator.displayName;
290
292
  const J = n.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ a.jsx(
291
293
  i.Item,
292
294
  {
@@ -302,84 +304,84 @@ J.displayName = i.Item.displayName;
302
304
  const K = ({ className: e, ...t }) => /* @__PURE__ */ a.jsx("span", { className: r("ml-auto text-xs tracking-widest text-muted-foreground", e), ...t });
303
305
  K.displayName = "CommandShortcut";
304
306
  export {
305
- Dt as Accordion,
306
- kt as AccordionContent,
307
- Rt as AccordionItem,
308
- It as AccordionTrigger,
309
- At as Alert,
310
- Pt as AlertDescription,
311
- Ve as AlertDialog,
312
- Ee as AlertDialogAction,
313
- Be as AlertDialogCancel,
314
- Oe as AlertDialogContent,
315
- qe as AlertDialogDescription,
316
- $e as AlertDialogFooter,
317
- Je as AlertDialogHeader,
318
- Ke as AlertDialogTitle,
319
- Qe as AlertDialogTrigger,
320
- Lt as AlertTitle,
307
+ yt as Accordion,
308
+ Nt as AccordionContent,
309
+ wt as AccordionItem,
310
+ Ct as AccordionTrigger,
311
+ vt as Alert,
312
+ jt as AlertDescription,
313
+ Lt as AlertDialog,
314
+ Gt as AlertDialogAction,
315
+ Ft as AlertDialogCancel,
316
+ Ht as AlertDialogContent,
317
+ zt as AlertDialogDescription,
318
+ Vt as AlertDialogFooter,
319
+ Et as AlertDialogHeader,
320
+ Bt as AlertDialogTitle,
321
+ Ot as AlertDialogTrigger,
322
+ Mt as AlertTitle,
321
323
  je as Badge,
322
- xt as Button,
323
- Gt as Card,
324
- Ft as CardContent,
325
- Ht as CardDescription,
326
- zt as CardFooter,
327
- Vt as CardHeader,
328
- Et as CardTitle,
324
+ nt as Button,
325
+ Tt as Card,
326
+ Dt as CardContent,
327
+ kt as CardDescription,
328
+ Rt as CardFooter,
329
+ It as CardHeader,
330
+ _t as CardTitle,
329
331
  f as Command,
330
332
  Pe as CommandDialog,
331
333
  O as CommandEmpty,
332
- q as CommandGroup,
334
+ $ as CommandGroup,
333
335
  E as CommandInput,
334
336
  J as CommandItem,
335
337
  B as CommandList,
336
- $ as CommandSeparator,
338
+ q as CommandSeparator,
337
339
  K as CommandShortcut,
338
- Ta as ContextMenu,
339
- Da as ContextMenuCheckboxItem,
340
- ka as ContextMenuContent,
341
- Ra as ContextMenuGroup,
342
- Ia as ContextMenuItem,
343
- _a as ContextMenuLabel,
344
- Aa as ContextMenuPortal,
345
- Pa as ContextMenuRadioGroup,
346
- La as ContextMenuRadioItem,
347
- Ga as ContextMenuSeparator,
348
- Fa as ContextMenuShortcut,
349
- Ha as ContextMenuSub,
350
- za as ContextMenuSubContent,
351
- Va as ContextMenuSubTrigger,
352
- Ea as ContextMenuTrigger,
340
+ va as ContextMenu,
341
+ ja as ContextMenuCheckboxItem,
342
+ Ma as ContextMenuContent,
343
+ Ta as ContextMenuGroup,
344
+ Da as ContextMenuItem,
345
+ ka as ContextMenuLabel,
346
+ Ra as ContextMenuPortal,
347
+ Ia as ContextMenuRadioGroup,
348
+ _a as ContextMenuRadioItem,
349
+ Aa as ContextMenuSeparator,
350
+ Pa as ContextMenuShortcut,
351
+ La as ContextMenuSub,
352
+ Ga as ContextMenuSubContent,
353
+ Fa as ContextMenuSubTrigger,
354
+ Ha as ContextMenuTrigger,
353
355
  g as Dialog,
354
356
  b as DialogContent,
355
357
  qt as DialogDescription,
356
- $t as DialogFooter,
357
- Jt as DialogHeader,
358
- Kt as DialogTitle,
359
- Qt as DialogTrigger,
360
- Ue as DropdownMenu,
361
- We as DropdownMenuCheckboxItem,
362
- Xe as DropdownMenuContent,
363
- Ye as DropdownMenuGroup,
364
- Ze as DropdownMenuItem,
365
- et as DropdownMenuLabel,
366
- tt as DropdownMenuPortal,
367
- at as DropdownMenuRadioGroup,
368
- ot as DropdownMenuRadioItem,
369
- st as DropdownMenuSeparator,
370
- rt as DropdownMenuShortcut,
371
- nt as DropdownMenuSub,
372
- dt as DropdownMenuSubContent,
373
- it as DropdownMenuSubTrigger,
374
- lt as DropdownMenuTrigger,
375
- mt as HoverCard,
376
- ct as HoverCardContent,
377
- pt as HoverCardTrigger,
378
- Wt as IconPickerField,
379
- Xt as ImagePickerField,
380
- Yt as Input,
381
- aa as Label,
382
- Zt as LinkField,
358
+ Jt as DialogFooter,
359
+ Kt as DialogHeader,
360
+ Qt as DialogTitle,
361
+ Ut as DialogTrigger,
362
+ Ve as DropdownMenu,
363
+ Ee as DropdownMenuCheckboxItem,
364
+ Be as DropdownMenuContent,
365
+ Oe as DropdownMenuGroup,
366
+ $e as DropdownMenuItem,
367
+ qe as DropdownMenuLabel,
368
+ Je as DropdownMenuPortal,
369
+ Ke as DropdownMenuRadioGroup,
370
+ Qe as DropdownMenuRadioItem,
371
+ Ue as DropdownMenuSeparator,
372
+ We as DropdownMenuShortcut,
373
+ Xe as DropdownMenuSub,
374
+ Ye as DropdownMenuSubContent,
375
+ Ze as DropdownMenuSubTrigger,
376
+ et as DropdownMenuTrigger,
377
+ tt as HoverCard,
378
+ at as HoverCardContent,
379
+ ot as HoverCardTrigger,
380
+ Va as IconPickerField,
381
+ Ea as ImagePickerField,
382
+ Xt as Input,
383
+ Zt as Label,
384
+ Ba as LinkField,
383
385
  v as Menubar,
384
386
  R as MenubarCheckboxItem,
385
387
  D as MenubarContent,
@@ -396,21 +398,21 @@ export {
396
398
  T as MenubarSubContent,
397
399
  M as MenubarSubTrigger,
398
400
  j as MenubarTrigger,
399
- pa as Popover,
400
- ua as PopoverContent,
401
- fa as PopoverTrigger,
402
- ea as RTEField,
403
- sa as ScrollArea,
404
- ra as ScrollBar,
405
- ga as Select,
406
- ba as SelectContent,
407
- ha as SelectGroup,
408
- ya as SelectItem,
409
- Na as SelectLabel,
410
- wa as SelectSeparator,
411
- Ca as SelectTrigger,
412
- Sa as SelectValue,
413
- ja as Separator,
401
+ la as Popover,
402
+ ma as PopoverContent,
403
+ ca as PopoverTrigger,
404
+ Oa as RTEField,
405
+ ta as ScrollArea,
406
+ aa as ScrollBar,
407
+ ua as Select,
408
+ fa as SelectContent,
409
+ xa as SelectGroup,
410
+ ga as SelectItem,
411
+ ba as SelectLabel,
412
+ ha as SelectSeparator,
413
+ ya as SelectTrigger,
414
+ Na as SelectValue,
415
+ Ca as Separator,
414
416
  Ie as Sheet,
415
417
  Ae as SheetClose,
416
418
  G as SheetContent,
@@ -419,24 +421,24 @@ export {
419
421
  F as SheetHeader,
420
422
  z as SheetTitle,
421
423
  _e as SheetTrigger,
422
- gt as Skeleton,
423
- ut as Switch,
424
- da as Tabs,
425
- ia as TabsContent,
426
- la as TabsList,
427
- ma as TabsTrigger,
428
- Bt as Textarea,
429
- bt as Toaster,
424
+ dt as Skeleton,
425
+ st as Switch,
426
+ sa as Tabs,
427
+ ra as TabsContent,
428
+ na as TabsList,
429
+ da as TabsTrigger,
430
+ At as Textarea,
431
+ it as Toaster,
430
432
  Fe as Toggle,
431
- ht as Tooltip,
432
- yt as TooltipContent,
433
- Nt as TooltipPortal,
434
- wt as TooltipProvider,
435
- Ct as TooltipTrigger,
433
+ lt as Tooltip,
434
+ mt as TooltipContent,
435
+ ct as TooltipPortal,
436
+ pt as TooltipProvider,
437
+ ut as TooltipTrigger,
436
438
  S as badgeVariants,
437
- St as buttonVariants,
438
- vt as reducer,
439
- jt as toast,
439
+ ft as buttonVariants,
440
+ xt as reducer,
441
+ gt as toast,
440
442
  He as toggleVariants,
441
- Mt as useToast
443
+ bt as useToast
442
444
  };
@@ -0,0 +1 @@
1
+ "use strict";const t=require("./index-ebd86d7f.cjs"),n=require("./index-207f2cbf.cjs");require("react-i18next");const a=require("./useBuilderProp-5e57d0c8.cjs"),c=()=>{const[s]=["SAVED"],[e,u]=t.useCurrentPage(),r=t.useBuilderReset();return i=>s==="UNSAVED"?(a.toast({variant:"destructive",title:"Please save unsaved changes"}),!1):e===i.uuid?!1:(r(),setTimeout(()=>{u(i.uuid)},100),!0)},d=()=>{const s=t.useQueryClient(),e=c();return n.useMutation({mutationFn:async u=>fetch("/pages",{method:"POST",body:JSON.stringify(u)}).then(r=>r.json()),onSuccess:u=>{s.invalidateQueries({queryKey:["pages"]}),e({uuid:u.uuid,slug:u.slug}),n.Nt.success("Page added successfully.")}})},o=()=>{const s=t.useQueryClient();return n.useMutation({mutationFn:async e=>fetch(`/page?uuid=${e.uuid}`,{method:"DELETE",body:JSON.stringify(e)}),onSuccess:()=>{n.Nt.success("Page deleted successfully."),s.invalidateQueries({queryKey:["pages"]})}})};exports.useAddPage=d;exports.useDeletePage=o;
@@ -0,0 +1,36 @@
1
+ import { a2 as c, a3 as o, X as n } from "./index-390f7bef.js";
2
+ import { u as r, N as i } from "./index-824a7bd0.js";
3
+ import "react-i18next";
4
+ import { t as d } from "./useBuilderProp-81a14920.js";
5
+ const g = () => {
6
+ const [t] = ["SAVED"], [e, s] = c(), u = o();
7
+ return (a) => t === "UNSAVED" ? (d({ variant: "destructive", title: "Please save unsaved changes" }), !1) : e === a.uuid ? !1 : (u(), setTimeout(() => {
8
+ s(a.uuid);
9
+ }, 100), !0);
10
+ }, P = () => {
11
+ const t = n(), e = g();
12
+ return r({
13
+ mutationFn: async (s) => fetch("/pages", {
14
+ method: "POST",
15
+ body: JSON.stringify(s)
16
+ }).then((u) => u.json()),
17
+ onSuccess: (s) => {
18
+ t.invalidateQueries({ queryKey: ["pages"] }), e({ uuid: s.uuid, slug: s.slug }), i.success("Page added successfully.");
19
+ }
20
+ });
21
+ }, h = () => {
22
+ const t = n();
23
+ return r({
24
+ mutationFn: async (e) => fetch(`/page?uuid=${e.uuid}`, {
25
+ method: "DELETE",
26
+ body: JSON.stringify(e)
27
+ }),
28
+ onSuccess: () => {
29
+ i.success("Page deleted successfully."), t.invalidateQueries({ queryKey: ["pages"] });
30
+ }
31
+ });
32
+ };
33
+ export {
34
+ h as a,
35
+ P as u
36
+ };
@@ -0,0 +1,17 @@
1
+ import { X as u, Y as o } from "./index-390f7bef.js";
2
+ import { u as a, N as c } from "./index-824a7bd0.js";
3
+ const p = (e = "Project updated successfully.") => {
4
+ const s = u(), t = o();
5
+ return a({
6
+ mutationFn: async (r) => await fetch(`${t}/project`, {
7
+ method: "PUT",
8
+ body: JSON.stringify(r)
9
+ }),
10
+ onSuccess: () => {
11
+ s.invalidateQueries({ queryKey: ["project"] }), c.success(e);
12
+ }
13
+ });
14
+ };
15
+ export {
16
+ p as u
17
+ };
@@ -0,0 +1 @@
1
+ "use strict";const e=require("./index-ebd86d7f.cjs"),t=require("./index-207f2cbf.cjs"),n=(s="Project updated successfully.")=>{const c=e.useQueryClient(),r=e.useApiBaseUrl();return t.useMutation({mutationFn:async u=>await fetch(`${r}/project`,{method:"PUT",body:JSON.stringify(u)}),onSuccess:()=>{c.invalidateQueries({queryKey:["project"]}),t.Nt.success(s)}})};exports.useUpdateProject=n;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chaibuilder/sdk",
3
3
  "private": false,
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -83,6 +83,7 @@
83
83
  "@tailwindcss/forms": "^0.5.6",
84
84
  "@tailwindcss/line-clamp": "^0.4.4",
85
85
  "@tailwindcss/typography": "^0.5.10",
86
+ "@tanstack/react-query": "^5.8.4",
86
87
  "analytics": "^0.8.9",
87
88
  "class-variance-authority": "0.6.1",
88
89
  "clsx": "1.2.1",
@@ -117,6 +118,7 @@
117
118
  "react-textarea-autosize": "^8.5.2",
118
119
  "react-wrap-balancer": "^1.0.0",
119
120
  "redux-undo": "1.1.0",
121
+ "sonner": "^1.2.0",
120
122
  "tailwind-merge": "1.13.2",
121
123
  "tailwindcss-animate": "1.0.6",
122
124
  "tippy.js": "^6.3.7",
@@ -126,7 +128,11 @@
126
128
  "devDependencies": {
127
129
  "@commitlint/cli": "17.7.1",
128
130
  "@commitlint/config-conventional": "17.7.0",
131
+ "@faker-js/faker": "^8.3.1",
132
+ "@nozbe/watermelondb": "^0.27.1",
129
133
  "@playwright/test": "^1.39.0",
134
+ "@tanstack/eslint-plugin-query": "^5.8.4",
135
+ "@types/better-sqlite3": "^7.6.7",
130
136
  "@types/jest": "^29.5.7",
131
137
  "@types/lodash": "^4.14.200",
132
138
  "@types/node": "^20.8.10",
@@ -137,12 +143,16 @@
137
143
  "@vitejs/plugin-react-swc": "^3.3.2",
138
144
  "autoprefixer": "^10.4.16",
139
145
  "better-docs": "^2.7.2",
146
+ "better-sqlite3": "^9.1.1",
147
+ "drizzle-kit": "^0.20.4",
148
+ "drizzle-orm": "^0.29.0",
140
149
  "eslint": "^8.45.0",
141
150
  "eslint-plugin-react-hooks": "^4.6.0",
142
151
  "eslint-plugin-react-refresh": "^0.4.3",
143
152
  "jest": "^29.7.0",
144
153
  "jest-environment-jsdom": "^29.7.0",
145
154
  "jsdoc": "^4.0.2",
155
+ "msw": "^2.0.8",
146
156
  "postcss": "^8.4.31",
147
157
  "prettier": "^3.0.3",
148
158
  "prettier-plugin-tailwindcss": "^0.5.6",
@@ -152,5 +162,8 @@
152
162
  "typescript": "^5.0.2",
153
163
  "vite": "^4.4.5",
154
164
  "vite-plugin-dts": "^3.6.3"
165
+ },
166
+ "msw": {
167
+ "workerDirectory": "public"
155
168
  }
156
169
  }
@@ -1,3 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),a=require("react"),s=require("lodash"),g=require("jotai"),k=require("./accordion-0afd8143.cjs"),C=require("./scroll-area-088530b9.cjs"),y=require("./tabs-860e37aa.cjs"),E=require("./useBuilderProp-5e57d0c8.cjs"),B=require("react-dnd"),v=require("@radix-ui/react-icons"),n=require("./index-506fb888.cjs");require("react-i18next");const w=require("@chaibuilder/blocks"),N=require("lucide-react"),q=require("./utils-3c452dd0.cjs"),f=require("./textarea-a338ede6.cjs"),I=require("./label-167415e5.cjs"),P=require("./html-to-json-d8ac554d.cjs");require("@radix-ui/react-accordion");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("i18next");require("flagged");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-0801d193.cjs");require("redux-undo");require("@react-hookz/web");require("./CONTROLS-031e1de3.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-label");require("himalaya");const L=({block:t})=>{const{type:r,icon:l,label:d}=t,{addCoreBlock:u,addPredefinedBlock:p}=n.useAddBlock(),[j]=n.useSelectedBlockIds(),[,x]=g.useAtom(n.activePanelAtom),[,i]=g.useAtom(n.addBlocksModalAtom),b=()=>{s.has(t,"blocks")?p(w.syncBlocksWithDefaults(t.blocks),s.first(j)):u(t,s.first(j)),i(!1),x("layers")},[,h,c]=B.useDrag(()=>({type:"CHAI_BLOCK",item:t}));return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(B.DragPreviewImage,{connect:c,src:"https://placehold.co/100x30/000000/FFF?text="+(d||r).replace(/ /g,"+")}),e.jsxRuntimeExports.jsxs(E.Tooltip,{children:[e.jsxRuntimeExports.jsx(E.TooltipTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs("button",{onClick:b,type:"button",ref:h,className:"cursor-grab space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50",children:[a.createElement(l||v.BoxIcon,{className:"w-4 h-4 mx-auto"}),e.jsxRuntimeExports.jsx("p",{className:"truncate text-xs",children:d||r})]})}),e.jsxRuntimeExports.jsx(E.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{children:d||r})})]})]})},S=({block:t,closePopover:r})=>{var c;const[l,d]=a.useState(!1),u=E.useBuilderProp("getExternalPredefinedBlock"),{addCoreBlock:p,addPredefinedBlock:j}=n.useAddBlock(),[x]=n.useSelectedBlockIds(),[,i,b]=B.useDrag(()=>({type:"CHAI_BLOCK",item:t}),[t]),h=a.useCallback(async R=>{if(R.stopPropagation(),s.has(t,"component")){p(t,s.first(x)),r();return}d(!0);const o=await u(t);s.isEmpty(o)||j(w.syncBlocksWithDefaults(o),s.first(x)),r()},[t]);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(B.DragPreviewImage,{connect:b,src:"https://placehold.co/100x30/000000/FFF?text="+((c=t.name||t.label)==null?void 0:c.replace(" ","+"))}),e.jsxRuntimeExports.jsxs("div",{ref:i,onClick:l?()=>{}:h,className:"relative cursor-grab overflow-hidden rounded-md border border-transparent duration-200 hover:scale-x-105 hover:border-foreground/20 hover:shadow-2xl",children:[l&&e.jsxRuntimeExports.jsxs("div",{className:"absolute flex h-full w-full items-center justify-center bg-black bg-opacity-70",children:[e.jsxRuntimeExports.jsx(N.Loader,{className:"animate-spin",size:15,color:"white"})," ",e.jsxRuntimeExports.jsx("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),t.preview?e.jsxRuntimeExports.jsx("img",{src:t.preview,className:"min-h-[50px] w-full rounded-md border border-gray-300",alt:t.name}):e.jsxRuntimeExports.jsx("div",{className:"flex h-20 items-center justify-center rounded-md border border-border border-gray-300 bg-gray-200",children:e.jsxRuntimeExports.jsx("p",{className:"max-w-xs text-center text-sm text-gray-700",children:t.name})})]})]})},M=()=>{const{data:t,isLoading:r}=n.useUILibraryBlocks(),l=w.useChaiBlocks(),d=s.filter(s.values(l),{category:"custom"}),u=s.groupBy(d,"group"),p=s.groupBy(t,"group"),[j,x]=a.useState(null),i=a.useMemo(()=>s.mergeWith(u,p,(o,m)=>{if(s.isArray(o)&&s.isArray(m))return[...o,...m]}),[u,p]),[,b]=g.useAtom(n.addBlocksModalAtom),[h,c]=a.useState("Navbar"),R=s.get(i,h,[]);return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full max-h-full overflow-hidden py-2",children:[e.jsxRuntimeExports.jsx("ul",{className:"sticky top-0 h-full w-48 space-y-1 overflow-y-auto border-r px-2",children:r?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("li",{className:"h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"})]}):a.Children.toArray(s.map(i,(o,m)=>e.jsxRuntimeExports.jsx("li",{onMouseOut:()=>{clearTimeout(j),x(null)},onMouseEnter:()=>{const A=setTimeout(()=>{c(m)},300);x(A)},onClick:()=>c(m),className:q.cn("-mx-2 cursor-default rounded-md rounded-r-none px-2 py-1 text-sm font-medium capitalize",h===m?"bg-blue-500 text-white":" text-gray-700 hover:bg-foreground/10"),children:m})))}),e.jsxRuntimeExports.jsx("div",{className:"h-full w-full space-y-2 overflow-y-auto px-8",children:a.Children.toArray(R.map(o=>e.jsxRuntimeExports.jsx(S,{block:o,closePopover:()=>b(!1)})))})]})},F=()=>{const[t,r]=a.useState(""),{addPredefinedBlock:l}=n.useAddBlock(),[d]=n.useSelectedBlockIds(),[,u]=g.useAtom(n.addBlockOffCanvasAtom),[,p]=g.useAtom(n.activePanelAtom),[,j]=g.useAtom(n.addBlocksModalAtom),x=()=>{const i=P.getBlocksFromHTML(t);l([...i],s.first(d)||null),r(""),u(!1),p("layers"),j(!1)};return e.jsxRuntimeExports.jsxs(f.Card,{className:"border-border/0 p-0 shadow-none",children:[e.jsxRuntimeExports.jsxs(f.CardHeader,{className:"p-3",children:[e.jsxRuntimeExports.jsx(f.CardTitle,{children:"Import HTML"}),e.jsxRuntimeExports.jsx(f.CardDescription,{children:"Use HTML snippets from component libraries like Tailwind UI, Flowbite, Preline, Kitwind, Tailblocks etc. or just copy paste your own HTML code. Only Tailwind CSS markup is supported."})]}),e.jsxRuntimeExports.jsx(f.CardContent,{className:"space-y-2 px-3 py-0",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(I.Label,{htmlFor:"current",className:"text-sm",children:"Enter HTML Code:"}),e.jsxRuntimeExports.jsx(f.Textarea,{autoFocus:!0,tabIndex:1,ref:i=>i&&i.focus(),defaultValue:t,onChange:i=>r(i.target.value),rows:12,placeholder:`<div>
2
- <h1>Enter code here</h1>
3
- </div>`,className:"resize-none overflow-x-auto whitespace-pre font-mono font-normal"})]})}),e.jsxRuntimeExports.jsxs(f.CardFooter,{className:"flex flex-col justify-end p-3",children:[e.jsxRuntimeExports.jsx(E.Button,{disabled:t.trim()==="",onClick:()=>x(),size:"sm",className:"w-full",children:"Import"}),e.jsxRuntimeExports.jsxs(f.Alert,{variant:"default",className:"mt-2 p-1 text-blue-400",children:[e.jsxRuntimeExports.jsx(v.ExclamationTriangleIcon,{className:"h-4 w-4"}),e.jsxRuntimeExports.jsx(f.AlertTitle,{className:"text-sm leading-4",children:"Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page."})]})]})]})},H=F,T=["ListItem","TableHead","TableBody","TableRow","TableCell","Column"],D=(t,r)=>{if(!t)return!s.includes(T,r);const l=t._type;return l==="List"?r==="ListItem":l==="Table"?r==="TableHead"||r==="TableBody":l==="TableHead"||l==="TableBody"?r==="TableRow":l==="TableRow"?r==="TableCell":l==="Row"?r==="Column":!s.includes(T,r)},O=()=>{const[t,r]=a.useState("core"),[l,d]=a.useState("basic"),u=w.useChaiBlocks(),[,p]=g.useAtom(n.showPredefinedBlockCategoryAtom),[,j]=g.useAtom(n.addBlocksModalAtom),[x]=n.useSelectedBlockIds(),i=n.useAllBlocks(),b=s.find(i,{_id:s.first(x)});console.log("chaiBlocks",u);const h=s.groupBy(s.filter(u,o=>D(b,o.type)),"category"),c=s.uniq(s.map(h.core,"group"));a.useEffect(()=>{!s.includes(c,l)&&!s.isEmpty(c)&&!s.isEmpty(l)&&d(s.first(c))},[c,l]);const R=o=>d(m=>m===o?"":o);return e.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-2 flex justify-between rounded-md bg-background/30 p-1",children:[e.jsxRuntimeExports.jsxs("h1",{className:"flex flex-col items-baseline px-1 text-2xl font-semibold xl:flex-row",children:["Add block",e.jsxRuntimeExports.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:t==="html"?"(Enter or paste your own HTML code)":"(Drag & drop into tree view or click to add)"})]}),e.jsxRuntimeExports.jsxs("button",{onClick:()=>j(!1),className:"flex h-max items-center gap-x-1 rounded-full border p-px text-xs text-gray-800 hover:bg-gray-100 md:p-2",children:[e.jsxRuntimeExports.jsx(v.Cross1Icon,{width:12})," Close"]})]}),e.jsxRuntimeExports.jsx(y.Tabs,{onValueChange:o=>{p(""),r(o)},value:t,className:"h-max",children:e.jsxRuntimeExports.jsxs(y.TabsList,{className:"grid w-full grid-cols-3",children:[e.jsxRuntimeExports.jsx(y.TabsTrigger,{value:"core",children:"Core"}),e.jsxRuntimeExports.jsx(y.TabsTrigger,{value:"ui-blocks",children:"UI Blocks"}),e.jsxRuntimeExports.jsx(y.TabsTrigger,{value:"html",children:"Import"})]})}),t==="core"&&e.jsxRuntimeExports.jsx(C.ScrollArea,{className:"-mx-1.5 h-full",children:e.jsxRuntimeExports.jsx(k.Accordion,{type:"single",value:l,className:"w-full px-3",children:a.Children.toArray(s.map(c,o=>s.reject(s.filter(s.values(h.core),{group:o}),{hidden:!0}).length?e.jsxRuntimeExports.jsxs(k.AccordionItem,{value:o,className:"border-border",children:[e.jsxRuntimeExports.jsx(k.AccordionTrigger,{onClick:()=>R(o),className:"py-2 capitalize",children:o}),e.jsxRuntimeExports.jsx(k.AccordionContent,{children:e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-4 gap-2",children:a.Children.toArray(s.reject(s.filter(s.values(h.core),{group:o}),{hidden:!0}).map(m=>e.jsxRuntimeExports.jsx(L,{block:m})))})})]}):null))})}),t==="ui-blocks"&&e.jsxRuntimeExports.jsx(a.Suspense,{fallback:e.jsxRuntimeExports.jsx(E.Skeleton,{className:"h-32 w-full"}),children:e.jsxRuntimeExports.jsx(M,{})}),t==="html"&&e.jsxRuntimeExports.jsx(H,{})]})};exports.default=O;