@chaibuilder/sdk 2.5.8 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +0 -2
- package/dist/core.js +743 -722
- 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",
|
|
@@ -751,20 +751,20 @@ const checkMissingTranslations = (o, r) => r ? o.some((n) => {
|
|
|
751
751
|
return console.warn(`Failed to get block definition for type: ${n._type}`, a), !1;
|
|
752
752
|
}
|
|
753
753
|
}) : !1, useSavePage = () => {
|
|
754
|
-
const [o, r] = useAtom$1(builderSaveStateAtom), n = useBuilderProp("onSave", async (
|
|
754
|
+
const [o, r] = useAtom$1(builderSaveStateAtom), n = useBuilderProp("onSave", async (x) => {
|
|
755
755
|
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
|
|
756
|
-
const
|
|
757
|
-
return !d || d === p ? !1 : checkMissingTranslations(
|
|
756
|
+
const x = l();
|
|
757
|
+
return !d || d === p ? !1 : checkMissingTranslations(x.blocks || [], d);
|
|
758
758
|
};
|
|
759
759
|
return { savePage: useThrottledCallback(
|
|
760
|
-
async (
|
|
760
|
+
async (x = !1) => {
|
|
761
761
|
if (!c("save_page") || !u)
|
|
762
762
|
return;
|
|
763
763
|
r("SAVING"), a("SAVING");
|
|
764
|
-
const
|
|
764
|
+
const f = l();
|
|
765
765
|
return await n({
|
|
766
|
-
autoSave:
|
|
767
|
-
blocks:
|
|
766
|
+
autoSave: x,
|
|
767
|
+
blocks: f.blocks,
|
|
768
768
|
theme: i,
|
|
769
769
|
needTranslations: g()
|
|
770
770
|
}), setTimeout(() => {
|
|
@@ -778,10 +778,10 @@ const checkMissingTranslations = (o, r) => r ? o.some((n) => {
|
|
|
778
778
|
if (!c("save_page") || !u)
|
|
779
779
|
return;
|
|
780
780
|
r("SAVING"), a("SAVING");
|
|
781
|
-
const
|
|
781
|
+
const x = l();
|
|
782
782
|
return await n({
|
|
783
783
|
autoSave: !0,
|
|
784
|
-
blocks:
|
|
784
|
+
blocks: x.blocks,
|
|
785
785
|
theme: i,
|
|
786
786
|
needTranslations: g()
|
|
787
787
|
}), setTimeout(() => {
|
|
@@ -839,65 +839,65 @@ const undoRedoStateAtom = atom({
|
|
|
839
839
|
updateBlocksProps: c
|
|
840
840
|
} = useBlocksStoreManager();
|
|
841
841
|
return {
|
|
842
|
-
moveBlocks: (
|
|
843
|
-
const A = map(
|
|
842
|
+
moveBlocks: (f, k, b) => {
|
|
843
|
+
const A = map(f, (_) => {
|
|
844
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(_);
|
|
845
845
|
return { _id: _, oldParent: w, oldPosition: v };
|
|
846
|
-
}), E = A.find(({ _id: _ }) => _ ===
|
|
847
|
-
E && E.oldParent ===
|
|
846
|
+
}), E = A.find(({ _id: _ }) => _ === f[0]);
|
|
847
|
+
E && E.oldParent === k && E.oldPosition === b || (i(f, k, b), o({
|
|
848
848
|
undo: () => each(A, ({ _id: _, oldParent: N, oldPosition: w }) => {
|
|
849
849
|
i([_], N, w);
|
|
850
850
|
}),
|
|
851
|
-
redo: () => i(
|
|
851
|
+
redo: () => i(f, k, b)
|
|
852
852
|
}));
|
|
853
853
|
},
|
|
854
|
-
addBlocks: (
|
|
855
|
-
a(
|
|
856
|
-
undo: () => l(map(
|
|
857
|
-
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)
|
|
858
858
|
});
|
|
859
859
|
},
|
|
860
|
-
removeBlocks: (
|
|
860
|
+
removeBlocks: (f) => {
|
|
861
861
|
var E;
|
|
862
|
-
const
|
|
863
|
-
l(map(
|
|
864
|
-
undo: () => a(
|
|
865
|
-
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"))
|
|
866
866
|
});
|
|
867
867
|
},
|
|
868
|
-
updateBlocks: (
|
|
868
|
+
updateBlocks: (f, k, b) => {
|
|
869
869
|
let A = [];
|
|
870
870
|
if (b)
|
|
871
|
-
A = map(
|
|
871
|
+
A = map(f, (E) => ({ _id: E, ...b }));
|
|
872
872
|
else {
|
|
873
|
-
const E = keys(
|
|
874
|
-
A = map(
|
|
875
|
-
const N = r.find((
|
|
876
|
-
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;
|
|
877
877
|
});
|
|
878
878
|
}
|
|
879
|
-
c(map(
|
|
879
|
+
c(map(f, (E) => ({ _id: E, ...k }))), o({
|
|
880
880
|
undo: () => c(A),
|
|
881
|
-
redo: () => c(map(
|
|
881
|
+
redo: () => c(map(f, (E) => ({ _id: E, ...k })))
|
|
882
882
|
});
|
|
883
883
|
},
|
|
884
|
-
updateBlocksRuntime: (
|
|
885
|
-
c(map(
|
|
884
|
+
updateBlocksRuntime: (f, k) => {
|
|
885
|
+
c(map(f, (b) => ({ _id: b, ...k })));
|
|
886
886
|
},
|
|
887
|
-
setNewBlocks: (
|
|
888
|
-
n(
|
|
887
|
+
setNewBlocks: (f) => {
|
|
888
|
+
n(f), o({
|
|
889
889
|
undo: () => n(r),
|
|
890
|
-
redo: () => n(
|
|
890
|
+
redo: () => n(f)
|
|
891
891
|
});
|
|
892
892
|
},
|
|
893
|
-
updateMultipleBlocksProps: (
|
|
894
|
-
let
|
|
895
|
-
|
|
893
|
+
updateMultipleBlocksProps: (f) => {
|
|
894
|
+
let k = [];
|
|
895
|
+
k = map(f, (b) => {
|
|
896
896
|
const A = keys(b), E = r.find((N) => N._id === b._id), _ = {};
|
|
897
897
|
return each(A, (N) => _[N] = E[N]), _;
|
|
898
|
-
}), c(
|
|
899
|
-
undo: () => c(
|
|
900
|
-
redo: () => c(
|
|
898
|
+
}), c(f), o({
|
|
899
|
+
undo: () => c(k),
|
|
900
|
+
redo: () => c(f)
|
|
901
901
|
});
|
|
902
902
|
}
|
|
903
903
|
};
|
|
@@ -905,12 +905,12 @@ const undoRedoStateAtom = atom({
|
|
|
905
905
|
const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
906
906
|
(i, c, d) => {
|
|
907
907
|
var m;
|
|
908
|
-
for (let
|
|
909
|
-
const { _id:
|
|
910
|
-
i[
|
|
911
|
-
const
|
|
912
|
-
for (let b = 0; b <
|
|
913
|
-
|
|
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;
|
|
914
914
|
}
|
|
915
915
|
const p = first(i);
|
|
916
916
|
let u, g;
|
|
@@ -921,8 +921,8 @@ const undoRedoStateAtom = atom({
|
|
|
921
921
|
return { addCoreBlock: useCallback(
|
|
922
922
|
(i, c, d) => {
|
|
923
923
|
if (has(i, "blocks")) {
|
|
924
|
-
const
|
|
925
|
-
return a(
|
|
924
|
+
const k = i.blocks;
|
|
925
|
+
return a(k, c, d);
|
|
926
926
|
}
|
|
927
927
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
928
928
|
_type: i.type,
|
|
@@ -2363,45 +2363,45 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2363
2363
|
return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
|
|
2364
2364
|
})
|
|
2365
2365
|
), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
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,
|
|
2367
|
-
const
|
|
2368
|
-
for (const
|
|
2369
|
-
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];
|
|
2370
2370
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
2371
2371
|
const { baseClasses: A, classes: E } = getSplitChaiClasses(b);
|
|
2372
|
-
|
|
2372
|
+
f[k] = compact(flattenDeep([A, E])).join(" ");
|
|
2373
2373
|
} else
|
|
2374
|
-
|
|
2374
|
+
k !== "_id" && delete f[k];
|
|
2375
2375
|
}
|
|
2376
|
-
return
|
|
2376
|
+
return f;
|
|
2377
2377
|
};
|
|
2378
2378
|
return {
|
|
2379
2379
|
askAi: useCallback(
|
|
2380
|
-
async (m,
|
|
2380
|
+
async (m, x, f, k) => {
|
|
2381
2381
|
if (l) {
|
|
2382
2382
|
r(!0), a(null);
|
|
2383
2383
|
try {
|
|
2384
2384
|
const b = p === u ? "" : p;
|
|
2385
|
-
console.log("prompt",
|
|
2386
|
-
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 } = _;
|
|
2387
2387
|
if (w) {
|
|
2388
2388
|
a(w);
|
|
2389
2389
|
return;
|
|
2390
2390
|
}
|
|
2391
2391
|
if (m === "styles") {
|
|
2392
|
-
const
|
|
2392
|
+
const y = N.map((v) => {
|
|
2393
2393
|
for (const B in v)
|
|
2394
2394
|
B !== "_id" && (v[B] = `${STYLES_KEY},${v[B]}`);
|
|
2395
2395
|
return v;
|
|
2396
2396
|
});
|
|
2397
|
-
c(
|
|
2397
|
+
c(y);
|
|
2398
2398
|
} else
|
|
2399
2399
|
i(N);
|
|
2400
|
-
|
|
2400
|
+
k && k(_);
|
|
2401
2401
|
} catch (b) {
|
|
2402
2402
|
a(b);
|
|
2403
2403
|
} finally {
|
|
2404
|
-
r(!1),
|
|
2404
|
+
r(!1), k && k();
|
|
2405
2405
|
}
|
|
2406
2406
|
}
|
|
2407
2407
|
},
|
|
@@ -2495,12 +2495,12 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2495
2495
|
if (!p)
|
|
2496
2496
|
return h;
|
|
2497
2497
|
let m = [];
|
|
2498
|
-
for (const
|
|
2499
|
-
if (
|
|
2500
|
-
let
|
|
2501
|
-
|
|
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];
|
|
2502
2502
|
} else
|
|
2503
|
-
m.push(
|
|
2503
|
+
m.push(x);
|
|
2504
2504
|
return m;
|
|
2505
2505
|
})
|
|
2506
2506
|
};
|
|
@@ -2683,13 +2683,13 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2683
2683
|
const d = o(c), p = a;
|
|
2684
2684
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2685
2685
|
return each(p, (h) => {
|
|
2686
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2687
|
-
u = u.replace(
|
|
2688
|
-
const
|
|
2689
|
-
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());
|
|
2690
2690
|
}), each(p, (h) => {
|
|
2691
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2692
|
-
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();
|
|
2693
2693
|
}), {
|
|
2694
2694
|
ids: [d._id],
|
|
2695
2695
|
props: {
|
|
@@ -2838,21 +2838,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2838
2838
|
return "VERTICAL";
|
|
2839
2839
|
}
|
|
2840
2840
|
}, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
|
|
2841
|
-
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (
|
|
2842
|
-
(
|
|
2843
|
-
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());
|
|
2844
2844
|
},
|
|
2845
2845
|
[g, h, p, u, i, c, r]
|
|
2846
2846
|
);
|
|
2847
2847
|
return useHotkeys(
|
|
2848
2848
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2849
|
-
({ key:
|
|
2850
|
-
var
|
|
2851
|
-
|
|
2849
|
+
({ key: f }) => {
|
|
2850
|
+
var k;
|
|
2851
|
+
x((k = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
|
|
2852
2852
|
},
|
|
2853
2853
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2854
|
-
[
|
|
2855
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock:
|
|
2854
|
+
[x]
|
|
2855
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: x, orientation: m };
|
|
2856
2856
|
}, BlockController = ({ block: o, updateFloatingBar: r }) => {
|
|
2857
2857
|
const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2858
2858
|
o,
|
|
@@ -3009,9 +3009,9 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3009
3009
|
}),
|
|
3010
3010
|
size({
|
|
3011
3011
|
boundary: u == null ? void 0 : u.body,
|
|
3012
|
-
apply({ availableWidth:
|
|
3012
|
+
apply({ availableWidth: k, availableHeight: b, elements: A }) {
|
|
3013
3013
|
Object.assign(A.floating.style, {
|
|
3014
|
-
maxWidth: `${Math.max(200,
|
|
3014
|
+
maxWidth: `${Math.max(200, k)}px`,
|
|
3015
3015
|
maxHeight: `${Math.max(100, b)}px`
|
|
3016
3016
|
});
|
|
3017
3017
|
}
|
|
@@ -3020,11 +3020,11 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3020
3020
|
elements: { reference: r }
|
|
3021
3021
|
});
|
|
3022
3022
|
useResizeObserver(r, () => m(), r !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
|
|
3023
|
-
const
|
|
3023
|
+
const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
3024
3024
|
return useEffect(() => {
|
|
3025
3025
|
if (r) {
|
|
3026
|
-
const
|
|
3027
|
-
return () => clearTimeout(
|
|
3026
|
+
const k = setTimeout(() => m(), 500);
|
|
3027
|
+
return () => clearTimeout(k);
|
|
3028
3028
|
} else
|
|
3029
3029
|
m();
|
|
3030
3030
|
}, [r]), !r || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
@@ -3034,25 +3034,25 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3034
3034
|
tabIndex: 0,
|
|
3035
3035
|
ref: h.setFloating,
|
|
3036
3036
|
style: g,
|
|
3037
|
-
onClick: (
|
|
3038
|
-
|
|
3037
|
+
onClick: (k) => {
|
|
3038
|
+
k.stopPropagation(), k.preventDefault();
|
|
3039
3039
|
},
|
|
3040
|
-
onMouseEnter: (
|
|
3041
|
-
|
|
3040
|
+
onMouseEnter: (k) => {
|
|
3041
|
+
k.stopPropagation(), i(null);
|
|
3042
3042
|
},
|
|
3043
|
-
onKeyDown: (
|
|
3043
|
+
onKeyDown: (k) => k.stopPropagation(),
|
|
3044
3044
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3045
3045
|
children: [
|
|
3046
|
-
|
|
3046
|
+
x && /* @__PURE__ */ jsx(
|
|
3047
3047
|
ArrowUpIcon,
|
|
3048
3048
|
{
|
|
3049
3049
|
className: "hover:scale-105",
|
|
3050
3050
|
onClick: () => {
|
|
3051
|
-
c([]), l([
|
|
3051
|
+
c([]), l([x]);
|
|
3052
3052
|
}
|
|
3053
3053
|
}
|
|
3054
3054
|
),
|
|
3055
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3055
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: o }),
|
|
3056
3056
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3057
3057
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3058
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,
|
|
@@ -3210,8 +3210,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3210
3210
|
i
|
|
3211
3211
|
]), useHotkeys(
|
|
3212
3212
|
"del, backspace",
|
|
3213
|
-
(
|
|
3214
|
-
|
|
3213
|
+
(x) => {
|
|
3214
|
+
x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
|
|
3215
3215
|
},
|
|
3216
3216
|
m,
|
|
3217
3217
|
[r, l]
|
|
@@ -3504,8 +3504,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3504
3504
|
],
|
|
3505
3505
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3506
3506
|
onBlur: ({ editor: u, event: g }) => {
|
|
3507
|
-
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"),
|
|
3508
|
-
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) {
|
|
3509
3509
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3510
3510
|
n(b);
|
|
3511
3511
|
}
|
|
@@ -3560,14 +3560,14 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3560
3560
|
useEffect(() => {
|
|
3561
3561
|
if (a.current) {
|
|
3562
3562
|
a.current.innerText = r, a.current.focus();
|
|
3563
|
-
const m = c.createRange(),
|
|
3564
|
-
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();
|
|
3565
3565
|
} else
|
|
3566
3566
|
n();
|
|
3567
3567
|
}, [c, d]);
|
|
3568
3568
|
const p = useMemo(() => {
|
|
3569
|
-
var
|
|
3570
|
-
const m = ((
|
|
3569
|
+
var x;
|
|
3570
|
+
const m = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
|
|
3571
3571
|
return m === "button" ? "div" : m;
|
|
3572
3572
|
}, [o]), u = useCallback(
|
|
3573
3573
|
(m) => {
|
|
@@ -3583,12 +3583,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3583
3583
|
contentEditable: !0,
|
|
3584
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]`,
|
|
3585
3585
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
3586
|
-
onInput: (
|
|
3587
|
-
const
|
|
3588
|
-
|
|
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));
|
|
3589
3589
|
},
|
|
3590
|
-
onClick: (
|
|
3591
|
-
|
|
3590
|
+
onClick: (x) => {
|
|
3591
|
+
x.stopPropagation(), x.preventDefault();
|
|
3592
3592
|
}
|
|
3593
3593
|
};
|
|
3594
3594
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
@@ -3601,33 +3601,33 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3601
3601
|
}
|
|
3602
3602
|
), WithBlockTextEditor = memo(
|
|
3603
3603
|
({ block: o, children: r }) => {
|
|
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:
|
|
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(() => {
|
|
3605
3605
|
var j;
|
|
3606
3606
|
const v = o._type;
|
|
3607
3607
|
let B = o[n];
|
|
3608
3608
|
const S = getRegisteredChaiBlock(o._type);
|
|
3609
|
-
return
|
|
3610
|
-
}, [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(
|
|
3611
3611
|
(v) => {
|
|
3612
3612
|
var S;
|
|
3613
3613
|
const B = v || ((S = g.current) == null ? void 0 : S.innerText);
|
|
3614
|
-
m([b], { [n]: B }), u(null), c(null), d(-1),
|
|
3614
|
+
m([b], { [n]: B }), u(null), c(null), d(-1), f(b ? [b] : []);
|
|
3615
3615
|
},
|
|
3616
|
-
[b, m, c,
|
|
3616
|
+
[b, m, c, f, x]
|
|
3617
3617
|
), N = useDebouncedCallback(
|
|
3618
3618
|
(v) => {
|
|
3619
3619
|
m([b], { [n]: v });
|
|
3620
3620
|
},
|
|
3621
|
-
[b, o, m,
|
|
3621
|
+
[b, o, m, x],
|
|
3622
3622
|
1e3
|
|
3623
3623
|
), w = useCallback(
|
|
3624
3624
|
(v) => {
|
|
3625
|
-
v.preventDefault(), b && (
|
|
3626
|
-
const B =
|
|
3627
|
-
|
|
3625
|
+
v.preventDefault(), b && (k.current = b), _(), setTimeout(() => {
|
|
3626
|
+
const B = k.current;
|
|
3627
|
+
k.current = null, f([B]);
|
|
3628
3628
|
}, 100);
|
|
3629
3629
|
},
|
|
3630
|
-
[
|
|
3630
|
+
[f, b, x]
|
|
3631
3631
|
);
|
|
3632
3632
|
useEffect(() => {
|
|
3633
3633
|
var C;
|
|
@@ -3635,7 +3635,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3635
3635
|
const v = `[data-block-id="${b}"]`, B = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${v}${B}`);
|
|
3636
3636
|
S && ((C = S == null ? void 0 : S.classList) == null || C.add("sr-only"), u(S));
|
|
3637
3637
|
}, [b, E, a, i]);
|
|
3638
|
-
const
|
|
3638
|
+
const y = useMemo(() => p ? (h(), E === "RichText" ? /* @__PURE__ */ jsx(
|
|
3639
3639
|
RichTextEditor,
|
|
3640
3640
|
{
|
|
3641
3641
|
blockContent: A,
|
|
@@ -3654,9 +3654,9 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3654
3654
|
onChange: N,
|
|
3655
3655
|
onEscape: w
|
|
3656
3656
|
}
|
|
3657
|
-
)) : null, [p, b, E, A, _,
|
|
3657
|
+
)) : null, [p, b, E, A, _, x]);
|
|
3658
3658
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3659
|
-
|
|
3659
|
+
y,
|
|
3660
3660
|
r
|
|
3661
3661
|
] });
|
|
3662
3662
|
},
|
|
@@ -3689,18 +3689,18 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3689
3689
|
blockAtom: r,
|
|
3690
3690
|
children: n
|
|
3691
3691
|
}) => {
|
|
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),
|
|
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(
|
|
3693
3693
|
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
3694
|
-
index:
|
|
3695
|
-
key:
|
|
3694
|
+
index: f,
|
|
3695
|
+
key: k
|
|
3696
3696
|
}) : applyLanguage(i, d, c),
|
|
3697
|
-
[i, d, c, g, m,
|
|
3697
|
+
[i, d, c, g, m, f, k]
|
|
3698
3698
|
), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), E = useMemo(
|
|
3699
3699
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
3700
3700
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
3701
3701
|
), _ = useMemo(
|
|
3702
3702
|
() => ({
|
|
3703
|
-
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 },
|
|
3704
3704
|
inBuilder: !0,
|
|
3705
3705
|
lang: d || p,
|
|
3706
3706
|
...b,
|
|
@@ -3719,8 +3719,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3719
3719
|
o
|
|
3720
3720
|
]
|
|
3721
3721
|
), N = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
|
|
3722
|
-
if (isNull(
|
|
3723
|
-
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, {
|
|
3724
3724
|
..._,
|
|
3725
3725
|
children: n({
|
|
3726
3726
|
_id: i._id,
|
|
@@ -3733,8 +3733,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3733
3733
|
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
3734
3734
|
})
|
|
3735
3735
|
}) });
|
|
3736
|
-
const
|
|
3737
|
-
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;
|
|
3738
3738
|
}, PartialWrapper = ({ children: o, partialBlockId: r }) => {
|
|
3739
3739
|
const n = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
3740
3740
|
(d) => {
|
|
@@ -3774,7 +3774,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3774
3774
|
);
|
|
3775
3775
|
return map(l, (c) => {
|
|
3776
3776
|
const d = a(c._id);
|
|
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:
|
|
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;
|
|
3778
3778
|
});
|
|
3779
3779
|
}, PageBlocksRenderer = () => {
|
|
3780
3780
|
const [o] = useBlocksStore();
|
|
@@ -3842,14 +3842,14 @@ const CanvasEventsWatcher = () => {
|
|
|
3842
3842
|
}, StaticCanvas = () => {
|
|
3843
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(
|
|
3844
3844
|
(m) => {
|
|
3845
|
-
i((
|
|
3845
|
+
i((x) => ({ ...x, width: m }));
|
|
3846
3846
|
},
|
|
3847
3847
|
[i]
|
|
3848
3848
|
);
|
|
3849
3849
|
useEffect(() => {
|
|
3850
3850
|
if (!a.current) return;
|
|
3851
|
-
const { clientWidth: m, clientHeight:
|
|
3852
|
-
i({ width: m, height:
|
|
3851
|
+
const { clientWidth: m, clientHeight: x } = a.current;
|
|
3852
|
+
i({ width: m, height: x });
|
|
3853
3853
|
}, [a, o]);
|
|
3854
3854
|
const h = useMemo(() => {
|
|
3855
3855
|
let m = IframeInitialContent;
|
|
@@ -3899,7 +3899,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3899
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: [
|
|
3900
3900
|
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
|
|
3901
3901
|
/* @__PURE__ */ jsx("p", { children: "Please try again." })
|
|
3902
|
-
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-
|
|
3902
|
+
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-CAnkmeVK.js")), CanvasArea = () => {
|
|
3903
3903
|
const [o] = useCodeEditor(), r = useBuilderProp("onError", noop);
|
|
3904
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: [
|
|
3905
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, {}) }) }),
|
|
@@ -3964,8 +3964,8 @@ const CanvasEventsWatcher = () => {
|
|
|
3964
3964
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3965
3965
|
] });
|
|
3966
3966
|
}, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
|
|
3967
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (
|
|
3968
|
-
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()) {
|
|
3969
3969
|
p(!1), g("Please enter a URL");
|
|
3970
3970
|
return;
|
|
3971
3971
|
}
|
|
@@ -3989,7 +3989,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3989
3989
|
{
|
|
3990
3990
|
placeholder: m(`Enter ${n} URL`),
|
|
3991
3991
|
value: a,
|
|
3992
|
-
onChange: (
|
|
3992
|
+
onChange: (x) => l(x.target.value),
|
|
3993
3993
|
onKeyUp: () => h(a)
|
|
3994
3994
|
}
|
|
3995
3995
|
),
|
|
@@ -4029,8 +4029,8 @@ const CanvasEventsWatcher = () => {
|
|
|
4029
4029
|
};
|
|
4030
4030
|
MediaManagerModal.displayName = "MediaManagerModal";
|
|
4031
4031
|
const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==", ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
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,
|
|
4033
|
-
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;
|
|
4034
4034
|
if (b) {
|
|
4035
4035
|
r(b == null ? void 0 : b.url);
|
|
4036
4036
|
const A = b == null ? void 0 : b.width, E = b == null ? void 0 : b.height;
|
|
@@ -4044,7 +4044,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4044
4044
|
d([c._id], _);
|
|
4045
4045
|
}
|
|
4046
4046
|
}
|
|
4047
|
-
},
|
|
4047
|
+
}, f = useCallback(() => {
|
|
4048
4048
|
r(PLACEHOLDER_IMAGE), c != null && c._id && d([c._id], { assetId: "" });
|
|
4049
4049
|
}, [r, c == null ? void 0 : c._id, d]);
|
|
4050
4050
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
|
|
@@ -4061,12 +4061,12 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4061
4061
|
"button",
|
|
4062
4062
|
{
|
|
4063
4063
|
type: "button",
|
|
4064
|
-
onClick:
|
|
4064
|
+
onClick: f,
|
|
4065
4065
|
className: "absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
|
|
4066
4066
|
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
4067
4067
|
}
|
|
4068
4068
|
),
|
|
4069
|
-
h && h !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect:
|
|
4069
|
+
h && h !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, assetId: h, children: /* @__PURE__ */ jsx(
|
|
4070
4070
|
"button",
|
|
4071
4071
|
{
|
|
4072
4072
|
type: "button",
|
|
@@ -4074,10 +4074,10 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4074
4074
|
children: /* @__PURE__ */ jsx(Edit2Icon, { className: "h-4 w-4 text-white" })
|
|
4075
4075
|
}
|
|
4076
4076
|
) })
|
|
4077
|
-
] }) : /* @__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]" }) }),
|
|
4078
4078
|
/* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
|
|
4079
4079
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4080
|
-
/* @__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") }) }),
|
|
4081
4081
|
/* @__PURE__ */ jsx("small", { className: "-pl-4 pt-2 text-center text-xs text-secondary-foreground", children: "OR" })
|
|
4082
4082
|
] }),
|
|
4083
4083
|
/* @__PURE__ */ jsx(
|
|
@@ -4091,8 +4091,8 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4091
4091
|
className: "text-xs",
|
|
4092
4092
|
placeholder: l("Enter image URL"),
|
|
4093
4093
|
value: o,
|
|
4094
|
-
onBlur: ({ target: { value:
|
|
4095
|
-
onChange: (
|
|
4094
|
+
onBlur: ({ target: { value: k } }) => a(n, k),
|
|
4095
|
+
onChange: (k) => r(k.target.value)
|
|
4096
4096
|
}
|
|
4097
4097
|
)
|
|
4098
4098
|
] })
|
|
@@ -4100,14 +4100,14 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4100
4100
|
}, PathDropdown = ({ data: o, onSelect: r, dataType: n }) => {
|
|
4101
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(
|
|
4102
4102
|
(h) => {
|
|
4103
|
-
const m = (
|
|
4104
|
-
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);
|
|
4105
4105
|
},
|
|
4106
4106
|
[a, r, n]
|
|
4107
4107
|
), u = React__default.useCallback(() => {
|
|
4108
4108
|
if (a.length > 0) {
|
|
4109
4109
|
const h = a.slice(0, -1);
|
|
4110
|
-
l(h), c(h.reduce((m,
|
|
4110
|
+
l(h), c(h.reduce((m, x) => m[x], o));
|
|
4111
4111
|
}
|
|
4112
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]);
|
|
4113
4113
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
@@ -4200,7 +4200,7 @@ const DataBindingSelector = ({
|
|
|
4200
4200
|
}) => {
|
|
4201
4201
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4202
4202
|
if (i.length === 1) return "";
|
|
4203
|
-
const g = i.find((
|
|
4203
|
+
const g = i.find((x) => x._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4204
4204
|
return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
|
|
4205
4205
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4206
4206
|
(g, h) => {
|
|
@@ -4208,19 +4208,19 @@ const DataBindingSelector = ({
|
|
|
4208
4208
|
r(`{{${g}}}`, {}, n);
|
|
4209
4209
|
return;
|
|
4210
4210
|
}
|
|
4211
|
-
const m = (b) => /[.,!?;:]/.test(b),
|
|
4211
|
+
const m = (b) => /[.,!?;:]/.test(b), x = (b, A, E) => {
|
|
4212
4212
|
let _ = "", N = "";
|
|
4213
|
-
const w = A > 0 ? b[A - 1] : "",
|
|
4214
|
-
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 = " "), {
|
|
4215
4215
|
text: _ + E + N,
|
|
4216
4216
|
prefixLength: _.length,
|
|
4217
4217
|
suffixLength: N.length
|
|
4218
4218
|
};
|
|
4219
|
-
},
|
|
4220
|
-
if (!
|
|
4221
|
-
const
|
|
4222
|
-
if (
|
|
4223
|
-
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;
|
|
4224
4224
|
if (b) {
|
|
4225
4225
|
const A = `{{${g}}}`;
|
|
4226
4226
|
b.commands.focus();
|
|
@@ -4228,9 +4228,9 @@ const DataBindingSelector = ({
|
|
|
4228
4228
|
if (E !== _)
|
|
4229
4229
|
b.chain().deleteSelection().insertContent(A).run();
|
|
4230
4230
|
else {
|
|
4231
|
-
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));
|
|
4232
4232
|
let S = "";
|
|
4233
|
-
|
|
4233
|
+
y > 0 && v !== " " && !m(v) && (S = " ");
|
|
4234
4234
|
let C = "";
|
|
4235
4235
|
B && B !== " " && !m(B) && (C = " "), b.chain().insertContent(S + A + C).run();
|
|
4236
4236
|
}
|
|
@@ -4238,13 +4238,13 @@ const DataBindingSelector = ({
|
|
|
4238
4238
|
return;
|
|
4239
4239
|
}
|
|
4240
4240
|
} else {
|
|
4241
|
-
const b =
|
|
4241
|
+
const b = f, A = b.selectionStart || 0, E = b.value || "", _ = b.selectionEnd || A;
|
|
4242
4242
|
if (_ > A) {
|
|
4243
|
-
const B = `{{${g}}}`, { text: S } =
|
|
4243
|
+
const B = `{{${g}}}`, { text: S } = x(E, A, B), C = E.slice(0, A) + S + E.slice(_);
|
|
4244
4244
|
r(C, {}, n);
|
|
4245
4245
|
return;
|
|
4246
4246
|
}
|
|
4247
|
-
const w = `{{${g}}}`, { text:
|
|
4247
|
+
const w = `{{${g}}}`, { text: y } = x(E, A, w), v = E.slice(0, A) + y + E.slice(A);
|
|
4248
4248
|
r(v, {}, n);
|
|
4249
4249
|
}
|
|
4250
4250
|
},
|
|
@@ -4267,9 +4267,9 @@ const DataBindingSelector = ({
|
|
|
4267
4267
|
onChange: n
|
|
4268
4268
|
}) => {
|
|
4269
4269
|
var B;
|
|
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(""), [
|
|
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;
|
|
4271
4271
|
useEffect(() => {
|
|
4272
|
-
if (m(""),
|
|
4272
|
+
if (m(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4273
4273
|
const S = split(o, ":"), C = get(S, 1, "page") || "page";
|
|
4274
4274
|
g(C), (async () => {
|
|
4275
4275
|
const j = await l(C, [get(S, 2, "page")]);
|
|
@@ -4279,10 +4279,10 @@ const DataBindingSelector = ({
|
|
|
4279
4279
|
const _ = useDebouncedCallback(
|
|
4280
4280
|
async (S) => {
|
|
4281
4281
|
if (isEmpty(S))
|
|
4282
|
-
|
|
4282
|
+
f([]);
|
|
4283
4283
|
else {
|
|
4284
4284
|
const C = await l(u, S);
|
|
4285
|
-
|
|
4285
|
+
f(C);
|
|
4286
4286
|
}
|
|
4287
4287
|
c(!1), b(-1);
|
|
4288
4288
|
},
|
|
@@ -4290,32 +4290,32 @@ const DataBindingSelector = ({
|
|
|
4290
4290
|
300
|
|
4291
4291
|
), N = (S) => {
|
|
4292
4292
|
const C = ["pageType", u, S.id];
|
|
4293
|
-
C[1] && (n(C.join(":")), m(S.name), p(!1),
|
|
4293
|
+
C[1] && (n(C.join(":")), m(S.name), p(!1), f([]), b(-1));
|
|
4294
4294
|
}, w = (S) => {
|
|
4295
4295
|
switch (S.key) {
|
|
4296
4296
|
case "ArrowDown":
|
|
4297
|
-
S.preventDefault(), b((C) => C <
|
|
4297
|
+
S.preventDefault(), b((C) => C < x.length - 1 ? C + 1 : C);
|
|
4298
4298
|
break;
|
|
4299
4299
|
case "ArrowUp":
|
|
4300
4300
|
S.preventDefault(), b((C) => C > 0 ? C - 1 : C);
|
|
4301
4301
|
break;
|
|
4302
4302
|
case "Enter":
|
|
4303
|
-
if (S.preventDefault(),
|
|
4304
|
-
|
|
4303
|
+
if (S.preventDefault(), x.length === 0) return;
|
|
4304
|
+
k >= 0 && N(x[k]);
|
|
4305
4305
|
break;
|
|
4306
4306
|
case "Escape":
|
|
4307
|
-
S.preventDefault(),
|
|
4307
|
+
S.preventDefault(), y();
|
|
4308
4308
|
break;
|
|
4309
4309
|
}
|
|
4310
4310
|
};
|
|
4311
4311
|
useEffect(() => {
|
|
4312
|
-
if (
|
|
4313
|
-
const S = A.current.children[
|
|
4312
|
+
if (k >= 0 && A.current) {
|
|
4313
|
+
const S = A.current.children[k];
|
|
4314
4314
|
S == null || S.scrollIntoView({ block: "nearest" });
|
|
4315
4315
|
}
|
|
4316
|
-
}, [
|
|
4317
|
-
const
|
|
4318
|
-
m(""),
|
|
4316
|
+
}, [k]);
|
|
4317
|
+
const y = () => {
|
|
4318
|
+
m(""), f([]), b(-1), p(!1), n("");
|
|
4319
4319
|
}, v = (S) => {
|
|
4320
4320
|
m(S), p(!isEmpty(S)), c(!0), _(S);
|
|
4321
4321
|
};
|
|
@@ -4333,21 +4333,21 @@ const DataBindingSelector = ({
|
|
|
4333
4333
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4334
4334
|
}
|
|
4335
4335
|
),
|
|
4336
|
-
/* @__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" }) }) })
|
|
4337
4337
|
] }),
|
|
4338
|
-
(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: [
|
|
4339
4339
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4340
4340
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4341
|
-
] }) : d && isEmpty(
|
|
4341
|
+
] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4342
4342
|
a("No results found for"),
|
|
4343
4343
|
' "',
|
|
4344
4344
|
h,
|
|
4345
4345
|
'"'
|
|
4346
|
-
] }) : /* @__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(
|
|
4347
4347
|
"li",
|
|
4348
4348
|
{
|
|
4349
4349
|
onClick: () => N(S),
|
|
4350
|
-
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"}`,
|
|
4351
4351
|
children: [
|
|
4352
4352
|
S.name,
|
|
4353
4353
|
" ",
|
|
@@ -4658,8 +4658,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4658
4658
|
if (!u) return;
|
|
4659
4659
|
const m = `{{${h}}}`;
|
|
4660
4660
|
u.commands.focus();
|
|
4661
|
-
const { from:
|
|
4662
|
-
if (
|
|
4661
|
+
const { from: x, to: f } = u.state.selection;
|
|
4662
|
+
if (x !== f)
|
|
4663
4663
|
u.chain().deleteSelection().insertContent(m).run();
|
|
4664
4664
|
else {
|
|
4665
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));
|
|
@@ -4705,13 +4705,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4705
4705
|
})
|
|
4706
4706
|
],
|
|
4707
4707
|
content: n || "",
|
|
4708
|
-
onUpdate: ({ editor:
|
|
4709
|
-
const
|
|
4710
|
-
a(
|
|
4708
|
+
onUpdate: ({ editor: x }) => {
|
|
4709
|
+
const f = x.getHTML();
|
|
4710
|
+
a(f), c || u(f);
|
|
4711
4711
|
},
|
|
4712
|
-
onBlur: ({ editor:
|
|
4713
|
-
const
|
|
4714
|
-
l(o,
|
|
4712
|
+
onBlur: ({ editor: x }) => {
|
|
4713
|
+
const f = x.getHTML();
|
|
4714
|
+
l(o, f);
|
|
4715
4715
|
},
|
|
4716
4716
|
editorProps: {
|
|
4717
4717
|
attributes: {
|
|
@@ -4724,8 +4724,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4724
4724
|
}, [g]), useEffect(() => {
|
|
4725
4725
|
u(n || "");
|
|
4726
4726
|
}, [n]);
|
|
4727
|
-
const h = (
|
|
4728
|
-
a(
|
|
4727
|
+
const h = (x) => {
|
|
4728
|
+
a(x);
|
|
4729
4729
|
}, m = () => {
|
|
4730
4730
|
d(!1), g && g.commands.setContent(p);
|
|
4731
4731
|
};
|
|
@@ -4758,25 +4758,25 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4758
4758
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
|
|
4759
4759
|
}, [o, u]);
|
|
4760
4760
|
const h = () => {
|
|
4761
|
-
const
|
|
4762
|
-
if (
|
|
4763
|
-
const
|
|
4761
|
+
const f = findIndex(u, { _id: g });
|
|
4762
|
+
if (f > -1) {
|
|
4763
|
+
const k = (f + 1) % u.length, b = get(u, [k, "_id"]);
|
|
4764
4764
|
if (!b) return;
|
|
4765
4765
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4766
4766
|
}
|
|
4767
4767
|
}, m = () => {
|
|
4768
|
-
const
|
|
4769
|
-
if (
|
|
4770
|
-
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"]);
|
|
4771
4771
|
if (!b) return;
|
|
4772
4772
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4773
4773
|
}
|
|
4774
|
-
},
|
|
4775
|
-
const
|
|
4774
|
+
}, x = () => {
|
|
4775
|
+
const f = i(
|
|
4776
4776
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4777
4777
|
p == null ? void 0 : p._id
|
|
4778
|
-
),
|
|
4779
|
-
|
|
4778
|
+
), k = f == null ? void 0 : f._id;
|
|
4779
|
+
k && (r({ ...o, currentSlide: k }), c([k]));
|
|
4780
4780
|
};
|
|
4781
4781
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4782
4782
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
@@ -4793,7 +4793,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4793
4793
|
/* @__PURE__ */ jsxs(
|
|
4794
4794
|
"button",
|
|
4795
4795
|
{
|
|
4796
|
-
onClick:
|
|
4796
|
+
onClick: x,
|
|
4797
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",
|
|
4798
4798
|
children: [
|
|
4799
4799
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4854,9 +4854,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4854
4854
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4855
4855
|
className: "text-xs",
|
|
4856
4856
|
pattern: "[0-9]*",
|
|
4857
|
-
onChange: (
|
|
4858
|
-
let
|
|
4859
|
-
|
|
4857
|
+
onChange: (f) => {
|
|
4858
|
+
let k = f.target.value;
|
|
4859
|
+
k.length && (k = k.replace("-", "")), r({ ...o, autoplayInterval: k });
|
|
4860
4860
|
}
|
|
4861
4861
|
}
|
|
4862
4862
|
)
|
|
@@ -4963,10 +4963,10 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4963
4963
|
formData: u,
|
|
4964
4964
|
onChange: g
|
|
4965
4965
|
}) => {
|
|
4966
|
-
const { selectedLang: h, fallbackLang: m, languages:
|
|
4967
|
-
() => isEmpty(
|
|
4968
|
-
[
|
|
4969
|
-
),
|
|
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(
|
|
4970
4970
|
() => get(E, [A == null ? void 0 : A._type, "i18nProps"], []),
|
|
4971
4971
|
[E, A == null ? void 0 : A._type]
|
|
4972
4972
|
), [N, w] = useState(null);
|
|
@@ -5018,7 +5018,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
5018
5018
|
" ",
|
|
5019
5019
|
v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5020
5020
|
" ",
|
|
5021
|
-
|
|
5021
|
+
k
|
|
5022
5022
|
] }),
|
|
5023
5023
|
d && p.type !== "object" ? " *" : null
|
|
5024
5024
|
] }),
|
|
@@ -5138,36 +5138,36 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
5138
5138
|
}), a;
|
|
5139
5139
|
};
|
|
5140
5140
|
function BlockSettings() {
|
|
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),
|
|
5142
|
-
|
|
5143
|
-
},
|
|
5144
|
-
debounce(({ formData: w },
|
|
5145
|
-
|
|
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);
|
|
5146
5146
|
}, 1500),
|
|
5147
5147
|
[r == null ? void 0 : r._id, o]
|
|
5148
|
-
),
|
|
5149
|
-
|
|
5150
|
-
}, b = ({ formData: w },
|
|
5151
|
-
|
|
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) }));
|
|
5152
5152
|
}, { schema: A, uiSchema: E } = useMemo(() => {
|
|
5153
5153
|
const w = r == null ? void 0 : r._type;
|
|
5154
5154
|
if (!w)
|
|
5155
5155
|
return { schema: {}, uiSchema: {} };
|
|
5156
5156
|
try {
|
|
5157
|
-
const { schema:
|
|
5157
|
+
const { schema: y, uiSchema: v } = getBlockFormSchemas(w);
|
|
5158
5158
|
if (w === "Repeater") {
|
|
5159
5159
|
const B = get(r, "repeaterItems", "");
|
|
5160
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" }));
|
|
5161
5161
|
}
|
|
5162
|
-
return { schema:
|
|
5162
|
+
return { schema: y, uiSchema: v };
|
|
5163
5163
|
} catch {
|
|
5164
5164
|
return { schema: {}, uiSchema: {} };
|
|
5165
5165
|
}
|
|
5166
5166
|
}, [r]), { wrapperSchema: _, wrapperUiSchema: N } = useMemo(() => {
|
|
5167
5167
|
if (!g || !(g != null && g._type))
|
|
5168
5168
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5169
|
-
const w = g == null ? void 0 : g._type, { schema:
|
|
5170
|
-
return { wrapperSchema:
|
|
5169
|
+
const w = g == null ? void 0 : g._type, { schema: y = {}, uiSchema: v = {} } = getBlockFormSchemas(w);
|
|
5170
|
+
return { wrapperSchema: y, wrapperUiSchema: v };
|
|
5171
5171
|
}, [g]);
|
|
5172
5172
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5173
5173
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
@@ -5204,7 +5204,7 @@ function BlockSettings() {
|
|
|
5204
5204
|
JSONForm,
|
|
5205
5205
|
{
|
|
5206
5206
|
blockId: r == null ? void 0 : r._id,
|
|
5207
|
-
onChange:
|
|
5207
|
+
onChange: k,
|
|
5208
5208
|
formData: i,
|
|
5209
5209
|
schema: A,
|
|
5210
5210
|
uiSchema: E
|
|
@@ -5213,34 +5213,34 @@ function BlockSettings() {
|
|
|
5213
5213
|
] });
|
|
5214
5214
|
}
|
|
5215
5215
|
const BlockStylingProps = () => {
|
|
5216
|
-
var
|
|
5216
|
+
var x;
|
|
5217
5217
|
const o = useSelectedBlock(), [r, n] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
|
|
5218
5218
|
if (!o) return null;
|
|
5219
5219
|
const c = Object.keys(o).filter(
|
|
5220
|
-
(
|
|
5221
|
-
), { 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);
|
|
5222
5222
|
return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5223
5223
|
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5224
5224
|
i("Style element"),
|
|
5225
5225
|
":"
|
|
5226
5226
|
] }),
|
|
5227
|
-
/* @__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(
|
|
5228
5228
|
Badge,
|
|
5229
5229
|
{
|
|
5230
5230
|
className: "flex cursor-pointer items-center gap-1 pr-1",
|
|
5231
|
-
variant: m(
|
|
5231
|
+
variant: m(f) ? "default" : "secondary",
|
|
5232
5232
|
onClick: () => {
|
|
5233
|
-
n([{ id: `${
|
|
5233
|
+
n([{ id: `${f}-${o._id}`, blockId: o._id, prop: f }]);
|
|
5234
5234
|
},
|
|
5235
5235
|
children: [
|
|
5236
|
-
startCase(
|
|
5236
|
+
startCase(f),
|
|
5237
5237
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5238
5238
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5239
5239
|
"button",
|
|
5240
5240
|
{
|
|
5241
5241
|
type: "button",
|
|
5242
5242
|
className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
|
|
5243
|
-
onClick: (
|
|
5243
|
+
onClick: (k) => k.stopPropagation(),
|
|
5244
5244
|
children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
|
|
5245
5245
|
}
|
|
5246
5246
|
) }),
|
|
@@ -5250,7 +5250,7 @@ const BlockStylingProps = () => {
|
|
|
5250
5250
|
{
|
|
5251
5251
|
className: "text-xs",
|
|
5252
5252
|
onClick: () => {
|
|
5253
|
-
d(
|
|
5253
|
+
d(f);
|
|
5254
5254
|
},
|
|
5255
5255
|
children: i("Reset style")
|
|
5256
5256
|
}
|
|
@@ -5269,7 +5269,7 @@ const BlockStylingProps = () => {
|
|
|
5269
5269
|
] })
|
|
5270
5270
|
]
|
|
5271
5271
|
},
|
|
5272
|
-
|
|
5272
|
+
f
|
|
5273
5273
|
)) }),
|
|
5274
5274
|
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5275
5275
|
] }) });
|
|
@@ -5418,7 +5418,7 @@ const BlockStylingProps = () => {
|
|
|
5418
5418
|
},
|
|
5419
5419
|
a
|
|
5420
5420
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
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]), [
|
|
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);
|
|
5422
5422
|
useEffect(() => {
|
|
5423
5423
|
const { value: S, unit: C } = getClassValueAndUnit(i);
|
|
5424
5424
|
if (C === "") {
|
|
@@ -5427,11 +5427,11 @@ const BlockStylingProps = () => {
|
|
|
5427
5427
|
}
|
|
5428
5428
|
m(C), l(C === "class" || isEmpty(S) ? "" : S);
|
|
5429
5429
|
}, [i, p, u]);
|
|
5430
|
-
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(
|
|
5431
5431
|
(S = !1) => {
|
|
5432
5432
|
const C = getUserInputValues(`${a}`, u);
|
|
5433
5433
|
if (get(C, "error", !1)) {
|
|
5434
|
-
|
|
5434
|
+
f(!0);
|
|
5435
5435
|
return;
|
|
5436
5436
|
}
|
|
5437
5437
|
const j = get(C, "unit") !== "" ? get(C, "unit") : h;
|
|
@@ -5442,14 +5442,14 @@ const BlockStylingProps = () => {
|
|
|
5442
5442
|
if (get(C, "value") === "")
|
|
5443
5443
|
return;
|
|
5444
5444
|
const T = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5445
|
-
S ?
|
|
5445
|
+
S ? y(T) : w(T);
|
|
5446
5446
|
},
|
|
5447
|
-
[w,
|
|
5447
|
+
[w, y, a, h, d, u]
|
|
5448
5448
|
), B = useCallback(
|
|
5449
5449
|
(S) => {
|
|
5450
5450
|
const C = getUserInputValues(`${a}`, u);
|
|
5451
5451
|
if (get(C, "error", !1)) {
|
|
5452
|
-
|
|
5452
|
+
f(!0);
|
|
5453
5453
|
return;
|
|
5454
5454
|
}
|
|
5455
5455
|
if (S === "auto" || S === "none") {
|
|
@@ -5493,23 +5493,23 @@ const BlockStylingProps = () => {
|
|
|
5493
5493
|
let j = isNaN$1(C) ? 0 : C;
|
|
5494
5494
|
S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
|
|
5495
5495
|
const I = `${j}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5496
|
-
|
|
5496
|
+
y(P);
|
|
5497
5497
|
},
|
|
5498
5498
|
onKeyUp: (S) => {
|
|
5499
5499
|
_ && (S.preventDefault(), N(!1));
|
|
5500
5500
|
},
|
|
5501
5501
|
onBlur: () => v(),
|
|
5502
5502
|
onChange: (S) => {
|
|
5503
|
-
|
|
5503
|
+
f(!1), l(S.target.value);
|
|
5504
5504
|
},
|
|
5505
5505
|
onClick: (S) => {
|
|
5506
5506
|
var C;
|
|
5507
5507
|
(C = S == null ? void 0 : S.target) == null || C.select(), n(!1);
|
|
5508
5508
|
},
|
|
5509
|
-
value: A ?
|
|
5509
|
+
value: A ? k : a,
|
|
5510
5510
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5511
5511
|
" ",
|
|
5512
|
-
|
|
5512
|
+
x ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
5513
5513
|
)
|
|
5514
5514
|
}
|
|
5515
5515
|
),
|
|
@@ -5553,7 +5553,7 @@ const BlockStylingProps = () => {
|
|
|
5553
5553
|
return;
|
|
5554
5554
|
b(S);
|
|
5555
5555
|
const C = `${S}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5556
|
-
|
|
5556
|
+
y(I);
|
|
5557
5557
|
},
|
|
5558
5558
|
currentValue: a,
|
|
5559
5559
|
unit: h,
|
|
@@ -5618,8 +5618,8 @@ const COLOR_PROP = {
|
|
|
5618
5618
|
}, ColorChoice = ({ property: o, onChange: r }) => {
|
|
5619
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(
|
|
5620
5620
|
// eslint-disable-next-line no-shadow
|
|
5621
|
-
(
|
|
5622
|
-
["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" })));
|
|
5623
5623
|
},
|
|
5624
5624
|
[c, p]
|
|
5625
5625
|
);
|
|
@@ -5628,21 +5628,21 @@ const COLOR_PROP = {
|
|
|
5628
5628
|
return c([]);
|
|
5629
5629
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5630
5630
|
}, [g]);
|
|
5631
|
-
const
|
|
5631
|
+
const x = useCallback(
|
|
5632
5632
|
// eslint-disable-next-line no-shadow
|
|
5633
|
-
(
|
|
5634
|
-
p({ color: g, shade:
|
|
5633
|
+
(k) => {
|
|
5634
|
+
p({ color: g, shade: k });
|
|
5635
5635
|
},
|
|
5636
5636
|
[g]
|
|
5637
5637
|
);
|
|
5638
5638
|
useEffect(() => {
|
|
5639
5639
|
p({ color: "", shade: "" });
|
|
5640
5640
|
}, [n]);
|
|
5641
|
-
const { match:
|
|
5641
|
+
const { match: f } = useTailwindClassList();
|
|
5642
5642
|
return useEffect(() => {
|
|
5643
5643
|
const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5644
|
-
|
|
5645
|
-
}, [
|
|
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: [
|
|
5646
5646
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5647
5647
|
DropDown,
|
|
5648
5648
|
{
|
|
@@ -5682,7 +5682,7 @@ const COLOR_PROP = {
|
|
|
5682
5682
|
]
|
|
5683
5683
|
}
|
|
5684
5684
|
) }),
|
|
5685
|
-
/* @__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 }) })
|
|
5686
5686
|
] });
|
|
5687
5687
|
}, EDITOR_ICONS = {
|
|
5688
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" }) }),
|
|
@@ -6016,22 +6016,22 @@ const COLOR_PROP = {
|
|
|
6016
6016
|
"2xl": "1536px"
|
|
6017
6017
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6018
6018
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6019
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(),
|
|
6020
|
-
(
|
|
6021
|
-
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: "" };
|
|
6022
6022
|
(p || u !== "") && (B.mq = "xs");
|
|
6023
6023
|
const S = generateFullClsName(B);
|
|
6024
|
-
m(
|
|
6024
|
+
m(f, [S], v);
|
|
6025
6025
|
},
|
|
6026
|
-
[
|
|
6026
|
+
[f, p, g, u, l, m]
|
|
6027
6027
|
), A = useCallback(() => {
|
|
6028
|
-
f
|
|
6029
|
-
}, [
|
|
6028
|
+
x(f, [k], !0);
|
|
6029
|
+
}, [f, k, x]), E = useMemo(() => canChangeClass(h, g), [h, g]);
|
|
6030
6030
|
useEffect(() => {
|
|
6031
6031
|
i(E, h);
|
|
6032
6032
|
}, [E, i, h]);
|
|
6033
6033
|
const [, , _] = useScreenSizeWidth(), N = useCallback(
|
|
6034
|
-
(
|
|
6034
|
+
(y) => {
|
|
6035
6035
|
_({
|
|
6036
6036
|
xs: 400,
|
|
6037
6037
|
sm: 640,
|
|
@@ -6039,7 +6039,7 @@ const COLOR_PROP = {
|
|
|
6039
6039
|
lg: 1024,
|
|
6040
6040
|
xl: 1420,
|
|
6041
6041
|
"2xl": 1920
|
|
6042
|
-
}[
|
|
6042
|
+
}[y]);
|
|
6043
6043
|
},
|
|
6044
6044
|
[_]
|
|
6045
6045
|
), w = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
|
|
@@ -6063,7 +6063,7 @@ const COLOR_PROP = {
|
|
|
6063
6063
|
n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
6064
6064
|
n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
6065
6065
|
] }),
|
|
6066
|
-
/* @__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: [
|
|
6067
6067
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6068
6068
|
"button",
|
|
6069
6069
|
{
|
|
@@ -6112,23 +6112,23 @@ const COLOR_PROP = {
|
|
|
6112
6112
|
children: [
|
|
6113
6113
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6114
6114
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6115
|
-
/* @__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: [
|
|
6116
6116
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6117
6117
|
"button",
|
|
6118
6118
|
{
|
|
6119
6119
|
type: "button",
|
|
6120
|
-
onClick: () => u(
|
|
6121
|
-
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"}`,
|
|
6122
6122
|
children: [
|
|
6123
6123
|
React__default.createElement("div", {
|
|
6124
|
-
className: h(
|
|
6124
|
+
className: h(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6125
6125
|
}),
|
|
6126
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6126
|
+
React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6127
6127
|
]
|
|
6128
6128
|
}
|
|
6129
6129
|
) }),
|
|
6130
6130
|
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
|
|
6131
|
-
] }) }, `option-${
|
|
6131
|
+
] }) }, `option-${f}`)) })
|
|
6132
6132
|
] }),
|
|
6133
6133
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6134
6134
|
BlockStyle,
|
|
@@ -6283,19 +6283,19 @@ const COLOR_PROP = {
|
|
|
6283
6283
|
canvas: r = !1,
|
|
6284
6284
|
tooltip: n = !0
|
|
6285
6285
|
}) => {
|
|
6286
|
-
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) => {
|
|
6287
6287
|
u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
|
|
6288
|
-
},
|
|
6288
|
+
}, f = (b) => {
|
|
6289
6289
|
r || l(b), c(b);
|
|
6290
|
-
},
|
|
6290
|
+
}, k = getBreakpointValue(r ? i : a).toLowerCase();
|
|
6291
6291
|
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
|
|
6292
6292
|
BreakpointCard,
|
|
6293
6293
|
{
|
|
6294
6294
|
canvas: r,
|
|
6295
6295
|
...b,
|
|
6296
|
-
onClick:
|
|
6296
|
+
onClick: f,
|
|
6297
6297
|
key: b.breakpoint,
|
|
6298
|
-
currentBreakpoint:
|
|
6298
|
+
currentBreakpoint: k
|
|
6299
6299
|
}
|
|
6300
6300
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
6301
6301
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
@@ -6307,9 +6307,9 @@ const COLOR_PROP = {
|
|
|
6307
6307
|
openDelay: o,
|
|
6308
6308
|
tooltip: n,
|
|
6309
6309
|
...b,
|
|
6310
|
-
onClick:
|
|
6310
|
+
onClick: f,
|
|
6311
6311
|
key: b.breakpoint,
|
|
6312
|
-
currentBreakpoint:
|
|
6312
|
+
currentBreakpoint: k
|
|
6313
6313
|
}
|
|
6314
6314
|
)
|
|
6315
6315
|
) }),
|
|
@@ -6322,7 +6322,7 @@ const COLOR_PROP = {
|
|
|
6322
6322
|
DropdownMenuCheckboxItem,
|
|
6323
6323
|
{
|
|
6324
6324
|
disabled: b.breakpoint === "xs",
|
|
6325
|
-
onCheckedChange: () =>
|
|
6325
|
+
onCheckedChange: () => x(toUpper(b.breakpoint)),
|
|
6326
6326
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6327
6327
|
children: h(b.title)
|
|
6328
6328
|
},
|
|
@@ -6407,8 +6407,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6407
6407
|
(m = d.current) == null || m.focus();
|
|
6408
6408
|
}, []);
|
|
6409
6409
|
const h = (m) => {
|
|
6410
|
-
const { usage:
|
|
6411
|
-
!l &&
|
|
6410
|
+
const { usage: x } = m || {};
|
|
6411
|
+
!l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6412
6412
|
};
|
|
6413
6413
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6414
6414
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
|
|
@@ -6464,9 +6464,9 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6464
6464
|
};
|
|
6465
6465
|
function ManualClasses() {
|
|
6466
6466
|
var I;
|
|
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), [
|
|
6468
|
-
const T =
|
|
6469
|
-
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("");
|
|
6470
6470
|
}, [_, N] = useState([]), w = ({ value: T }) => {
|
|
6471
6471
|
const P = T.trim().toLowerCase(), L = P.match(/.+:/g);
|
|
6472
6472
|
let D = [];
|
|
@@ -6479,7 +6479,7 @@ function ManualClasses() {
|
|
|
6479
6479
|
} else
|
|
6480
6480
|
D = i.search(P);
|
|
6481
6481
|
return N(map(D, "item"));
|
|
6482
|
-
},
|
|
6482
|
+
}, y = () => {
|
|
6483
6483
|
N([]);
|
|
6484
6484
|
}, v = (T) => T.name, B = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
|
|
6485
6485
|
() => ({
|
|
@@ -6489,19 +6489,19 @@ function ManualClasses() {
|
|
|
6489
6489
|
autoCapitalize: "off",
|
|
6490
6490
|
spellCheck: !1,
|
|
6491
6491
|
placeholder: c("Enter classes separated by space"),
|
|
6492
|
-
value:
|
|
6492
|
+
value: x,
|
|
6493
6493
|
onFocus: (T) => {
|
|
6494
6494
|
setTimeout(() => {
|
|
6495
6495
|
T.target && T.target.select();
|
|
6496
6496
|
}, 0);
|
|
6497
6497
|
},
|
|
6498
6498
|
onKeyDown: (T) => {
|
|
6499
|
-
T.key === "Enter" &&
|
|
6499
|
+
T.key === "Enter" && x.trim() !== "" && E();
|
|
6500
6500
|
},
|
|
6501
|
-
onChange: (T, { newValue: P }) =>
|
|
6501
|
+
onChange: (T, { newValue: P }) => f(P),
|
|
6502
6502
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6503
6503
|
}),
|
|
6504
|
-
[
|
|
6504
|
+
[x, c, o]
|
|
6505
6505
|
), C = (T) => {
|
|
6506
6506
|
debugger;
|
|
6507
6507
|
const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
@@ -6536,7 +6536,7 @@ function ManualClasses() {
|
|
|
6536
6536
|
{
|
|
6537
6537
|
suggestions: _,
|
|
6538
6538
|
onSuggestionsFetchRequested: w,
|
|
6539
|
-
onSuggestionsClearRequested:
|
|
6539
|
+
onSuggestionsClearRequested: y,
|
|
6540
6540
|
getSuggestionValue: v,
|
|
6541
6541
|
renderSuggestion: B,
|
|
6542
6542
|
inputProps: S,
|
|
@@ -6556,7 +6556,7 @@ function ManualClasses() {
|
|
|
6556
6556
|
variant: "outline",
|
|
6557
6557
|
className: "h-6 border-border",
|
|
6558
6558
|
onClick: E,
|
|
6559
|
-
disabled:
|
|
6559
|
+
disabled: x.trim() === "",
|
|
6560
6560
|
size: "sm",
|
|
6561
6561
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
6562
6562
|
}
|
|
@@ -6587,7 +6587,7 @@ function ManualClasses() {
|
|
|
6587
6587
|
"button",
|
|
6588
6588
|
{
|
|
6589
6589
|
onDoubleClick: () => {
|
|
6590
|
-
|
|
6590
|
+
f(T), g(h, [T]), setTimeout(() => {
|
|
6591
6591
|
o.current && o.current.focus();
|
|
6592
6592
|
}, 10);
|
|
6593
6593
|
},
|
|
@@ -6743,10 +6743,10 @@ function BlockStyling() {
|
|
|
6743
6743
|
const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
|
|
6744
6744
|
let m = parseFloat(i.dragStartValue);
|
|
6745
6745
|
m = isNaN(m) ? 0 : m;
|
|
6746
|
-
let
|
|
6747
|
-
(startsWith(h, "scale") || h === "opacity") && (
|
|
6748
|
-
let
|
|
6749
|
-
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}`);
|
|
6750
6750
|
},
|
|
6751
6751
|
[i],
|
|
6752
6752
|
50
|
|
@@ -6789,12 +6789,12 @@ const CoreBlock = ({
|
|
|
6789
6789
|
}) => {
|
|
6790
6790
|
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
|
|
6791
6791
|
if (has(o, "blocks")) {
|
|
6792
|
-
const
|
|
6793
|
-
u(syncBlocksWithDefaults(
|
|
6792
|
+
const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
6793
|
+
u(syncBlocksWithDefaults(k), n || null, a);
|
|
6794
6794
|
} else
|
|
6795
6795
|
p(o, n || null, a);
|
|
6796
6796
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6797
|
-
},
|
|
6797
|
+
}, x = useFeature("dnd"), { t: f } = useTranslation();
|
|
6798
6798
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6799
6799
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6800
6800
|
"button",
|
|
@@ -6802,20 +6802,20 @@ const CoreBlock = ({
|
|
|
6802
6802
|
disabled: r,
|
|
6803
6803
|
onClick: m,
|
|
6804
6804
|
type: "button",
|
|
6805
|
-
onDragStart: (
|
|
6806
|
-
|
|
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(() => {
|
|
6807
6807
|
g([]), h();
|
|
6808
6808
|
}, 200);
|
|
6809
6809
|
},
|
|
6810
|
-
draggable:
|
|
6810
|
+
draggable: x ? "true" : "false",
|
|
6811
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",
|
|
6812
6812
|
children: [
|
|
6813
6813
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6814
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6814
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(f(d || i)) })
|
|
6815
6815
|
]
|
|
6816
6816
|
}
|
|
6817
6817
|
) }),
|
|
6818
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6818
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f(d || i) }) })
|
|
6819
6819
|
] }) });
|
|
6820
6820
|
}, DefaultChaiBlocks = ({
|
|
6821
6821
|
parentId: o,
|
|
@@ -7018,7 +7018,7 @@ const CoreBlock = ({
|
|
|
7018
7018
|
}
|
|
7019
7019
|
}
|
|
7020
7020
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
7021
|
-
var h, m,
|
|
7021
|
+
var h, m, x, f, k, b, A, E, _, N;
|
|
7022
7022
|
if (n.type === "comment") return [];
|
|
7023
7023
|
let a = { _id: generateUUID() };
|
|
7024
7024
|
if (r && (a._parent = r.block._id), n.type === "text")
|
|
@@ -7040,7 +7040,7 @@ const CoreBlock = ({
|
|
|
7040
7040
|
...getAttrs(n),
|
|
7041
7041
|
...getStyles(n)
|
|
7042
7042
|
}, n.attributes) {
|
|
7043
|
-
const w = n.attributes.find((
|
|
7043
|
+
const w = n.attributes.find((y) => includes(NAME_ATTRIBUTES, y.key));
|
|
7044
7044
|
w && (a._name = w.value);
|
|
7045
7045
|
}
|
|
7046
7046
|
if (i)
|
|
@@ -7058,26 +7058,26 @@ const CoreBlock = ({
|
|
|
7058
7058
|
];
|
|
7059
7059
|
a = {
|
|
7060
7060
|
...a,
|
|
7061
|
-
href: ((h = l.find((
|
|
7062
|
-
hrefType: ((m = l.find((
|
|
7063
|
-
autoplay: ((
|
|
7064
|
-
maxWidth: ((
|
|
7065
|
-
backdropColor: ((b = l.find((
|
|
7066
|
-
galleryName: ((A = l.find((
|
|
7067
|
-
}, forEach(w, (
|
|
7068
|
-
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];
|
|
7069
7069
|
});
|
|
7070
7070
|
}
|
|
7071
7071
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
7072
7072
|
delete a.styles_attrs;
|
|
7073
7073
|
const w = filter(n.children || [], (v) => (v == null ? void 0 : v.tagName) !== "span");
|
|
7074
7074
|
a.content = getTextContent(w);
|
|
7075
|
-
const
|
|
7075
|
+
const y = find(
|
|
7076
7076
|
n.children || [],
|
|
7077
7077
|
(v) => (v == null ? void 0 : v.tagName) === "span" && some(v.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg")
|
|
7078
7078
|
);
|
|
7079
|
-
if (
|
|
7080
|
-
const v = find(
|
|
7079
|
+
if (y) {
|
|
7080
|
+
const v = find(y.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg");
|
|
7081
7081
|
if (v) {
|
|
7082
7082
|
a.icon = stringify([v]);
|
|
7083
7083
|
const { height: B, width: S } = getSvgDimensions(v, "16px", "16px");
|
|
@@ -7093,9 +7093,9 @@ const CoreBlock = ({
|
|
|
7093
7093
|
const w = stringify([n]);
|
|
7094
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];
|
|
7095
7095
|
} else if (n.tagName === "svg") {
|
|
7096
|
-
const w = get(find(n.attributes, { key: "class" }), "value", ""), { height:
|
|
7097
|
-
if (
|
|
7098
|
-
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", "");
|
|
7099
7099
|
else {
|
|
7100
7100
|
const B = (E = find(n.attributes, { key: "height" })) == null ? void 0 : E.value, S = (_ = find(n.attributes, { key: "width" })) == null ? void 0 : _.value;
|
|
7101
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();
|
|
@@ -7217,7 +7217,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7217
7217
|
parentId: n = void 0,
|
|
7218
7218
|
position: a = -1
|
|
7219
7219
|
}) => {
|
|
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", ""),
|
|
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) => {
|
|
7221
7221
|
const _ = has(E, "styles_attrs.data-page-section");
|
|
7222
7222
|
return E._type === "Box" && _;
|
|
7223
7223
|
}, b = useCallback(
|
|
@@ -7238,20 +7238,20 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7238
7238
|
{
|
|
7239
7239
|
onClick: l ? () => {
|
|
7240
7240
|
} : b,
|
|
7241
|
-
draggable:
|
|
7241
|
+
draggable: x ? "true" : "false",
|
|
7242
7242
|
onDragStart: async (E) => {
|
|
7243
7243
|
const _ = await c({ library: r, block: o });
|
|
7244
7244
|
let N = n;
|
|
7245
|
-
if (
|
|
7245
|
+
if (k(first(_)) && (N = null), !isEmpty(_)) {
|
|
7246
7246
|
const w = { blocks: _, uiLibrary: !0, parent: N };
|
|
7247
7247
|
if (E.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
|
|
7248
|
-
const
|
|
7249
|
-
|
|
7250
|
-
E.dataTransfer.setDragImage(
|
|
7248
|
+
const y = new Image();
|
|
7249
|
+
y.src = o.preview, y.onload = () => {
|
|
7250
|
+
E.dataTransfer.setDragImage(y, 0, 0);
|
|
7251
7251
|
};
|
|
7252
7252
|
} else
|
|
7253
7253
|
E.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7254
|
-
|
|
7254
|
+
f(w), setTimeout(() => {
|
|
7255
7255
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7256
7256
|
}, 200);
|
|
7257
7257
|
}
|
|
@@ -7277,37 +7277,37 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7277
7277
|
] }) })
|
|
7278
7278
|
] });
|
|
7279
7279
|
}, UILibrarySection = ({ parentId: o, position: r }) => {
|
|
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([]),
|
|
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);
|
|
7281
7281
|
useEffect(() => {
|
|
7282
|
-
c && c.length > 0 && (
|
|
7282
|
+
c && c.length > 0 && (x.current = new Fuse(c, {
|
|
7283
7283
|
keys: ["name", "label", "description", "group"],
|
|
7284
7284
|
threshold: 0.4,
|
|
7285
7285
|
ignoreLocation: !0
|
|
7286
7286
|
}));
|
|
7287
7287
|
}, [c]), useEffect(() => {
|
|
7288
|
-
if (!u.trim() || !
|
|
7288
|
+
if (!u.trim() || !x.current) {
|
|
7289
7289
|
m([]);
|
|
7290
7290
|
return;
|
|
7291
7291
|
}
|
|
7292
|
-
const C =
|
|
7292
|
+
const C = x.current.search(u).map((j) => j.item);
|
|
7293
7293
|
m(C);
|
|
7294
7294
|
}, [u]);
|
|
7295
|
-
const
|
|
7295
|
+
const f = u.trim() && !isEmpty(h) ? h : c, k = groupBy(f, "group"), [b, A] = useState(null);
|
|
7296
7296
|
useEffect(() => {
|
|
7297
|
-
if (isEmpty(keys(
|
|
7297
|
+
if (isEmpty(keys(k))) {
|
|
7298
7298
|
A(null);
|
|
7299
7299
|
return;
|
|
7300
7300
|
}
|
|
7301
|
-
if (!b || !
|
|
7302
|
-
A(first(keys(
|
|
7301
|
+
if (!b || !k[b]) {
|
|
7302
|
+
A(first(keys(k)));
|
|
7303
7303
|
return;
|
|
7304
7304
|
}
|
|
7305
|
-
}, [
|
|
7306
|
-
const E = get(
|
|
7305
|
+
}, [k, b]);
|
|
7306
|
+
const E = get(k, b, []), _ = useRef(null), { t: N } = useTranslation(), w = (C) => {
|
|
7307
7307
|
_.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
|
|
7308
7308
|
_.current && A(C);
|
|
7309
7309
|
}, 400);
|
|
7310
|
-
},
|
|
7310
|
+
}, y = () => {
|
|
7311
7311
|
i != null && i.id && p(i.id);
|
|
7312
7312
|
}, v = () => {
|
|
7313
7313
|
g("");
|
|
@@ -7345,13 +7345,13 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7345
7345
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7346
7346
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: N("Groups") }),
|
|
7347
7347
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7348
|
-
/* @__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: [
|
|
7349
7349
|
/* @__PURE__ */ jsx("p", { className: "text-sm", children: N("Failed to load the UI library. Try again") }),
|
|
7350
|
-
/* @__PURE__ */ jsxs(Button, { onClick:
|
|
7350
|
+
/* @__PURE__ */ jsxs(Button, { onClick: y, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7351
7351
|
/* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
|
|
7352
7352
|
N("Retry")
|
|
7353
7353
|
] })
|
|
7354
|
-
] }) }) : map(
|
|
7354
|
+
] }) }) : map(k, (C, j) => /* @__PURE__ */ jsxs(
|
|
7355
7355
|
"div",
|
|
7356
7356
|
{
|
|
7357
7357
|
onMouseEnter: () => w(j),
|
|
@@ -7377,7 +7377,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7377
7377
|
onMouseEnter: () => _.current ? clearTimeout(_.current) : null,
|
|
7378
7378
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7379
7379
|
children: [
|
|
7380
|
-
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: [
|
|
7381
7381
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: B.map((C, j) => /* @__PURE__ */ jsx(
|
|
7382
7382
|
BlockCard,
|
|
7383
7383
|
{
|
|
@@ -7432,25 +7432,25 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7432
7432
|
error: c
|
|
7433
7433
|
}), g(!0);
|
|
7434
7434
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7435
|
-
const m = Object.entries(a).map(([
|
|
7436
|
-
const b =
|
|
7435
|
+
const m = Object.entries(a).map(([f, k]) => {
|
|
7436
|
+
const b = k, A = b.type || "partial", E = formatReadableName(A);
|
|
7437
7437
|
return {
|
|
7438
7438
|
type: "PartialBlock",
|
|
7439
7439
|
// Set the type to PartialBlock
|
|
7440
|
-
label: formatReadableName(b.name ||
|
|
7440
|
+
label: formatReadableName(b.name || f),
|
|
7441
7441
|
description: b.description || "",
|
|
7442
7442
|
icon: Globe,
|
|
7443
7443
|
group: E,
|
|
7444
7444
|
// Use formatted type as group
|
|
7445
7445
|
category: "partial",
|
|
7446
|
-
partialBlockId:
|
|
7446
|
+
partialBlockId: f,
|
|
7447
7447
|
// Store the original ID as partialBlockId
|
|
7448
7448
|
_name: b.name
|
|
7449
7449
|
};
|
|
7450
|
-
}),
|
|
7450
|
+
}), x = uniq(map(m, "group"));
|
|
7451
7451
|
p({
|
|
7452
7452
|
blocks: m,
|
|
7453
|
-
groups:
|
|
7453
|
+
groups: x,
|
|
7454
7454
|
isLoading: !1,
|
|
7455
7455
|
error: null
|
|
7456
7456
|
}), g(!0);
|
|
@@ -7496,7 +7496,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7496
7496
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
|
|
7497
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" }) => {
|
|
7498
7498
|
var S;
|
|
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,
|
|
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);
|
|
7500
7500
|
useEffect(() => {
|
|
7501
7501
|
const C = setTimeout(() => {
|
|
7502
7502
|
var j;
|
|
@@ -7504,18 +7504,18 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7504
7504
|
}, 0);
|
|
7505
7505
|
return () => clearTimeout(C);
|
|
7506
7506
|
}, [g]), useEffect(() => {
|
|
7507
|
-
d && (
|
|
7507
|
+
d && (x("all"), k(null));
|
|
7508
7508
|
}, [d]), useEffect(() => (b.current = debounce((C) => {
|
|
7509
|
-
|
|
7509
|
+
x(C);
|
|
7510
7510
|
}, 500), () => {
|
|
7511
7511
|
b.current && b.current.cancel();
|
|
7512
7512
|
}), []);
|
|
7513
7513
|
const A = useCallback((C) => {
|
|
7514
|
-
|
|
7514
|
+
k(C), b.current && b.current(C);
|
|
7515
7515
|
}, []), E = useCallback(() => {
|
|
7516
|
-
|
|
7516
|
+
k(null), b.current && b.current.cancel();
|
|
7517
7517
|
}, []), _ = useCallback((C) => {
|
|
7518
|
-
b.current && b.current.cancel(),
|
|
7518
|
+
b.current && b.current.cancel(), x(C), k(null);
|
|
7519
7519
|
}, []), N = useMemo(
|
|
7520
7520
|
() => d ? values(r).filter(
|
|
7521
7521
|
(C) => {
|
|
@@ -7529,10 +7529,10 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7529
7529
|
(C) => reject(filter(values(N), { group: C }), { hidden: !0 }).length > 0
|
|
7530
7530
|
) : o.filter((C) => reject(filter(values(r), { group: C }), { hidden: !0 }).length > 0),
|
|
7531
7531
|
[r, N, o, d]
|
|
7532
|
-
),
|
|
7532
|
+
), y = useMemo(
|
|
7533
7533
|
() => sortBy(w, (C) => CORE_GROUPS.indexOf(C) === -1 ? 99 : CORE_GROUPS.indexOf(C)),
|
|
7534
7534
|
[w]
|
|
7535
|
-
), 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]);
|
|
7536
7536
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7537
7537
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7538
7538
|
Input$1,
|
|
@@ -7546,25 +7546,25 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7546
7546
|
}
|
|
7547
7547
|
) }),
|
|
7548
7548
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7549
|
-
|
|
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: [
|
|
7550
7550
|
/* @__PURE__ */ jsx(
|
|
7551
7551
|
"button",
|
|
7552
7552
|
{
|
|
7553
7553
|
onClick: () => _("all"),
|
|
7554
7554
|
onMouseEnter: () => A("all"),
|
|
7555
7555
|
onMouseLeave: E,
|
|
7556
|
-
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"}`,
|
|
7557
7557
|
children: i("All")
|
|
7558
7558
|
},
|
|
7559
7559
|
"sidebar-all"
|
|
7560
7560
|
),
|
|
7561
|
-
|
|
7561
|
+
y.map((C) => /* @__PURE__ */ jsx(
|
|
7562
7562
|
"button",
|
|
7563
7563
|
{
|
|
7564
7564
|
onClick: () => _(C),
|
|
7565
7565
|
onMouseEnter: () => A(C),
|
|
7566
7566
|
onMouseLeave: E,
|
|
7567
|
-
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"}`,
|
|
7568
7568
|
children: capitalize(i(C.toLowerCase()))
|
|
7569
7569
|
},
|
|
7570
7570
|
`sidebar-${C}`
|
|
@@ -7605,7 +7605,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7605
7605
|
}, [i, g, c]);
|
|
7606
7606
|
const m = useCallback(() => {
|
|
7607
7607
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7608
|
-
}, []),
|
|
7608
|
+
}, []), x = useChaiAddBlockTabs(), f = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
|
|
7609
7609
|
return useEffect(() => {
|
|
7610
7610
|
i === "library" && !b && c("core");
|
|
7611
7611
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7626,14 +7626,14 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7626
7626
|
b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7627
7627
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7628
7628
|
g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7629
|
-
|
|
7630
|
-
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}`))
|
|
7631
7631
|
] }),
|
|
7632
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 }) }) }) }),
|
|
7633
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 }) }),
|
|
7634
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 }) }) }) }),
|
|
7635
|
-
|
|
7636
|
-
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}`))
|
|
7637
7637
|
]
|
|
7638
7638
|
}
|
|
7639
7639
|
)
|
|
@@ -7943,13 +7943,13 @@ const Input = ({ node: o }) => {
|
|
|
7943
7943
|
var P;
|
|
7944
7944
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7945
7945
|
let p = null;
|
|
7946
|
-
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) => {
|
|
7947
7947
|
L.stopPropagation(), !l.includes(m) && o.toggle();
|
|
7948
7948
|
}, N = (L) => {
|
|
7949
7949
|
L.isInternal && (p = L.isOpen, L.isOpen && L.close());
|
|
7950
7950
|
}, w = (L) => {
|
|
7951
7951
|
L.isInternal && p !== null && (p ? L.open() : L.close(), p = null);
|
|
7952
|
-
}, [
|
|
7952
|
+
}, [y, v] = useAtom$1(currentAddSelection), B = () => {
|
|
7953
7953
|
var L;
|
|
7954
7954
|
S(), o.parent.isSelected || v((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
|
|
7955
7955
|
}, S = () => {
|
|
@@ -7959,10 +7959,10 @@ const Input = ({ node: o }) => {
|
|
|
7959
7959
|
};
|
|
7960
7960
|
useEffect(() => {
|
|
7961
7961
|
const L = setTimeout(() => {
|
|
7962
|
-
|
|
7962
|
+
k && !o.isOpen && !b && !l.includes(m) && o.toggle();
|
|
7963
7963
|
}, 500);
|
|
7964
7964
|
return () => clearTimeout(L);
|
|
7965
|
-
}, [
|
|
7965
|
+
}, [k, o, b]);
|
|
7966
7966
|
const j = (L, D) => {
|
|
7967
7967
|
const R = c.contentDocument || c.contentWindow.document, M = R.querySelector(`[data-block-id=${L}]`);
|
|
7968
7968
|
M && M.setAttribute("data-drop", D);
|
|
@@ -7991,7 +7991,7 @@ const Input = ({ node: o }) => {
|
|
|
7991
7991
|
),
|
|
7992
7992
|
/* @__PURE__ */ jsx("br", {})
|
|
7993
7993
|
] });
|
|
7994
|
-
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]);
|
|
7995
7995
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7996
7996
|
"div",
|
|
7997
7997
|
{
|
|
@@ -8030,12 +8030,12 @@ const Input = ({ node: o }) => {
|
|
|
8030
8030
|
{
|
|
8031
8031
|
className: cn(
|
|
8032
8032
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
(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" : "",
|
|
8036
8036
|
b && "opacity-20",
|
|
8037
8037
|
l.includes(m) ? "opacity-50" : "",
|
|
8038
|
-
T &&
|
|
8038
|
+
T && f && "bg-primary/20 text-primary"
|
|
8039
8039
|
),
|
|
8040
8040
|
children: [
|
|
8041
8041
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -8043,7 +8043,7 @@ const Input = ({ node: o }) => {
|
|
|
8043
8043
|
"div",
|
|
8044
8044
|
{
|
|
8045
8045
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
8046
|
-
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"}` }) })
|
|
8047
8047
|
}
|
|
8048
8048
|
),
|
|
8049
8049
|
/* @__PURE__ */ jsxs(
|
|
@@ -8052,10 +8052,10 @@ const Input = ({ node: o }) => {
|
|
|
8052
8052
|
className: cn(
|
|
8053
8053
|
"leading-1 flex items-center",
|
|
8054
8054
|
T && "text-primary/60",
|
|
8055
|
-
T &&
|
|
8055
|
+
T && f && "text-primary/80"
|
|
8056
8056
|
),
|
|
8057
8057
|
children: [
|
|
8058
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
8058
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
|
|
8059
8059
|
A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
|
|
8060
8060
|
"div",
|
|
8061
8061
|
{
|
|
@@ -8063,7 +8063,7 @@ const Input = ({ node: o }) => {
|
|
|
8063
8063
|
onDoubleClick: (L) => {
|
|
8064
8064
|
L.stopPropagation(), o.edit(), o.deselect();
|
|
8065
8065
|
},
|
|
8066
|
-
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(
|
|
8066
|
+
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(x) })
|
|
8067
8067
|
}
|
|
8068
8068
|
)
|
|
8069
8069
|
]
|
|
@@ -8071,7 +8071,7 @@ const Input = ({ node: o }) => {
|
|
|
8071
8071
|
)
|
|
8072
8072
|
] }),
|
|
8073
8073
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
8074
|
-
canAddChildBlock(
|
|
8074
|
+
canAddChildBlock(x == null ? void 0 : x._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8075
8075
|
/* @__PURE__ */ jsx(
|
|
8076
8076
|
TooltipTrigger,
|
|
8077
8077
|
{
|
|
@@ -8361,8 +8361,8 @@ const Input = ({ node: o }) => {
|
|
|
8361
8361
|
] });
|
|
8362
8362
|
}, defaultShadcnPreset = {
|
|
8363
8363
|
fontFamily: {
|
|
8364
|
-
heading: "
|
|
8365
|
-
body: "
|
|
8364
|
+
heading: "Poppins",
|
|
8365
|
+
body: "Poppins"
|
|
8366
8366
|
},
|
|
8367
8367
|
borderRadius: "6px",
|
|
8368
8368
|
colors: {
|
|
@@ -8386,9 +8386,131 @@ const Input = ({ node: o }) => {
|
|
|
8386
8386
|
popover: ["#ffffff", "#262626"],
|
|
8387
8387
|
"popover-foreground": ["#0a0a0a", "#fafafa"]
|
|
8388
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
|
+
}
|
|
8389
8505
|
}, LazyCssImportModal = lazy(
|
|
8390
|
-
() => import("./css-import-modal-
|
|
8391
|
-
), 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) => {
|
|
8392
8514
|
if (!(typeof window > "u"))
|
|
8393
8515
|
try {
|
|
8394
8516
|
localStorage.setItem(PREV_THEME_KEY, JSON.stringify(o));
|
|
@@ -8404,18 +8526,24 @@ const Input = ({ node: o }) => {
|
|
|
8404
8526
|
}
|
|
8405
8527
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8406
8528
|
const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
|
|
8407
|
-
|
|
8408
|
-
|
|
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(
|
|
8409
8537
|
(w) => {
|
|
8410
|
-
const
|
|
8411
|
-
setPreviousTheme(
|
|
8538
|
+
const y = { ...g };
|
|
8539
|
+
setPreviousTheme(y), h(w), toast.success("Theme updated", {
|
|
8412
8540
|
action: {
|
|
8413
8541
|
label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8414
8542
|
/* @__PURE__ */ jsx(Undo$1, { className: "h-4 w-4" }),
|
|
8415
8543
|
" Undo"
|
|
8416
8544
|
] }),
|
|
8417
8545
|
onClick: () => {
|
|
8418
|
-
h(
|
|
8546
|
+
h(y), clearPreviousTheme(), toast.dismiss();
|
|
8419
8547
|
}
|
|
8420
8548
|
},
|
|
8421
8549
|
closeButton: !0,
|
|
@@ -8423,22 +8551,22 @@ const Input = ({ node: o }) => {
|
|
|
8423
8551
|
});
|
|
8424
8552
|
},
|
|
8425
8553
|
[g, h]
|
|
8426
|
-
),
|
|
8427
|
-
const w = d.find((
|
|
8554
|
+
), k = () => {
|
|
8555
|
+
const w = d.find((y) => Object.keys(y)[0] === a);
|
|
8428
8556
|
if (w) {
|
|
8429
|
-
const
|
|
8430
|
-
|
|
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);
|
|
8431
8559
|
} else
|
|
8432
8560
|
console.error("Preset not found:", a);
|
|
8433
8561
|
}, b = (w) => {
|
|
8434
|
-
|
|
8562
|
+
f(w), l("");
|
|
8435
8563
|
}, A = useDebouncedCallback(
|
|
8436
|
-
(w,
|
|
8564
|
+
(w, y) => {
|
|
8437
8565
|
h(() => ({
|
|
8438
8566
|
...g,
|
|
8439
8567
|
fontFamily: {
|
|
8440
8568
|
...g.fontFamily,
|
|
8441
|
-
[w.replace(/font-/g, "")]:
|
|
8569
|
+
[w.replace(/font-/g, "")]: y
|
|
8442
8570
|
}
|
|
8443
8571
|
}));
|
|
8444
8572
|
},
|
|
@@ -8453,10 +8581,10 @@ const Input = ({ node: o }) => {
|
|
|
8453
8581
|
},
|
|
8454
8582
|
[g]
|
|
8455
8583
|
), _ = useDebouncedCallback(
|
|
8456
|
-
(w,
|
|
8584
|
+
(w, y) => {
|
|
8457
8585
|
h(() => {
|
|
8458
8586
|
const v = get(g, `colors.${w}`);
|
|
8459
|
-
return r ? set(v, 1,
|
|
8587
|
+
return r ? set(v, 1, y) : set(v, 0, y), {
|
|
8460
8588
|
...g,
|
|
8461
8589
|
colors: {
|
|
8462
8590
|
...g.colors,
|
|
@@ -8467,38 +8595,38 @@ const Input = ({ node: o }) => {
|
|
|
8467
8595
|
},
|
|
8468
8596
|
[g],
|
|
8469
8597
|
200
|
|
8470
|
-
), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([
|
|
8471
|
-
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}`);
|
|
8472
8600
|
return v ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8473
8601
|
/* @__PURE__ */ jsx(
|
|
8474
8602
|
ColorPickerInput,
|
|
8475
8603
|
{
|
|
8476
8604
|
value: v,
|
|
8477
|
-
onChange: (B) => _(
|
|
8605
|
+
onChange: (B) => _(y, B)
|
|
8478
8606
|
}
|
|
8479
8607
|
),
|
|
8480
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children:
|
|
8481
|
-
] },
|
|
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;
|
|
8482
8610
|
}) });
|
|
8483
8611
|
return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8484
8612
|
/* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8485
8613
|
d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
|
|
8486
8614
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
8487
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8615
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: x("Presets") }),
|
|
8488
8616
|
/* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
|
|
8489
8617
|
/* @__PURE__ */ jsx(ImportIcon, { className: "h-4 w-4" }),
|
|
8490
|
-
|
|
8618
|
+
x("Import theme")
|
|
8491
8619
|
] }) })
|
|
8492
8620
|
] }),
|
|
8493
8621
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
|
|
8494
8622
|
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
|
|
8495
8623
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
|
|
8496
8624
|
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
|
|
8497
|
-
const
|
|
8498
|
-
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);
|
|
8499
8627
|
}) })
|
|
8500
8628
|
] }) }),
|
|
8501
|
-
/* @__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") }) })
|
|
8502
8630
|
] })
|
|
8503
8631
|
] }),
|
|
8504
8632
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
@@ -8507,11 +8635,11 @@ const Input = ({ node: o }) => {
|
|
|
8507
8635
|
/* @__PURE__ */ jsx(Type, { className: "h-3 w-3 text-gray-600" }),
|
|
8508
8636
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
|
|
8509
8637
|
] }),
|
|
8510
|
-
(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(
|
|
8511
8639
|
FontSelector,
|
|
8512
8640
|
{
|
|
8513
8641
|
label: w,
|
|
8514
|
-
value: g.fontFamily[w.replace(/font-/g, "")] ||
|
|
8642
|
+
value: g.fontFamily[w.replace(/font-/g, "")] || y[Object.keys(y)[0]],
|
|
8515
8643
|
onChange: (v) => A(w, v)
|
|
8516
8644
|
},
|
|
8517
8645
|
w
|
|
@@ -9048,186 +9176,80 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9048
9176
|
) }) });
|
|
9049
9177
|
}
|
|
9050
9178
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
9051
|
-
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);
|
|
9052
9180
|
useEffect(() => {
|
|
9053
|
-
var
|
|
9054
|
-
(
|
|
9181
|
+
var m;
|
|
9182
|
+
(m = u.current) == null || m.focus();
|
|
9055
9183
|
}, []);
|
|
9056
|
-
const
|
|
9057
|
-
const { usage:
|
|
9058
|
-
!l &&
|
|
9184
|
+
const h = (m) => {
|
|
9185
|
+
const { usage: x } = m || {};
|
|
9186
|
+
!l && x && p(x), g.current = setTimeout(() => p(void 0), 1e4), l || c("");
|
|
9059
9187
|
};
|
|
9060
|
-
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
9061
|
-
/* @__PURE__ */
|
|
9062
|
-
|
|
9188
|
+
return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "mt-2", children: [
|
|
9189
|
+
/* @__PURE__ */ jsx(
|
|
9190
|
+
Textarea,
|
|
9063
9191
|
{
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
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
|
+
}
|
|
9070
9201
|
}
|
|
9071
9202
|
),
|
|
9072
|
-
|
|
9073
|
-
/* @__PURE__ */ jsx(
|
|
9074
|
-
|
|
9203
|
+
/* @__PURE__ */ jsxs("div", { className: "my-2 flex items-center gap-2", children: [
|
|
9204
|
+
a ? null : /* @__PURE__ */ jsx(
|
|
9205
|
+
Button,
|
|
9075
9206
|
{
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
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")
|
|
9085
9218
|
}
|
|
9086
9219
|
),
|
|
9087
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
{
|
|
9091
|
-
disabled: i.trim().length < 5 || a,
|
|
9092
|
-
onClick: () => {
|
|
9093
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f);
|
|
9094
|
-
},
|
|
9095
|
-
variant: "default",
|
|
9096
|
-
className: "w-fit",
|
|
9097
|
-
size: "sm",
|
|
9098
|
-
children: a ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9099
|
-
/* @__PURE__ */ jsx(Loader, { className: "h-5 w-5 animate-spin" }),
|
|
9100
|
-
r("Generating... Please wait...")
|
|
9101
|
-
] }) : r("Edit with AI")
|
|
9102
|
-
}
|
|
9103
|
-
),
|
|
9104
|
-
a ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
9105
|
-
/* @__PURE__ */ jsxs(Skeleton, { className: "flex w-full items-center space-x-1 px-4 py-1 pl-2", children: [
|
|
9106
|
-
/* @__PURE__ */ jsx(Loader, { className: "h-4 w-4 animate-spin text-gray-500" }),
|
|
9107
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs", children: r("Generating... Please wait...") })
|
|
9108
|
-
] }),
|
|
9109
|
-
/* @__PURE__ */ jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: r("Stop") })
|
|
9110
|
-
] }) : null
|
|
9111
|
-
] }),
|
|
9112
|
-
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: [
|
|
9113
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
9114
|
-
r("Total tokens used"),
|
|
9115
|
-
": ",
|
|
9116
|
-
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...") })
|
|
9117
9224
|
] }),
|
|
9118
|
-
/* @__PURE__ */ jsx(
|
|
9119
|
-
] })
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
/* @__PURE__ */
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
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);
|
|
9128
9243
|
}
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
] });
|
|
9135
|
-
}, AISetContext = () => {
|
|
9136
|
-
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);
|
|
9137
|
-
useEffect(() => {
|
|
9138
|
-
r && a(r);
|
|
9139
|
-
}, [r]);
|
|
9140
|
-
const m = async () => {
|
|
9141
|
-
try {
|
|
9142
|
-
d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
|
|
9143
|
-
} catch (f) {
|
|
9144
|
-
u(f);
|
|
9145
|
-
} finally {
|
|
9146
|
-
d(!1);
|
|
9147
|
-
}
|
|
9148
|
-
};
|
|
9149
|
-
return /* @__PURE__ */ jsx(
|
|
9150
|
-
Accordion,
|
|
9151
|
-
{
|
|
9152
|
-
onValueChange: (f) => {
|
|
9153
|
-
g(f !== "");
|
|
9154
|
-
},
|
|
9155
|
-
type: "single",
|
|
9156
|
-
collapsible: !0,
|
|
9157
|
-
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
9158
|
-
/* @__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") }) }) }),
|
|
9159
|
-
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
9160
|
-
/* @__PURE__ */ jsx(
|
|
9161
|
-
Textarea,
|
|
9162
|
-
{
|
|
9163
|
-
ref: l,
|
|
9164
|
-
value: n,
|
|
9165
|
-
onChange: (f) => a(f.target.value),
|
|
9166
|
-
placeholder: o("Tell about this page eg this page is about"),
|
|
9167
|
-
className: "mt-1 w-full",
|
|
9168
|
-
rows: 10,
|
|
9169
|
-
onKeyDown: (f) => {
|
|
9170
|
-
f.key === "Enter" && (f.preventDefault(), m());
|
|
9171
|
-
}
|
|
9172
|
-
}
|
|
9173
|
-
),
|
|
9174
|
-
r.trim().length === 0 ? /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-gray-500", children: o(
|
|
9175
|
-
"Eg: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI."
|
|
9176
|
-
) }) : null,
|
|
9177
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-center", children: [
|
|
9178
|
-
/* @__PURE__ */ jsx(
|
|
9179
|
-
Button,
|
|
9180
|
-
{
|
|
9181
|
-
disabled: n.trim().length < 5,
|
|
9182
|
-
onClick: () => m(),
|
|
9183
|
-
variant: "default",
|
|
9184
|
-
className: "w-fit",
|
|
9185
|
-
size: "sm",
|
|
9186
|
-
children: c ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9187
|
-
/* @__PURE__ */ jsx(Loader, { className: "h-5 w-5 animate-spin" }),
|
|
9188
|
-
o("Saving... Please wait...")
|
|
9189
|
-
] }) : o("Save")
|
|
9190
|
-
}
|
|
9191
|
-
),
|
|
9192
|
-
r.trim().length > 0 ? /* @__PURE__ */ jsxs(AlertDialog, { children: [
|
|
9193
|
-
/* @__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: [
|
|
9194
|
-
/* @__PURE__ */ jsx(Loader, { className: "h-5 w-5 animate-spin" }),
|
|
9195
|
-
o("Deleting... Please wait...")
|
|
9196
|
-
] }) : o("Delete") }) }),
|
|
9197
|
-
/* @__PURE__ */ jsxs(AlertDialogContent, { children: [
|
|
9198
|
-
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
9199
|
-
/* @__PURE__ */ jsxs(AlertDialogTitle, { children: [
|
|
9200
|
-
o("Delete context"),
|
|
9201
|
-
" ?"
|
|
9202
|
-
] }),
|
|
9203
|
-
/* @__PURE__ */ jsx(AlertDialogDescription, {})
|
|
9204
|
-
] }),
|
|
9205
|
-
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
9206
|
-
/* @__PURE__ */ jsx(AlertDialogCancel, { children: o("Cancel") }),
|
|
9207
|
-
/* @__PURE__ */ jsx(
|
|
9208
|
-
AlertDialogAction,
|
|
9209
|
-
{
|
|
9210
|
-
onClick: () => {
|
|
9211
|
-
a(""), m();
|
|
9212
|
-
},
|
|
9213
|
-
children: o("Yes, Delete")
|
|
9214
|
-
}
|
|
9215
|
-
)
|
|
9216
|
-
] })
|
|
9217
|
-
] })
|
|
9218
|
-
] }) : null
|
|
9219
|
-
] }),
|
|
9220
|
-
/* @__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 }) })
|
|
9221
|
-
] })
|
|
9222
|
-
] })
|
|
9223
|
-
}
|
|
9224
|
-
);
|
|
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
|
+
] }) }) });
|
|
9225
9250
|
}, AskAI = () => {
|
|
9226
9251
|
const [o] = useSelectedBlockIds();
|
|
9227
|
-
return /* @__PURE__ */
|
|
9228
|
-
/* @__PURE__ */ jsx(AISetContext, {}),
|
|
9229
|
-
/* @__PURE__ */ jsx(AIUserPrompt, { blockId: first(o) })
|
|
9230
|
-
] });
|
|
9252
|
+
return /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx(AIUserPrompt, { blockId: first(o) }) });
|
|
9231
9253
|
};
|
|
9232
9254
|
function DarkMode() {
|
|
9233
9255
|
const [o, r] = useDarkMode();
|
|
@@ -9288,7 +9310,7 @@ function AIChatPanel() {
|
|
|
9288
9310
|
}, 1500);
|
|
9289
9311
|
}, m = (b) => {
|
|
9290
9312
|
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
|
|
9291
|
-
},
|
|
9313
|
+
}, x = (b) => {
|
|
9292
9314
|
var E;
|
|
9293
9315
|
const A = (E = b.target.files) == null ? void 0 : E[0];
|
|
9294
9316
|
if (A) {
|
|
@@ -9298,10 +9320,10 @@ function AIChatPanel() {
|
|
|
9298
9320
|
d((w = N.target) == null ? void 0 : w.result);
|
|
9299
9321
|
}, _.readAsDataURL(A);
|
|
9300
9322
|
}
|
|
9301
|
-
},
|
|
9323
|
+
}, f = () => {
|
|
9302
9324
|
var b;
|
|
9303
9325
|
(b = p.current) == null || b.click();
|
|
9304
|
-
},
|
|
9326
|
+
}, k = () => {
|
|
9305
9327
|
d(null), p.current && (p.current.value = "");
|
|
9306
9328
|
};
|
|
9307
9329
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
|
|
@@ -9347,7 +9369,7 @@ function AIChatPanel() {
|
|
|
9347
9369
|
size: "icon",
|
|
9348
9370
|
variant: "destructive",
|
|
9349
9371
|
className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
|
|
9350
|
-
onClick:
|
|
9372
|
+
onClick: k,
|
|
9351
9373
|
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
9352
9374
|
}
|
|
9353
9375
|
)
|
|
@@ -9365,14 +9387,14 @@ function AIChatPanel() {
|
|
|
9365
9387
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9366
9388
|
}
|
|
9367
9389
|
),
|
|
9368
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange:
|
|
9390
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: x, accept: "image/*", className: "hidden" }),
|
|
9369
9391
|
/* @__PURE__ */ jsx(
|
|
9370
9392
|
Button,
|
|
9371
9393
|
{
|
|
9372
9394
|
size: "icon",
|
|
9373
9395
|
variant: "ghost",
|
|
9374
9396
|
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9375
|
-
onClick:
|
|
9397
|
+
onClick: f,
|
|
9376
9398
|
children: /* @__PURE__ */ jsx(Image$1, { className: "h-4 w-4 text-muted-foreground" })
|
|
9377
9399
|
}
|
|
9378
9400
|
)
|
|
@@ -9490,7 +9512,7 @@ const AiAssistant = () => {
|
|
|
9490
9512
|
preloadedAttributes: r = [],
|
|
9491
9513
|
onAttributesChange: n
|
|
9492
9514
|
}) {
|
|
9493
|
-
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();
|
|
9494
9516
|
useEffect(() => {
|
|
9495
9517
|
l(r);
|
|
9496
9518
|
}, [r]);
|
|
@@ -9500,26 +9522,26 @@ const AiAssistant = () => {
|
|
|
9500
9522
|
return;
|
|
9501
9523
|
}
|
|
9502
9524
|
if (i) {
|
|
9503
|
-
const
|
|
9504
|
-
n(
|
|
9525
|
+
const y = [...a, { key: i, value: d }];
|
|
9526
|
+
n(y), l(a), c(""), p(""), m("");
|
|
9505
9527
|
}
|
|
9506
|
-
}, A = (
|
|
9507
|
-
const v = a.filter((B, S) => S !==
|
|
9528
|
+
}, A = (y) => {
|
|
9529
|
+
const v = a.filter((B, S) => S !== y);
|
|
9508
9530
|
n(v), l(v);
|
|
9509
|
-
}, E = (
|
|
9510
|
-
g(
|
|
9531
|
+
}, E = (y) => {
|
|
9532
|
+
g(y), c(a[y].key), p(a[y].value);
|
|
9511
9533
|
}, _ = () => {
|
|
9512
9534
|
if (i.startsWith("@")) {
|
|
9513
9535
|
m("Attribute keys cannot start with '@'");
|
|
9514
9536
|
return;
|
|
9515
9537
|
}
|
|
9516
9538
|
if (u !== null && i) {
|
|
9517
|
-
const
|
|
9518
|
-
|
|
9539
|
+
const y = [...a];
|
|
9540
|
+
y[u] = { key: i, value: d }, n(y), l(y), g(null), c(""), p(""), m("");
|
|
9519
9541
|
}
|
|
9520
|
-
}, N = (
|
|
9521
|
-
|
|
9522
|
-
}, w = useCallback((
|
|
9542
|
+
}, N = (y) => {
|
|
9543
|
+
y.key === "Enter" && !y.shiftKey && (y.preventDefault(), u !== null ? _() : b());
|
|
9544
|
+
}, w = useCallback((y) => {
|
|
9523
9545
|
const v = (C) => /[.,!?;:]/.test(C), B = (C, j, I) => {
|
|
9524
9546
|
let T = "", P = "";
|
|
9525
9547
|
const L = j > 0 ? C[j - 1] : "", D = j < C.length ? C[j] : "";
|
|
@@ -9528,15 +9550,15 @@ const AiAssistant = () => {
|
|
|
9528
9550
|
prefixLength: T.length,
|
|
9529
9551
|
suffixLength: P.length
|
|
9530
9552
|
};
|
|
9531
|
-
}, S =
|
|
9553
|
+
}, S = f.current;
|
|
9532
9554
|
if (S) {
|
|
9533
9555
|
const C = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || C;
|
|
9534
9556
|
if (I > C) {
|
|
9535
|
-
const R = `{{${
|
|
9557
|
+
const R = `{{${y}}}`, { text: M } = B(j, C, R), $ = j.slice(0, C) + M + j.slice(I);
|
|
9536
9558
|
p($);
|
|
9537
9559
|
return;
|
|
9538
9560
|
}
|
|
9539
|
-
const P = `{{${
|
|
9561
|
+
const P = `{{${y}}}`, { text: L } = B(j, C, P), D = j.slice(0, C) + L + j.slice(C);
|
|
9540
9562
|
p(D);
|
|
9541
9563
|
}
|
|
9542
9564
|
}, []);
|
|
@@ -9544,8 +9566,8 @@ const AiAssistant = () => {
|
|
|
9544
9566
|
/* @__PURE__ */ jsxs(
|
|
9545
9567
|
"form",
|
|
9546
9568
|
{
|
|
9547
|
-
onSubmit: (
|
|
9548
|
-
|
|
9569
|
+
onSubmit: (y) => {
|
|
9570
|
+
y.preventDefault(), u !== null ? _() : b();
|
|
9549
9571
|
},
|
|
9550
9572
|
className: "space-y-3",
|
|
9551
9573
|
children: [
|
|
@@ -9559,9 +9581,9 @@ const AiAssistant = () => {
|
|
|
9559
9581
|
autoCorrect: "off",
|
|
9560
9582
|
spellCheck: "false",
|
|
9561
9583
|
id: "attrKey",
|
|
9562
|
-
ref:
|
|
9584
|
+
ref: x,
|
|
9563
9585
|
value: i,
|
|
9564
|
-
onChange: (
|
|
9586
|
+
onChange: (y) => c(y.target.value),
|
|
9565
9587
|
placeholder: "Enter Key",
|
|
9566
9588
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9567
9589
|
}
|
|
@@ -9570,7 +9592,7 @@ const AiAssistant = () => {
|
|
|
9570
9592
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9571
9593
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9572
9594
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9573
|
-
!isEmpty(
|
|
9595
|
+
!isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: w })
|
|
9574
9596
|
] }),
|
|
9575
9597
|
/* @__PURE__ */ jsx(
|
|
9576
9598
|
Textarea,
|
|
@@ -9580,9 +9602,9 @@ const AiAssistant = () => {
|
|
|
9580
9602
|
spellCheck: "false",
|
|
9581
9603
|
id: "attrValue",
|
|
9582
9604
|
rows: 2,
|
|
9583
|
-
ref:
|
|
9605
|
+
ref: f,
|
|
9584
9606
|
value: d,
|
|
9585
|
-
onChange: (
|
|
9607
|
+
onChange: (y) => p(y.target.value),
|
|
9586
9608
|
onKeyDown: N,
|
|
9587
9609
|
placeholder: "Enter Value",
|
|
9588
9610
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
@@ -9595,10 +9617,10 @@ const AiAssistant = () => {
|
|
|
9595
9617
|
]
|
|
9596
9618
|
}
|
|
9597
9619
|
),
|
|
9598
|
-
/* @__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: [
|
|
9599
9621
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9600
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9601
|
-
/* @__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() })
|
|
9602
9624
|
] }),
|
|
9603
9625
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9604
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 +9749,7 @@ const SettingsPanel = () => {
|
|
|
9727
9749
|
has(CHAI_BUILDER_PANELS, o) && console.warn(`Panel ${o} already registered. Overriding...`), set(CHAI_BUILDER_PANELS, o, { id: o, ...r });
|
|
9728
9750
|
}, useChaiSidebarPanels = (o) => useMemo(
|
|
9729
9751
|
() => filter(values(CHAI_BUILDER_PANELS), (r) => r.position === o),
|
|
9730
|
-
[o]
|
|
9752
|
+
[o, CHAI_BUILDER_PANELS]
|
|
9731
9753
|
), DefaultTopBar = () => /* @__PURE__ */ jsx("div", {}), TOP_BAR = {
|
|
9732
9754
|
component: DefaultTopBar
|
|
9733
9755
|
}, registerChaiTopBar = (o) => {
|
|
@@ -9766,42 +9788,42 @@ const RootLayout = () => {
|
|
|
9766
9788
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9767
9789
|
n("outline");
|
|
9768
9790
|
});
|
|
9769
|
-
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((
|
|
9770
|
-
|
|
9791
|
+
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((y) => {
|
|
9792
|
+
y.preventDefault();
|
|
9771
9793
|
}, []), m = useCallback(
|
|
9772
|
-
(
|
|
9773
|
-
n(r ===
|
|
9794
|
+
(y) => {
|
|
9795
|
+
n(r === y ? null : y);
|
|
9774
9796
|
},
|
|
9775
9797
|
[r]
|
|
9776
|
-
), { t:
|
|
9798
|
+
), { t: x } = useTranslation(), f = useMemo(
|
|
9777
9799
|
() => [...p, ...u, ...g],
|
|
9778
9800
|
[p, u, g]
|
|
9779
|
-
),
|
|
9801
|
+
), k = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: r }) ?? first(f), A = get(b, "width", DEFAULT_PANEL_WIDTH);
|
|
9780
9802
|
useEffect(() => {
|
|
9781
9803
|
if (r !== null) {
|
|
9782
|
-
const
|
|
9783
|
-
|
|
9804
|
+
const y = find(f, { id: r });
|
|
9805
|
+
y && get(y, "view", "standard") === "standard" && (a.current = r, i(get(y, "width", DEFAULT_PANEL_WIDTH)));
|
|
9784
9806
|
}
|
|
9785
|
-
}, [r,
|
|
9807
|
+
}, [r, f]);
|
|
9786
9808
|
const E = useMemo(() => {
|
|
9787
9809
|
if (r === null) return 0;
|
|
9788
|
-
const
|
|
9789
|
-
return get(
|
|
9790
|
-
}, [r, A, l,
|
|
9810
|
+
const y = find(f, { id: r });
|
|
9811
|
+
return get(y, "view", "standard") === "standard" ? A : l;
|
|
9812
|
+
}, [r, A, l, f]), _ = useCallback(() => {
|
|
9791
9813
|
n(a.current);
|
|
9792
9814
|
}, [n]), N = useCallback(() => {
|
|
9793
9815
|
n("outline");
|
|
9794
9816
|
}, [n]);
|
|
9795
9817
|
useEffect(() => {
|
|
9796
|
-
find(
|
|
9797
|
-
}, [r,
|
|
9818
|
+
find(f, { id: r }) || n("outline");
|
|
9819
|
+
}, [r, f]);
|
|
9798
9820
|
const w = useCallback(
|
|
9799
|
-
(
|
|
9800
|
-
m(
|
|
9821
|
+
(y) => {
|
|
9822
|
+
m(y);
|
|
9801
9823
|
},
|
|
9802
9824
|
[m]
|
|
9803
9825
|
);
|
|
9804
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
9826
|
+
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: [
|
|
9805
9827
|
/* @__PURE__ */ jsxs(
|
|
9806
9828
|
"div",
|
|
9807
9829
|
{
|
|
@@ -9811,24 +9833,24 @@ const RootLayout = () => {
|
|
|
9811
9833
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9812
9834
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9813
9835
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9814
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((
|
|
9815
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9836
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9837
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
|
|
9816
9838
|
position: "top",
|
|
9817
|
-
panelId:
|
|
9818
|
-
isActive: r ===
|
|
9819
|
-
show: () => w(
|
|
9839
|
+
panelId: y.id,
|
|
9840
|
+
isActive: r === y.id,
|
|
9841
|
+
show: () => w(y.id)
|
|
9820
9842
|
}) }),
|
|
9821
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9843
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
|
|
9822
9844
|
] }, "button-top-" + v)) }),
|
|
9823
9845
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9824
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((
|
|
9825
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9846
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9847
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
|
|
9826
9848
|
position: "bottom",
|
|
9827
|
-
panelId:
|
|
9828
|
-
isActive: r ===
|
|
9829
|
-
show: () => w(
|
|
9849
|
+
panelId: y.id,
|
|
9850
|
+
isActive: r === y.id,
|
|
9851
|
+
show: () => w(y.id)
|
|
9830
9852
|
}) }),
|
|
9831
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9853
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
|
|
9832
9854
|
] }, "button-bottom-" + v)) })
|
|
9833
9855
|
] }),
|
|
9834
9856
|
/* @__PURE__ */ jsx(
|
|
@@ -9844,7 +9866,7 @@ const RootLayout = () => {
|
|
|
9844
9866
|
"div",
|
|
9845
9867
|
{
|
|
9846
9868
|
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
|
|
9847
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9869
|
+
children: /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9848
9870
|
}
|
|
9849
9871
|
),
|
|
9850
9872
|
/* @__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), {}) }) })
|
|
@@ -9867,11 +9889,11 @@ const RootLayout = () => {
|
|
|
9867
9889
|
/* @__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: [
|
|
9868
9890
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9869
9891
|
" ",
|
|
9870
|
-
|
|
9892
|
+
x("AI Assistant")
|
|
9871
9893
|
] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9872
9894
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9873
9895
|
/* @__PURE__ */ jsx(Palette, { className: "w-4 h-4 text-gray-600" }),
|
|
9874
|
-
|
|
9896
|
+
x("Theme Settings")
|
|
9875
9897
|
] }),
|
|
9876
9898
|
/* @__PURE__ */ jsx(
|
|
9877
9899
|
Button,
|
|
@@ -9902,7 +9924,7 @@ const RootLayout = () => {
|
|
|
9902
9924
|
children: [
|
|
9903
9925
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
9904
9926
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9905
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9927
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9906
9928
|
] }) }),
|
|
9907
9929
|
/* @__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), {
|
|
9908
9930
|
close: N
|
|
@@ -9914,7 +9936,7 @@ const RootLayout = () => {
|
|
|
9914
9936
|
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: [
|
|
9915
9937
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
9916
9938
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9917
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9939
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9918
9940
|
] }) }),
|
|
9919
9941
|
/* @__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), {
|
|
9920
9942
|
close: N
|
|
@@ -9940,7 +9962,7 @@ const RootLayout = () => {
|
|
|
9940
9962
|
/* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
|
|
9941
9963
|
/* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
|
|
9942
9964
|
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
|
|
9943
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9965
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9944
9966
|
] }),
|
|
9945
9967
|
/* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
|
|
9946
9968
|
] }),
|
|
@@ -9984,36 +10006,36 @@ const RootLayout = () => {
|
|
|
9984
10006
|
}) => {
|
|
9985
10007
|
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
|
|
9986
10008
|
if (!l.trim()) return a;
|
|
9987
|
-
const
|
|
10009
|
+
const f = l.toLowerCase();
|
|
9988
10010
|
return Object.fromEntries(
|
|
9989
|
-
Object.entries(a).filter(([
|
|
10011
|
+
Object.entries(a).filter(([k, b]) => {
|
|
9990
10012
|
var A;
|
|
9991
|
-
return (
|
|
10013
|
+
return (k == null ? void 0 : k.toLowerCase().includes(f)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(f));
|
|
9992
10014
|
})
|
|
9993
10015
|
);
|
|
9994
|
-
}, [a, l]), h = (
|
|
10016
|
+
}, [a, l]), h = (f) => {
|
|
9995
10017
|
d(!0), u({
|
|
9996
|
-
x:
|
|
9997
|
-
y:
|
|
10018
|
+
x: f.clientX - r.x,
|
|
10019
|
+
y: f.clientY - r.y
|
|
9998
10020
|
});
|
|
9999
|
-
}, m = (
|
|
10021
|
+
}, m = (f) => {
|
|
10000
10022
|
if (!c) return;
|
|
10001
|
-
const
|
|
10002
|
-
n(
|
|
10003
|
-
},
|
|
10023
|
+
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));
|
|
10024
|
+
n(y, v);
|
|
10025
|
+
}, x = () => {
|
|
10004
10026
|
d(!1);
|
|
10005
10027
|
};
|
|
10006
10028
|
return useEffect(() => {
|
|
10007
|
-
const
|
|
10029
|
+
const f = () => {
|
|
10008
10030
|
c && d(!1);
|
|
10009
10031
|
};
|
|
10010
|
-
return window.addEventListener("mouseup",
|
|
10032
|
+
return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
|
|
10011
10033
|
}, [c]), !r || r.x < 0 || r.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
10012
10034
|
"div",
|
|
10013
10035
|
{
|
|
10014
10036
|
onMouseDown: h,
|
|
10015
10037
|
onMouseMove: m,
|
|
10016
|
-
onMouseUp:
|
|
10038
|
+
onMouseUp: x,
|
|
10017
10039
|
className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
|
|
10018
10040
|
style: {
|
|
10019
10041
|
left: r.x,
|
|
@@ -10055,13 +10077,13 @@ const RootLayout = () => {
|
|
|
10055
10077
|
placeholder: "Search features...",
|
|
10056
10078
|
className: "w-full pl-8",
|
|
10057
10079
|
value: l,
|
|
10058
|
-
onChange: (
|
|
10080
|
+
onChange: (f) => i(f.target.value),
|
|
10059
10081
|
autoFocus: !0
|
|
10060
10082
|
}
|
|
10061
10083
|
)
|
|
10062
10084
|
] })
|
|
10063
10085
|
] }),
|
|
10064
|
-
/* @__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(([
|
|
10086
|
+
/* @__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: [
|
|
10065
10087
|
'No features found matching "',
|
|
10066
10088
|
l,
|
|
10067
10089
|
'"'
|
|
@@ -10169,17 +10191,17 @@ const RootLayout = () => {
|
|
|
10169
10191
|
for (const i of r.p)
|
|
10170
10192
|
l.add(i);
|
|
10171
10193
|
return l;
|
|
10172
|
-
}, 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, ...
|
|
10173
|
-
var
|
|
10174
|
-
return (
|
|
10175
|
-
}, g = (m,
|
|
10176
|
-
var
|
|
10177
|
-
return (
|
|
10194
|
+
}, 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) => {
|
|
10195
|
+
var f;
|
|
10196
|
+
return (f = m.unstable_onInit) == null ? void 0 : f.call(m, x);
|
|
10197
|
+
}, g = (m, x) => {
|
|
10198
|
+
var f;
|
|
10199
|
+
return (f = m.onMount) == null ? void 0 : f.call(m, x);
|
|
10178
10200
|
}, ...h) => {
|
|
10179
10201
|
const m = h[0] || ((v) => {
|
|
10180
10202
|
let B = o.get(v);
|
|
10181
|
-
return B || (B = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(v, B), u == null || u(v,
|
|
10182
|
-
}),
|
|
10203
|
+
return B || (B = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(v, B), u == null || u(v, y)), B;
|
|
10204
|
+
}), x = h[1] || (() => {
|
|
10183
10205
|
const v = [], B = (S) => {
|
|
10184
10206
|
try {
|
|
10185
10207
|
S();
|
|
@@ -10193,11 +10215,11 @@ const RootLayout = () => {
|
|
|
10193
10215
|
a.forEach((j) => {
|
|
10194
10216
|
var I;
|
|
10195
10217
|
return (I = r.get(j)) == null ? void 0 : I.l.forEach(C);
|
|
10196
|
-
}), a.clear(), i.forEach(C), i.clear(), l.forEach(C), l.clear(), S.forEach(B), a.size &&
|
|
10218
|
+
}), a.clear(), i.forEach(C), i.clear(), l.forEach(C), l.clear(), S.forEach(B), a.size && f();
|
|
10197
10219
|
} while (a.size || i.size || l.size);
|
|
10198
10220
|
if (v.length)
|
|
10199
10221
|
throw new AggregateError(v);
|
|
10200
|
-
}),
|
|
10222
|
+
}), f = h[2] || (() => {
|
|
10201
10223
|
const v = [], B = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), C = Array.from(a);
|
|
10202
10224
|
for (; C.length; ) {
|
|
10203
10225
|
const j = C[C.length - 1], I = m(j);
|
|
@@ -10221,23 +10243,23 @@ const RootLayout = () => {
|
|
|
10221
10243
|
P = !0;
|
|
10222
10244
|
break;
|
|
10223
10245
|
}
|
|
10224
|
-
P && (
|
|
10246
|
+
P && (k(I), E(I)), n.delete(I);
|
|
10225
10247
|
}
|
|
10226
|
-
}),
|
|
10248
|
+
}), k = h[3] || ((v) => {
|
|
10227
10249
|
var B;
|
|
10228
10250
|
const S = m(v);
|
|
10229
10251
|
if (isAtomStateInitialized(S) && (r.has(v) && n.get(v) !== S.n || Array.from(S.d).every(
|
|
10230
10252
|
([R, M]) => (
|
|
10231
10253
|
// Recursively, read the atom state of the dependency, and
|
|
10232
10254
|
// check if the atom epoch number is unchanged
|
|
10233
|
-
|
|
10255
|
+
k(R).n === M
|
|
10234
10256
|
)
|
|
10235
10257
|
)))
|
|
10236
10258
|
return S;
|
|
10237
10259
|
S.d.clear();
|
|
10238
10260
|
let C = !0;
|
|
10239
10261
|
const j = () => {
|
|
10240
|
-
r.has(v) && (E(v),
|
|
10262
|
+
r.has(v) && (E(v), f(), x());
|
|
10241
10263
|
}, I = (R) => {
|
|
10242
10264
|
var M;
|
|
10243
10265
|
if (isSelfAtom(v, R)) {
|
|
@@ -10249,7 +10271,7 @@ const RootLayout = () => {
|
|
|
10249
10271
|
throw new Error("no atom init");
|
|
10250
10272
|
return returnAtomValue(O);
|
|
10251
10273
|
}
|
|
10252
|
-
const $ =
|
|
10274
|
+
const $ = k(R);
|
|
10253
10275
|
try {
|
|
10254
10276
|
return returnAtomValue($);
|
|
10255
10277
|
} finally {
|
|
@@ -10267,7 +10289,7 @@ const RootLayout = () => {
|
|
|
10267
10289
|
try {
|
|
10268
10290
|
return A(v, ...R);
|
|
10269
10291
|
} finally {
|
|
10270
|
-
|
|
10292
|
+
f(), x();
|
|
10271
10293
|
}
|
|
10272
10294
|
}), P;
|
|
10273
10295
|
}
|
|
@@ -10294,7 +10316,7 @@ const RootLayout = () => {
|
|
|
10294
10316
|
}
|
|
10295
10317
|
}), A = h[5] || ((v, ...B) => {
|
|
10296
10318
|
let S = !0;
|
|
10297
|
-
const C = (I) => returnAtomValue(
|
|
10319
|
+
const C = (I) => returnAtomValue(k(I)), j = (I, ...T) => {
|
|
10298
10320
|
var P;
|
|
10299
10321
|
const L = m(I);
|
|
10300
10322
|
try {
|
|
@@ -10307,7 +10329,7 @@ const RootLayout = () => {
|
|
|
10307
10329
|
} else
|
|
10308
10330
|
return A(I, ...T);
|
|
10309
10331
|
} finally {
|
|
10310
|
-
S || (
|
|
10332
|
+
S || (f(), x());
|
|
10311
10333
|
}
|
|
10312
10334
|
};
|
|
10313
10335
|
try {
|
|
@@ -10336,7 +10358,7 @@ const RootLayout = () => {
|
|
|
10336
10358
|
const S = m(v);
|
|
10337
10359
|
let C = r.get(v);
|
|
10338
10360
|
if (!C) {
|
|
10339
|
-
|
|
10361
|
+
k(v);
|
|
10340
10362
|
for (const j of S.d.keys())
|
|
10341
10363
|
_(j).t.add(v);
|
|
10342
10364
|
if (C = {
|
|
@@ -10350,7 +10372,7 @@ const RootLayout = () => {
|
|
|
10350
10372
|
try {
|
|
10351
10373
|
return A(v, ...P);
|
|
10352
10374
|
} finally {
|
|
10353
|
-
I || (
|
|
10375
|
+
I || (f(), x());
|
|
10354
10376
|
}
|
|
10355
10377
|
};
|
|
10356
10378
|
try {
|
|
@@ -10403,31 +10425,31 @@ const RootLayout = () => {
|
|
|
10403
10425
|
g,
|
|
10404
10426
|
// building-block functions
|
|
10405
10427
|
m,
|
|
10406
|
-
f,
|
|
10407
10428
|
x,
|
|
10408
|
-
|
|
10429
|
+
f,
|
|
10430
|
+
k,
|
|
10409
10431
|
b,
|
|
10410
10432
|
A,
|
|
10411
10433
|
E,
|
|
10412
10434
|
_,
|
|
10413
10435
|
N
|
|
10414
|
-
],
|
|
10415
|
-
get: (v) => returnAtomValue(
|
|
10436
|
+
], y = {
|
|
10437
|
+
get: (v) => returnAtomValue(k(v)),
|
|
10416
10438
|
set: (v, ...B) => {
|
|
10417
10439
|
try {
|
|
10418
10440
|
return A(v, ...B);
|
|
10419
10441
|
} finally {
|
|
10420
|
-
|
|
10442
|
+
f(), x();
|
|
10421
10443
|
}
|
|
10422
10444
|
},
|
|
10423
10445
|
sub: (v, B) => {
|
|
10424
10446
|
const C = _(v).l;
|
|
10425
|
-
return C.add(B),
|
|
10426
|
-
C.delete(B), N(v),
|
|
10447
|
+
return C.add(B), x(), () => {
|
|
10448
|
+
C.delete(B), N(v), x();
|
|
10427
10449
|
};
|
|
10428
10450
|
}
|
|
10429
10451
|
};
|
|
10430
|
-
return Object.defineProperty(
|
|
10452
|
+
return Object.defineProperty(y, BUILDING_BLOCKS, { value: w }), y;
|
|
10431
10453
|
}, INTERNAL_buildStoreRev1 = buildStore, INTERNAL_registerAbortHandler = registerAbortHandler;
|
|
10432
10454
|
function createStore() {
|
|
10433
10455
|
return INTERNAL_buildStoreRev1();
|
|
@@ -10580,7 +10602,6 @@ registerFeatureFlags();
|
|
|
10580
10602
|
export {
|
|
10581
10603
|
AddBlocksDialog as ChaiAddBlocksDialog,
|
|
10582
10604
|
AddBlocksPanel as ChaiAddBlocksPanel,
|
|
10583
|
-
AISetContext as ChaiAskAiPanel,
|
|
10584
10605
|
AIUserPrompt as ChaiAskAiUserPrompt,
|
|
10585
10606
|
BlockAttributesEditor as ChaiBlockAttributesEditor,
|
|
10586
10607
|
BlockSettings as ChaiBlockPropsEditor,
|