@chaibuilder/sdk 2.5.7 → 2.5.9
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/{code-editor-0HrsuGAE.js → code-editor-CAnkmeVK.js} +1 -1
- package/dist/{code-editor-67qfXwGU.cjs → code-editor-D5TOcelm.cjs} +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.d.ts +1 -3
- package/dist/core.js +749 -727
- package/dist/{css-import-modal-CcUf6F6T.js → css-import-modal-Ds-qmte_.js} +99 -90
- package/dist/{css-import-modal-CdOK43Be.cjs → css-import-modal-w1WZrKpm.cjs} +2 -2
- package/dist/{toggle-BgZfmuec.cjs → toggle-CCqv4Cah.cjs} +1 -1
- package/dist/{toggle-CyXEVUOu.js → toggle-DXTcRcvD.js} +60 -60
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +123 -119
- package/package.json +2 -2
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, 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, a9 as DialogTitle, 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, B as Badge, b6 as TooltipProvider, 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, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch, 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,
|
|
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, a9 as DialogTitle, 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, B as Badge, b6 as TooltipProvider, 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, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch, r as Avatar, 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, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./toggle-DXTcRcvD.js";
|
|
14
14
|
import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, Edit2Icon, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, Info, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Undo as Undo$1, ImportIcon, Type, CornerUpRight, Palette, Sun, Moon, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Layers } from "lucide-react";
|
|
15
15
|
import clsx$1, { clsx } from "clsx";
|
|
16
16
|
import { twMerge } from "tailwind-merge";
|
|
@@ -343,16 +343,16 @@ function insertBlocksAtPosition(o, r, n, a) {
|
|
|
343
343
|
_type: "Text",
|
|
344
344
|
content: u.content
|
|
345
345
|
};
|
|
346
|
-
Object.keys(u).forEach((
|
|
347
|
-
|
|
348
|
-
}), l.unshift(m), i = i.map((
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
return Object.keys(
|
|
352
|
-
|
|
353
|
-
}),
|
|
346
|
+
Object.keys(u).forEach((x) => {
|
|
347
|
+
x.startsWith("content-") && (m[x] = u[x]);
|
|
348
|
+
}), l.unshift(m), i = i.map((x) => {
|
|
349
|
+
if (x._id === n) {
|
|
350
|
+
const f = { ...x, content: "" };
|
|
351
|
+
return Object.keys(f).forEach((k) => {
|
|
352
|
+
k.startsWith("content-") && (f[k] = "");
|
|
353
|
+
}), f;
|
|
354
354
|
}
|
|
355
|
-
return
|
|
355
|
+
return x;
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
358
|
}
|
|
@@ -480,15 +480,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
480
480
|
if (g.length === 2) {
|
|
481
481
|
const h = g.find((m) => m._id !== d);
|
|
482
482
|
if (h && h._type === "Text") {
|
|
483
|
-
const m = n.find((
|
|
484
|
-
m && "content" in m && (n = n.map((
|
|
485
|
-
if (
|
|
486
|
-
const
|
|
487
|
-
return Object.keys(h).forEach((
|
|
488
|
-
|
|
489
|
-
}),
|
|
483
|
+
const m = n.find((x) => x._id === u);
|
|
484
|
+
m && "content" in m && (n = n.map((x) => {
|
|
485
|
+
if (x._id === u) {
|
|
486
|
+
const f = { ...x, content: h.content };
|
|
487
|
+
return Object.keys(h).forEach((k) => {
|
|
488
|
+
k.startsWith("content-") && (f[k] = h[k]);
|
|
489
|
+
}), f;
|
|
490
490
|
}
|
|
491
|
-
return
|
|
491
|
+
return x;
|
|
492
492
|
}), a.push(h._id));
|
|
493
493
|
}
|
|
494
494
|
}
|
|
@@ -571,32 +571,32 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
571
571
|
status: "idle",
|
|
572
572
|
props: {},
|
|
573
573
|
error: void 0
|
|
574
|
-
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (
|
|
574
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, n ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), h = (o == null ? void 0 : o._type) !== "Repeater" && r === "live";
|
|
575
575
|
return useEffect(() => {
|
|
576
576
|
if (r === "mock") {
|
|
577
577
|
if (isFunction(a)) {
|
|
578
|
-
i((
|
|
579
|
-
const
|
|
580
|
-
if (!isObject(
|
|
578
|
+
i((f) => ({ ...f, status: "loading", props: {} }));
|
|
579
|
+
const x = a({ block: o });
|
|
580
|
+
if (!isObject(x))
|
|
581
581
|
throw new Error("mockDataProvider should return an object");
|
|
582
|
-
i((
|
|
582
|
+
i((f) => ({ ...f, status: "loaded", props: x }));
|
|
583
583
|
}
|
|
584
584
|
return;
|
|
585
585
|
}
|
|
586
|
-
r === "live" && (!g && !h || (i((
|
|
587
|
-
g ? (p((
|
|
588
|
-
...
|
|
586
|
+
r === "live" && (!g && !h || (i((x) => ({ ...x, status: "loading", props: {} })), d({ block: o }).then((x = {}) => {
|
|
587
|
+
g ? (p((f) => ({
|
|
588
|
+
...f,
|
|
589
589
|
[o._id]: {
|
|
590
590
|
status: "loaded",
|
|
591
|
-
props: get(
|
|
591
|
+
props: get(x, "items", []),
|
|
592
592
|
repeaterItems: o.repeaterItems
|
|
593
593
|
}
|
|
594
|
-
})), i((
|
|
595
|
-
}).catch((
|
|
596
|
-
g ? (p((
|
|
597
|
-
...
|
|
598
|
-
[o._id]: { status: "error", error:
|
|
599
|
-
})), i((
|
|
594
|
+
})), i((f) => ({ ...f, status: "loaded", props: { totalItems: get(x, "totalItems") } })), c([o._id], { totalItems: get(x, "totalItems") })) : i((f) => ({ ...f, status: "loaded", props: isObject(x) ? x : {} }));
|
|
595
|
+
}).catch((x) => {
|
|
596
|
+
g ? (p((f) => ({
|
|
597
|
+
...f,
|
|
598
|
+
[o._id]: { status: "error", error: x, props: [] }
|
|
599
|
+
})), i((f) => ({ ...f, status: "error", error: x, props: {} }))) : i((f) => ({ ...f, status: "error", error: x, props: {} }));
|
|
600
600
|
})));
|
|
601
601
|
}, [o == null ? void 0 : o._id, u, g, h, a, r]), {
|
|
602
602
|
$loading: get(l, "status") === "loading",
|
|
@@ -736,10 +736,7 @@ const useLanguages = () => {
|
|
|
736
736
|
selectedLang: n,
|
|
737
737
|
setSelectedLang: l
|
|
738
738
|
};
|
|
739
|
-
}, isPageLoadedAtom = atom(!1), useIsPageLoaded = () =>
|
|
740
|
-
const [o] = useAtom$1(isPageLoadedAtom);
|
|
741
|
-
return o;
|
|
742
|
-
}, builderSaveStateAtom = atom("SAVED");
|
|
739
|
+
}, isPageLoadedAtom = atom(!1), useIsPageLoaded = () => useAtom$1(isPageLoadedAtom), builderSaveStateAtom = atom("SAVED");
|
|
743
740
|
builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
|
|
744
741
|
const checkMissingTranslations = (o, r) => r ? o.some((n) => {
|
|
745
742
|
if (!(n != null && n._type) || n._type === "PartialBlock")
|
|
@@ -754,20 +751,20 @@ const checkMissingTranslations = (o, r) => r ? o.some((n) => {
|
|
|
754
751
|
return console.warn(`Failed to get block definition for type: ${n._type}`, a), !1;
|
|
755
752
|
}
|
|
756
753
|
}) : !1, useSavePage = () => {
|
|
757
|
-
const [o, r] = useAtom$1(builderSaveStateAtom), n = useBuilderProp("onSave", async (
|
|
758
|
-
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useIsPageLoaded(), g = () => {
|
|
759
|
-
const
|
|
760
|
-
return !d || d === p ? !1 : checkMissingTranslations(
|
|
754
|
+
const [o, r] = useAtom$1(builderSaveStateAtom), n = useBuilderProp("onSave", async (x) => {
|
|
755
|
+
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
|
|
756
|
+
const x = l();
|
|
757
|
+
return !d || d === p ? !1 : checkMissingTranslations(x.blocks || [], d);
|
|
761
758
|
};
|
|
762
759
|
return { savePage: useThrottledCallback(
|
|
763
|
-
async (
|
|
760
|
+
async (x = !1) => {
|
|
764
761
|
if (!c("save_page") || !u)
|
|
765
762
|
return;
|
|
766
763
|
r("SAVING"), a("SAVING");
|
|
767
|
-
const
|
|
764
|
+
const f = l();
|
|
768
765
|
return await n({
|
|
769
|
-
autoSave:
|
|
770
|
-
blocks:
|
|
766
|
+
autoSave: x,
|
|
767
|
+
blocks: f.blocks,
|
|
771
768
|
theme: i,
|
|
772
769
|
needTranslations: g()
|
|
773
770
|
}), setTimeout(() => {
|
|
@@ -781,10 +778,10 @@ const checkMissingTranslations = (o, r) => r ? o.some((n) => {
|
|
|
781
778
|
if (!c("save_page") || !u)
|
|
782
779
|
return;
|
|
783
780
|
r("SAVING"), a("SAVING");
|
|
784
|
-
const
|
|
781
|
+
const x = l();
|
|
785
782
|
return await n({
|
|
786
783
|
autoSave: !0,
|
|
787
|
-
blocks:
|
|
784
|
+
blocks: x.blocks,
|
|
788
785
|
theme: i,
|
|
789
786
|
needTranslations: g()
|
|
790
787
|
}), setTimeout(() => {
|
|
@@ -842,65 +839,65 @@ const undoRedoStateAtom = atom({
|
|
|
842
839
|
updateBlocksProps: c
|
|
843
840
|
} = useBlocksStoreManager();
|
|
844
841
|
return {
|
|
845
|
-
moveBlocks: (
|
|
846
|
-
const A = map(
|
|
842
|
+
moveBlocks: (f, k, b) => {
|
|
843
|
+
const A = map(f, (_) => {
|
|
847
844
|
const w = r.find((B) => B._id === _)._parent || null, v = r.filter((B) => w ? B._parent === w : !B._parent).map((B) => B._id).indexOf(_);
|
|
848
845
|
return { _id: _, oldParent: w, oldPosition: v };
|
|
849
|
-
}), E = A.find(({ _id: _ }) => _ ===
|
|
850
|
-
E && E.oldParent ===
|
|
846
|
+
}), E = A.find(({ _id: _ }) => _ === f[0]);
|
|
847
|
+
E && E.oldParent === k && E.oldPosition === b || (i(f, k, b), o({
|
|
851
848
|
undo: () => each(A, ({ _id: _, oldParent: N, oldPosition: w }) => {
|
|
852
849
|
i([_], N, w);
|
|
853
850
|
}),
|
|
854
|
-
redo: () => i(
|
|
851
|
+
redo: () => i(f, k, b)
|
|
855
852
|
}));
|
|
856
853
|
},
|
|
857
|
-
addBlocks: (
|
|
858
|
-
a(
|
|
859
|
-
undo: () => l(map(
|
|
860
|
-
redo: () => a(
|
|
854
|
+
addBlocks: (f, k, b) => {
|
|
855
|
+
a(f, k, b), o({
|
|
856
|
+
undo: () => l(map(f, "_id")),
|
|
857
|
+
redo: () => a(f, k, b)
|
|
861
858
|
});
|
|
862
859
|
},
|
|
863
|
-
removeBlocks: (
|
|
860
|
+
removeBlocks: (f) => {
|
|
864
861
|
var E;
|
|
865
|
-
const
|
|
866
|
-
l(map(
|
|
867
|
-
undo: () => a(
|
|
868
|
-
redo: () => l(map(
|
|
862
|
+
const k = (E = first(f)) == null ? void 0 : E._parent, A = r.filter((_) => k ? _._parent === k : !_._parent).indexOf(first(f));
|
|
863
|
+
l(map(f, "_id")), o({
|
|
864
|
+
undo: () => a(f, k, A),
|
|
865
|
+
redo: () => l(map(f, "_id"))
|
|
869
866
|
});
|
|
870
867
|
},
|
|
871
|
-
updateBlocks: (
|
|
868
|
+
updateBlocks: (f, k, b) => {
|
|
872
869
|
let A = [];
|
|
873
870
|
if (b)
|
|
874
|
-
A = map(
|
|
871
|
+
A = map(f, (E) => ({ _id: E, ...b }));
|
|
875
872
|
else {
|
|
876
|
-
const E = keys(
|
|
877
|
-
A = map(
|
|
878
|
-
const N = r.find((
|
|
879
|
-
return each(E, (
|
|
873
|
+
const E = keys(k);
|
|
874
|
+
A = map(f, (_) => {
|
|
875
|
+
const N = r.find((y) => y._id === _), w = { _id: _ };
|
|
876
|
+
return each(E, (y) => w[y] = N[y]), w;
|
|
880
877
|
});
|
|
881
878
|
}
|
|
882
|
-
c(map(
|
|
879
|
+
c(map(f, (E) => ({ _id: E, ...k }))), o({
|
|
883
880
|
undo: () => c(A),
|
|
884
|
-
redo: () => c(map(
|
|
881
|
+
redo: () => c(map(f, (E) => ({ _id: E, ...k })))
|
|
885
882
|
});
|
|
886
883
|
},
|
|
887
|
-
updateBlocksRuntime: (
|
|
888
|
-
c(map(
|
|
884
|
+
updateBlocksRuntime: (f, k) => {
|
|
885
|
+
c(map(f, (b) => ({ _id: b, ...k })));
|
|
889
886
|
},
|
|
890
|
-
setNewBlocks: (
|
|
891
|
-
n(
|
|
887
|
+
setNewBlocks: (f) => {
|
|
888
|
+
n(f), o({
|
|
892
889
|
undo: () => n(r),
|
|
893
|
-
redo: () => n(
|
|
890
|
+
redo: () => n(f)
|
|
894
891
|
});
|
|
895
892
|
},
|
|
896
|
-
updateMultipleBlocksProps: (
|
|
897
|
-
let
|
|
898
|
-
|
|
893
|
+
updateMultipleBlocksProps: (f) => {
|
|
894
|
+
let k = [];
|
|
895
|
+
k = map(f, (b) => {
|
|
899
896
|
const A = keys(b), E = r.find((N) => N._id === b._id), _ = {};
|
|
900
897
|
return each(A, (N) => _[N] = E[N]), _;
|
|
901
|
-
}), c(
|
|
902
|
-
undo: () => c(
|
|
903
|
-
redo: () => c(
|
|
898
|
+
}), c(f), o({
|
|
899
|
+
undo: () => c(k),
|
|
900
|
+
redo: () => c(f)
|
|
904
901
|
});
|
|
905
902
|
}
|
|
906
903
|
};
|
|
@@ -908,12 +905,12 @@ const undoRedoStateAtom = atom({
|
|
|
908
905
|
const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
909
906
|
(i, c, d) => {
|
|
910
907
|
var m;
|
|
911
|
-
for (let
|
|
912
|
-
const { _id:
|
|
913
|
-
i[
|
|
914
|
-
const
|
|
915
|
-
for (let b = 0; b <
|
|
916
|
-
|
|
908
|
+
for (let x = 0; x < i.length; x++) {
|
|
909
|
+
const { _id: f } = i[x];
|
|
910
|
+
i[x]._id = generateUUID();
|
|
911
|
+
const k = filter(i, { _parent: f });
|
|
912
|
+
for (let b = 0; b < k.length; b++)
|
|
913
|
+
k[b]._parent = i[x]._id;
|
|
917
914
|
}
|
|
918
915
|
const p = first(i);
|
|
919
916
|
let u, g;
|
|
@@ -924,8 +921,8 @@ const undoRedoStateAtom = atom({
|
|
|
924
921
|
return { addCoreBlock: useCallback(
|
|
925
922
|
(i, c, d) => {
|
|
926
923
|
if (has(i, "blocks")) {
|
|
927
|
-
const
|
|
928
|
-
return a(
|
|
924
|
+
const k = i.blocks;
|
|
925
|
+
return a(k, c, d);
|
|
929
926
|
}
|
|
930
927
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
931
928
|
_type: i.type,
|
|
@@ -2366,45 +2363,45 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2366
2363
|
return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
|
|
2367
2364
|
})
|
|
2368
2365
|
), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2369
|
-
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m,
|
|
2370
|
-
const
|
|
2371
|
-
for (const
|
|
2372
|
-
const b =
|
|
2366
|
+
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, x) => {
|
|
2367
|
+
const f = cloneDeep(x.find((k) => k._id === m));
|
|
2368
|
+
for (const k in f) {
|
|
2369
|
+
const b = f[k];
|
|
2373
2370
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
2374
2371
|
const { baseClasses: A, classes: E } = getSplitChaiClasses(b);
|
|
2375
|
-
|
|
2372
|
+
f[k] = compact(flattenDeep([A, E])).join(" ");
|
|
2376
2373
|
} else
|
|
2377
|
-
|
|
2374
|
+
k !== "_id" && delete f[k];
|
|
2378
2375
|
}
|
|
2379
|
-
return
|
|
2376
|
+
return f;
|
|
2380
2377
|
};
|
|
2381
2378
|
return {
|
|
2382
2379
|
askAi: useCallback(
|
|
2383
|
-
async (m,
|
|
2380
|
+
async (m, x, f, k) => {
|
|
2384
2381
|
if (l) {
|
|
2385
2382
|
r(!0), a(null);
|
|
2386
2383
|
try {
|
|
2387
2384
|
const b = p === u ? "" : p;
|
|
2388
|
-
console.log("prompt",
|
|
2389
|
-
const A =
|
|
2385
|
+
console.log("prompt", f);
|
|
2386
|
+
const A = f.toLowerCase().includes("translate the content"), E = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p, A) : [h(x, d)], _ = await l(m, addLangToPrompt(f, g, m), E, b), { blocks: N, error: w } = _;
|
|
2390
2387
|
if (w) {
|
|
2391
2388
|
a(w);
|
|
2392
2389
|
return;
|
|
2393
2390
|
}
|
|
2394
2391
|
if (m === "styles") {
|
|
2395
|
-
const
|
|
2392
|
+
const y = N.map((v) => {
|
|
2396
2393
|
for (const B in v)
|
|
2397
2394
|
B !== "_id" && (v[B] = `${STYLES_KEY},${v[B]}`);
|
|
2398
2395
|
return v;
|
|
2399
2396
|
});
|
|
2400
|
-
c(
|
|
2397
|
+
c(y);
|
|
2401
2398
|
} else
|
|
2402
2399
|
i(N);
|
|
2403
|
-
|
|
2400
|
+
k && k(_);
|
|
2404
2401
|
} catch (b) {
|
|
2405
2402
|
a(b);
|
|
2406
2403
|
} finally {
|
|
2407
|
-
r(!1),
|
|
2404
|
+
r(!1), k && k();
|
|
2408
2405
|
}
|
|
2409
2406
|
}
|
|
2410
2407
|
},
|
|
@@ -2498,12 +2495,12 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2498
2495
|
if (!p)
|
|
2499
2496
|
return h;
|
|
2500
2497
|
let m = [];
|
|
2501
|
-
for (const
|
|
2502
|
-
if (
|
|
2503
|
-
let
|
|
2504
|
-
|
|
2498
|
+
for (const x of h)
|
|
2499
|
+
if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
|
|
2500
|
+
let f = l(x.partialBlockId);
|
|
2501
|
+
x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((k) => (isEmpty(k._parent) && set(k, "_parent", x._parent), k))), m = [...m, ...f];
|
|
2505
2502
|
} else
|
|
2506
|
-
m.push(
|
|
2503
|
+
m.push(x);
|
|
2507
2504
|
return m;
|
|
2508
2505
|
})
|
|
2509
2506
|
};
|
|
@@ -2686,13 +2683,13 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2686
2683
|
const d = o(c), p = a;
|
|
2687
2684
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2688
2685
|
return each(p, (h) => {
|
|
2689
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2690
|
-
u = u.replace(
|
|
2691
|
-
const
|
|
2692
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2686
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2687
|
+
u = u.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2688
|
+
const f = first(h.split(":"));
|
|
2689
|
+
includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(h.split(":").pop().trim());
|
|
2693
2690
|
}), each(p, (h) => {
|
|
2694
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2695
|
-
g = g.replace(
|
|
2691
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2692
|
+
g = g.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2696
2693
|
}), {
|
|
2697
2694
|
ids: [d._id],
|
|
2698
2695
|
props: {
|
|
@@ -2841,21 +2838,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2841
2838
|
return "VERTICAL";
|
|
2842
2839
|
}
|
|
2843
2840
|
}, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
|
|
2844
|
-
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (
|
|
2845
|
-
(
|
|
2846
|
-
isDisabledControl(g, h,
|
|
2841
|
+
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (f) => c ? get(f, "_parent") === c : !get(f, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), x = useCallback(
|
|
2842
|
+
(f) => {
|
|
2843
|
+
isDisabledControl(g, h, f) || p || (f === "UP" || f === "LEFT" ? l([i], c || null, u - 1) : (f === "DOWN" || f === "RIGHT") && l([i], c || null, u + 2), r());
|
|
2847
2844
|
},
|
|
2848
2845
|
[g, h, p, u, i, c, r]
|
|
2849
2846
|
);
|
|
2850
2847
|
return useHotkeys(
|
|
2851
2848
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2852
|
-
({ key:
|
|
2853
|
-
var
|
|
2854
|
-
|
|
2849
|
+
({ key: f }) => {
|
|
2850
|
+
var k;
|
|
2851
|
+
x((k = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
|
|
2855
2852
|
},
|
|
2856
2853
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2857
|
-
[
|
|
2858
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock:
|
|
2854
|
+
[x]
|
|
2855
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: x, orientation: m };
|
|
2859
2856
|
}, BlockController = ({ block: o, updateFloatingBar: r }) => {
|
|
2860
2857
|
const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2861
2858
|
o,
|
|
@@ -3012,9 +3009,9 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3012
3009
|
}),
|
|
3013
3010
|
size({
|
|
3014
3011
|
boundary: u == null ? void 0 : u.body,
|
|
3015
|
-
apply({ availableWidth:
|
|
3012
|
+
apply({ availableWidth: k, availableHeight: b, elements: A }) {
|
|
3016
3013
|
Object.assign(A.floating.style, {
|
|
3017
|
-
maxWidth: `${Math.max(200,
|
|
3014
|
+
maxWidth: `${Math.max(200, k)}px`,
|
|
3018
3015
|
maxHeight: `${Math.max(100, b)}px`
|
|
3019
3016
|
});
|
|
3020
3017
|
}
|
|
@@ -3023,11 +3020,11 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3023
3020
|
elements: { reference: r }
|
|
3024
3021
|
});
|
|
3025
3022
|
useResizeObserver(r, () => m(), r !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
|
|
3026
|
-
const
|
|
3023
|
+
const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
3027
3024
|
return useEffect(() => {
|
|
3028
3025
|
if (r) {
|
|
3029
|
-
const
|
|
3030
|
-
return () => clearTimeout(
|
|
3026
|
+
const k = setTimeout(() => m(), 500);
|
|
3027
|
+
return () => clearTimeout(k);
|
|
3031
3028
|
} else
|
|
3032
3029
|
m();
|
|
3033
3030
|
}, [r]), !r || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
@@ -3037,25 +3034,25 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3037
3034
|
tabIndex: 0,
|
|
3038
3035
|
ref: h.setFloating,
|
|
3039
3036
|
style: g,
|
|
3040
|
-
onClick: (
|
|
3041
|
-
|
|
3037
|
+
onClick: (k) => {
|
|
3038
|
+
k.stopPropagation(), k.preventDefault();
|
|
3042
3039
|
},
|
|
3043
|
-
onMouseEnter: (
|
|
3044
|
-
|
|
3040
|
+
onMouseEnter: (k) => {
|
|
3041
|
+
k.stopPropagation(), i(null);
|
|
3045
3042
|
},
|
|
3046
|
-
onKeyDown: (
|
|
3043
|
+
onKeyDown: (k) => k.stopPropagation(),
|
|
3047
3044
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3048
3045
|
children: [
|
|
3049
|
-
|
|
3046
|
+
x && /* @__PURE__ */ jsx(
|
|
3050
3047
|
ArrowUpIcon,
|
|
3051
3048
|
{
|
|
3052
3049
|
className: "hover:scale-105",
|
|
3053
3050
|
onClick: () => {
|
|
3054
|
-
c([]), l([
|
|
3051
|
+
c([]), l([x]);
|
|
3055
3052
|
}
|
|
3056
3053
|
}
|
|
3057
3054
|
),
|
|
3058
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3055
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: o }),
|
|
3059
3056
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3060
3057
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3061
3058
|
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
|
|
@@ -3213,8 +3210,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3213
3210
|
i
|
|
3214
3211
|
]), useHotkeys(
|
|
3215
3212
|
"del, backspace",
|
|
3216
|
-
(
|
|
3217
|
-
|
|
3213
|
+
(x) => {
|
|
3214
|
+
x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
|
|
3218
3215
|
},
|
|
3219
3216
|
m,
|
|
3220
3217
|
[r, l]
|
|
@@ -3507,8 +3504,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3507
3504
|
],
|
|
3508
3505
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3509
3506
|
onBlur: ({ editor: u, event: g }) => {
|
|
3510
|
-
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"),
|
|
3511
|
-
if (!
|
|
3507
|
+
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = m == null ? void 0 : m.contains(h), k = x == null ? void 0 : x.contains(h);
|
|
3508
|
+
if (!f && !k) {
|
|
3512
3509
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3513
3510
|
n(b);
|
|
3514
3511
|
}
|
|
@@ -3563,14 +3560,14 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3563
3560
|
useEffect(() => {
|
|
3564
3561
|
if (a.current) {
|
|
3565
3562
|
a.current.innerText = r, a.current.focus();
|
|
3566
|
-
const m = c.createRange(),
|
|
3567
|
-
m.selectNodeContents(a.current), m.collapse(!1),
|
|
3563
|
+
const m = c.createRange(), x = d.getSelection();
|
|
3564
|
+
m.selectNodeContents(a.current), m.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(m), a.current.focus();
|
|
3568
3565
|
} else
|
|
3569
3566
|
n();
|
|
3570
3567
|
}, [c, d]);
|
|
3571
3568
|
const p = useMemo(() => {
|
|
3572
|
-
var
|
|
3573
|
-
const m = ((
|
|
3569
|
+
var x;
|
|
3570
|
+
const m = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
|
|
3574
3571
|
return m === "button" ? "div" : m;
|
|
3575
3572
|
}, [o]), u = useCallback(
|
|
3576
3573
|
(m) => {
|
|
@@ -3586,12 +3583,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3586
3583
|
contentEditable: !0,
|
|
3587
3584
|
className: `${((m = o == null ? void 0 : o.className) == null ? void 0 : m.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
|
|
3588
3585
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
3589
|
-
onInput: (
|
|
3590
|
-
const
|
|
3591
|
-
|
|
3586
|
+
onInput: (x) => {
|
|
3587
|
+
const f = x.target;
|
|
3588
|
+
f && (f.innerText.trim() === "" ? (f.setAttribute("data-placeholder", "Enter text here"), f.children.length > 0 && f.children[0].remove()) : x.target.removeAttribute("data-placeholder"), l(x.target.innerText));
|
|
3592
3589
|
},
|
|
3593
|
-
onClick: (
|
|
3594
|
-
|
|
3590
|
+
onClick: (x) => {
|
|
3591
|
+
x.stopPropagation(), x.preventDefault();
|
|
3595
3592
|
}
|
|
3596
3593
|
};
|
|
3597
3594
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
@@ -3604,33 +3601,33 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3604
3601
|
}
|
|
3605
3602
|
), WithBlockTextEditor = memo(
|
|
3606
3603
|
({ block: o, children: r }) => {
|
|
3607
|
-
const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang:
|
|
3604
|
+
const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), k = useRef(null), b = l, { blockContent: A, blockType: E } = useMemo(() => {
|
|
3608
3605
|
var j;
|
|
3609
3606
|
const v = o._type;
|
|
3610
3607
|
let B = o[n];
|
|
3611
3608
|
const S = getRegisteredChaiBlock(o._type);
|
|
3612
|
-
return
|
|
3613
|
-
}, [o,
|
|
3609
|
+
return x && ((j = S == null ? void 0 : S.i18nProps) == null ? void 0 : j.includes(n)) && has(o, `${n}-${x}`) && (B = get(o, `${n}-${x}`)), { blockContent: B, blockType: v };
|
|
3610
|
+
}, [o, x]), _ = useCallback(
|
|
3614
3611
|
(v) => {
|
|
3615
3612
|
var S;
|
|
3616
3613
|
const B = v || ((S = g.current) == null ? void 0 : S.innerText);
|
|
3617
|
-
m([b], { [n]: B }), u(null), c(null), d(-1),
|
|
3614
|
+
m([b], { [n]: B }), u(null), c(null), d(-1), f(b ? [b] : []);
|
|
3618
3615
|
},
|
|
3619
|
-
[b, m, c,
|
|
3616
|
+
[b, m, c, f, x]
|
|
3620
3617
|
), N = useDebouncedCallback(
|
|
3621
3618
|
(v) => {
|
|
3622
3619
|
m([b], { [n]: v });
|
|
3623
3620
|
},
|
|
3624
|
-
[b, o, m,
|
|
3621
|
+
[b, o, m, x],
|
|
3625
3622
|
1e3
|
|
3626
3623
|
), w = useCallback(
|
|
3627
3624
|
(v) => {
|
|
3628
|
-
v.preventDefault(), b && (
|
|
3629
|
-
const B =
|
|
3630
|
-
|
|
3625
|
+
v.preventDefault(), b && (k.current = b), _(), setTimeout(() => {
|
|
3626
|
+
const B = k.current;
|
|
3627
|
+
k.current = null, f([B]);
|
|
3631
3628
|
}, 100);
|
|
3632
3629
|
},
|
|
3633
|
-
[
|
|
3630
|
+
[f, b, x]
|
|
3634
3631
|
);
|
|
3635
3632
|
useEffect(() => {
|
|
3636
3633
|
var C;
|
|
@@ -3638,7 +3635,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3638
3635
|
const v = `[data-block-id="${b}"]`, B = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${v}${B}`);
|
|
3639
3636
|
S && ((C = S == null ? void 0 : S.classList) == null || C.add("sr-only"), u(S));
|
|
3640
3637
|
}, [b, E, a, i]);
|
|
3641
|
-
const
|
|
3638
|
+
const y = useMemo(() => p ? (h(), E === "RichText" ? /* @__PURE__ */ jsx(
|
|
3642
3639
|
RichTextEditor,
|
|
3643
3640
|
{
|
|
3644
3641
|
blockContent: A,
|
|
@@ -3657,9 +3654,9 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3657
3654
|
onChange: N,
|
|
3658
3655
|
onEscape: w
|
|
3659
3656
|
}
|
|
3660
|
-
)) : null, [p, b, E, A, _,
|
|
3657
|
+
)) : null, [p, b, E, A, _, x]);
|
|
3661
3658
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3662
|
-
|
|
3659
|
+
y,
|
|
3663
3660
|
r
|
|
3664
3661
|
] });
|
|
3665
3662
|
},
|
|
@@ -3692,18 +3689,18 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3692
3689
|
blockAtom: r,
|
|
3693
3690
|
children: n
|
|
3694
3691
|
}) => {
|
|
3695
|
-
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom),
|
|
3692
|
+
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: k } = useContext(RepeaterContext), b = useMemo(
|
|
3696
3693
|
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
3697
|
-
index:
|
|
3698
|
-
key:
|
|
3694
|
+
index: f,
|
|
3695
|
+
key: k
|
|
3699
3696
|
}) : applyLanguage(i, d, c),
|
|
3700
|
-
[i, d, c, g, m,
|
|
3697
|
+
[i, d, c, g, m, f, k]
|
|
3701
3698
|
), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), E = useMemo(
|
|
3702
3699
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
3703
3700
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
3704
3701
|
), _ = useMemo(
|
|
3705
3702
|
() => ({
|
|
3706
|
-
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index":
|
|
3703
|
+
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
|
|
3707
3704
|
inBuilder: !0,
|
|
3708
3705
|
lang: d || p,
|
|
3709
3706
|
...b,
|
|
@@ -3722,8 +3719,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3722
3719
|
o
|
|
3723
3720
|
]
|
|
3724
3721
|
), N = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
|
|
3725
|
-
if (isNull(
|
|
3726
|
-
let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(
|
|
3722
|
+
if (isNull(x) || h.includes(i._id)) return null;
|
|
3723
|
+
let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
|
|
3727
3724
|
..._,
|
|
3728
3725
|
children: n({
|
|
3729
3726
|
_id: i._id,
|
|
@@ -3736,8 +3733,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3736
3733
|
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
3737
3734
|
})
|
|
3738
3735
|
}) });
|
|
3739
|
-
const
|
|
3740
|
-
return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children:
|
|
3736
|
+
const y = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
|
|
3737
|
+
return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: y }) : y;
|
|
3741
3738
|
}, PartialWrapper = ({ children: o, partialBlockId: r }) => {
|
|
3742
3739
|
const n = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
3743
3740
|
(d) => {
|
|
@@ -3777,7 +3774,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3777
3774
|
);
|
|
3778
3775
|
return map(l, (c) => {
|
|
3779
3776
|
const d = a(c._id);
|
|
3780
|
-
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey:
|
|
3777
|
+
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(m) && m.map((f, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${k}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
|
|
3781
3778
|
});
|
|
3782
3779
|
}, PageBlocksRenderer = () => {
|
|
3783
3780
|
const [o] = useBlocksStore();
|
|
@@ -3845,14 +3842,14 @@ const CanvasEventsWatcher = () => {
|
|
|
3845
3842
|
}, StaticCanvas = () => {
|
|
3846
3843
|
const [o] = useCanvasDisplayWidth(), [, r] = useHighlightBlockId(), n = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
|
|
3847
3844
|
(m) => {
|
|
3848
|
-
i((
|
|
3845
|
+
i((x) => ({ ...x, width: m }));
|
|
3849
3846
|
},
|
|
3850
3847
|
[i]
|
|
3851
3848
|
);
|
|
3852
3849
|
useEffect(() => {
|
|
3853
3850
|
if (!a.current) return;
|
|
3854
|
-
const { clientWidth: m, clientHeight:
|
|
3855
|
-
i({ width: m, height:
|
|
3851
|
+
const { clientWidth: m, clientHeight: x } = a.current;
|
|
3852
|
+
i({ width: m, height: x });
|
|
3856
3853
|
}, [a, o]);
|
|
3857
3854
|
const h = useMemo(() => {
|
|
3858
3855
|
let m = IframeInitialContent;
|
|
@@ -3902,7 +3899,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3902
3899
|
}, 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: [
|
|
3903
3900
|
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
|
|
3904
3901
|
/* @__PURE__ */ jsx("p", { children: "Please try again." })
|
|
3905
|
-
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-
|
|
3902
|
+
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-CAnkmeVK.js")), CanvasArea = () => {
|
|
3906
3903
|
const [o] = useCodeEditor(), r = useBuilderProp("onError", noop);
|
|
3907
3904
|
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: [
|
|
3908
3905
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -3967,8 +3964,8 @@ const CanvasEventsWatcher = () => {
|
|
|
3967
3964
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3968
3965
|
] });
|
|
3969
3966
|
}, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
|
|
3970
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (
|
|
3971
|
-
if (!
|
|
3967
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (x) => {
|
|
3968
|
+
if (!x.trim()) {
|
|
3972
3969
|
p(!1), g("Please enter a URL");
|
|
3973
3970
|
return;
|
|
3974
3971
|
}
|
|
@@ -3992,7 +3989,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3992
3989
|
{
|
|
3993
3990
|
placeholder: m(`Enter ${n} URL`),
|
|
3994
3991
|
value: a,
|
|
3995
|
-
onChange: (
|
|
3992
|
+
onChange: (x) => l(x.target.value),
|
|
3996
3993
|
onKeyUp: () => h(a)
|
|
3997
3994
|
}
|
|
3998
3995
|
),
|
|
@@ -4032,8 +4029,8 @@ const CanvasEventsWatcher = () => {
|
|
|
4032
4029
|
};
|
|
4033
4030
|
MediaManagerModal.displayName = "MediaManagerModal";
|
|
4034
4031
|
const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==", ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
4035
|
-
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = n.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, u, g ? c == null ? void 0 : c.assetId : ""), m = !!h,
|
|
4036
|
-
const b = isArray(
|
|
4032
|
+
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = n.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, u, g ? c == null ? void 0 : c.assetId : ""), m = !!h, x = (k) => {
|
|
4033
|
+
const b = isArray(k) ? first(k) : k;
|
|
4037
4034
|
if (b) {
|
|
4038
4035
|
r(b == null ? void 0 : b.url);
|
|
4039
4036
|
const A = b == null ? void 0 : b.width, E = b == null ? void 0 : b.height;
|
|
@@ -4047,7 +4044,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4047
4044
|
d([c._id], _);
|
|
4048
4045
|
}
|
|
4049
4046
|
}
|
|
4050
|
-
},
|
|
4047
|
+
}, f = useCallback(() => {
|
|
4051
4048
|
r(PLACEHOLDER_IMAGE), c != null && c._id && d([c._id], { assetId: "" });
|
|
4052
4049
|
}, [r, c == null ? void 0 : c._id, d]);
|
|
4053
4050
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
|
|
@@ -4064,12 +4061,12 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4064
4061
|
"button",
|
|
4065
4062
|
{
|
|
4066
4063
|
type: "button",
|
|
4067
|
-
onClick:
|
|
4064
|
+
onClick: f,
|
|
4068
4065
|
className: "absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
|
|
4069
4066
|
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
4070
4067
|
}
|
|
4071
4068
|
),
|
|
4072
|
-
h && h !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect:
|
|
4069
|
+
h && h !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, assetId: h, children: /* @__PURE__ */ jsx(
|
|
4073
4070
|
"button",
|
|
4074
4071
|
{
|
|
4075
4072
|
type: "button",
|
|
@@ -4077,10 +4074,10 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4077
4074
|
children: /* @__PURE__ */ jsx(Edit2Icon, { className: "h-4 w-4 text-white" })
|
|
4078
4075
|
}
|
|
4079
4076
|
) })
|
|
4080
|
-
] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect:
|
|
4077
|
+
] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, mode: "image", assetId: h, children: /* @__PURE__ */ jsx("div", { className: "h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
|
|
4081
4078
|
/* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
|
|
4082
4079
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4083
|
-
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect:
|
|
4080
|
+
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: o || !isEmpty(o) ? l("Replace image") : l("Choose image") }) }),
|
|
4084
4081
|
/* @__PURE__ */ jsx("small", { className: "-pl-4 pt-2 text-center text-xs text-secondary-foreground", children: "OR" })
|
|
4085
4082
|
] }),
|
|
4086
4083
|
/* @__PURE__ */ jsx(
|
|
@@ -4094,8 +4091,8 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4094
4091
|
className: "text-xs",
|
|
4095
4092
|
placeholder: l("Enter image URL"),
|
|
4096
4093
|
value: o,
|
|
4097
|
-
onBlur: ({ target: { value:
|
|
4098
|
-
onChange: (
|
|
4094
|
+
onBlur: ({ target: { value: k } }) => a(n, k),
|
|
4095
|
+
onChange: (k) => r(k.target.value)
|
|
4099
4096
|
}
|
|
4100
4097
|
)
|
|
4101
4098
|
] })
|
|
@@ -4103,14 +4100,14 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4103
4100
|
}, PathDropdown = ({ data: o, onSelect: r, dataType: n }) => {
|
|
4104
4101
|
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", p = React__default.useCallback(
|
|
4105
4102
|
(h) => {
|
|
4106
|
-
const m = (
|
|
4107
|
-
h.type === "object" ? (l((
|
|
4103
|
+
const m = (x) => n === "value" ? x === "value" || x === "object" : n === "array" ? x === "array" : x === n;
|
|
4104
|
+
h.type === "object" ? (l((x) => [...x, h.key]), c(h.value)) : m(h.type) && r([...a, h.key].join("."), n);
|
|
4108
4105
|
},
|
|
4109
4106
|
[a, r, n]
|
|
4110
4107
|
), u = React__default.useCallback(() => {
|
|
4111
4108
|
if (a.length > 0) {
|
|
4112
4109
|
const h = a.slice(0, -1);
|
|
4113
|
-
l(h), c(h.reduce((m,
|
|
4110
|
+
l(h), c(h.reduce((m, x) => m[x], o));
|
|
4114
4111
|
}
|
|
4115
4112
|
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([h, m]) => ({ key: h, value: m, type: d(m) })).filter((h) => !startsWith(h.key, REPEATER_PREFIX) && h.key.includes("/") ? !1 : n === "value" ? h.type === "value" || h.type === "object" : n === "array" ? h.type === "array" || h.type === "object" : n === "object" ? h.type === "object" : !0) : [], [i, n]);
|
|
4116
4113
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
@@ -4203,7 +4200,7 @@ const DataBindingSelector = ({
|
|
|
4203
4200
|
}) => {
|
|
4204
4201
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4205
4202
|
if (i.length === 1) return "";
|
|
4206
|
-
const g = i.find((
|
|
4203
|
+
const g = i.find((x) => x._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4207
4204
|
return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
|
|
4208
4205
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4209
4206
|
(g, h) => {
|
|
@@ -4211,19 +4208,19 @@ const DataBindingSelector = ({
|
|
|
4211
4208
|
r(`{{${g}}}`, {}, n);
|
|
4212
4209
|
return;
|
|
4213
4210
|
}
|
|
4214
|
-
const m = (b) => /[.,!?;:]/.test(b),
|
|
4211
|
+
const m = (b) => /[.,!?;:]/.test(b), x = (b, A, E) => {
|
|
4215
4212
|
let _ = "", N = "";
|
|
4216
|
-
const w = A > 0 ? b[A - 1] : "",
|
|
4217
|
-
return A > 0 && (w === "." || !m(w) && w !== " ") && (_ = " "), A < b.length && !m(
|
|
4213
|
+
const w = A > 0 ? b[A - 1] : "", y = A < b.length ? b[A] : "";
|
|
4214
|
+
return A > 0 && (w === "." || !m(w) && w !== " ") && (_ = " "), A < b.length && !m(y) && y !== " " && (N = " "), {
|
|
4218
4215
|
text: _ + E + N,
|
|
4219
4216
|
prefixLength: _.length,
|
|
4220
4217
|
suffixLength: N.length
|
|
4221
4218
|
};
|
|
4222
|
-
},
|
|
4223
|
-
if (!
|
|
4224
|
-
const
|
|
4225
|
-
if (
|
|
4226
|
-
const b =
|
|
4219
|
+
}, f = document.getElementById(n);
|
|
4220
|
+
if (!f) return;
|
|
4221
|
+
const k = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
|
|
4222
|
+
if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
|
|
4223
|
+
const b = k.__chaiRTE;
|
|
4227
4224
|
if (b) {
|
|
4228
4225
|
const A = `{{${g}}}`;
|
|
4229
4226
|
b.commands.focus();
|
|
@@ -4231,9 +4228,9 @@ const DataBindingSelector = ({
|
|
|
4231
4228
|
if (E !== _)
|
|
4232
4229
|
b.chain().deleteSelection().insertContent(A).run();
|
|
4233
4230
|
else {
|
|
4234
|
-
const { state: w } = b,
|
|
4231
|
+
const { state: w } = b, y = w.selection.from, v = w.doc.textBetween(Math.max(0, y - 1), y), B = w.doc.textBetween(y, Math.min(y + 1, w.doc.content.size));
|
|
4235
4232
|
let S = "";
|
|
4236
|
-
|
|
4233
|
+
y > 0 && v !== " " && !m(v) && (S = " ");
|
|
4237
4234
|
let C = "";
|
|
4238
4235
|
B && B !== " " && !m(B) && (C = " "), b.chain().insertContent(S + A + C).run();
|
|
4239
4236
|
}
|
|
@@ -4241,13 +4238,13 @@ const DataBindingSelector = ({
|
|
|
4241
4238
|
return;
|
|
4242
4239
|
}
|
|
4243
4240
|
} else {
|
|
4244
|
-
const b =
|
|
4241
|
+
const b = f, A = b.selectionStart || 0, E = b.value || "", _ = b.selectionEnd || A;
|
|
4245
4242
|
if (_ > A) {
|
|
4246
|
-
const B = `{{${g}}}`, { text: S } =
|
|
4243
|
+
const B = `{{${g}}}`, { text: S } = x(E, A, B), C = E.slice(0, A) + S + E.slice(_);
|
|
4247
4244
|
r(C, {}, n);
|
|
4248
4245
|
return;
|
|
4249
4246
|
}
|
|
4250
|
-
const w = `{{${g}}}`, { text:
|
|
4247
|
+
const w = `{{${g}}}`, { text: y } = x(E, A, w), v = E.slice(0, A) + y + E.slice(A);
|
|
4251
4248
|
r(v, {}, n);
|
|
4252
4249
|
}
|
|
4253
4250
|
},
|
|
@@ -4270,9 +4267,9 @@ const DataBindingSelector = ({
|
|
|
4270
4267
|
onChange: n
|
|
4271
4268
|
}) => {
|
|
4272
4269
|
var B;
|
|
4273
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [
|
|
4270
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [x, f] = useState([]), [k, b] = useState(-1), A = useRef(null), E = (B = r == null ? void 0 : r.find((S) => S.key === u)) == null ? void 0 : B.name;
|
|
4274
4271
|
useEffect(() => {
|
|
4275
|
-
if (m(""),
|
|
4272
|
+
if (m(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4276
4273
|
const S = split(o, ":"), C = get(S, 1, "page") || "page";
|
|
4277
4274
|
g(C), (async () => {
|
|
4278
4275
|
const j = await l(C, [get(S, 2, "page")]);
|
|
@@ -4282,10 +4279,10 @@ const DataBindingSelector = ({
|
|
|
4282
4279
|
const _ = useDebouncedCallback(
|
|
4283
4280
|
async (S) => {
|
|
4284
4281
|
if (isEmpty(S))
|
|
4285
|
-
|
|
4282
|
+
f([]);
|
|
4286
4283
|
else {
|
|
4287
4284
|
const C = await l(u, S);
|
|
4288
|
-
|
|
4285
|
+
f(C);
|
|
4289
4286
|
}
|
|
4290
4287
|
c(!1), b(-1);
|
|
4291
4288
|
},
|
|
@@ -4293,32 +4290,32 @@ const DataBindingSelector = ({
|
|
|
4293
4290
|
300
|
|
4294
4291
|
), N = (S) => {
|
|
4295
4292
|
const C = ["pageType", u, S.id];
|
|
4296
|
-
C[1] && (n(C.join(":")), m(S.name), p(!1),
|
|
4293
|
+
C[1] && (n(C.join(":")), m(S.name), p(!1), f([]), b(-1));
|
|
4297
4294
|
}, w = (S) => {
|
|
4298
4295
|
switch (S.key) {
|
|
4299
4296
|
case "ArrowDown":
|
|
4300
|
-
S.preventDefault(), b((C) => C <
|
|
4297
|
+
S.preventDefault(), b((C) => C < x.length - 1 ? C + 1 : C);
|
|
4301
4298
|
break;
|
|
4302
4299
|
case "ArrowUp":
|
|
4303
4300
|
S.preventDefault(), b((C) => C > 0 ? C - 1 : C);
|
|
4304
4301
|
break;
|
|
4305
4302
|
case "Enter":
|
|
4306
|
-
if (S.preventDefault(),
|
|
4307
|
-
|
|
4303
|
+
if (S.preventDefault(), x.length === 0) return;
|
|
4304
|
+
k >= 0 && N(x[k]);
|
|
4308
4305
|
break;
|
|
4309
4306
|
case "Escape":
|
|
4310
|
-
S.preventDefault(),
|
|
4307
|
+
S.preventDefault(), y();
|
|
4311
4308
|
break;
|
|
4312
4309
|
}
|
|
4313
4310
|
};
|
|
4314
4311
|
useEffect(() => {
|
|
4315
|
-
if (
|
|
4316
|
-
const S = A.current.children[
|
|
4312
|
+
if (k >= 0 && A.current) {
|
|
4313
|
+
const S = A.current.children[k];
|
|
4317
4314
|
S == null || S.scrollIntoView({ block: "nearest" });
|
|
4318
4315
|
}
|
|
4319
|
-
}, [
|
|
4320
|
-
const
|
|
4321
|
-
m(""),
|
|
4316
|
+
}, [k]);
|
|
4317
|
+
const y = () => {
|
|
4318
|
+
m(""), f([]), b(-1), p(!1), n("");
|
|
4322
4319
|
}, v = (S) => {
|
|
4323
4320
|
m(S), p(!isEmpty(S)), c(!0), _(S);
|
|
4324
4321
|
};
|
|
@@ -4336,21 +4333,21 @@ const DataBindingSelector = ({
|
|
|
4336
4333
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4337
4334
|
}
|
|
4338
4335
|
),
|
|
4339
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick:
|
|
4336
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: y, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4340
4337
|
] }),
|
|
4341
|
-
(i || !isEmpty(
|
|
4338
|
+
(i || !isEmpty(x) || d && isEmpty(x)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4342
4339
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4343
4340
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4344
|
-
] }) : d && isEmpty(
|
|
4341
|
+
] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4345
4342
|
a("No results found for"),
|
|
4346
4343
|
' "',
|
|
4347
4344
|
h,
|
|
4348
4345
|
'"'
|
|
4349
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(
|
|
4346
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(x == null ? void 0 : x.slice(0, 20), (S, C) => /* @__PURE__ */ jsxs(
|
|
4350
4347
|
"li",
|
|
4351
4348
|
{
|
|
4352
4349
|
onClick: () => N(S),
|
|
4353
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(S.id) ? "bg-blue-200" : C ===
|
|
4350
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(S.id) ? "bg-blue-200" : C === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4354
4351
|
children: [
|
|
4355
4352
|
S.name,
|
|
4356
4353
|
" ",
|
|
@@ -4661,8 +4658,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4661
4658
|
if (!u) return;
|
|
4662
4659
|
const m = `{{${h}}}`;
|
|
4663
4660
|
u.commands.focus();
|
|
4664
|
-
const { from:
|
|
4665
|
-
if (
|
|
4661
|
+
const { from: x, to: f } = u.state.selection;
|
|
4662
|
+
if (x !== f)
|
|
4666
4663
|
u.chain().deleteSelection().insertContent(m).run();
|
|
4667
4664
|
else {
|
|
4668
4665
|
const { state: b } = u, A = b.selection.from, E = b.doc.textBetween(Math.max(0, A - 1), A), _ = b.doc.textBetween(A, Math.min(A + 1, b.doc.content.size));
|
|
@@ -4708,13 +4705,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4708
4705
|
})
|
|
4709
4706
|
],
|
|
4710
4707
|
content: n || "",
|
|
4711
|
-
onUpdate: ({ editor:
|
|
4712
|
-
const
|
|
4713
|
-
a(
|
|
4708
|
+
onUpdate: ({ editor: x }) => {
|
|
4709
|
+
const f = x.getHTML();
|
|
4710
|
+
a(f), c || u(f);
|
|
4714
4711
|
},
|
|
4715
|
-
onBlur: ({ editor:
|
|
4716
|
-
const
|
|
4717
|
-
l(o,
|
|
4712
|
+
onBlur: ({ editor: x }) => {
|
|
4713
|
+
const f = x.getHTML();
|
|
4714
|
+
l(o, f);
|
|
4718
4715
|
},
|
|
4719
4716
|
editorProps: {
|
|
4720
4717
|
attributes: {
|
|
@@ -4727,8 +4724,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4727
4724
|
}, [g]), useEffect(() => {
|
|
4728
4725
|
u(n || "");
|
|
4729
4726
|
}, [n]);
|
|
4730
|
-
const h = (
|
|
4731
|
-
a(
|
|
4727
|
+
const h = (x) => {
|
|
4728
|
+
a(x);
|
|
4732
4729
|
}, m = () => {
|
|
4733
4730
|
d(!1), g && g.commands.setContent(p);
|
|
4734
4731
|
};
|
|
@@ -4761,25 +4758,25 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4761
4758
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
|
|
4762
4759
|
}, [o, u]);
|
|
4763
4760
|
const h = () => {
|
|
4764
|
-
const
|
|
4765
|
-
if (
|
|
4766
|
-
const
|
|
4761
|
+
const f = findIndex(u, { _id: g });
|
|
4762
|
+
if (f > -1) {
|
|
4763
|
+
const k = (f + 1) % u.length, b = get(u, [k, "_id"]);
|
|
4767
4764
|
if (!b) return;
|
|
4768
4765
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4769
4766
|
}
|
|
4770
4767
|
}, m = () => {
|
|
4771
|
-
const
|
|
4772
|
-
if (
|
|
4773
|
-
const
|
|
4768
|
+
const f = findIndex(u, { _id: g });
|
|
4769
|
+
if (f > -1) {
|
|
4770
|
+
const k = (f - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
|
|
4774
4771
|
if (!b) return;
|
|
4775
4772
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4776
4773
|
}
|
|
4777
|
-
},
|
|
4778
|
-
const
|
|
4774
|
+
}, x = () => {
|
|
4775
|
+
const f = i(
|
|
4779
4776
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4780
4777
|
p == null ? void 0 : p._id
|
|
4781
|
-
),
|
|
4782
|
-
|
|
4778
|
+
), k = f == null ? void 0 : f._id;
|
|
4779
|
+
k && (r({ ...o, currentSlide: k }), c([k]));
|
|
4783
4780
|
};
|
|
4784
4781
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4785
4782
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
@@ -4796,7 +4793,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4796
4793
|
/* @__PURE__ */ jsxs(
|
|
4797
4794
|
"button",
|
|
4798
4795
|
{
|
|
4799
|
-
onClick:
|
|
4796
|
+
onClick: x,
|
|
4800
4797
|
className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
|
|
4801
4798
|
children: [
|
|
4802
4799
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4857,9 +4854,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4857
4854
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4858
4855
|
className: "text-xs",
|
|
4859
4856
|
pattern: "[0-9]*",
|
|
4860
|
-
onChange: (
|
|
4861
|
-
let
|
|
4862
|
-
|
|
4857
|
+
onChange: (f) => {
|
|
4858
|
+
let k = f.target.value;
|
|
4859
|
+
k.length && (k = k.replace("-", "")), r({ ...o, autoplayInterval: k });
|
|
4863
4860
|
}
|
|
4864
4861
|
}
|
|
4865
4862
|
)
|
|
@@ -4966,10 +4963,10 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4966
4963
|
formData: u,
|
|
4967
4964
|
onChange: g
|
|
4968
4965
|
}) => {
|
|
4969
|
-
const { selectedLang: h, fallbackLang: m, languages:
|
|
4970
|
-
() => isEmpty(
|
|
4971
|
-
[
|
|
4972
|
-
),
|
|
4966
|
+
const { selectedLang: h, fallbackLang: m, languages: x } = useLanguages(), f = useMemo(
|
|
4967
|
+
() => isEmpty(x) ? "" : isEmpty(h) ? m : h,
|
|
4968
|
+
[x, h, m]
|
|
4969
|
+
), k = useMemo(() => get(LANGUAGES, f, f), [f]), b = usePageExternalData(), A = useSelectedBlock(), E = useRegisteredChaiBlocks(), _ = useMemo(
|
|
4973
4970
|
() => get(E, [A == null ? void 0 : A._type, "i18nProps"], []),
|
|
4974
4971
|
[E, A == null ? void 0 : A._type]
|
|
4975
4972
|
), [N, w] = useState(null);
|
|
@@ -5021,7 +5018,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
5021
5018
|
" ",
|
|
5022
5019
|
v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5023
5020
|
" ",
|
|
5024
|
-
|
|
5021
|
+
k
|
|
5025
5022
|
] }),
|
|
5026
5023
|
d && p.type !== "object" ? " *" : null
|
|
5027
5024
|
] }),
|
|
@@ -5141,36 +5138,36 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
5141
5138
|
}), a;
|
|
5142
5139
|
};
|
|
5143
5140
|
function BlockSettings() {
|
|
5144
|
-
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h),
|
|
5145
|
-
|
|
5146
|
-
},
|
|
5147
|
-
debounce(({ formData: w },
|
|
5148
|
-
|
|
5141
|
+
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), x = ({ formData: w }, y, v) => {
|
|
5142
|
+
y && (c == null ? void 0 : c._id) === r._id && a([r._id], { [y]: get(w, y) }, v);
|
|
5143
|
+
}, f = useCallback(
|
|
5144
|
+
debounce(({ formData: w }, y, v) => {
|
|
5145
|
+
x({ formData: w }, y, v), d(w);
|
|
5149
5146
|
}, 1500),
|
|
5150
5147
|
[r == null ? void 0 : r._id, o]
|
|
5151
|
-
),
|
|
5152
|
-
|
|
5153
|
-
}, b = ({ formData: w },
|
|
5154
|
-
|
|
5148
|
+
), k = ({ formData: w }, y) => {
|
|
5149
|
+
y && (n([r._id], { [y]: get(w, y) }), f({ formData: w }, y, { [y]: get(c, y) }));
|
|
5150
|
+
}, b = ({ formData: w }, y) => {
|
|
5151
|
+
y && (n([g._id], { [y]: get(w, y) }), f({ formData: w }, y, { [y]: get(c, y) }));
|
|
5155
5152
|
}, { schema: A, uiSchema: E } = useMemo(() => {
|
|
5156
5153
|
const w = r == null ? void 0 : r._type;
|
|
5157
5154
|
if (!w)
|
|
5158
5155
|
return { schema: {}, uiSchema: {} };
|
|
5159
5156
|
try {
|
|
5160
|
-
const { schema:
|
|
5157
|
+
const { schema: y, uiSchema: v } = getBlockFormSchemas(w);
|
|
5161
5158
|
if (w === "Repeater") {
|
|
5162
5159
|
const B = get(r, "repeaterItems", "");
|
|
5163
5160
|
startsWith(B, `{{${COLLECTION_PREFIX}`) ? (set(v, "filter", { "ui:widget": "collectionSelect" }), set(v, "sort", { "ui:widget": "collectionSelect" })) : (set(v, "filter", { "ui:widget": "hidden" }), set(v, "sort", { "ui:widget": "hidden" }));
|
|
5164
5161
|
}
|
|
5165
|
-
return { schema:
|
|
5162
|
+
return { schema: y, uiSchema: v };
|
|
5166
5163
|
} catch {
|
|
5167
5164
|
return { schema: {}, uiSchema: {} };
|
|
5168
5165
|
}
|
|
5169
5166
|
}, [r]), { wrapperSchema: _, wrapperUiSchema: N } = useMemo(() => {
|
|
5170
5167
|
if (!g || !(g != null && g._type))
|
|
5171
5168
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5172
|
-
const w = g == null ? void 0 : g._type, { schema:
|
|
5173
|
-
return { wrapperSchema:
|
|
5169
|
+
const w = g == null ? void 0 : g._type, { schema: y = {}, uiSchema: v = {} } = getBlockFormSchemas(w);
|
|
5170
|
+
return { wrapperSchema: y, wrapperUiSchema: v };
|
|
5174
5171
|
}, [g]);
|
|
5175
5172
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5176
5173
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
@@ -5207,7 +5204,7 @@ function BlockSettings() {
|
|
|
5207
5204
|
JSONForm,
|
|
5208
5205
|
{
|
|
5209
5206
|
blockId: r == null ? void 0 : r._id,
|
|
5210
|
-
onChange:
|
|
5207
|
+
onChange: k,
|
|
5211
5208
|
formData: i,
|
|
5212
5209
|
schema: A,
|
|
5213
5210
|
uiSchema: E
|
|
@@ -5216,34 +5213,34 @@ function BlockSettings() {
|
|
|
5216
5213
|
] });
|
|
5217
5214
|
}
|
|
5218
5215
|
const BlockStylingProps = () => {
|
|
5219
|
-
var
|
|
5216
|
+
var x;
|
|
5220
5217
|
const o = useSelectedBlock(), [r, n] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
|
|
5221
5218
|
if (!o) return null;
|
|
5222
5219
|
const c = Object.keys(o).filter(
|
|
5223
|
-
(
|
|
5224
|
-
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (
|
|
5220
|
+
(f) => typeof o[f] == "string" && o[f].startsWith("#styles:")
|
|
5221
|
+
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (x = r[0]) == null ? void 0 : x.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((f) => !isEmpty(f)) : [], m = (f) => find(r, (k) => k.prop === f);
|
|
5225
5222
|
return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5226
5223
|
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5227
5224
|
i("Style element"),
|
|
5228
5225
|
":"
|
|
5229
5226
|
] }),
|
|
5230
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (
|
|
5227
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (f) => /* @__PURE__ */ jsxs(
|
|
5231
5228
|
Badge,
|
|
5232
5229
|
{
|
|
5233
5230
|
className: "flex cursor-pointer items-center gap-1 pr-1",
|
|
5234
|
-
variant: m(
|
|
5231
|
+
variant: m(f) ? "default" : "secondary",
|
|
5235
5232
|
onClick: () => {
|
|
5236
|
-
n([{ id: `${
|
|
5233
|
+
n([{ id: `${f}-${o._id}`, blockId: o._id, prop: f }]);
|
|
5237
5234
|
},
|
|
5238
5235
|
children: [
|
|
5239
|
-
startCase(
|
|
5236
|
+
startCase(f),
|
|
5240
5237
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5241
5238
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5242
5239
|
"button",
|
|
5243
5240
|
{
|
|
5244
5241
|
type: "button",
|
|
5245
5242
|
className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
|
|
5246
|
-
onClick: (
|
|
5243
|
+
onClick: (k) => k.stopPropagation(),
|
|
5247
5244
|
children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
|
|
5248
5245
|
}
|
|
5249
5246
|
) }),
|
|
@@ -5253,7 +5250,7 @@ const BlockStylingProps = () => {
|
|
|
5253
5250
|
{
|
|
5254
5251
|
className: "text-xs",
|
|
5255
5252
|
onClick: () => {
|
|
5256
|
-
d(
|
|
5253
|
+
d(f);
|
|
5257
5254
|
},
|
|
5258
5255
|
children: i("Reset style")
|
|
5259
5256
|
}
|
|
@@ -5272,7 +5269,7 @@ const BlockStylingProps = () => {
|
|
|
5272
5269
|
] })
|
|
5273
5270
|
]
|
|
5274
5271
|
},
|
|
5275
|
-
|
|
5272
|
+
f
|
|
5276
5273
|
)) }),
|
|
5277
5274
|
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5278
5275
|
] }) });
|
|
@@ -5421,7 +5418,7 @@ const BlockStylingProps = () => {
|
|
|
5421
5418
|
},
|
|
5422
5419
|
a
|
|
5423
5420
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5424
|
-
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [
|
|
5421
|
+
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [k, b] = useState(""), [A, E] = useState(!1), [_, N] = useState(!1);
|
|
5425
5422
|
useEffect(() => {
|
|
5426
5423
|
const { value: S, unit: C } = getClassValueAndUnit(i);
|
|
5427
5424
|
if (C === "") {
|
|
@@ -5430,11 +5427,11 @@ const BlockStylingProps = () => {
|
|
|
5430
5427
|
}
|
|
5431
5428
|
m(C), l(C === "class" || isEmpty(S) ? "" : S);
|
|
5432
5429
|
}, [i, p, u]);
|
|
5433
|
-
const w = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME),
|
|
5430
|
+
const w = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), y = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), v = useCallback(
|
|
5434
5431
|
(S = !1) => {
|
|
5435
5432
|
const C = getUserInputValues(`${a}`, u);
|
|
5436
5433
|
if (get(C, "error", !1)) {
|
|
5437
|
-
|
|
5434
|
+
f(!0);
|
|
5438
5435
|
return;
|
|
5439
5436
|
}
|
|
5440
5437
|
const j = get(C, "unit") !== "" ? get(C, "unit") : h;
|
|
@@ -5445,14 +5442,14 @@ const BlockStylingProps = () => {
|
|
|
5445
5442
|
if (get(C, "value") === "")
|
|
5446
5443
|
return;
|
|
5447
5444
|
const T = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5448
|
-
S ?
|
|
5445
|
+
S ? y(T) : w(T);
|
|
5449
5446
|
},
|
|
5450
|
-
[w,
|
|
5447
|
+
[w, y, a, h, d, u]
|
|
5451
5448
|
), B = useCallback(
|
|
5452
5449
|
(S) => {
|
|
5453
5450
|
const C = getUserInputValues(`${a}`, u);
|
|
5454
5451
|
if (get(C, "error", !1)) {
|
|
5455
|
-
|
|
5452
|
+
f(!0);
|
|
5456
5453
|
return;
|
|
5457
5454
|
}
|
|
5458
5455
|
if (S === "auto" || S === "none") {
|
|
@@ -5496,23 +5493,23 @@ const BlockStylingProps = () => {
|
|
|
5496
5493
|
let j = isNaN$1(C) ? 0 : C;
|
|
5497
5494
|
S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
|
|
5498
5495
|
const I = `${j}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5499
|
-
|
|
5496
|
+
y(P);
|
|
5500
5497
|
},
|
|
5501
5498
|
onKeyUp: (S) => {
|
|
5502
5499
|
_ && (S.preventDefault(), N(!1));
|
|
5503
5500
|
},
|
|
5504
5501
|
onBlur: () => v(),
|
|
5505
5502
|
onChange: (S) => {
|
|
5506
|
-
|
|
5503
|
+
f(!1), l(S.target.value);
|
|
5507
5504
|
},
|
|
5508
5505
|
onClick: (S) => {
|
|
5509
5506
|
var C;
|
|
5510
5507
|
(C = S == null ? void 0 : S.target) == null || C.select(), n(!1);
|
|
5511
5508
|
},
|
|
5512
|
-
value: A ?
|
|
5509
|
+
value: A ? k : a,
|
|
5513
5510
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5514
5511
|
" ",
|
|
5515
|
-
|
|
5512
|
+
x ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
5516
5513
|
)
|
|
5517
5514
|
}
|
|
5518
5515
|
),
|
|
@@ -5556,7 +5553,7 @@ const BlockStylingProps = () => {
|
|
|
5556
5553
|
return;
|
|
5557
5554
|
b(S);
|
|
5558
5555
|
const C = `${S}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5559
|
-
|
|
5556
|
+
y(I);
|
|
5560
5557
|
},
|
|
5561
5558
|
currentValue: a,
|
|
5562
5559
|
unit: h,
|
|
@@ -5621,8 +5618,8 @@ const COLOR_PROP = {
|
|
|
5621
5618
|
}, ColorChoice = ({ property: o, onChange: r }) => {
|
|
5622
5619
|
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
|
|
5623
5620
|
// eslint-disable-next-line no-shadow
|
|
5624
|
-
(
|
|
5625
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
5621
|
+
(k) => {
|
|
5622
|
+
["current", "inherit", "transparent", "black", "white"].includes(k) ? (c([]), p({ color: k })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
|
|
5626
5623
|
},
|
|
5627
5624
|
[c, p]
|
|
5628
5625
|
);
|
|
@@ -5631,21 +5628,21 @@ const COLOR_PROP = {
|
|
|
5631
5628
|
return c([]);
|
|
5632
5629
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5633
5630
|
}, [g]);
|
|
5634
|
-
const
|
|
5631
|
+
const x = useCallback(
|
|
5635
5632
|
// eslint-disable-next-line no-shadow
|
|
5636
|
-
(
|
|
5637
|
-
p({ color: g, shade:
|
|
5633
|
+
(k) => {
|
|
5634
|
+
p({ color: g, shade: k });
|
|
5638
5635
|
},
|
|
5639
5636
|
[g]
|
|
5640
5637
|
);
|
|
5641
5638
|
useEffect(() => {
|
|
5642
5639
|
p({ color: "", shade: "" });
|
|
5643
5640
|
}, [n]);
|
|
5644
|
-
const { match:
|
|
5641
|
+
const { match: f } = useTailwindClassList();
|
|
5645
5642
|
return useEffect(() => {
|
|
5646
5643
|
const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5647
|
-
|
|
5648
|
-
}, [
|
|
5644
|
+
f(o, b) && r(b, o);
|
|
5645
|
+
}, [f, d, r, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5649
5646
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5650
5647
|
DropDown,
|
|
5651
5648
|
{
|
|
@@ -5685,7 +5682,7 @@ const COLOR_PROP = {
|
|
|
5685
5682
|
]
|
|
5686
5683
|
}
|
|
5687
5684
|
) }),
|
|
5688
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange:
|
|
5685
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: x, options: i }) })
|
|
5689
5686
|
] });
|
|
5690
5687
|
}, EDITOR_ICONS = {
|
|
5691
5688
|
"not-italic": () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z", fill: "white" }) }),
|
|
@@ -6019,22 +6016,22 @@ const COLOR_PROP = {
|
|
|
6019
6016
|
"2xl": "1536px"
|
|
6020
6017
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6021
6018
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6022
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(),
|
|
6023
|
-
(
|
|
6024
|
-
const B = { dark: p, mq: g, mod: u, cls:
|
|
6019
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), k = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
|
|
6020
|
+
(y, v = !0) => {
|
|
6021
|
+
const B = { dark: p, mq: g, mod: u, cls: y, property: l, fullCls: "" };
|
|
6025
6022
|
(p || u !== "") && (B.mq = "xs");
|
|
6026
6023
|
const S = generateFullClsName(B);
|
|
6027
|
-
m(
|
|
6024
|
+
m(f, [S], v);
|
|
6028
6025
|
},
|
|
6029
|
-
[
|
|
6026
|
+
[f, p, g, u, l, m]
|
|
6030
6027
|
), A = useCallback(() => {
|
|
6031
|
-
f
|
|
6032
|
-
}, [
|
|
6028
|
+
x(f, [k], !0);
|
|
6029
|
+
}, [f, k, x]), E = useMemo(() => canChangeClass(h, g), [h, g]);
|
|
6033
6030
|
useEffect(() => {
|
|
6034
6031
|
i(E, h);
|
|
6035
6032
|
}, [E, i, h]);
|
|
6036
6033
|
const [, , _] = useScreenSizeWidth(), N = useCallback(
|
|
6037
|
-
(
|
|
6034
|
+
(y) => {
|
|
6038
6035
|
_({
|
|
6039
6036
|
xs: 400,
|
|
6040
6037
|
sm: 640,
|
|
@@ -6042,7 +6039,7 @@ const COLOR_PROP = {
|
|
|
6042
6039
|
lg: 1024,
|
|
6043
6040
|
xl: 1420,
|
|
6044
6041
|
"2xl": 1920
|
|
6045
|
-
}[
|
|
6042
|
+
}[y]);
|
|
6046
6043
|
},
|
|
6047
6044
|
[_]
|
|
6048
6045
|
), w = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
|
|
@@ -6066,7 +6063,7 @@ const COLOR_PROP = {
|
|
|
6066
6063
|
n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
6067
6064
|
n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
6068
6065
|
] }),
|
|
6069
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
6066
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${k ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6070
6067
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6071
6068
|
"button",
|
|
6072
6069
|
{
|
|
@@ -6115,23 +6112,23 @@ const COLOR_PROP = {
|
|
|
6115
6112
|
children: [
|
|
6116
6113
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6117
6114
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6118
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key:
|
|
6115
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: x }, f) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6119
6116
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6120
6117
|
"button",
|
|
6121
6118
|
{
|
|
6122
6119
|
type: "button",
|
|
6123
|
-
onClick: () => u(
|
|
6124
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6120
|
+
onClick: () => u(x),
|
|
6121
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6125
6122
|
children: [
|
|
6126
6123
|
React__default.createElement("div", {
|
|
6127
|
-
className: h(
|
|
6124
|
+
className: h(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6128
6125
|
}),
|
|
6129
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6126
|
+
React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6130
6127
|
]
|
|
6131
6128
|
}
|
|
6132
6129
|
) }),
|
|
6133
6130
|
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
|
|
6134
|
-
] }) }, `option-${
|
|
6131
|
+
] }) }, `option-${f}`)) })
|
|
6135
6132
|
] }),
|
|
6136
6133
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6137
6134
|
BlockStyle,
|
|
@@ -6286,19 +6283,19 @@ const COLOR_PROP = {
|
|
|
6286
6283
|
canvas: r = !1,
|
|
6287
6284
|
tooltip: n = !0
|
|
6288
6285
|
}) => {
|
|
6289
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS),
|
|
6286
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
|
|
6290
6287
|
u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
|
|
6291
|
-
},
|
|
6288
|
+
}, f = (b) => {
|
|
6292
6289
|
r || l(b), c(b);
|
|
6293
|
-
},
|
|
6290
|
+
}, k = getBreakpointValue(r ? i : a).toLowerCase();
|
|
6294
6291
|
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
|
|
6295
6292
|
BreakpointCard,
|
|
6296
6293
|
{
|
|
6297
6294
|
canvas: r,
|
|
6298
6295
|
...b,
|
|
6299
|
-
onClick:
|
|
6296
|
+
onClick: f,
|
|
6300
6297
|
key: b.breakpoint,
|
|
6301
|
-
currentBreakpoint:
|
|
6298
|
+
currentBreakpoint: k
|
|
6302
6299
|
}
|
|
6303
6300
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
6304
6301
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
@@ -6310,9 +6307,9 @@ const COLOR_PROP = {
|
|
|
6310
6307
|
openDelay: o,
|
|
6311
6308
|
tooltip: n,
|
|
6312
6309
|
...b,
|
|
6313
|
-
onClick:
|
|
6310
|
+
onClick: f,
|
|
6314
6311
|
key: b.breakpoint,
|
|
6315
|
-
currentBreakpoint:
|
|
6312
|
+
currentBreakpoint: k
|
|
6316
6313
|
}
|
|
6317
6314
|
)
|
|
6318
6315
|
) }),
|
|
@@ -6325,7 +6322,7 @@ const COLOR_PROP = {
|
|
|
6325
6322
|
DropdownMenuCheckboxItem,
|
|
6326
6323
|
{
|
|
6327
6324
|
disabled: b.breakpoint === "xs",
|
|
6328
|
-
onCheckedChange: () =>
|
|
6325
|
+
onCheckedChange: () => x(toUpper(b.breakpoint)),
|
|
6329
6326
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6330
6327
|
children: h(b.title)
|
|
6331
6328
|
},
|
|
@@ -6410,8 +6407,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6410
6407
|
(m = d.current) == null || m.focus();
|
|
6411
6408
|
}, []);
|
|
6412
6409
|
const h = (m) => {
|
|
6413
|
-
const { usage:
|
|
6414
|
-
!l &&
|
|
6410
|
+
const { usage: x } = m || {};
|
|
6411
|
+
!l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6415
6412
|
};
|
|
6416
6413
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6417
6414
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
|
|
@@ -6467,9 +6464,9 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6467
6464
|
};
|
|
6468
6465
|
function ManualClasses() {
|
|
6469
6466
|
var I;
|
|
6470
|
-
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [
|
|
6471
|
-
const T =
|
|
6472
|
-
u(h, T, !0),
|
|
6467
|
+
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), k = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), A = b.split(" ").filter((T) => !isEmpty(T)), E = () => {
|
|
6468
|
+
const T = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6469
|
+
u(h, T, !0), f("");
|
|
6473
6470
|
}, [_, N] = useState([]), w = ({ value: T }) => {
|
|
6474
6471
|
const P = T.trim().toLowerCase(), L = P.match(/.+:/g);
|
|
6475
6472
|
let D = [];
|
|
@@ -6482,7 +6479,7 @@ function ManualClasses() {
|
|
|
6482
6479
|
} else
|
|
6483
6480
|
D = i.search(P);
|
|
6484
6481
|
return N(map(D, "item"));
|
|
6485
|
-
},
|
|
6482
|
+
}, y = () => {
|
|
6486
6483
|
N([]);
|
|
6487
6484
|
}, v = (T) => T.name, B = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
|
|
6488
6485
|
() => ({
|
|
@@ -6492,19 +6489,19 @@ function ManualClasses() {
|
|
|
6492
6489
|
autoCapitalize: "off",
|
|
6493
6490
|
spellCheck: !1,
|
|
6494
6491
|
placeholder: c("Enter classes separated by space"),
|
|
6495
|
-
value:
|
|
6492
|
+
value: x,
|
|
6496
6493
|
onFocus: (T) => {
|
|
6497
6494
|
setTimeout(() => {
|
|
6498
6495
|
T.target && T.target.select();
|
|
6499
6496
|
}, 0);
|
|
6500
6497
|
},
|
|
6501
6498
|
onKeyDown: (T) => {
|
|
6502
|
-
T.key === "Enter" &&
|
|
6499
|
+
T.key === "Enter" && x.trim() !== "" && E();
|
|
6503
6500
|
},
|
|
6504
|
-
onChange: (T, { newValue: P }) =>
|
|
6501
|
+
onChange: (T, { newValue: P }) => f(P),
|
|
6505
6502
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6506
6503
|
}),
|
|
6507
|
-
[
|
|
6504
|
+
[x, c, o]
|
|
6508
6505
|
), C = (T) => {
|
|
6509
6506
|
debugger;
|
|
6510
6507
|
const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
@@ -6539,7 +6536,7 @@ function ManualClasses() {
|
|
|
6539
6536
|
{
|
|
6540
6537
|
suggestions: _,
|
|
6541
6538
|
onSuggestionsFetchRequested: w,
|
|
6542
|
-
onSuggestionsClearRequested:
|
|
6539
|
+
onSuggestionsClearRequested: y,
|
|
6543
6540
|
getSuggestionValue: v,
|
|
6544
6541
|
renderSuggestion: B,
|
|
6545
6542
|
inputProps: S,
|
|
@@ -6559,7 +6556,7 @@ function ManualClasses() {
|
|
|
6559
6556
|
variant: "outline",
|
|
6560
6557
|
className: "h-6 border-border",
|
|
6561
6558
|
onClick: E,
|
|
6562
|
-
disabled:
|
|
6559
|
+
disabled: x.trim() === "",
|
|
6563
6560
|
size: "sm",
|
|
6564
6561
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
6565
6562
|
}
|
|
@@ -6590,7 +6587,7 @@ function ManualClasses() {
|
|
|
6590
6587
|
"button",
|
|
6591
6588
|
{
|
|
6592
6589
|
onDoubleClick: () => {
|
|
6593
|
-
|
|
6590
|
+
f(T), g(h, [T]), setTimeout(() => {
|
|
6594
6591
|
o.current && o.current.focus();
|
|
6595
6592
|
}, 10);
|
|
6596
6593
|
},
|
|
@@ -6746,10 +6743,10 @@ function BlockStyling() {
|
|
|
6746
6743
|
const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
|
|
6747
6744
|
let m = parseFloat(i.dragStartValue);
|
|
6748
6745
|
m = isNaN(m) ? 0 : m;
|
|
6749
|
-
let
|
|
6750
|
-
(startsWith(h, "scale") || h === "opacity") && (
|
|
6751
|
-
let
|
|
6752
|
-
g &&
|
|
6746
|
+
let x = MAPPER[i.dragUnit];
|
|
6747
|
+
(startsWith(h, "scale") || h === "opacity") && (x = 10);
|
|
6748
|
+
let k = (i.dragStartY - u.pageY) / x + m;
|
|
6749
|
+
g && k < 0 && (k = 0), h === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
|
|
6753
6750
|
},
|
|
6754
6751
|
[i],
|
|
6755
6752
|
50
|
|
@@ -6792,12 +6789,12 @@ const CoreBlock = ({
|
|
|
6792
6789
|
}) => {
|
|
6793
6790
|
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
|
|
6794
6791
|
if (has(o, "blocks")) {
|
|
6795
|
-
const
|
|
6796
|
-
u(syncBlocksWithDefaults(
|
|
6792
|
+
const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
6793
|
+
u(syncBlocksWithDefaults(k), n || null, a);
|
|
6797
6794
|
} else
|
|
6798
6795
|
p(o, n || null, a);
|
|
6799
6796
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6800
|
-
},
|
|
6797
|
+
}, x = useFeature("dnd"), { t: f } = useTranslation();
|
|
6801
6798
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6802
6799
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6803
6800
|
"button",
|
|
@@ -6805,20 +6802,20 @@ const CoreBlock = ({
|
|
|
6805
6802
|
disabled: r,
|
|
6806
6803
|
onClick: m,
|
|
6807
6804
|
type: "button",
|
|
6808
|
-
onDragStart: (
|
|
6809
|
-
|
|
6805
|
+
onDragStart: (k) => {
|
|
6806
|
+
k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6810
6807
|
g([]), h();
|
|
6811
6808
|
}, 200);
|
|
6812
6809
|
},
|
|
6813
|
-
draggable:
|
|
6810
|
+
draggable: x ? "true" : "false",
|
|
6814
6811
|
className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
|
|
6815
6812
|
children: [
|
|
6816
6813
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6817
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6814
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(f(d || i)) })
|
|
6818
6815
|
]
|
|
6819
6816
|
}
|
|
6820
6817
|
) }),
|
|
6821
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6818
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f(d || i) }) })
|
|
6822
6819
|
] }) });
|
|
6823
6820
|
}, DefaultChaiBlocks = ({
|
|
6824
6821
|
parentId: o,
|
|
@@ -7021,7 +7018,7 @@ const CoreBlock = ({
|
|
|
7021
7018
|
}
|
|
7022
7019
|
}
|
|
7023
7020
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
7024
|
-
var h, m,
|
|
7021
|
+
var h, m, x, f, k, b, A, E, _, N;
|
|
7025
7022
|
if (n.type === "comment") return [];
|
|
7026
7023
|
let a = { _id: generateUUID() };
|
|
7027
7024
|
if (r && (a._parent = r.block._id), n.type === "text")
|
|
@@ -7043,7 +7040,7 @@ const CoreBlock = ({
|
|
|
7043
7040
|
...getAttrs(n),
|
|
7044
7041
|
...getStyles(n)
|
|
7045
7042
|
}, n.attributes) {
|
|
7046
|
-
const w = n.attributes.find((
|
|
7043
|
+
const w = n.attributes.find((y) => includes(NAME_ATTRIBUTES, y.key));
|
|
7047
7044
|
w && (a._name = w.value);
|
|
7048
7045
|
}
|
|
7049
7046
|
if (i)
|
|
@@ -7061,26 +7058,26 @@ const CoreBlock = ({
|
|
|
7061
7058
|
];
|
|
7062
7059
|
a = {
|
|
7063
7060
|
...a,
|
|
7064
|
-
href: ((h = l.find((
|
|
7065
|
-
hrefType: ((m = l.find((
|
|
7066
|
-
autoplay: ((
|
|
7067
|
-
maxWidth: ((
|
|
7068
|
-
backdropColor: ((b = l.find((
|
|
7069
|
-
galleryName: ((A = l.find((
|
|
7070
|
-
}, forEach(w, (
|
|
7071
|
-
has(a, `styles_attrs.${
|
|
7061
|
+
href: ((h = l.find((y) => y.key === "href")) == null ? void 0 : h.value) || "",
|
|
7062
|
+
hrefType: ((m = l.find((y) => y.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
|
|
7063
|
+
autoplay: ((x = l.find((y) => y.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
|
|
7064
|
+
maxWidth: ((k = (f = l.find((y) => y.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : k.replace("px", "")) || "",
|
|
7065
|
+
backdropColor: ((b = l.find((y) => y.key === "data-overlay")) == null ? void 0 : b.value) || "",
|
|
7066
|
+
galleryName: ((A = l.find((y) => y.key === "data-gall")) == null ? void 0 : A.value) || ""
|
|
7067
|
+
}, forEach(w, (y) => {
|
|
7068
|
+
has(a, `styles_attrs.${y}`) && delete a.styles_attrs[y];
|
|
7072
7069
|
});
|
|
7073
7070
|
}
|
|
7074
7071
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
7075
7072
|
delete a.styles_attrs;
|
|
7076
7073
|
const w = filter(n.children || [], (v) => (v == null ? void 0 : v.tagName) !== "span");
|
|
7077
7074
|
a.content = getTextContent(w);
|
|
7078
|
-
const
|
|
7075
|
+
const y = find(
|
|
7079
7076
|
n.children || [],
|
|
7080
7077
|
(v) => (v == null ? void 0 : v.tagName) === "span" && some(v.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg")
|
|
7081
7078
|
);
|
|
7082
|
-
if (
|
|
7083
|
-
const v = find(
|
|
7079
|
+
if (y) {
|
|
7080
|
+
const v = find(y.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg");
|
|
7084
7081
|
if (v) {
|
|
7085
7082
|
a.icon = stringify([v]);
|
|
7086
7083
|
const { height: B, width: S } = getSvgDimensions(v, "16px", "16px");
|
|
@@ -7096,9 +7093,9 @@ const CoreBlock = ({
|
|
|
7096
7093
|
const w = stringify([n]);
|
|
7097
7094
|
return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
|
|
7098
7095
|
} else if (n.tagName === "svg") {
|
|
7099
|
-
const w = get(find(n.attributes, { key: "class" }), "value", ""), { height:
|
|
7100
|
-
if (
|
|
7101
|
-
a.styles = `${STYLES_KEY}, ${cn$2(`w-${v} h-${
|
|
7096
|
+
const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: y, width: v } = getHeightAndWidthFromClass(w);
|
|
7097
|
+
if (y && v)
|
|
7098
|
+
a.styles = `${STYLES_KEY}, ${cn$2(`w-${v} h-${y}`, w)}`.trim(), a.height = y == null ? void 0 : y.replace("px", ""), a.width = v == null ? void 0 : v.replace("px", "");
|
|
7102
7099
|
else {
|
|
7103
7100
|
const B = (E = find(n.attributes, { key: "height" })) == null ? void 0 : E.value, S = (_ = find(n.attributes, { key: "width" })) == null ? void 0 : _.value;
|
|
7104
7101
|
B && S ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${S}px] h-[${B}px]`, w)}`.trim(), a.height = B, a.width = S) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
|
|
@@ -7220,7 +7217,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7220
7217
|
parentId: n = void 0,
|
|
7221
7218
|
position: a = -1
|
|
7222
7219
|
}) => {
|
|
7223
|
-
const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""),
|
|
7220
|
+
const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), k = (E) => {
|
|
7224
7221
|
const _ = has(E, "styles_attrs.data-page-section");
|
|
7225
7222
|
return E._type === "Box" && _;
|
|
7226
7223
|
}, b = useCallback(
|
|
@@ -7241,20 +7238,20 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7241
7238
|
{
|
|
7242
7239
|
onClick: l ? () => {
|
|
7243
7240
|
} : b,
|
|
7244
|
-
draggable:
|
|
7241
|
+
draggable: x ? "true" : "false",
|
|
7245
7242
|
onDragStart: async (E) => {
|
|
7246
7243
|
const _ = await c({ library: r, block: o });
|
|
7247
7244
|
let N = n;
|
|
7248
|
-
if (
|
|
7245
|
+
if (k(first(_)) && (N = null), !isEmpty(_)) {
|
|
7249
7246
|
const w = { blocks: _, uiLibrary: !0, parent: N };
|
|
7250
7247
|
if (E.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
|
|
7251
|
-
const
|
|
7252
|
-
|
|
7253
|
-
E.dataTransfer.setDragImage(
|
|
7248
|
+
const y = new Image();
|
|
7249
|
+
y.src = o.preview, y.onload = () => {
|
|
7250
|
+
E.dataTransfer.setDragImage(y, 0, 0);
|
|
7254
7251
|
};
|
|
7255
7252
|
} else
|
|
7256
7253
|
E.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7257
|
-
|
|
7254
|
+
f(w), setTimeout(() => {
|
|
7258
7255
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7259
7256
|
}, 200);
|
|
7260
7257
|
}
|
|
@@ -7280,37 +7277,37 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7280
7277
|
] }) })
|
|
7281
7278
|
] });
|
|
7282
7279
|
}, UILibrarySection = ({ parentId: o, position: r }) => {
|
|
7283
|
-
const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((C) => C.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]),
|
|
7280
|
+
const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((C) => C.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), x = useRef(null);
|
|
7284
7281
|
useEffect(() => {
|
|
7285
|
-
c && c.length > 0 && (
|
|
7282
|
+
c && c.length > 0 && (x.current = new Fuse(c, {
|
|
7286
7283
|
keys: ["name", "label", "description", "group"],
|
|
7287
7284
|
threshold: 0.4,
|
|
7288
7285
|
ignoreLocation: !0
|
|
7289
7286
|
}));
|
|
7290
7287
|
}, [c]), useEffect(() => {
|
|
7291
|
-
if (!u.trim() || !
|
|
7288
|
+
if (!u.trim() || !x.current) {
|
|
7292
7289
|
m([]);
|
|
7293
7290
|
return;
|
|
7294
7291
|
}
|
|
7295
|
-
const C =
|
|
7292
|
+
const C = x.current.search(u).map((j) => j.item);
|
|
7296
7293
|
m(C);
|
|
7297
7294
|
}, [u]);
|
|
7298
|
-
const
|
|
7295
|
+
const f = u.trim() && !isEmpty(h) ? h : c, k = groupBy(f, "group"), [b, A] = useState(null);
|
|
7299
7296
|
useEffect(() => {
|
|
7300
|
-
if (isEmpty(keys(
|
|
7297
|
+
if (isEmpty(keys(k))) {
|
|
7301
7298
|
A(null);
|
|
7302
7299
|
return;
|
|
7303
7300
|
}
|
|
7304
|
-
if (!b || !
|
|
7305
|
-
A(first(keys(
|
|
7301
|
+
if (!b || !k[b]) {
|
|
7302
|
+
A(first(keys(k)));
|
|
7306
7303
|
return;
|
|
7307
7304
|
}
|
|
7308
|
-
}, [
|
|
7309
|
-
const E = get(
|
|
7305
|
+
}, [k, b]);
|
|
7306
|
+
const E = get(k, b, []), _ = useRef(null), { t: N } = useTranslation(), w = (C) => {
|
|
7310
7307
|
_.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
|
|
7311
7308
|
_.current && A(C);
|
|
7312
7309
|
}, 400);
|
|
7313
|
-
},
|
|
7310
|
+
}, y = () => {
|
|
7314
7311
|
i != null && i.id && p(i.id);
|
|
7315
7312
|
}, v = () => {
|
|
7316
7313
|
g("");
|
|
@@ -7348,13 +7345,13 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7348
7345
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7349
7346
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: N("Groups") }),
|
|
7350
7347
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7351
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(
|
|
7348
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7352
7349
|
/* @__PURE__ */ jsx("p", { className: "text-sm", children: N("Failed to load the UI library. Try again") }),
|
|
7353
|
-
/* @__PURE__ */ jsxs(Button, { onClick:
|
|
7350
|
+
/* @__PURE__ */ jsxs(Button, { onClick: y, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7354
7351
|
/* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
|
|
7355
7352
|
N("Retry")
|
|
7356
7353
|
] })
|
|
7357
|
-
] }) }) : map(
|
|
7354
|
+
] }) }) : map(k, (C, j) => /* @__PURE__ */ jsxs(
|
|
7358
7355
|
"div",
|
|
7359
7356
|
{
|
|
7360
7357
|
onMouseEnter: () => w(j),
|
|
@@ -7380,7 +7377,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7380
7377
|
onMouseEnter: () => _.current ? clearTimeout(_.current) : null,
|
|
7381
7378
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7382
7379
|
children: [
|
|
7383
|
-
isEmpty(E) && !isEmpty(
|
|
7380
|
+
isEmpty(E) && !isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
|
|
7384
7381
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: B.map((C, j) => /* @__PURE__ */ jsx(
|
|
7385
7382
|
BlockCard,
|
|
7386
7383
|
{
|
|
@@ -7435,25 +7432,25 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7435
7432
|
error: c
|
|
7436
7433
|
}), g(!0);
|
|
7437
7434
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7438
|
-
const m = Object.entries(a).map(([
|
|
7439
|
-
const b =
|
|
7435
|
+
const m = Object.entries(a).map(([f, k]) => {
|
|
7436
|
+
const b = k, A = b.type || "partial", E = formatReadableName(A);
|
|
7440
7437
|
return {
|
|
7441
7438
|
type: "PartialBlock",
|
|
7442
7439
|
// Set the type to PartialBlock
|
|
7443
|
-
label: formatReadableName(b.name ||
|
|
7440
|
+
label: formatReadableName(b.name || f),
|
|
7444
7441
|
description: b.description || "",
|
|
7445
7442
|
icon: Globe,
|
|
7446
7443
|
group: E,
|
|
7447
7444
|
// Use formatted type as group
|
|
7448
7445
|
category: "partial",
|
|
7449
|
-
partialBlockId:
|
|
7446
|
+
partialBlockId: f,
|
|
7450
7447
|
// Store the original ID as partialBlockId
|
|
7451
7448
|
_name: b.name
|
|
7452
7449
|
};
|
|
7453
|
-
}),
|
|
7450
|
+
}), x = uniq(map(m, "group"));
|
|
7454
7451
|
p({
|
|
7455
7452
|
blocks: m,
|
|
7456
|
-
groups:
|
|
7453
|
+
groups: x,
|
|
7457
7454
|
isLoading: !1,
|
|
7458
7455
|
error: null
|
|
7459
7456
|
}), g(!0);
|
|
@@ -7499,7 +7496,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7499
7496
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
|
|
7500
7497
|
}, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7501
7498
|
var S;
|
|
7502
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (S = find(c, (C) => C._id === n)) == null ? void 0 : S._type, [m,
|
|
7499
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (S = find(c, (C) => C._id === n)) == null ? void 0 : S._type, [m, x] = useState("all"), [f, k] = useState(null), b = useRef(null);
|
|
7503
7500
|
useEffect(() => {
|
|
7504
7501
|
const C = setTimeout(() => {
|
|
7505
7502
|
var j;
|
|
@@ -7507,18 +7504,18 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7507
7504
|
}, 0);
|
|
7508
7505
|
return () => clearTimeout(C);
|
|
7509
7506
|
}, [g]), useEffect(() => {
|
|
7510
|
-
d && (
|
|
7507
|
+
d && (x("all"), k(null));
|
|
7511
7508
|
}, [d]), useEffect(() => (b.current = debounce((C) => {
|
|
7512
|
-
|
|
7509
|
+
x(C);
|
|
7513
7510
|
}, 500), () => {
|
|
7514
7511
|
b.current && b.current.cancel();
|
|
7515
7512
|
}), []);
|
|
7516
7513
|
const A = useCallback((C) => {
|
|
7517
|
-
|
|
7514
|
+
k(C), b.current && b.current(C);
|
|
7518
7515
|
}, []), E = useCallback(() => {
|
|
7519
|
-
|
|
7516
|
+
k(null), b.current && b.current.cancel();
|
|
7520
7517
|
}, []), _ = useCallback((C) => {
|
|
7521
|
-
b.current && b.current.cancel(),
|
|
7518
|
+
b.current && b.current.cancel(), x(C), k(null);
|
|
7522
7519
|
}, []), N = useMemo(
|
|
7523
7520
|
() => d ? values(r).filter(
|
|
7524
7521
|
(C) => {
|
|
@@ -7532,10 +7529,10 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7532
7529
|
(C) => reject(filter(values(N), { group: C }), { hidden: !0 }).length > 0
|
|
7533
7530
|
) : o.filter((C) => reject(filter(values(r), { group: C }), { hidden: !0 }).length > 0),
|
|
7534
7531
|
[r, N, o, d]
|
|
7535
|
-
),
|
|
7532
|
+
), y = useMemo(
|
|
7536
7533
|
() => sortBy(w, (C) => CORE_GROUPS.indexOf(C) === -1 ? 99 : CORE_GROUPS.indexOf(C)),
|
|
7537
7534
|
[w]
|
|
7538
|
-
), v = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), B = useMemo(() => m === "all" ?
|
|
7535
|
+
), v = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), B = useMemo(() => m === "all" ? y : [m], [y, m]);
|
|
7539
7536
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7540
7537
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7541
7538
|
Input$1,
|
|
@@ -7549,25 +7546,25 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7549
7546
|
}
|
|
7550
7547
|
) }),
|
|
7551
7548
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7552
|
-
|
|
7549
|
+
y.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
7553
7550
|
/* @__PURE__ */ jsx(
|
|
7554
7551
|
"button",
|
|
7555
7552
|
{
|
|
7556
7553
|
onClick: () => _("all"),
|
|
7557
7554
|
onMouseEnter: () => A("all"),
|
|
7558
7555
|
onMouseLeave: E,
|
|
7559
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" ||
|
|
7556
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7560
7557
|
children: i("All")
|
|
7561
7558
|
},
|
|
7562
7559
|
"sidebar-all"
|
|
7563
7560
|
),
|
|
7564
|
-
|
|
7561
|
+
y.map((C) => /* @__PURE__ */ jsx(
|
|
7565
7562
|
"button",
|
|
7566
7563
|
{
|
|
7567
7564
|
onClick: () => _(C),
|
|
7568
7565
|
onMouseEnter: () => A(C),
|
|
7569
7566
|
onMouseLeave: E,
|
|
7570
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === C ||
|
|
7567
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === C || f === C ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7571
7568
|
children: capitalize(i(C.toLowerCase()))
|
|
7572
7569
|
},
|
|
7573
7570
|
`sidebar-${C}`
|
|
@@ -7608,7 +7605,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7608
7605
|
}, [i, g, c]);
|
|
7609
7606
|
const m = useCallback(() => {
|
|
7610
7607
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7611
|
-
}, []),
|
|
7608
|
+
}, []), x = useChaiAddBlockTabs(), f = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
|
|
7612
7609
|
return useEffect(() => {
|
|
7613
7610
|
i === "library" && !b && c("core");
|
|
7614
7611
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7629,14 +7626,14 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7629
7626
|
b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7630
7627
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7631
7628
|
g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7632
|
-
|
|
7633
|
-
map(
|
|
7629
|
+
f ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7630
|
+
map(x, (A) => /* @__PURE__ */ jsx(TabsTrigger, { value: A.id, children: React__default.createElement(A.tab) }, `tab-add-block-${A.id}`))
|
|
7634
7631
|
] }),
|
|
7635
7632
|
/* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
|
|
7636
7633
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
|
|
7637
7634
|
g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
|
|
7638
|
-
|
|
7639
|
-
map(
|
|
7635
|
+
f ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
|
|
7636
|
+
map(x, (A) => /* @__PURE__ */ jsx(TabsContent, { value: A.id, children: React__default.createElement(A.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${A.id}`))
|
|
7640
7637
|
]
|
|
7641
7638
|
}
|
|
7642
7639
|
)
|
|
@@ -7946,13 +7943,13 @@ const Input = ({ node: o }) => {
|
|
|
7946
7943
|
var P;
|
|
7947
7944
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7948
7945
|
let p = null;
|
|
7949
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data:
|
|
7946
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: x, isSelected: f, willReceiveDrop: k, isDragging: b, isEditing: A, handleClick: E } = o, _ = (L) => {
|
|
7950
7947
|
L.stopPropagation(), !l.includes(m) && o.toggle();
|
|
7951
7948
|
}, N = (L) => {
|
|
7952
7949
|
L.isInternal && (p = L.isOpen, L.isOpen && L.close());
|
|
7953
7950
|
}, w = (L) => {
|
|
7954
7951
|
L.isInternal && p !== null && (p ? L.open() : L.close(), p = null);
|
|
7955
|
-
}, [
|
|
7952
|
+
}, [y, v] = useAtom$1(currentAddSelection), B = () => {
|
|
7956
7953
|
var L;
|
|
7957
7954
|
S(), o.parent.isSelected || v((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
|
|
7958
7955
|
}, S = () => {
|
|
@@ -7962,10 +7959,10 @@ const Input = ({ node: o }) => {
|
|
|
7962
7959
|
};
|
|
7963
7960
|
useEffect(() => {
|
|
7964
7961
|
const L = setTimeout(() => {
|
|
7965
|
-
|
|
7962
|
+
k && !o.isOpen && !b && !l.includes(m) && o.toggle();
|
|
7966
7963
|
}, 500);
|
|
7967
7964
|
return () => clearTimeout(L);
|
|
7968
|
-
}, [
|
|
7965
|
+
}, [k, o, b]);
|
|
7969
7966
|
const j = (L, D) => {
|
|
7970
7967
|
const R = c.contentDocument || c.contentWindow.document, M = R.querySelector(`[data-block-id=${L}]`);
|
|
7971
7968
|
M && M.setAttribute("data-drop", D);
|
|
@@ -7994,7 +7991,7 @@ const Input = ({ node: o }) => {
|
|
|
7994
7991
|
),
|
|
7995
7992
|
/* @__PURE__ */ jsx("br", {})
|
|
7996
7993
|
] });
|
|
7997
|
-
const T = useMemo(() => has(
|
|
7994
|
+
const T = useMemo(() => has(x, "_libBlockId") && !isEmpty(x._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [x, d]);
|
|
7998
7995
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7999
7996
|
"div",
|
|
8000
7997
|
{
|
|
@@ -8033,12 +8030,12 @@ const Input = ({ node: o }) => {
|
|
|
8033
8030
|
{
|
|
8034
8031
|
className: cn(
|
|
8035
8032
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
(o == null ? void 0 : o.id) ===
|
|
8033
|
+
f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
|
|
8034
|
+
k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
|
|
8035
|
+
(o == null ? void 0 : o.id) === y ? "bg-primary/10" : "",
|
|
8039
8036
|
b && "opacity-20",
|
|
8040
8037
|
l.includes(m) ? "opacity-50" : "",
|
|
8041
|
-
T &&
|
|
8038
|
+
T && f && "bg-primary/20 text-primary"
|
|
8042
8039
|
),
|
|
8043
8040
|
children: [
|
|
8044
8041
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -8046,7 +8043,7 @@ const Input = ({ node: o }) => {
|
|
|
8046
8043
|
"div",
|
|
8047
8044
|
{
|
|
8048
8045
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
8049
|
-
children: u && /* @__PURE__ */ jsx("button", { onClick: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${
|
|
8046
|
+
children: u && /* @__PURE__ */ jsx("button", { onClick: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${f ? "text-white" : "text-slate-400"}` }) })
|
|
8050
8047
|
}
|
|
8051
8048
|
),
|
|
8052
8049
|
/* @__PURE__ */ jsxs(
|
|
@@ -8055,10 +8052,10 @@ const Input = ({ node: o }) => {
|
|
|
8055
8052
|
className: cn(
|
|
8056
8053
|
"leading-1 flex items-center",
|
|
8057
8054
|
T && "text-primary/60",
|
|
8058
|
-
T &&
|
|
8055
|
+
T && f && "text-primary/80"
|
|
8059
8056
|
),
|
|
8060
8057
|
children: [
|
|
8061
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
8058
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
|
|
8062
8059
|
A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
|
|
8063
8060
|
"div",
|
|
8064
8061
|
{
|
|
@@ -8066,7 +8063,7 @@ const Input = ({ node: o }) => {
|
|
|
8066
8063
|
onDoubleClick: (L) => {
|
|
8067
8064
|
L.stopPropagation(), o.edit(), o.deselect();
|
|
8068
8065
|
},
|
|
8069
|
-
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(
|
|
8066
|
+
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(x) })
|
|
8070
8067
|
}
|
|
8071
8068
|
)
|
|
8072
8069
|
]
|
|
@@ -8074,7 +8071,7 @@ const Input = ({ node: o }) => {
|
|
|
8074
8071
|
)
|
|
8075
8072
|
] }),
|
|
8076
8073
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
8077
|
-
canAddChildBlock(
|
|
8074
|
+
canAddChildBlock(x == null ? void 0 : x._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8078
8075
|
/* @__PURE__ */ jsx(
|
|
8079
8076
|
TooltipTrigger,
|
|
8080
8077
|
{
|
|
@@ -8364,8 +8361,8 @@ const Input = ({ node: o }) => {
|
|
|
8364
8361
|
] });
|
|
8365
8362
|
}, defaultShadcnPreset = {
|
|
8366
8363
|
fontFamily: {
|
|
8367
|
-
heading: "
|
|
8368
|
-
body: "
|
|
8364
|
+
heading: "Poppins",
|
|
8365
|
+
body: "Poppins"
|
|
8369
8366
|
},
|
|
8370
8367
|
borderRadius: "6px",
|
|
8371
8368
|
colors: {
|
|
@@ -8389,9 +8386,131 @@ const Input = ({ node: o }) => {
|
|
|
8389
8386
|
popover: ["#ffffff", "#262626"],
|
|
8390
8387
|
"popover-foreground": ["#0a0a0a", "#fafafa"]
|
|
8391
8388
|
}
|
|
8389
|
+
}, twitter = {
|
|
8390
|
+
fontFamily: {
|
|
8391
|
+
heading: "Poppins",
|
|
8392
|
+
body: "Poppins"
|
|
8393
|
+
},
|
|
8394
|
+
borderRadius: "4px",
|
|
8395
|
+
colors: {
|
|
8396
|
+
background: ["#ffffff", "#000000"],
|
|
8397
|
+
foreground: ["#0f1419", "#e7e9ea"],
|
|
8398
|
+
primary: ["#1e9df1", "#1c9cf0"],
|
|
8399
|
+
"primary-foreground": ["#ffffff", "#ffffff"],
|
|
8400
|
+
secondary: ["#0f1419", "#f0f3f4"],
|
|
8401
|
+
"secondary-foreground": ["#ffffff", "#0f1419"],
|
|
8402
|
+
muted: ["#e5e5e6", "#181818"],
|
|
8403
|
+
"muted-foreground": ["#0f1419", "#72767a"],
|
|
8404
|
+
accent: ["#e3ecf6", "#061622"],
|
|
8405
|
+
"accent-foreground": ["#1e9df1", "#1c9cf0"],
|
|
8406
|
+
destructive: ["#f4212e", "#f4212e"],
|
|
8407
|
+
"destructive-foreground": ["#ffffff", "#ffffff"],
|
|
8408
|
+
border: ["#e1eaef", "#242628"],
|
|
8409
|
+
input: ["#f7f9fa", "#22303c"],
|
|
8410
|
+
ring: ["#1da1f2", "#1da1f2"],
|
|
8411
|
+
card: ["#f7f8f8", "#17181c"],
|
|
8412
|
+
"card-foreground": ["#0f1419", "#d9d9d9"],
|
|
8413
|
+
popover: ["#ffffff", "#000000"],
|
|
8414
|
+
"popover-foreground": ["#0f1419", "#e7e9ea"],
|
|
8415
|
+
sidebar: ["#f7f8f8", "#17181c"],
|
|
8416
|
+
"sidebar-foreground": ["#0f1419", "#d9d9d9"],
|
|
8417
|
+
"sidebar-primary": ["#1e9df1", "#1da1f2"],
|
|
8418
|
+
"sidebar-primary-foreground": ["#ffffff", "#ffffff"],
|
|
8419
|
+
"sidebar-accent": ["#e3ecf6", "#061622"],
|
|
8420
|
+
"sidebar-accent-foreground": ["#1e9df1", "#1c9cf0"],
|
|
8421
|
+
"sidebar-border": ["#e1e8ed", "#38444d"],
|
|
8422
|
+
"sidebar-ring": ["#1da1f2", "#1da1f2"]
|
|
8423
|
+
}
|
|
8424
|
+
}, solarized = {
|
|
8425
|
+
fontFamily: {
|
|
8426
|
+
heading: "Geist",
|
|
8427
|
+
body: "Geist"
|
|
8428
|
+
},
|
|
8429
|
+
borderRadius: "4px",
|
|
8430
|
+
colors: {
|
|
8431
|
+
background: ["#fdf6e3", "#002b36"],
|
|
8432
|
+
foreground: ["#073642", "#93a1a1"],
|
|
8433
|
+
primary: ["#d33682", "#d33682"],
|
|
8434
|
+
"primary-foreground": ["#ffffff", "#ffffff"],
|
|
8435
|
+
secondary: ["#2aa198", "#2aa198"],
|
|
8436
|
+
"secondary-foreground": ["#ffffff", "#ffffff"],
|
|
8437
|
+
muted: ["#93a1a1", "#586e75"],
|
|
8438
|
+
"muted-foreground": ["#073642", "#93a1a1"],
|
|
8439
|
+
accent: ["#cb4b16", "#cb4b16"],
|
|
8440
|
+
"accent-foreground": ["#ffffff", "#ffffff"],
|
|
8441
|
+
destructive: ["#dc322f", "#dc322f"],
|
|
8442
|
+
"destructive-foreground": ["#ffffff", "#ffffff"],
|
|
8443
|
+
border: ["#839496", "#586e75"],
|
|
8444
|
+
input: ["#839496", "#586e75"],
|
|
8445
|
+
ring: ["#d33682", "#d33682"],
|
|
8446
|
+
card: ["#eee8d5", "#073642"],
|
|
8447
|
+
"card-foreground": ["#073642", "#93a1a1"],
|
|
8448
|
+
popover: ["#eee8d5", "#073642"],
|
|
8449
|
+
"popover-foreground": ["#073642", "#93a1a1"]
|
|
8450
|
+
}
|
|
8451
|
+
}, claude = {
|
|
8452
|
+
fontFamily: {
|
|
8453
|
+
heading: "Poppins",
|
|
8454
|
+
body: "Poppins"
|
|
8455
|
+
},
|
|
8456
|
+
borderRadius: "6px",
|
|
8457
|
+
colors: {
|
|
8458
|
+
background: ["#faf9f5", "#262624"],
|
|
8459
|
+
foreground: ["#3d3929", "#c3c0b6"],
|
|
8460
|
+
primary: ["#c96442", "#d97757"],
|
|
8461
|
+
"primary-foreground": ["#ffffff", "#ffffff"],
|
|
8462
|
+
secondary: ["#e9e6dc", "#faf9f5"],
|
|
8463
|
+
"secondary-foreground": ["#535146", "#30302e"],
|
|
8464
|
+
muted: ["#ede9de", "#1b1b19"],
|
|
8465
|
+
"muted-foreground": ["#83827d", "#b7b5a9"],
|
|
8466
|
+
accent: ["#e9e6dc", "#1a1915"],
|
|
8467
|
+
"accent-foreground": ["#28261b", "#f5f4ee"],
|
|
8468
|
+
destructive: ["#141413", "#ef4444"],
|
|
8469
|
+
"destructive-foreground": ["#ffffff", "#ffffff"],
|
|
8470
|
+
border: ["#dad9d4", "#3e3e38"],
|
|
8471
|
+
input: ["#b4b2a7", "#52514a"],
|
|
8472
|
+
ring: ["#c96442", "#d97757"],
|
|
8473
|
+
card: ["#faf9f5", "#262624"],
|
|
8474
|
+
"card-foreground": ["#141413", "#faf9f5"],
|
|
8475
|
+
popover: ["#ffffff", "#30302e"],
|
|
8476
|
+
"popover-foreground": ["#28261b", "#e5e5e2"]
|
|
8477
|
+
}
|
|
8478
|
+
}, supabase = {
|
|
8479
|
+
fontFamily: {
|
|
8480
|
+
heading: "Inter",
|
|
8481
|
+
body: "Inter"
|
|
8482
|
+
},
|
|
8483
|
+
borderRadius: "6px",
|
|
8484
|
+
colors: {
|
|
8485
|
+
background: ["#fff9f5", "#2a2024"],
|
|
8486
|
+
foreground: ["#3d3436", "#f2e9e4"],
|
|
8487
|
+
primary: ["#ff7e5f", "#ff7e5f"],
|
|
8488
|
+
"primary-foreground": ["#ffffff", "#ffffff"],
|
|
8489
|
+
secondary: ["#ffedea", "#463a41"],
|
|
8490
|
+
"secondary-foreground": ["#b35340", "#f2e9e4"],
|
|
8491
|
+
muted: ["#fff0eb", "#392f35"],
|
|
8492
|
+
"muted-foreground": ["#78716c", "#d7c6bc"],
|
|
8493
|
+
accent: ["#feb47b", "#feb47b"],
|
|
8494
|
+
"accent-foreground": ["#3d3436", "#2a2024"],
|
|
8495
|
+
destructive: ["#e63946", "#e63946"],
|
|
8496
|
+
"destructive-foreground": ["#ffffff", "#ffffff"],
|
|
8497
|
+
border: ["#ffe0d6", "#463a41"],
|
|
8498
|
+
input: ["#ffe0d6", "#463a41"],
|
|
8499
|
+
ring: ["#ff7e5f", "#ff7e5f"],
|
|
8500
|
+
card: ["#ffffff", "#392f35"],
|
|
8501
|
+
"card-foreground": ["#3d3436", "#f2e9e4"],
|
|
8502
|
+
popover: ["#ffffff", "#392f35"],
|
|
8503
|
+
"popover-foreground": ["#3d3436", "#f2e9e4"]
|
|
8504
|
+
}
|
|
8392
8505
|
}, LazyCssImportModal = lazy(
|
|
8393
|
-
() => import("./css-import-modal-
|
|
8394
|
-
), PREV_THEME_KEY = "chai-builder-previous-theme", DEFAULT_THEME_PRESET = [
|
|
8506
|
+
() => import("./css-import-modal-Ds-qmte_.js").then((o) => ({ default: o.CssImportModal }))
|
|
8507
|
+
), PREV_THEME_KEY = "chai-builder-previous-theme", DEFAULT_THEME_PRESET = [
|
|
8508
|
+
{ shadcn_default: defaultShadcnPreset },
|
|
8509
|
+
{ twitter_theme: twitter },
|
|
8510
|
+
{ solarized_theme: solarized },
|
|
8511
|
+
{ claude_theme: claude },
|
|
8512
|
+
{ supabase_theme: supabase }
|
|
8513
|
+
], setPreviousTheme = (o) => {
|
|
8395
8514
|
if (!(typeof window > "u"))
|
|
8396
8515
|
try {
|
|
8397
8516
|
localStorage.setItem(PREV_THEME_KEY, JSON.stringify(o));
|
|
@@ -8407,18 +8526,24 @@ const Input = ({ node: o }) => {
|
|
|
8407
8526
|
}
|
|
8408
8527
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8409
8528
|
const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
|
|
8410
|
-
|
|
8411
|
-
|
|
8529
|
+
if (d) {
|
|
8530
|
+
const w = d.map((y) => Object.keys(y)[0]);
|
|
8531
|
+
DEFAULT_THEME_PRESET.forEach((y) => {
|
|
8532
|
+
const v = Object.keys(y)[0];
|
|
8533
|
+
w.includes(v) || d.push(y);
|
|
8534
|
+
});
|
|
8535
|
+
}
|
|
8536
|
+
const [g, h] = useTheme(), m = useThemeOptions(), { t: x } = useTranslation(), f = React.useCallback(
|
|
8412
8537
|
(w) => {
|
|
8413
|
-
const
|
|
8414
|
-
setPreviousTheme(
|
|
8538
|
+
const y = { ...g };
|
|
8539
|
+
setPreviousTheme(y), h(w), toast.success("Theme updated", {
|
|
8415
8540
|
action: {
|
|
8416
8541
|
label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8417
8542
|
/* @__PURE__ */ jsx(Undo$1, { className: "h-4 w-4" }),
|
|
8418
8543
|
" Undo"
|
|
8419
8544
|
] }),
|
|
8420
8545
|
onClick: () => {
|
|
8421
|
-
h(
|
|
8546
|
+
h(y), clearPreviousTheme(), toast.dismiss();
|
|
8422
8547
|
}
|
|
8423
8548
|
},
|
|
8424
8549
|
closeButton: !0,
|
|
@@ -8426,22 +8551,22 @@ const Input = ({ node: o }) => {
|
|
|
8426
8551
|
});
|
|
8427
8552
|
},
|
|
8428
8553
|
[g, h]
|
|
8429
|
-
),
|
|
8430
|
-
const w = d.find((
|
|
8554
|
+
), k = () => {
|
|
8555
|
+
const w = d.find((y) => Object.keys(y)[0] === a);
|
|
8431
8556
|
if (w) {
|
|
8432
|
-
const
|
|
8433
|
-
|
|
8557
|
+
const y = Object.values(w)[0];
|
|
8558
|
+
y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? (f(y), l("")) : console.error("Invalid preset structure:", y);
|
|
8434
8559
|
} else
|
|
8435
8560
|
console.error("Preset not found:", a);
|
|
8436
8561
|
}, b = (w) => {
|
|
8437
|
-
|
|
8562
|
+
f(w), l("");
|
|
8438
8563
|
}, A = useDebouncedCallback(
|
|
8439
|
-
(w,
|
|
8564
|
+
(w, y) => {
|
|
8440
8565
|
h(() => ({
|
|
8441
8566
|
...g,
|
|
8442
8567
|
fontFamily: {
|
|
8443
8568
|
...g.fontFamily,
|
|
8444
|
-
[w.replace(/font-/g, "")]:
|
|
8569
|
+
[w.replace(/font-/g, "")]: y
|
|
8445
8570
|
}
|
|
8446
8571
|
}));
|
|
8447
8572
|
},
|
|
@@ -8456,10 +8581,10 @@ const Input = ({ node: o }) => {
|
|
|
8456
8581
|
},
|
|
8457
8582
|
[g]
|
|
8458
8583
|
), _ = useDebouncedCallback(
|
|
8459
|
-
(w,
|
|
8584
|
+
(w, y) => {
|
|
8460
8585
|
h(() => {
|
|
8461
8586
|
const v = get(g, `colors.${w}`);
|
|
8462
|
-
return r ? set(v, 1,
|
|
8587
|
+
return r ? set(v, 1, y) : set(v, 0, y), {
|
|
8463
8588
|
...g,
|
|
8464
8589
|
colors: {
|
|
8465
8590
|
...g.colors,
|
|
@@ -8470,38 +8595,38 @@ const Input = ({ node: o }) => {
|
|
|
8470
8595
|
},
|
|
8471
8596
|
[g],
|
|
8472
8597
|
200
|
|
8473
|
-
), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([
|
|
8474
|
-
const v = get(g, `colors.${
|
|
8598
|
+
), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([y]) => {
|
|
8599
|
+
const v = get(g, `colors.${y}.${r ? 1 : 0}`);
|
|
8475
8600
|
return v ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8476
8601
|
/* @__PURE__ */ jsx(
|
|
8477
8602
|
ColorPickerInput,
|
|
8478
8603
|
{
|
|
8479
8604
|
value: v,
|
|
8480
|
-
onChange: (B) => _(
|
|
8605
|
+
onChange: (B) => _(y, B)
|
|
8481
8606
|
}
|
|
8482
8607
|
),
|
|
8483
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children:
|
|
8484
|
-
] },
|
|
8608
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: y.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((B) => B.charAt(0).toUpperCase() + B.slice(1)).join(" ") + (!y.toLowerCase().includes("foreground") && !y.toLowerCase().includes("border") && !y.toLowerCase().includes("input") && !y.toLowerCase().includes("ring") && !y.toLowerCase().includes("background") ? " Background" : "") })
|
|
8609
|
+
] }, y) : null;
|
|
8485
8610
|
}) });
|
|
8486
8611
|
return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8487
8612
|
/* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8488
8613
|
d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
|
|
8489
8614
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
8490
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8615
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: x("Presets") }),
|
|
8491
8616
|
/* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
|
|
8492
8617
|
/* @__PURE__ */ jsx(ImportIcon, { className: "h-4 w-4" }),
|
|
8493
|
-
|
|
8618
|
+
x("Import theme")
|
|
8494
8619
|
] }) })
|
|
8495
8620
|
] }),
|
|
8496
8621
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
|
|
8497
8622
|
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
|
|
8498
8623
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
|
|
8499
8624
|
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
|
|
8500
|
-
const
|
|
8501
|
-
return /* @__PURE__ */ jsx(SelectItem, { value:
|
|
8625
|
+
const y = Object.keys(w)[0], v = y.replaceAll("_", " ");
|
|
8626
|
+
return /* @__PURE__ */ jsx(SelectItem, { value: y, children: capitalize(v) }, y);
|
|
8502
8627
|
}) })
|
|
8503
8628
|
] }) }),
|
|
8504
|
-
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick:
|
|
8629
|
+
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children: x("Apply") }) })
|
|
8505
8630
|
] })
|
|
8506
8631
|
] }),
|
|
8507
8632
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
@@ -8510,11 +8635,11 @@ const Input = ({ node: o }) => {
|
|
|
8510
8635
|
/* @__PURE__ */ jsx(Type, { className: "h-3 w-3 text-gray-600" }),
|
|
8511
8636
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
|
|
8512
8637
|
] }),
|
|
8513
|
-
(m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w,
|
|
8638
|
+
(m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w, y]) => /* @__PURE__ */ jsx(
|
|
8514
8639
|
FontSelector,
|
|
8515
8640
|
{
|
|
8516
8641
|
label: w,
|
|
8517
|
-
value: g.fontFamily[w.replace(/font-/g, "")] ||
|
|
8642
|
+
value: g.fontFamily[w.replace(/font-/g, "")] || y[Object.keys(y)[0]],
|
|
8518
8643
|
onChange: (v) => A(w, v)
|
|
8519
8644
|
},
|
|
8520
8645
|
w
|
|
@@ -9051,186 +9176,80 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9051
9176
|
) }) });
|
|
9052
9177
|
}
|
|
9053
9178
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
9054
|
-
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(
|
|
9179
|
+
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(), u = useRef(null), g = useRef(null);
|
|
9055
9180
|
useEffect(() => {
|
|
9056
|
-
var
|
|
9057
|
-
(
|
|
9181
|
+
var m;
|
|
9182
|
+
(m = u.current) == null || m.focus();
|
|
9058
9183
|
}, []);
|
|
9059
|
-
const
|
|
9060
|
-
const { usage:
|
|
9061
|
-
!l &&
|
|
9184
|
+
const h = (m) => {
|
|
9185
|
+
const { usage: x } = m || {};
|
|
9186
|
+
!l && x && p(x), g.current = setTimeout(() => p(void 0), 1e4), l || c("");
|
|
9062
9187
|
};
|
|
9063
|
-
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
9064
|
-
/* @__PURE__ */
|
|
9065
|
-
|
|
9188
|
+
return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "mt-2", children: [
|
|
9189
|
+
/* @__PURE__ */ jsx(
|
|
9190
|
+
Textarea,
|
|
9066
9191
|
{
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9192
|
+
ref: u,
|
|
9193
|
+
value: i,
|
|
9194
|
+
onChange: (m) => c(m.target.value),
|
|
9195
|
+
placeholder: r("Ask AI to edit content"),
|
|
9196
|
+
className: "w-full",
|
|
9197
|
+
rows: 3,
|
|
9198
|
+
onKeyDown: (m) => {
|
|
9199
|
+
m.key === "Enter" && (m.preventDefault(), g.current && clearTimeout(g.current), p(void 0), n("content", o, i, h));
|
|
9200
|
+
}
|
|
9073
9201
|
}
|
|
9074
9202
|
),
|
|
9075
|
-
|
|
9076
|
-
/* @__PURE__ */ jsx(
|
|
9077
|
-
|
|
9203
|
+
/* @__PURE__ */ jsxs("div", { className: "my-2 flex items-center gap-2", children: [
|
|
9204
|
+
a ? null : /* @__PURE__ */ jsx(
|
|
9205
|
+
Button,
|
|
9078
9206
|
{
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9207
|
+
disabled: i.trim().length < 5 || a,
|
|
9208
|
+
onClick: () => {
|
|
9209
|
+
g.current && clearTimeout(g.current), p(void 0), n("content", o, i, h);
|
|
9210
|
+
},
|
|
9211
|
+
variant: "default",
|
|
9212
|
+
className: "w-fit",
|
|
9213
|
+
size: "sm",
|
|
9214
|
+
children: a ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9215
|
+
/* @__PURE__ */ jsx(Loader, { className: "h-5 w-5 animate-spin" }),
|
|
9216
|
+
r("Generating... Please wait...")
|
|
9217
|
+
] }) : r("Edit with AI")
|
|
9088
9218
|
}
|
|
9089
9219
|
),
|
|
9090
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
{
|
|
9094
|
-
disabled: i.trim().length < 5 || a,
|
|
9095
|
-
onClick: () => {
|
|
9096
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f);
|
|
9097
|
-
},
|
|
9098
|
-
variant: "default",
|
|
9099
|
-
className: "w-fit",
|
|
9100
|
-
size: "sm",
|
|
9101
|
-
children: a ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9102
|
-
/* @__PURE__ */ jsx(Loader, { className: "h-5 w-5 animate-spin" }),
|
|
9103
|
-
r("Generating... Please wait...")
|
|
9104
|
-
] }) : r("Edit with AI")
|
|
9105
|
-
}
|
|
9106
|
-
),
|
|
9107
|
-
a ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
9108
|
-
/* @__PURE__ */ jsxs(Skeleton, { className: "flex w-full items-center space-x-1 px-4 py-1 pl-2", children: [
|
|
9109
|
-
/* @__PURE__ */ jsx(Loader, { className: "h-4 w-4 animate-spin text-gray-500" }),
|
|
9110
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs", children: r("Generating... Please wait...") })
|
|
9111
|
-
] }),
|
|
9112
|
-
/* @__PURE__ */ jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: r("Stop") })
|
|
9113
|
-
] }) : null
|
|
9114
|
-
] }),
|
|
9115
|
-
u ? /* @__PURE__ */ jsx("div", { className: "max-w-full", children: /* @__PURE__ */ jsxs("p", { className: "mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500", children: [
|
|
9116
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
9117
|
-
r("Total tokens used"),
|
|
9118
|
-
": ",
|
|
9119
|
-
u.totalTokens
|
|
9220
|
+
a ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
9221
|
+
/* @__PURE__ */ jsxs(Skeleton, { className: "flex w-full items-center space-x-1 px-4 py-1 pl-2", children: [
|
|
9222
|
+
/* @__PURE__ */ jsx(Loader, { className: "h-4 w-4 animate-spin text-gray-500" }),
|
|
9223
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs", children: r("Generating... Please wait...") })
|
|
9120
9224
|
] }),
|
|
9121
|
-
/* @__PURE__ */ jsx(
|
|
9122
|
-
] })
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
/* @__PURE__ */
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9225
|
+
/* @__PURE__ */ jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: r("Stop") })
|
|
9226
|
+
] }) : null
|
|
9227
|
+
] }),
|
|
9228
|
+
d ? /* @__PURE__ */ jsx("div", { className: "max-w-full", children: /* @__PURE__ */ jsxs("p", { className: "mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500", children: [
|
|
9229
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
9230
|
+
r("Total tokens used"),
|
|
9231
|
+
": ",
|
|
9232
|
+
d.totalTokens
|
|
9233
|
+
] }),
|
|
9234
|
+
/* @__PURE__ */ jsx(Countdown, {})
|
|
9235
|
+
] }) }) : null,
|
|
9236
|
+
/* @__PURE__ */ jsx("div", { className: "max-w-full", children: l && /* @__PURE__ */ jsx("p", { className: "break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500", children: l.message }) }),
|
|
9237
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
9238
|
+
/* @__PURE__ */ jsx(
|
|
9239
|
+
QuickPrompts,
|
|
9240
|
+
{
|
|
9241
|
+
onClick: (m) => {
|
|
9242
|
+
g.current && clearTimeout(g.current), p(void 0), n("content", o, m, h);
|
|
9131
9243
|
}
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
] });
|
|
9138
|
-
}, AISetContext = () => {
|
|
9139
|
-
const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
|
|
9140
|
-
useEffect(() => {
|
|
9141
|
-
r && a(r);
|
|
9142
|
-
}, [r]);
|
|
9143
|
-
const m = async () => {
|
|
9144
|
-
try {
|
|
9145
|
-
d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
|
|
9146
|
-
} catch (f) {
|
|
9147
|
-
u(f);
|
|
9148
|
-
} finally {
|
|
9149
|
-
d(!1);
|
|
9150
|
-
}
|
|
9151
|
-
};
|
|
9152
|
-
return /* @__PURE__ */ jsx(
|
|
9153
|
-
Accordion,
|
|
9154
|
-
{
|
|
9155
|
-
onValueChange: (f) => {
|
|
9156
|
-
g(f !== "");
|
|
9157
|
-
},
|
|
9158
|
-
type: "single",
|
|
9159
|
-
collapsible: !0,
|
|
9160
|
-
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
9161
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref: h, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
9162
|
-
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
9163
|
-
/* @__PURE__ */ jsx(
|
|
9164
|
-
Textarea,
|
|
9165
|
-
{
|
|
9166
|
-
ref: l,
|
|
9167
|
-
value: n,
|
|
9168
|
-
onChange: (f) => a(f.target.value),
|
|
9169
|
-
placeholder: o("Tell about this page eg this page is about"),
|
|
9170
|
-
className: "mt-1 w-full",
|
|
9171
|
-
rows: 10,
|
|
9172
|
-
onKeyDown: (f) => {
|
|
9173
|
-
f.key === "Enter" && (f.preventDefault(), m());
|
|
9174
|
-
}
|
|
9175
|
-
}
|
|
9176
|
-
),
|
|
9177
|
-
r.trim().length === 0 ? /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-gray-500", children: o(
|
|
9178
|
-
"Eg: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI."
|
|
9179
|
-
) }) : null,
|
|
9180
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-center", children: [
|
|
9181
|
-
/* @__PURE__ */ jsx(
|
|
9182
|
-
Button,
|
|
9183
|
-
{
|
|
9184
|
-
disabled: n.trim().length < 5,
|
|
9185
|
-
onClick: () => m(),
|
|
9186
|
-
variant: "default",
|
|
9187
|
-
className: "w-fit",
|
|
9188
|
-
size: "sm",
|
|
9189
|
-
children: c ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9190
|
-
/* @__PURE__ */ jsx(Loader, { className: "h-5 w-5 animate-spin" }),
|
|
9191
|
-
o("Saving... Please wait...")
|
|
9192
|
-
] }) : o("Save")
|
|
9193
|
-
}
|
|
9194
|
-
),
|
|
9195
|
-
r.trim().length > 0 ? /* @__PURE__ */ jsxs(AlertDialog, { children: [
|
|
9196
|
-
/* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { disabled: r.trim().length === 0, variant: "ghost", className: "w-fit", size: "sm", children: c ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9197
|
-
/* @__PURE__ */ jsx(Loader, { className: "h-5 w-5 animate-spin" }),
|
|
9198
|
-
o("Deleting... Please wait...")
|
|
9199
|
-
] }) : o("Delete") }) }),
|
|
9200
|
-
/* @__PURE__ */ jsxs(AlertDialogContent, { children: [
|
|
9201
|
-
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
9202
|
-
/* @__PURE__ */ jsxs(AlertDialogTitle, { children: [
|
|
9203
|
-
o("Delete context"),
|
|
9204
|
-
" ?"
|
|
9205
|
-
] }),
|
|
9206
|
-
/* @__PURE__ */ jsx(AlertDialogDescription, {})
|
|
9207
|
-
] }),
|
|
9208
|
-
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
9209
|
-
/* @__PURE__ */ jsx(AlertDialogCancel, { children: o("Cancel") }),
|
|
9210
|
-
/* @__PURE__ */ jsx(
|
|
9211
|
-
AlertDialogAction,
|
|
9212
|
-
{
|
|
9213
|
-
onClick: () => {
|
|
9214
|
-
a(""), m();
|
|
9215
|
-
},
|
|
9216
|
-
children: o("Yes, Delete")
|
|
9217
|
-
}
|
|
9218
|
-
)
|
|
9219
|
-
] })
|
|
9220
|
-
] })
|
|
9221
|
-
] }) : null
|
|
9222
|
-
] }),
|
|
9223
|
-
/* @__PURE__ */ jsx("div", { className: "mt-2 max-w-full", children: p && /* @__PURE__ */ jsx("p", { className: "break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500", children: p.message }) })
|
|
9224
|
-
] })
|
|
9225
|
-
] })
|
|
9226
|
-
}
|
|
9227
|
-
);
|
|
9244
|
+
}
|
|
9245
|
+
)
|
|
9246
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
|
|
9247
|
+
/* @__PURE__ */ jsx(SparklesIcon, { className: "mx-auto text-3xl text-muted-foreground" }),
|
|
9248
|
+
/* @__PURE__ */ jsx("h1", { children: r("Please select a block to Ask AI") })
|
|
9249
|
+
] }) }) });
|
|
9228
9250
|
}, AskAI = () => {
|
|
9229
9251
|
const [o] = useSelectedBlockIds();
|
|
9230
|
-
return /* @__PURE__ */
|
|
9231
|
-
/* @__PURE__ */ jsx(AISetContext, {}),
|
|
9232
|
-
/* @__PURE__ */ jsx(AIUserPrompt, { blockId: first(o) })
|
|
9233
|
-
] });
|
|
9252
|
+
return /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx(AIUserPrompt, { blockId: first(o) }) });
|
|
9234
9253
|
};
|
|
9235
9254
|
function DarkMode() {
|
|
9236
9255
|
const [o, r] = useDarkMode();
|
|
@@ -9291,7 +9310,7 @@ function AIChatPanel() {
|
|
|
9291
9310
|
}, 1500);
|
|
9292
9311
|
}, m = (b) => {
|
|
9293
9312
|
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
|
|
9294
|
-
},
|
|
9313
|
+
}, x = (b) => {
|
|
9295
9314
|
var E;
|
|
9296
9315
|
const A = (E = b.target.files) == null ? void 0 : E[0];
|
|
9297
9316
|
if (A) {
|
|
@@ -9301,10 +9320,10 @@ function AIChatPanel() {
|
|
|
9301
9320
|
d((w = N.target) == null ? void 0 : w.result);
|
|
9302
9321
|
}, _.readAsDataURL(A);
|
|
9303
9322
|
}
|
|
9304
|
-
},
|
|
9323
|
+
}, f = () => {
|
|
9305
9324
|
var b;
|
|
9306
9325
|
(b = p.current) == null || b.click();
|
|
9307
|
-
},
|
|
9326
|
+
}, k = () => {
|
|
9308
9327
|
d(null), p.current && (p.current.value = "");
|
|
9309
9328
|
};
|
|
9310
9329
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
|
|
@@ -9350,7 +9369,7 @@ function AIChatPanel() {
|
|
|
9350
9369
|
size: "icon",
|
|
9351
9370
|
variant: "destructive",
|
|
9352
9371
|
className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
|
|
9353
|
-
onClick:
|
|
9372
|
+
onClick: k,
|
|
9354
9373
|
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
9355
9374
|
}
|
|
9356
9375
|
)
|
|
@@ -9368,14 +9387,14 @@ function AIChatPanel() {
|
|
|
9368
9387
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9369
9388
|
}
|
|
9370
9389
|
),
|
|
9371
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange:
|
|
9390
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: x, accept: "image/*", className: "hidden" }),
|
|
9372
9391
|
/* @__PURE__ */ jsx(
|
|
9373
9392
|
Button,
|
|
9374
9393
|
{
|
|
9375
9394
|
size: "icon",
|
|
9376
9395
|
variant: "ghost",
|
|
9377
9396
|
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9378
|
-
onClick:
|
|
9397
|
+
onClick: f,
|
|
9379
9398
|
children: /* @__PURE__ */ jsx(Image$1, { className: "h-4 w-4 text-muted-foreground" })
|
|
9380
9399
|
}
|
|
9381
9400
|
)
|
|
@@ -9493,7 +9512,7 @@ const AiAssistant = () => {
|
|
|
9493
9512
|
preloadedAttributes: r = [],
|
|
9494
9513
|
onAttributesChange: n
|
|
9495
9514
|
}) {
|
|
9496
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""),
|
|
9515
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), x = useRef(null), f = useRef(null), k = usePageExternalData();
|
|
9497
9516
|
useEffect(() => {
|
|
9498
9517
|
l(r);
|
|
9499
9518
|
}, [r]);
|
|
@@ -9503,26 +9522,26 @@ const AiAssistant = () => {
|
|
|
9503
9522
|
return;
|
|
9504
9523
|
}
|
|
9505
9524
|
if (i) {
|
|
9506
|
-
const
|
|
9507
|
-
n(
|
|
9525
|
+
const y = [...a, { key: i, value: d }];
|
|
9526
|
+
n(y), l(a), c(""), p(""), m("");
|
|
9508
9527
|
}
|
|
9509
|
-
}, A = (
|
|
9510
|
-
const v = a.filter((B, S) => S !==
|
|
9528
|
+
}, A = (y) => {
|
|
9529
|
+
const v = a.filter((B, S) => S !== y);
|
|
9511
9530
|
n(v), l(v);
|
|
9512
|
-
}, E = (
|
|
9513
|
-
g(
|
|
9531
|
+
}, E = (y) => {
|
|
9532
|
+
g(y), c(a[y].key), p(a[y].value);
|
|
9514
9533
|
}, _ = () => {
|
|
9515
9534
|
if (i.startsWith("@")) {
|
|
9516
9535
|
m("Attribute keys cannot start with '@'");
|
|
9517
9536
|
return;
|
|
9518
9537
|
}
|
|
9519
9538
|
if (u !== null && i) {
|
|
9520
|
-
const
|
|
9521
|
-
|
|
9539
|
+
const y = [...a];
|
|
9540
|
+
y[u] = { key: i, value: d }, n(y), l(y), g(null), c(""), p(""), m("");
|
|
9522
9541
|
}
|
|
9523
|
-
}, N = (
|
|
9524
|
-
|
|
9525
|
-
}, w = useCallback((
|
|
9542
|
+
}, N = (y) => {
|
|
9543
|
+
y.key === "Enter" && !y.shiftKey && (y.preventDefault(), u !== null ? _() : b());
|
|
9544
|
+
}, w = useCallback((y) => {
|
|
9526
9545
|
const v = (C) => /[.,!?;:]/.test(C), B = (C, j, I) => {
|
|
9527
9546
|
let T = "", P = "";
|
|
9528
9547
|
const L = j > 0 ? C[j - 1] : "", D = j < C.length ? C[j] : "";
|
|
@@ -9531,15 +9550,15 @@ const AiAssistant = () => {
|
|
|
9531
9550
|
prefixLength: T.length,
|
|
9532
9551
|
suffixLength: P.length
|
|
9533
9552
|
};
|
|
9534
|
-
}, S =
|
|
9553
|
+
}, S = f.current;
|
|
9535
9554
|
if (S) {
|
|
9536
9555
|
const C = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || C;
|
|
9537
9556
|
if (I > C) {
|
|
9538
|
-
const R = `{{${
|
|
9557
|
+
const R = `{{${y}}}`, { text: M } = B(j, C, R), $ = j.slice(0, C) + M + j.slice(I);
|
|
9539
9558
|
p($);
|
|
9540
9559
|
return;
|
|
9541
9560
|
}
|
|
9542
|
-
const P = `{{${
|
|
9561
|
+
const P = `{{${y}}}`, { text: L } = B(j, C, P), D = j.slice(0, C) + L + j.slice(C);
|
|
9543
9562
|
p(D);
|
|
9544
9563
|
}
|
|
9545
9564
|
}, []);
|
|
@@ -9547,8 +9566,8 @@ const AiAssistant = () => {
|
|
|
9547
9566
|
/* @__PURE__ */ jsxs(
|
|
9548
9567
|
"form",
|
|
9549
9568
|
{
|
|
9550
|
-
onSubmit: (
|
|
9551
|
-
|
|
9569
|
+
onSubmit: (y) => {
|
|
9570
|
+
y.preventDefault(), u !== null ? _() : b();
|
|
9552
9571
|
},
|
|
9553
9572
|
className: "space-y-3",
|
|
9554
9573
|
children: [
|
|
@@ -9562,9 +9581,9 @@ const AiAssistant = () => {
|
|
|
9562
9581
|
autoCorrect: "off",
|
|
9563
9582
|
spellCheck: "false",
|
|
9564
9583
|
id: "attrKey",
|
|
9565
|
-
ref:
|
|
9584
|
+
ref: x,
|
|
9566
9585
|
value: i,
|
|
9567
|
-
onChange: (
|
|
9586
|
+
onChange: (y) => c(y.target.value),
|
|
9568
9587
|
placeholder: "Enter Key",
|
|
9569
9588
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9570
9589
|
}
|
|
@@ -9573,7 +9592,7 @@ const AiAssistant = () => {
|
|
|
9573
9592
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9574
9593
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9575
9594
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9576
|
-
!isEmpty(
|
|
9595
|
+
!isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: w })
|
|
9577
9596
|
] }),
|
|
9578
9597
|
/* @__PURE__ */ jsx(
|
|
9579
9598
|
Textarea,
|
|
@@ -9583,9 +9602,9 @@ const AiAssistant = () => {
|
|
|
9583
9602
|
spellCheck: "false",
|
|
9584
9603
|
id: "attrValue",
|
|
9585
9604
|
rows: 2,
|
|
9586
|
-
ref:
|
|
9605
|
+
ref: f,
|
|
9587
9606
|
value: d,
|
|
9588
|
-
onChange: (
|
|
9607
|
+
onChange: (y) => p(y.target.value),
|
|
9589
9608
|
onKeyDown: N,
|
|
9590
9609
|
placeholder: "Enter Value",
|
|
9591
9610
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
@@ -9598,10 +9617,10 @@ const AiAssistant = () => {
|
|
|
9598
9617
|
]
|
|
9599
9618
|
}
|
|
9600
9619
|
),
|
|
9601
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
9620
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((y, v) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9602
9621
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9603
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9604
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children:
|
|
9622
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: y.key }),
|
|
9623
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: y.value.toString() })
|
|
9605
9624
|
] }),
|
|
9606
9625
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9607
9626
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(v), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
@@ -9727,7 +9746,11 @@ const SettingsPanel = () => {
|
|
|
9727
9746
|
)
|
|
9728
9747
|
] }) });
|
|
9729
9748
|
}, CHAI_BUILDER_PANELS = {}, registerChaiSidebarPanel = (o, r) => {
|
|
9730
|
-
has(CHAI_BUILDER_PANELS, o)
|
|
9749
|
+
if (has(CHAI_BUILDER_PANELS, o)) {
|
|
9750
|
+
console.warn(`Panel ${o} already registered. Overriding...`);
|
|
9751
|
+
return;
|
|
9752
|
+
}
|
|
9753
|
+
set(CHAI_BUILDER_PANELS, o, { id: o, ...r });
|
|
9731
9754
|
}, useChaiSidebarPanels = (o) => useMemo(
|
|
9732
9755
|
() => filter(values(CHAI_BUILDER_PANELS), (r) => r.position === o),
|
|
9733
9756
|
[o]
|
|
@@ -9769,42 +9792,42 @@ const RootLayout = () => {
|
|
|
9769
9792
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9770
9793
|
n("outline");
|
|
9771
9794
|
});
|
|
9772
|
-
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((
|
|
9773
|
-
|
|
9795
|
+
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((y) => {
|
|
9796
|
+
y.preventDefault();
|
|
9774
9797
|
}, []), m = useCallback(
|
|
9775
|
-
(
|
|
9776
|
-
n(r ===
|
|
9798
|
+
(y) => {
|
|
9799
|
+
n(r === y ? null : y);
|
|
9777
9800
|
},
|
|
9778
9801
|
[r]
|
|
9779
|
-
), { t:
|
|
9802
|
+
), { t: x } = useTranslation(), f = useMemo(
|
|
9780
9803
|
() => [...p, ...u, ...g],
|
|
9781
9804
|
[p, u, g]
|
|
9782
|
-
),
|
|
9805
|
+
), k = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: r }) ?? first(f), A = get(b, "width", DEFAULT_PANEL_WIDTH);
|
|
9783
9806
|
useEffect(() => {
|
|
9784
9807
|
if (r !== null) {
|
|
9785
|
-
const
|
|
9786
|
-
|
|
9808
|
+
const y = find(f, { id: r });
|
|
9809
|
+
y && get(y, "view", "standard") === "standard" && (a.current = r, i(get(y, "width", DEFAULT_PANEL_WIDTH)));
|
|
9787
9810
|
}
|
|
9788
|
-
}, [r,
|
|
9811
|
+
}, [r, f]);
|
|
9789
9812
|
const E = useMemo(() => {
|
|
9790
9813
|
if (r === null) return 0;
|
|
9791
|
-
const
|
|
9792
|
-
return get(
|
|
9793
|
-
}, [r, A, l,
|
|
9814
|
+
const y = find(f, { id: r });
|
|
9815
|
+
return get(y, "view", "standard") === "standard" ? A : l;
|
|
9816
|
+
}, [r, A, l, f]), _ = useCallback(() => {
|
|
9794
9817
|
n(a.current);
|
|
9795
9818
|
}, [n]), N = useCallback(() => {
|
|
9796
9819
|
n("outline");
|
|
9797
9820
|
}, [n]);
|
|
9798
9821
|
useEffect(() => {
|
|
9799
|
-
find(
|
|
9800
|
-
}, [r,
|
|
9822
|
+
find(f, { id: r }) || n("outline");
|
|
9823
|
+
}, [r, f]);
|
|
9801
9824
|
const w = useCallback(
|
|
9802
|
-
(
|
|
9803
|
-
m(
|
|
9825
|
+
(y) => {
|
|
9826
|
+
m(y);
|
|
9804
9827
|
},
|
|
9805
9828
|
[m]
|
|
9806
9829
|
);
|
|
9807
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
9830
|
+
return /* @__PURE__ */ jsx("div", { dir: k, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9808
9831
|
/* @__PURE__ */ jsxs(
|
|
9809
9832
|
"div",
|
|
9810
9833
|
{
|
|
@@ -9814,24 +9837,24 @@ const RootLayout = () => {
|
|
|
9814
9837
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9815
9838
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9816
9839
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9817
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((
|
|
9818
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9840
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9841
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
|
|
9819
9842
|
position: "top",
|
|
9820
|
-
panelId:
|
|
9821
|
-
isActive: r ===
|
|
9822
|
-
show: () => w(
|
|
9843
|
+
panelId: y.id,
|
|
9844
|
+
isActive: r === y.id,
|
|
9845
|
+
show: () => w(y.id)
|
|
9823
9846
|
}) }),
|
|
9824
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9847
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
|
|
9825
9848
|
] }, "button-top-" + v)) }),
|
|
9826
9849
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9827
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((
|
|
9828
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9850
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9851
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
|
|
9829
9852
|
position: "bottom",
|
|
9830
|
-
panelId:
|
|
9831
|
-
isActive: r ===
|
|
9832
|
-
show: () => w(
|
|
9853
|
+
panelId: y.id,
|
|
9854
|
+
isActive: r === y.id,
|
|
9855
|
+
show: () => w(y.id)
|
|
9833
9856
|
}) }),
|
|
9834
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9857
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
|
|
9835
9858
|
] }, "button-bottom-" + v)) })
|
|
9836
9859
|
] }),
|
|
9837
9860
|
/* @__PURE__ */ jsx(
|
|
@@ -9847,7 +9870,7 @@ const RootLayout = () => {
|
|
|
9847
9870
|
"div",
|
|
9848
9871
|
{
|
|
9849
9872
|
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
|
|
9850
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9873
|
+
children: /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9851
9874
|
}
|
|
9852
9875
|
),
|
|
9853
9876
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {}) }) })
|
|
@@ -9870,11 +9893,11 @@ const RootLayout = () => {
|
|
|
9870
9893
|
/* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: c === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9871
9894
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9872
9895
|
" ",
|
|
9873
|
-
|
|
9896
|
+
x("AI Assistant")
|
|
9874
9897
|
] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9875
9898
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9876
9899
|
/* @__PURE__ */ jsx(Palette, { className: "w-4 h-4 text-gray-600" }),
|
|
9877
|
-
|
|
9900
|
+
x("Theme Settings")
|
|
9878
9901
|
] }),
|
|
9879
9902
|
/* @__PURE__ */ jsx(
|
|
9880
9903
|
Button,
|
|
@@ -9905,7 +9928,7 @@ const RootLayout = () => {
|
|
|
9905
9928
|
children: [
|
|
9906
9929
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
9907
9930
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9908
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9931
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9909
9932
|
] }) }),
|
|
9910
9933
|
/* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
9911
9934
|
close: N
|
|
@@ -9917,7 +9940,7 @@ const RootLayout = () => {
|
|
|
9917
9940
|
r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${A}px` }, children: [
|
|
9918
9941
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
9919
9942
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9920
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9943
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9921
9944
|
] }) }),
|
|
9922
9945
|
/* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
9923
9946
|
close: N
|
|
@@ -9943,7 +9966,7 @@ const RootLayout = () => {
|
|
|
9943
9966
|
/* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
|
|
9944
9967
|
/* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
|
|
9945
9968
|
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
|
|
9946
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9969
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9947
9970
|
] }),
|
|
9948
9971
|
/* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
|
|
9949
9972
|
] }),
|
|
@@ -9987,36 +10010,36 @@ const RootLayout = () => {
|
|
|
9987
10010
|
}) => {
|
|
9988
10011
|
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
|
|
9989
10012
|
if (!l.trim()) return a;
|
|
9990
|
-
const
|
|
10013
|
+
const f = l.toLowerCase();
|
|
9991
10014
|
return Object.fromEntries(
|
|
9992
|
-
Object.entries(a).filter(([
|
|
10015
|
+
Object.entries(a).filter(([k, b]) => {
|
|
9993
10016
|
var A;
|
|
9994
|
-
return (
|
|
10017
|
+
return (k == null ? void 0 : k.toLowerCase().includes(f)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(f));
|
|
9995
10018
|
})
|
|
9996
10019
|
);
|
|
9997
|
-
}, [a, l]), h = (
|
|
10020
|
+
}, [a, l]), h = (f) => {
|
|
9998
10021
|
d(!0), u({
|
|
9999
|
-
x:
|
|
10000
|
-
y:
|
|
10022
|
+
x: f.clientX - r.x,
|
|
10023
|
+
y: f.clientY - r.y
|
|
10001
10024
|
});
|
|
10002
|
-
}, m = (
|
|
10025
|
+
}, m = (f) => {
|
|
10003
10026
|
if (!c) return;
|
|
10004
|
-
const
|
|
10005
|
-
n(
|
|
10006
|
-
},
|
|
10027
|
+
const k = f.clientX - p.x, b = f.clientY - p.y, A = f.currentTarget, E = A.offsetWidth, _ = A.offsetHeight, N = window.innerWidth - E, w = window.innerHeight - _, y = Math.max(0, Math.min(k, N)), v = Math.max(0, Math.min(b, w));
|
|
10028
|
+
n(y, v);
|
|
10029
|
+
}, x = () => {
|
|
10007
10030
|
d(!1);
|
|
10008
10031
|
};
|
|
10009
10032
|
return useEffect(() => {
|
|
10010
|
-
const
|
|
10033
|
+
const f = () => {
|
|
10011
10034
|
c && d(!1);
|
|
10012
10035
|
};
|
|
10013
|
-
return window.addEventListener("mouseup",
|
|
10036
|
+
return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
|
|
10014
10037
|
}, [c]), !r || r.x < 0 || r.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
10015
10038
|
"div",
|
|
10016
10039
|
{
|
|
10017
10040
|
onMouseDown: h,
|
|
10018
10041
|
onMouseMove: m,
|
|
10019
|
-
onMouseUp:
|
|
10042
|
+
onMouseUp: x,
|
|
10020
10043
|
className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
|
|
10021
10044
|
style: {
|
|
10022
10045
|
left: r.x,
|
|
@@ -10058,13 +10081,13 @@ const RootLayout = () => {
|
|
|
10058
10081
|
placeholder: "Search features...",
|
|
10059
10082
|
className: "w-full pl-8",
|
|
10060
10083
|
value: l,
|
|
10061
|
-
onChange: (
|
|
10084
|
+
onChange: (f) => i(f.target.value),
|
|
10062
10085
|
autoFocus: !0
|
|
10063
10086
|
}
|
|
10064
10087
|
)
|
|
10065
10088
|
] })
|
|
10066
10089
|
] }),
|
|
10067
|
-
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([
|
|
10090
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, k]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: k }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
|
|
10068
10091
|
'No features found matching "',
|
|
10069
10092
|
l,
|
|
10070
10093
|
'"'
|
|
@@ -10172,17 +10195,17 @@ const RootLayout = () => {
|
|
|
10172
10195
|
for (const i of r.p)
|
|
10173
10196
|
l.add(i);
|
|
10174
10197
|
return l;
|
|
10175
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...
|
|
10176
|
-
var
|
|
10177
|
-
return (
|
|
10178
|
-
}, g = (m,
|
|
10179
|
-
var
|
|
10180
|
-
return (
|
|
10198
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...x) => m.read(...x), p = (m, ...x) => m.write(...x), u = (m, x) => {
|
|
10199
|
+
var f;
|
|
10200
|
+
return (f = m.unstable_onInit) == null ? void 0 : f.call(m, x);
|
|
10201
|
+
}, g = (m, x) => {
|
|
10202
|
+
var f;
|
|
10203
|
+
return (f = m.onMount) == null ? void 0 : f.call(m, x);
|
|
10181
10204
|
}, ...h) => {
|
|
10182
10205
|
const m = h[0] || ((v) => {
|
|
10183
10206
|
let B = o.get(v);
|
|
10184
|
-
return B || (B = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(v, B), u == null || u(v,
|
|
10185
|
-
}),
|
|
10207
|
+
return B || (B = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(v, B), u == null || u(v, y)), B;
|
|
10208
|
+
}), x = h[1] || (() => {
|
|
10186
10209
|
const v = [], B = (S) => {
|
|
10187
10210
|
try {
|
|
10188
10211
|
S();
|
|
@@ -10196,11 +10219,11 @@ const RootLayout = () => {
|
|
|
10196
10219
|
a.forEach((j) => {
|
|
10197
10220
|
var I;
|
|
10198
10221
|
return (I = r.get(j)) == null ? void 0 : I.l.forEach(C);
|
|
10199
|
-
}), a.clear(), i.forEach(C), i.clear(), l.forEach(C), l.clear(), S.forEach(B), a.size &&
|
|
10222
|
+
}), a.clear(), i.forEach(C), i.clear(), l.forEach(C), l.clear(), S.forEach(B), a.size && f();
|
|
10200
10223
|
} while (a.size || i.size || l.size);
|
|
10201
10224
|
if (v.length)
|
|
10202
10225
|
throw new AggregateError(v);
|
|
10203
|
-
}),
|
|
10226
|
+
}), f = h[2] || (() => {
|
|
10204
10227
|
const v = [], B = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), C = Array.from(a);
|
|
10205
10228
|
for (; C.length; ) {
|
|
10206
10229
|
const j = C[C.length - 1], I = m(j);
|
|
@@ -10224,23 +10247,23 @@ const RootLayout = () => {
|
|
|
10224
10247
|
P = !0;
|
|
10225
10248
|
break;
|
|
10226
10249
|
}
|
|
10227
|
-
P && (
|
|
10250
|
+
P && (k(I), E(I)), n.delete(I);
|
|
10228
10251
|
}
|
|
10229
|
-
}),
|
|
10252
|
+
}), k = h[3] || ((v) => {
|
|
10230
10253
|
var B;
|
|
10231
10254
|
const S = m(v);
|
|
10232
10255
|
if (isAtomStateInitialized(S) && (r.has(v) && n.get(v) !== S.n || Array.from(S.d).every(
|
|
10233
10256
|
([R, M]) => (
|
|
10234
10257
|
// Recursively, read the atom state of the dependency, and
|
|
10235
10258
|
// check if the atom epoch number is unchanged
|
|
10236
|
-
|
|
10259
|
+
k(R).n === M
|
|
10237
10260
|
)
|
|
10238
10261
|
)))
|
|
10239
10262
|
return S;
|
|
10240
10263
|
S.d.clear();
|
|
10241
10264
|
let C = !0;
|
|
10242
10265
|
const j = () => {
|
|
10243
|
-
r.has(v) && (E(v),
|
|
10266
|
+
r.has(v) && (E(v), f(), x());
|
|
10244
10267
|
}, I = (R) => {
|
|
10245
10268
|
var M;
|
|
10246
10269
|
if (isSelfAtom(v, R)) {
|
|
@@ -10252,7 +10275,7 @@ const RootLayout = () => {
|
|
|
10252
10275
|
throw new Error("no atom init");
|
|
10253
10276
|
return returnAtomValue(O);
|
|
10254
10277
|
}
|
|
10255
|
-
const $ =
|
|
10278
|
+
const $ = k(R);
|
|
10256
10279
|
try {
|
|
10257
10280
|
return returnAtomValue($);
|
|
10258
10281
|
} finally {
|
|
@@ -10270,7 +10293,7 @@ const RootLayout = () => {
|
|
|
10270
10293
|
try {
|
|
10271
10294
|
return A(v, ...R);
|
|
10272
10295
|
} finally {
|
|
10273
|
-
|
|
10296
|
+
f(), x();
|
|
10274
10297
|
}
|
|
10275
10298
|
}), P;
|
|
10276
10299
|
}
|
|
@@ -10297,7 +10320,7 @@ const RootLayout = () => {
|
|
|
10297
10320
|
}
|
|
10298
10321
|
}), A = h[5] || ((v, ...B) => {
|
|
10299
10322
|
let S = !0;
|
|
10300
|
-
const C = (I) => returnAtomValue(
|
|
10323
|
+
const C = (I) => returnAtomValue(k(I)), j = (I, ...T) => {
|
|
10301
10324
|
var P;
|
|
10302
10325
|
const L = m(I);
|
|
10303
10326
|
try {
|
|
@@ -10310,7 +10333,7 @@ const RootLayout = () => {
|
|
|
10310
10333
|
} else
|
|
10311
10334
|
return A(I, ...T);
|
|
10312
10335
|
} finally {
|
|
10313
|
-
S || (
|
|
10336
|
+
S || (f(), x());
|
|
10314
10337
|
}
|
|
10315
10338
|
};
|
|
10316
10339
|
try {
|
|
@@ -10339,7 +10362,7 @@ const RootLayout = () => {
|
|
|
10339
10362
|
const S = m(v);
|
|
10340
10363
|
let C = r.get(v);
|
|
10341
10364
|
if (!C) {
|
|
10342
|
-
|
|
10365
|
+
k(v);
|
|
10343
10366
|
for (const j of S.d.keys())
|
|
10344
10367
|
_(j).t.add(v);
|
|
10345
10368
|
if (C = {
|
|
@@ -10353,7 +10376,7 @@ const RootLayout = () => {
|
|
|
10353
10376
|
try {
|
|
10354
10377
|
return A(v, ...P);
|
|
10355
10378
|
} finally {
|
|
10356
|
-
I || (
|
|
10379
|
+
I || (f(), x());
|
|
10357
10380
|
}
|
|
10358
10381
|
};
|
|
10359
10382
|
try {
|
|
@@ -10406,31 +10429,31 @@ const RootLayout = () => {
|
|
|
10406
10429
|
g,
|
|
10407
10430
|
// building-block functions
|
|
10408
10431
|
m,
|
|
10409
|
-
f,
|
|
10410
10432
|
x,
|
|
10411
|
-
|
|
10433
|
+
f,
|
|
10434
|
+
k,
|
|
10412
10435
|
b,
|
|
10413
10436
|
A,
|
|
10414
10437
|
E,
|
|
10415
10438
|
_,
|
|
10416
10439
|
N
|
|
10417
|
-
],
|
|
10418
|
-
get: (v) => returnAtomValue(
|
|
10440
|
+
], y = {
|
|
10441
|
+
get: (v) => returnAtomValue(k(v)),
|
|
10419
10442
|
set: (v, ...B) => {
|
|
10420
10443
|
try {
|
|
10421
10444
|
return A(v, ...B);
|
|
10422
10445
|
} finally {
|
|
10423
|
-
|
|
10446
|
+
f(), x();
|
|
10424
10447
|
}
|
|
10425
10448
|
},
|
|
10426
10449
|
sub: (v, B) => {
|
|
10427
10450
|
const C = _(v).l;
|
|
10428
|
-
return C.add(B),
|
|
10429
|
-
C.delete(B), N(v),
|
|
10451
|
+
return C.add(B), x(), () => {
|
|
10452
|
+
C.delete(B), N(v), x();
|
|
10430
10453
|
};
|
|
10431
10454
|
}
|
|
10432
10455
|
};
|
|
10433
|
-
return Object.defineProperty(
|
|
10456
|
+
return Object.defineProperty(y, BUILDING_BLOCKS, { value: w }), y;
|
|
10434
10457
|
}, INTERNAL_buildStoreRev1 = buildStore, INTERNAL_registerAbortHandler = registerAbortHandler;
|
|
10435
10458
|
function createStore() {
|
|
10436
10459
|
return INTERNAL_buildStoreRev1();
|
|
@@ -10583,7 +10606,6 @@ registerFeatureFlags();
|
|
|
10583
10606
|
export {
|
|
10584
10607
|
AddBlocksDialog as ChaiAddBlocksDialog,
|
|
10585
10608
|
AddBlocksPanel as ChaiAddBlocksPanel,
|
|
10586
|
-
AISetContext as ChaiAskAiPanel,
|
|
10587
10609
|
AIUserPrompt as ChaiAskAiUserPrompt,
|
|
10588
10610
|
BlockAttributesEditor as ChaiBlockAttributesEditor,
|
|
10589
10611
|
BlockSettings as ChaiBlockPropsEditor,
|