@chaibuilder/sdk 2.3.4 → 2.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.d.ts CHANGED
@@ -702,6 +702,7 @@ export declare const useRightPanel: () => ["block" | "theme" | "ai" | "settings"
702
702
 
703
703
  export declare const useSavePage: () => {
704
704
  savePage: ThrottledFunction<(autoSave?: boolean) => Promise<boolean>>;
705
+ savePageAsync: () => Promise<boolean>;
705
706
  saveState: "SAVED" | "SAVING" | "UNSAVED";
706
707
  setSaveState: (args_0: "SAVED" | "SAVING" | "UNSAVED" | ((prev: "SAVED" | "SAVING" | "UNSAVED") => "SAVED" | "SAVING" | "UNSAVED")) => void;
707
708
  };
package/dist/core.js CHANGED
@@ -10,7 +10,7 @@ import React__default, { useMemo, useCallback, useEffect, useState, useRef, Comp
10
10
  import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
11
11
  import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
12
12
  import { g as generateUUID, a as getBreakpointValue, c as cn$2 } from "./common-functions-BGzDsf1z.js";
13
- import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b9 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b5 as Tooltip, b8 as TooltipTrigger, ay as PopoverTrigger, b6 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b2 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, a_ as Tabs, b0 as TabsList, b1 as TabsTrigger, a$ as TabsContent, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, aZ as Switch, r as Avatar, aL as Separator, b7 as TooltipProvider, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle, aY as Toaster } from "./toggle-DW7GHkUt.js";
13
+ import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b8 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b1 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, aY as Switch, r as Avatar, aL as Separator, b6 as TooltipProvider, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./toggle-BKtuoy5e.js";
14
14
  import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
15
15
  import clsx$1, { clsx } from "clsx";
16
16
  import { twMerge } from "tailwind-merge";
@@ -19,9 +19,9 @@ import { C as COLLECTION_PREFIX, S as STYLES_KEY, f as getSplitChaiClasses, a as
19
19
  import { d as defaultThemeOptions, f as defaultThemeValues, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, h as getThemeFontsUrls, i as getThemeCustomFontFace } from "./plugin-BOcGV_IY.js";
20
20
  import { isObject } from "@rjsf/utils";
21
21
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
22
- import { toast } from "sonner";
22
+ import { toast, Toaster } from "sonner";
23
23
  import { useTranslation, initReactI18next } from "react-i18next";
24
- import { useTranslation as Ve } from "react-i18next";
24
+ import { useTranslation as Ue } from "react-i18next";
25
25
  import Fuse from "fuse.js";
26
26
  import UndoManager from "undo-manager";
27
27
  import Link from "@tiptap/extension-link";
@@ -37,7 +37,7 @@ import { useFeature } from "flagged";
37
37
  import { parse, stringify } from "himalaya";
38
38
  import { Tree } from "react-arborist";
39
39
  import i18n from "i18next";
40
- import { default as ze } from "i18next";
40
+ import { default as We } from "i18next";
41
41
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
42
42
  import tailwindForms from "@tailwindcss/forms";
43
43
  import tailwindTypography from "@tailwindcss/typography";
@@ -46,7 +46,6 @@ import "@mhsdesign/jit-browser-tailwindcss";
46
46
  import twContainer from "@tailwindcss/container-queries";
47
47
  import { ErrorBoundary } from "react-error-boundary";
48
48
  import { motion } from "framer-motion";
49
- import "next-themes";
50
49
  import { useHotkeys } from "react-hotkeys-hook";
51
50
  import { flip } from "@floating-ui/dom";
52
51
  import { useFloating, shift } from "@floating-ui/react-dom";
@@ -728,17 +727,17 @@ const useBrandingOptions = () => {
728
727
  }, rightPanelAtom = atom("block"), useRightPanel = () => useAtom$1(rightPanelAtom), builderSaveStateAtom = atom("SAVED");
729
728
  builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
730
729
  const useSavePage = () => {
731
- const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (p) => {
730
+ const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (u) => {
732
731
  }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions();
733
732
  return { savePage: useThrottledCallback(
734
- async (p = !1) => {
733
+ async (u = !1) => {
735
734
  if (!c("save_page"))
736
735
  return;
737
736
  n("SAVING"), a("SAVING");
738
- const u = l();
737
+ const g = l();
739
738
  return await r({
740
- autoSave: p,
741
- blocks: u.blocks,
739
+ autoSave: u,
740
+ blocks: g.blocks,
742
741
  theme: i
743
742
  }), setTimeout(() => {
744
743
  n("SAVED"), a("SAVED");
@@ -747,7 +746,19 @@ const useSavePage = () => {
747
746
  [l, n, i, r, a],
748
747
  3e3
749
748
  // save only every 5 seconds
750
- ), saveState: o, setSaveState: n };
749
+ ), savePageAsync: async () => {
750
+ if (!c("save_page"))
751
+ return;
752
+ n("SAVING"), a("SAVING");
753
+ const u = l();
754
+ return await r({
755
+ autoSave: !0,
756
+ blocks: u.blocks,
757
+ theme: i
758
+ }), setTimeout(() => {
759
+ n("SAVED"), a("SAVED");
760
+ }, 100), !0;
761
+ }, saveState: o, setSaveState: n };
751
762
  }, undoManager = new UndoManager();
752
763
  undoManager.setLimit(50);
753
764
  const undoRedoStateAtom = atom({
@@ -3822,7 +3833,7 @@ const CanvasEventsWatcher = () => {
3822
3833
  }, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
3823
3834
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
3824
3835
  /* @__PURE__ */ jsx("p", { children: "Please try again." })
3825
- ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-BqhH_IQC.js")), CanvasArea = () => {
3836
+ ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-CJfScsxg.js")), CanvasArea = () => {
3826
3837
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
3827
3838
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
3828
3839
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -9364,7 +9375,7 @@ const AiAssistant = () => {
9364
9375
  "button",
9365
9376
  {
9366
9377
  type: "button",
9367
- className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
9378
+ className: " p-0.5 rounded-sm hover:bg-gray-300",
9368
9379
  onClick: (r) => r.stopPropagation(),
9369
9380
  children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
9370
9381
  }
@@ -9426,10 +9437,10 @@ const SettingsPanel = () => {
9426
9437
  ] }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "settings", className: "flex flex-1 flex-col", children: [
9427
9438
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
9428
9439
  /* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: "Settings" }),
9429
- /* @__PURE__ */ jsxs(TabsTrigger, { value: "styles", className: "flex items-center justify-between text-xs", children: [
9430
- "Styles",
9431
- /* @__PURE__ */ jsx(ResetStylesButton, {})
9432
- ] })
9440
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "styles", className: "text-xs", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
9441
+ /* @__PURE__ */ jsx("span", { className: "w-[90%] text-center", children: "Styles" }),
9442
+ /* @__PURE__ */ jsx("span", { className: "w-[10%]", children: /* @__PURE__ */ jsx(ResetStylesButton, {}) })
9443
+ ] }) })
9433
9444
  ] }) }),
9434
9445
  /* @__PURE__ */ jsxs(TabsContent, { value: "settings", className: "no-scrollbar h-full max-h-min overflow-y-auto", children: [
9435
9446
  /* @__PURE__ */ jsx(BlockSettings, {}),
@@ -10306,7 +10317,7 @@ export {
10306
10317
  getBlocksFromHTML as convertHTMLToChaiBlocks,
10307
10318
  generateUUID as generateBlockId,
10308
10319
  getBlocksFromHTML,
10309
- ze as i18n,
10320
+ We as i18n,
10310
10321
  cn$2 as mergeClasses,
10311
10322
  registerBlockSettingField,
10312
10323
  registerBlockSettingTemplate,
@@ -10370,7 +10381,7 @@ export {
10370
10381
  useTheme,
10371
10382
  useThemeOptions,
10372
10383
  useToggleChaiFeatureFlag,
10373
- Ve as useTranslation,
10384
+ Ue as useTranslation,
10374
10385
  useUndoManager,
10375
10386
  useUpdateBlocksProps,
10376
10387
  useUpdateBlocksPropsRealtime,