@chaibuilder/sdk 2.4.5 → 2.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +4 -4
- package/dist/core.js +763 -737
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -11,7 +11,7 @@ import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultS
|
|
|
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
13
|
import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b8 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, 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, r as Avatar, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./toggle-CyXEVUOu.js";
|
|
14
|
-
import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, 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";
|
|
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";
|
|
17
17
|
import TreeModel from "tree-model";
|
|
@@ -37,7 +37,7 @@ import { useFeature } from "flagged";
|
|
|
37
37
|
import { parse, stringify } from "himalaya";
|
|
38
38
|
import { Tree } from "react-arborist";
|
|
39
39
|
import i18n from "i18next";
|
|
40
|
-
import { default as
|
|
40
|
+
import { default as ze } from "i18next";
|
|
41
41
|
import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
|
|
42
42
|
import tailwindForms from "@tailwindcss/forms";
|
|
43
43
|
import tailwindTypography from "@tailwindcss/typography";
|
|
@@ -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
|
-
k.startsWith("content-") && (
|
|
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
|
|
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
487
|
return Object.keys(h).forEach((k) => {
|
|
488
|
-
k.startsWith("content-") && (
|
|
489
|
-
}),
|
|
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",
|
|
@@ -761,10 +761,10 @@ const checkMissingTranslations = (o, r) => r ? o.some((n) => {
|
|
|
761
761
|
if (!c("save_page"))
|
|
762
762
|
return;
|
|
763
763
|
r("SAVING"), a("SAVING");
|
|
764
|
-
const
|
|
764
|
+
const x = l();
|
|
765
765
|
return await n({
|
|
766
766
|
autoSave: m,
|
|
767
|
-
blocks:
|
|
767
|
+
blocks: x.blocks,
|
|
768
768
|
theme: i,
|
|
769
769
|
needTranslations: u()
|
|
770
770
|
}), setTimeout(() => {
|
|
@@ -839,65 +839,65 @@ const undoRedoStateAtom = atom({
|
|
|
839
839
|
updateBlocksProps: c
|
|
840
840
|
} = useBlocksStoreManager();
|
|
841
841
|
return {
|
|
842
|
-
moveBlocks: (
|
|
843
|
-
const A = map(
|
|
844
|
-
const w = r.find((
|
|
845
|
-
return { _id: _, oldParent: w, oldPosition:
|
|
846
|
-
}),
|
|
847
|
-
|
|
842
|
+
moveBlocks: (f, k, b) => {
|
|
843
|
+
const A = map(f, (_) => {
|
|
844
|
+
const w = r.find((B) => B._id === _)._parent || null, S = r.filter((B) => w ? B._parent === w : !B._parent).map((B) => B._id).indexOf(_);
|
|
845
|
+
return { _id: _, oldParent: w, oldPosition: S };
|
|
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: (
|
|
861
|
-
var
|
|
862
|
-
const k = (
|
|
863
|
-
l(map(
|
|
864
|
-
undo: () => a(
|
|
865
|
-
redo: () => l(map(
|
|
860
|
+
removeBlocks: (f) => {
|
|
861
|
+
var E;
|
|
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
|
|
874
|
-
A = map(
|
|
873
|
+
const E = keys(k);
|
|
874
|
+
A = map(f, (_) => {
|
|
875
875
|
const N = r.find((y) => y._id === _), w = { _id: _ };
|
|
876
|
-
return each(
|
|
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: (
|
|
893
|
+
updateMultipleBlocksProps: (f) => {
|
|
894
894
|
let k = [];
|
|
895
|
-
k = map(
|
|
896
|
-
const A = keys(b),
|
|
897
|
-
return each(A, (N) => _[N] =
|
|
898
|
-
}), c(
|
|
895
|
+
k = map(f, (b) => {
|
|
896
|
+
const A = keys(b), E = r.find((N) => N._id === b._id), _ = {};
|
|
897
|
+
return each(A, (N) => _[N] = E[N]), _;
|
|
898
|
+
}), c(f), o({
|
|
899
899
|
undo: () => c(k),
|
|
900
|
-
redo: () => c(
|
|
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 k = filter(i, { _parent:
|
|
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
912
|
for (let b = 0; b < k.length; b++)
|
|
913
|
-
k[b]._parent = i[
|
|
913
|
+
k[b]._parent = i[x]._id;
|
|
914
914
|
}
|
|
915
915
|
const p = first(i);
|
|
916
916
|
let u, g;
|
|
@@ -2360,39 +2360,39 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2360
2360
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2361
2361
|
})
|
|
2362
2362
|
), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2363
|
-
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,
|
|
2364
|
-
const
|
|
2365
|
-
for (const k in
|
|
2366
|
-
const b =
|
|
2363
|
+
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) => {
|
|
2364
|
+
const f = cloneDeep(x.find((k) => k._id === m));
|
|
2365
|
+
for (const k in f) {
|
|
2366
|
+
const b = f[k];
|
|
2367
2367
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
2368
|
-
const { baseClasses: A, classes:
|
|
2369
|
-
|
|
2368
|
+
const { baseClasses: A, classes: E } = getSplitChaiClasses(b);
|
|
2369
|
+
f[k] = compact(flattenDeep([A, E])).join(" ");
|
|
2370
2370
|
} else
|
|
2371
|
-
k !== "_id" && delete
|
|
2371
|
+
k !== "_id" && delete f[k];
|
|
2372
2372
|
}
|
|
2373
|
-
return
|
|
2373
|
+
return f;
|
|
2374
2374
|
};
|
|
2375
2375
|
return {
|
|
2376
2376
|
askAi: useCallback(
|
|
2377
|
-
async (m,
|
|
2377
|
+
async (m, x, f, k) => {
|
|
2378
2378
|
if (l) {
|
|
2379
2379
|
r(!0), a(null);
|
|
2380
2380
|
try {
|
|
2381
|
-
const b = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(
|
|
2381
|
+
const b = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p) : [h(x, d)], E = await l(m, addLangToPrompt(f, g, m), A, b), { blocks: _, error: N } = E;
|
|
2382
2382
|
if (N) {
|
|
2383
2383
|
a(N);
|
|
2384
2384
|
return;
|
|
2385
2385
|
}
|
|
2386
2386
|
if (m === "styles") {
|
|
2387
2387
|
const w = _.map((y) => {
|
|
2388
|
-
for (const
|
|
2389
|
-
|
|
2388
|
+
for (const S in y)
|
|
2389
|
+
S !== "_id" && (y[S] = `${STYLES_KEY},${y[S]}`);
|
|
2390
2390
|
return y;
|
|
2391
2391
|
});
|
|
2392
2392
|
c(w);
|
|
2393
2393
|
} else
|
|
2394
2394
|
i(_);
|
|
2395
|
-
k && k(
|
|
2395
|
+
k && k(E);
|
|
2396
2396
|
} catch (b) {
|
|
2397
2397
|
a(b);
|
|
2398
2398
|
} finally {
|
|
@@ -2490,12 +2490,12 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2490
2490
|
if (!p)
|
|
2491
2491
|
return h;
|
|
2492
2492
|
let m = [];
|
|
2493
|
-
for (const
|
|
2494
|
-
if (
|
|
2495
|
-
let
|
|
2496
|
-
|
|
2493
|
+
for (const x of h)
|
|
2494
|
+
if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
|
|
2495
|
+
let f = l(x.partialBlockId);
|
|
2496
|
+
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];
|
|
2497
2497
|
} else
|
|
2498
|
-
m.push(
|
|
2498
|
+
m.push(x);
|
|
2499
2499
|
return m;
|
|
2500
2500
|
})
|
|
2501
2501
|
};
|
|
@@ -2678,13 +2678,13 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2678
2678
|
const d = o(c), p = a;
|
|
2679
2679
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2680
2680
|
return each(p, (h) => {
|
|
2681
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2682
|
-
u = u.replace(
|
|
2683
|
-
const
|
|
2684
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2681
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2682
|
+
u = u.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2683
|
+
const f = first(h.split(":"));
|
|
2684
|
+
includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(h.split(":").pop().trim());
|
|
2685
2685
|
}), each(p, (h) => {
|
|
2686
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2687
|
-
g = g.replace(
|
|
2686
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2687
|
+
g = g.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2688
2688
|
}), {
|
|
2689
2689
|
ids: [d._id],
|
|
2690
2690
|
props: {
|
|
@@ -2833,21 +2833,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2833
2833
|
return "VERTICAL";
|
|
2834
2834
|
}
|
|
2835
2835
|
}, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
|
|
2836
|
-
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (
|
|
2837
|
-
(
|
|
2838
|
-
isDisabledControl(g, h,
|
|
2836
|
+
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(
|
|
2837
|
+
(f) => {
|
|
2838
|
+
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());
|
|
2839
2839
|
},
|
|
2840
2840
|
[g, h, p, u, i, c, r]
|
|
2841
2841
|
);
|
|
2842
2842
|
return useHotkeys(
|
|
2843
2843
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2844
|
-
({ key:
|
|
2844
|
+
({ key: f }) => {
|
|
2845
2845
|
var k;
|
|
2846
|
-
|
|
2846
|
+
x((k = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
|
|
2847
2847
|
},
|
|
2848
2848
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2849
|
-
[
|
|
2850
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock:
|
|
2849
|
+
[x]
|
|
2850
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: x, orientation: m };
|
|
2851
2851
|
}, BlockController = ({ block: o, updateFloatingBar: r }) => {
|
|
2852
2852
|
const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2853
2853
|
o,
|
|
@@ -3015,7 +3015,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3015
3015
|
elements: { reference: r }
|
|
3016
3016
|
});
|
|
3017
3017
|
useResizeObserver(r, () => m(), r !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
|
|
3018
|
-
const
|
|
3018
|
+
const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
3019
3019
|
return useEffect(() => {
|
|
3020
3020
|
if (r) {
|
|
3021
3021
|
const k = setTimeout(() => m(), 500);
|
|
@@ -3038,16 +3038,16 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3038
3038
|
onKeyDown: (k) => k.stopPropagation(),
|
|
3039
3039
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3040
3040
|
children: [
|
|
3041
|
-
|
|
3041
|
+
x && /* @__PURE__ */ jsx(
|
|
3042
3042
|
ArrowUpIcon,
|
|
3043
3043
|
{
|
|
3044
3044
|
className: "hover:scale-105",
|
|
3045
3045
|
onClick: () => {
|
|
3046
|
-
c([]), l([
|
|
3046
|
+
c([]), l([x]);
|
|
3047
3047
|
}
|
|
3048
3048
|
}
|
|
3049
3049
|
),
|
|
3050
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3050
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: o }),
|
|
3051
3051
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3052
3052
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3053
3053
|
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
|
|
@@ -3205,8 +3205,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3205
3205
|
i
|
|
3206
3206
|
]), useHotkeys(
|
|
3207
3207
|
"del, backspace",
|
|
3208
|
-
(
|
|
3209
|
-
|
|
3208
|
+
(x) => {
|
|
3209
|
+
x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
|
|
3210
3210
|
},
|
|
3211
3211
|
m,
|
|
3212
3212
|
[r, l]
|
|
@@ -3499,8 +3499,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3499
3499
|
],
|
|
3500
3500
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3501
3501
|
onBlur: ({ editor: u, event: g }) => {
|
|
3502
|
-
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"),
|
|
3503
|
-
if (!
|
|
3502
|
+
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);
|
|
3503
|
+
if (!f && !k) {
|
|
3504
3504
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3505
3505
|
n(b);
|
|
3506
3506
|
}
|
|
@@ -3555,14 +3555,14 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3555
3555
|
useEffect(() => {
|
|
3556
3556
|
if (a.current) {
|
|
3557
3557
|
a.current.innerText = r, a.current.focus();
|
|
3558
|
-
const m = c.createRange(),
|
|
3559
|
-
m.selectNodeContents(a.current), m.collapse(!1),
|
|
3558
|
+
const m = c.createRange(), x = d.getSelection();
|
|
3559
|
+
m.selectNodeContents(a.current), m.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(m), a.current.focus();
|
|
3560
3560
|
} else
|
|
3561
3561
|
n();
|
|
3562
3562
|
}, [c, d]);
|
|
3563
3563
|
const p = useMemo(() => {
|
|
3564
|
-
var
|
|
3565
|
-
const m = ((
|
|
3564
|
+
var x;
|
|
3565
|
+
const m = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
|
|
3566
3566
|
return m === "button" ? "div" : m;
|
|
3567
3567
|
}, [o]), u = useCallback(
|
|
3568
3568
|
(m) => {
|
|
@@ -3578,12 +3578,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3578
3578
|
contentEditable: !0,
|
|
3579
3579
|
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]`,
|
|
3580
3580
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
3581
|
-
onInput: (
|
|
3582
|
-
const
|
|
3583
|
-
|
|
3581
|
+
onInput: (x) => {
|
|
3582
|
+
const f = x.target;
|
|
3583
|
+
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));
|
|
3584
3584
|
},
|
|
3585
|
-
onClick: (
|
|
3586
|
-
|
|
3585
|
+
onClick: (x) => {
|
|
3586
|
+
x.stopPropagation(), x.preventDefault();
|
|
3587
3587
|
}
|
|
3588
3588
|
};
|
|
3589
3589
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
@@ -3596,41 +3596,41 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3596
3596
|
}
|
|
3597
3597
|
), WithBlockTextEditor = memo(
|
|
3598
3598
|
({ block: o, children: r }) => {
|
|
3599
|
-
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:
|
|
3599
|
+
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(() => {
|
|
3600
3600
|
var j;
|
|
3601
|
-
const
|
|
3602
|
-
let
|
|
3601
|
+
const S = o._type;
|
|
3602
|
+
let B = o[n];
|
|
3603
3603
|
const v = getRegisteredChaiBlock(o._type);
|
|
3604
|
-
return
|
|
3605
|
-
}, [o,
|
|
3606
|
-
(
|
|
3604
|
+
return x && ((j = v == null ? void 0 : v.i18nProps) == null ? void 0 : j.includes(n)) && has(o, `${n}-${x}`) && (B = get(o, `${n}-${x}`)), { blockContent: B, blockType: S };
|
|
3605
|
+
}, [o, x]), _ = useCallback(
|
|
3606
|
+
(S) => {
|
|
3607
3607
|
var v;
|
|
3608
|
-
const
|
|
3609
|
-
m([b], { [n]:
|
|
3608
|
+
const B = S || ((v = g.current) == null ? void 0 : v.innerText);
|
|
3609
|
+
m([b], { [n]: B }), u(null), c(null), d(-1), f(b ? [b] : []);
|
|
3610
3610
|
},
|
|
3611
|
-
[b, m, c,
|
|
3611
|
+
[b, m, c, f, x]
|
|
3612
3612
|
), N = useDebouncedCallback(
|
|
3613
|
-
(
|
|
3614
|
-
m([b], { [n]:
|
|
3613
|
+
(S) => {
|
|
3614
|
+
m([b], { [n]: S });
|
|
3615
3615
|
},
|
|
3616
|
-
[b, o, m,
|
|
3616
|
+
[b, o, m, x],
|
|
3617
3617
|
1e3
|
|
3618
3618
|
), w = useCallback(
|
|
3619
|
-
(
|
|
3620
|
-
|
|
3621
|
-
const
|
|
3622
|
-
k.current = null,
|
|
3619
|
+
(S) => {
|
|
3620
|
+
S.preventDefault(), b && (k.current = b), _(), setTimeout(() => {
|
|
3621
|
+
const B = k.current;
|
|
3622
|
+
k.current = null, f([B]);
|
|
3623
3623
|
}, 100);
|
|
3624
3624
|
},
|
|
3625
|
-
[
|
|
3625
|
+
[f, b, x]
|
|
3626
3626
|
);
|
|
3627
3627
|
useEffect(() => {
|
|
3628
|
-
var
|
|
3628
|
+
var C;
|
|
3629
3629
|
if (!b) return;
|
|
3630
|
-
const
|
|
3631
|
-
v && ((
|
|
3632
|
-
}, [b,
|
|
3633
|
-
const y = useMemo(() => p ? (h(),
|
|
3630
|
+
const S = `[data-block-id="${b}"]`, B = i >= 0 ? `[data-block-index="${i}"]` : "", v = a.querySelector(`${S}${B}`);
|
|
3631
|
+
v && ((C = v == null ? void 0 : v.classList) == null || C.add("sr-only"), u(v));
|
|
3632
|
+
}, [b, E, a, i]);
|
|
3633
|
+
const y = useMemo(() => p ? (h(), E === "RichText" ? /* @__PURE__ */ jsx(
|
|
3634
3634
|
RichTextEditor,
|
|
3635
3635
|
{
|
|
3636
3636
|
blockContent: A,
|
|
@@ -3649,7 +3649,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3649
3649
|
onChange: N,
|
|
3650
3650
|
onEscape: w
|
|
3651
3651
|
}
|
|
3652
|
-
)) : null, [p, b,
|
|
3652
|
+
)) : null, [p, b, E, A, _, x]);
|
|
3653
3653
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3654
3654
|
y,
|
|
3655
3655
|
r
|
|
@@ -3684,23 +3684,23 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3684
3684
|
blockAtom: r,
|
|
3685
3685
|
children: n
|
|
3686
3686
|
}) => {
|
|
3687
|
-
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),
|
|
3687
|
+
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(
|
|
3688
3688
|
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
3689
|
-
index:
|
|
3689
|
+
index: f,
|
|
3690
3690
|
key: k
|
|
3691
3691
|
}) : applyLanguage(i, d, c),
|
|
3692
|
-
[i, d, c, g, m,
|
|
3693
|
-
), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]),
|
|
3692
|
+
[i, d, c, g, m, f, k]
|
|
3693
|
+
), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), E = useMemo(
|
|
3694
3694
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
3695
3695
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
3696
3696
|
), _ = useMemo(
|
|
3697
3697
|
() => ({
|
|
3698
|
-
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index":
|
|
3698
|
+
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
|
|
3699
3699
|
inBuilder: !0,
|
|
3700
3700
|
lang: d || p,
|
|
3701
3701
|
...b,
|
|
3702
3702
|
...A,
|
|
3703
|
-
...
|
|
3703
|
+
...E,
|
|
3704
3704
|
...o
|
|
3705
3705
|
}),
|
|
3706
3706
|
[
|
|
@@ -3710,12 +3710,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3710
3710
|
p,
|
|
3711
3711
|
b,
|
|
3712
3712
|
A,
|
|
3713
|
-
|
|
3713
|
+
E,
|
|
3714
3714
|
o
|
|
3715
3715
|
]
|
|
3716
3716
|
), N = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
|
|
3717
|
-
if (isNull(
|
|
3718
|
-
let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(
|
|
3717
|
+
if (isNull(x) || h.includes(i._id)) return null;
|
|
3718
|
+
let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
|
|
3719
3719
|
..._,
|
|
3720
3720
|
children: n({
|
|
3721
3721
|
_id: i._id,
|
|
@@ -3728,7 +3728,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3728
3728
|
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
3729
3729
|
})
|
|
3730
3730
|
}) });
|
|
3731
|
-
const y = a === i._id && (l ===
|
|
3731
|
+
const y = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
|
|
3732
3732
|
return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: y }) : y;
|
|
3733
3733
|
}, PartialWrapper = ({ children: o, partialBlockId: r }) => {
|
|
3734
3734
|
const n = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
@@ -3769,7 +3769,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3769
3769
|
);
|
|
3770
3770
|
return map(l, (c) => {
|
|
3771
3771
|
const d = a(c._id);
|
|
3772
|
-
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:
|
|
3772
|
+
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;
|
|
3773
3773
|
});
|
|
3774
3774
|
}, PageBlocksRenderer = () => {
|
|
3775
3775
|
const [o] = useBlocksStore();
|
|
@@ -3837,14 +3837,14 @@ const CanvasEventsWatcher = () => {
|
|
|
3837
3837
|
}, StaticCanvas = () => {
|
|
3838
3838
|
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(
|
|
3839
3839
|
(m) => {
|
|
3840
|
-
i((
|
|
3840
|
+
i((x) => ({ ...x, width: m }));
|
|
3841
3841
|
},
|
|
3842
3842
|
[i]
|
|
3843
3843
|
);
|
|
3844
3844
|
useEffect(() => {
|
|
3845
3845
|
if (!a.current) return;
|
|
3846
|
-
const { clientWidth: m, clientHeight:
|
|
3847
|
-
i({ width: m, height:
|
|
3846
|
+
const { clientWidth: m, clientHeight: x } = a.current;
|
|
3847
|
+
i({ width: m, height: x });
|
|
3848
3848
|
}, [a, o]);
|
|
3849
3849
|
const h = useMemo(() => {
|
|
3850
3850
|
let m = IframeInitialContent;
|
|
@@ -3959,8 +3959,8 @@ const CanvasEventsWatcher = () => {
|
|
|
3959
3959
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3960
3960
|
] });
|
|
3961
3961
|
}, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
|
|
3962
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (
|
|
3963
|
-
if (!
|
|
3962
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (x) => {
|
|
3963
|
+
if (!x.trim()) {
|
|
3964
3964
|
p(!1), g("Please enter a URL");
|
|
3965
3965
|
return;
|
|
3966
3966
|
}
|
|
@@ -3984,7 +3984,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3984
3984
|
{
|
|
3985
3985
|
placeholder: m(`Enter ${n} URL`),
|
|
3986
3986
|
value: a,
|
|
3987
|
-
onChange: (
|
|
3987
|
+
onChange: (x) => l(x.target.value),
|
|
3988
3988
|
onKeyUp: () => h(a)
|
|
3989
3989
|
}
|
|
3990
3990
|
),
|
|
@@ -4020,42 +4020,58 @@ const CanvasEventsWatcher = () => {
|
|
|
4020
4020
|
] });
|
|
4021
4021
|
};
|
|
4022
4022
|
MediaManagerModal.displayName = "MediaManagerModal";
|
|
4023
|
-
const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4023
|
+
const PLACEHOLDER_IMAGE_URL = "https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/dam-assets/02817647-2581-4c50-a005-f72de13d3da7/banner-placeholder.png?cid=20250730t1809109830000?v=2025-07-30T18:09:11.041925+00:00", ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
4024
|
+
var h;
|
|
4025
|
+
const { t: l } = useTranslation(), i = useSelectedBlock(), c = useUpdateBlocksProps(), d = !((h = o == null ? void 0 : o.startsWith) != null && h.call(o, "https://fldwljgzcktqnysdkxnn")), p = (m) => {
|
|
4026
|
+
const x = isArray(m) ? first(m) : m;
|
|
4027
|
+
if (x) {
|
|
4028
|
+
r(x == null ? void 0 : x.url);
|
|
4029
|
+
const f = x == null ? void 0 : x.width, k = x == null ? void 0 : x.height;
|
|
4029
4030
|
if (i != null && i._id) {
|
|
4030
|
-
const
|
|
4031
|
-
...
|
|
4032
|
-
...
|
|
4033
|
-
...
|
|
4034
|
-
...
|
|
4031
|
+
const b = {
|
|
4032
|
+
...f && { width: f },
|
|
4033
|
+
...k && { height: k },
|
|
4034
|
+
...x.description && { alt: x.description },
|
|
4035
|
+
...x.id && { assetId: x.id }
|
|
4035
4036
|
};
|
|
4036
|
-
if (isEmpty(
|
|
4037
|
-
c([i._id],
|
|
4037
|
+
if (isEmpty(b)) return;
|
|
4038
|
+
c([i._id], b);
|
|
4038
4039
|
}
|
|
4039
4040
|
}
|
|
4040
|
-
},
|
|
4041
|
-
r(
|
|
4042
|
-
}, [r, i == null ? void 0 : i._id, c]),
|
|
4041
|
+
}, u = useCallback(() => {
|
|
4042
|
+
r(PLACEHOLDER_IMAGE_URL), i != null && i._id && c([i._id], { assetId: "" });
|
|
4043
|
+
}, [r, i == null ? void 0 : i._id, c]), g = get(i, "assetId", "");
|
|
4043
4044
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
|
|
4044
|
-
o ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
4045
|
-
/* @__PURE__ */ jsx("img", { src: o, className: "h-20 w-20 overflow-hidden rounded-md border border-border object-cover", alt: "" }),
|
|
4045
|
+
o ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
|
|
4046
4046
|
/* @__PURE__ */ jsx(
|
|
4047
|
+
"img",
|
|
4048
|
+
{
|
|
4049
|
+
src: o,
|
|
4050
|
+
className: "h-20 w-20 overflow-hidden rounded-md border border-border object-cover transition duration-200 " + (g && g !== "" ? "cursor-pointer group-hover:blur-sm" : ""),
|
|
4051
|
+
alt: ""
|
|
4052
|
+
}
|
|
4053
|
+
),
|
|
4054
|
+
d && /* @__PURE__ */ jsx(
|
|
4047
4055
|
"button",
|
|
4048
4056
|
{
|
|
4049
4057
|
type: "button",
|
|
4050
|
-
onClick:
|
|
4051
|
-
className: "absolute -right-2 -top-2 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
|
|
4058
|
+
onClick: u,
|
|
4059
|
+
className: "absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
|
|
4052
4060
|
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
4053
4061
|
}
|
|
4054
|
-
)
|
|
4055
|
-
|
|
4062
|
+
),
|
|
4063
|
+
g && g !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: p, assetId: g, children: /* @__PURE__ */ jsx(
|
|
4064
|
+
"button",
|
|
4065
|
+
{
|
|
4066
|
+
type: "button",
|
|
4067
|
+
className: "absolute inset-0 z-10 flex cursor-pointer items-center justify-center bg-black/10 opacity-0 transition duration-200 group-hover:bg-black/30 group-hover:opacity-100",
|
|
4068
|
+
children: /* @__PURE__ */ jsx(Edit2Icon, { className: "h-4 w-4 text-white" })
|
|
4069
|
+
}
|
|
4070
|
+
) })
|
|
4071
|
+
] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: p, mode: "image", assetId: g, 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]" }) }),
|
|
4056
4072
|
/* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
|
|
4057
4073
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4058
|
-
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect:
|
|
4074
|
+
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect: p, 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") }) }),
|
|
4059
4075
|
/* @__PURE__ */ jsx("small", { className: "-pl-4 pt-2 text-center text-xs text-secondary-foreground", children: "OR" })
|
|
4060
4076
|
] }),
|
|
4061
4077
|
/* @__PURE__ */ jsx(
|
|
@@ -4069,8 +4085,8 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
4069
4085
|
className: "text-xs",
|
|
4070
4086
|
placeholder: l("Enter image URL"),
|
|
4071
4087
|
value: o,
|
|
4072
|
-
onBlur: ({ target: { value:
|
|
4073
|
-
onChange: (
|
|
4088
|
+
onBlur: ({ target: { value: m } }) => a(n, m),
|
|
4089
|
+
onChange: (m) => r(m.target.value)
|
|
4074
4090
|
}
|
|
4075
4091
|
)
|
|
4076
4092
|
] })
|
|
@@ -4078,14 +4094,14 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
4078
4094
|
}, PathDropdown = ({ data: o, onSelect: r, dataType: n }) => {
|
|
4079
4095
|
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(
|
|
4080
4096
|
(h) => {
|
|
4081
|
-
const m = (
|
|
4082
|
-
h.type === "object" ? (l((
|
|
4097
|
+
const m = (x) => n === "value" ? x === "value" || x === "object" : n === "array" ? x === "array" : x === n;
|
|
4098
|
+
h.type === "object" ? (l((x) => [...x, h.key]), c(h.value)) : m(h.type) && r([...a, h.key].join("."), n);
|
|
4083
4099
|
},
|
|
4084
4100
|
[a, r, n]
|
|
4085
4101
|
), u = React__default.useCallback(() => {
|
|
4086
4102
|
if (a.length > 0) {
|
|
4087
4103
|
const h = a.slice(0, -1);
|
|
4088
|
-
l(h), c(h.reduce((m,
|
|
4104
|
+
l(h), c(h.reduce((m, x) => m[x], o));
|
|
4089
4105
|
}
|
|
4090
4106
|
}, [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]);
|
|
4091
4107
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
@@ -4178,7 +4194,7 @@ const DataBindingSelector = ({
|
|
|
4178
4194
|
}) => {
|
|
4179
4195
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4180
4196
|
if (i.length === 1) return "";
|
|
4181
|
-
const g = i.find((
|
|
4197
|
+
const g = i.find((x) => x._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4182
4198
|
return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
|
|
4183
4199
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4184
4200
|
(g, h) => {
|
|
@@ -4186,44 +4202,44 @@ const DataBindingSelector = ({
|
|
|
4186
4202
|
r(`{{${g}}}`, {}, n);
|
|
4187
4203
|
return;
|
|
4188
4204
|
}
|
|
4189
|
-
const m = (b) => /[.,!?;:]/.test(b),
|
|
4205
|
+
const m = (b) => /[.,!?;:]/.test(b), x = (b, A, E) => {
|
|
4190
4206
|
let _ = "", N = "";
|
|
4191
4207
|
const w = A > 0 ? b[A - 1] : "", y = A < b.length ? b[A] : "";
|
|
4192
4208
|
return A > 0 && (w === "." || !m(w) && w !== " ") && (_ = " "), A < b.length && !m(y) && y !== " " && (N = " "), {
|
|
4193
|
-
text: _ +
|
|
4209
|
+
text: _ + E + N,
|
|
4194
4210
|
prefixLength: _.length,
|
|
4195
4211
|
suffixLength: N.length
|
|
4196
4212
|
};
|
|
4197
|
-
},
|
|
4198
|
-
if (!
|
|
4213
|
+
}, f = document.getElementById(n);
|
|
4214
|
+
if (!f) return;
|
|
4199
4215
|
const k = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
|
|
4200
4216
|
if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
|
|
4201
4217
|
const b = k.__chaiRTE;
|
|
4202
4218
|
if (b) {
|
|
4203
4219
|
const A = `{{${g}}}`;
|
|
4204
4220
|
b.commands.focus();
|
|
4205
|
-
const { from:
|
|
4206
|
-
if (
|
|
4221
|
+
const { from: E, to: _ } = b.state.selection;
|
|
4222
|
+
if (E !== _)
|
|
4207
4223
|
b.chain().deleteSelection().insertContent(A).run();
|
|
4208
4224
|
else {
|
|
4209
|
-
const { state: w } = b, y = w.selection.from,
|
|
4225
|
+
const { state: w } = b, y = w.selection.from, S = w.doc.textBetween(Math.max(0, y - 1), y), B = w.doc.textBetween(y, Math.min(y + 1, w.doc.content.size));
|
|
4210
4226
|
let v = "";
|
|
4211
|
-
y > 0 &&
|
|
4212
|
-
let
|
|
4213
|
-
|
|
4227
|
+
y > 0 && S !== " " && !m(S) && (v = " ");
|
|
4228
|
+
let C = "";
|
|
4229
|
+
B && B !== " " && !m(B) && (C = " "), b.chain().insertContent(v + A + C).run();
|
|
4214
4230
|
}
|
|
4215
4231
|
setTimeout(() => r(b.getHTML(), {}, n), 100);
|
|
4216
4232
|
return;
|
|
4217
4233
|
}
|
|
4218
4234
|
} else {
|
|
4219
|
-
const b =
|
|
4235
|
+
const b = f, A = b.selectionStart || 0, E = b.value || "", _ = b.selectionEnd || A;
|
|
4220
4236
|
if (_ > A) {
|
|
4221
|
-
const
|
|
4222
|
-
r(
|
|
4237
|
+
const B = `{{${g}}}`, { text: v } = x(E, A, B), C = E.slice(0, A) + v + E.slice(_);
|
|
4238
|
+
r(C, {}, n);
|
|
4223
4239
|
return;
|
|
4224
4240
|
}
|
|
4225
|
-
const w = `{{${g}}}`, { text: y } =
|
|
4226
|
-
r(
|
|
4241
|
+
const w = `{{${g}}}`, { text: y } = x(E, A, w), S = E.slice(0, A) + y + E.slice(A);
|
|
4242
|
+
r(S, {}, n);
|
|
4227
4243
|
}
|
|
4228
4244
|
},
|
|
4229
4245
|
[n, r, a, c == null ? void 0 : c._id, d]
|
|
@@ -4244,42 +4260,42 @@ const DataBindingSelector = ({
|
|
|
4244
4260
|
pageTypes: r,
|
|
4245
4261
|
onChange: n
|
|
4246
4262
|
}) => {
|
|
4247
|
-
var
|
|
4248
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v,
|
|
4263
|
+
var B;
|
|
4264
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, 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((v) => v.key === u)) == null ? void 0 : B.name;
|
|
4249
4265
|
useEffect(() => {
|
|
4250
|
-
if (m(""),
|
|
4251
|
-
const v = split(o, ":"),
|
|
4252
|
-
g(
|
|
4253
|
-
const j = await l(
|
|
4266
|
+
if (m(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4267
|
+
const v = split(o, ":"), C = get(v, 1, "page") || "page";
|
|
4268
|
+
g(C), (async () => {
|
|
4269
|
+
const j = await l(C, [get(v, 2, "page")]);
|
|
4254
4270
|
j && Array.isArray(j) && m(get(j, [0, "name"], ""));
|
|
4255
4271
|
})();
|
|
4256
4272
|
}, [o]);
|
|
4257
4273
|
const _ = useDebouncedCallback(
|
|
4258
4274
|
async (v) => {
|
|
4259
4275
|
if (isEmpty(v))
|
|
4260
|
-
|
|
4276
|
+
f([]);
|
|
4261
4277
|
else {
|
|
4262
|
-
const
|
|
4263
|
-
|
|
4278
|
+
const C = await l(u, v);
|
|
4279
|
+
f(C);
|
|
4264
4280
|
}
|
|
4265
4281
|
c(!1), b(-1);
|
|
4266
4282
|
},
|
|
4267
4283
|
[u],
|
|
4268
4284
|
300
|
|
4269
4285
|
), N = (v) => {
|
|
4270
|
-
const
|
|
4271
|
-
|
|
4286
|
+
const C = ["pageType", u, v.id];
|
|
4287
|
+
C[1] && (n(C.join(":")), m(v.name), p(!1), f([]), b(-1));
|
|
4272
4288
|
}, w = (v) => {
|
|
4273
4289
|
switch (v.key) {
|
|
4274
4290
|
case "ArrowDown":
|
|
4275
|
-
v.preventDefault(), b((
|
|
4291
|
+
v.preventDefault(), b((C) => C < x.length - 1 ? C + 1 : C);
|
|
4276
4292
|
break;
|
|
4277
4293
|
case "ArrowUp":
|
|
4278
|
-
v.preventDefault(), b((
|
|
4294
|
+
v.preventDefault(), b((C) => C > 0 ? C - 1 : C);
|
|
4279
4295
|
break;
|
|
4280
4296
|
case "Enter":
|
|
4281
|
-
if (v.preventDefault(),
|
|
4282
|
-
k >= 0 && N(
|
|
4297
|
+
if (v.preventDefault(), x.length === 0) return;
|
|
4298
|
+
k >= 0 && N(x[k]);
|
|
4283
4299
|
break;
|
|
4284
4300
|
case "Escape":
|
|
4285
4301
|
v.preventDefault(), y();
|
|
@@ -4293,8 +4309,8 @@ const DataBindingSelector = ({
|
|
|
4293
4309
|
}
|
|
4294
4310
|
}, [k]);
|
|
4295
4311
|
const y = () => {
|
|
4296
|
-
m(""),
|
|
4297
|
-
},
|
|
4312
|
+
m(""), f([]), b(-1), p(!1), n("");
|
|
4313
|
+
}, S = (v) => {
|
|
4298
4314
|
m(v), p(!isEmpty(v)), c(!0), _(v);
|
|
4299
4315
|
};
|
|
4300
4316
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -4305,27 +4321,27 @@ const DataBindingSelector = ({
|
|
|
4305
4321
|
{
|
|
4306
4322
|
type: "text",
|
|
4307
4323
|
value: h,
|
|
4308
|
-
onChange: (v) =>
|
|
4324
|
+
onChange: (v) => S(v.target.value),
|
|
4309
4325
|
onKeyDown: w,
|
|
4310
|
-
placeholder: a(`Search ${
|
|
4326
|
+
placeholder: a(`Search ${E ?? ""}`),
|
|
4311
4327
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4312
4328
|
}
|
|
4313
4329
|
),
|
|
4314
4330
|
/* @__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" }) }) })
|
|
4315
4331
|
] }),
|
|
4316
|
-
(i || !isEmpty(
|
|
4332
|
+
(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: [
|
|
4317
4333
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4318
4334
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4319
|
-
] }) : d && isEmpty(
|
|
4335
|
+
] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4320
4336
|
a("No results found for"),
|
|
4321
4337
|
' "',
|
|
4322
4338
|
h,
|
|
4323
4339
|
'"'
|
|
4324
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(
|
|
4340
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(x == null ? void 0 : x.slice(0, 20), (v, C) => /* @__PURE__ */ jsxs(
|
|
4325
4341
|
"li",
|
|
4326
4342
|
{
|
|
4327
4343
|
onClick: () => N(v),
|
|
4328
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" :
|
|
4344
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : C === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4329
4345
|
children: [
|
|
4330
4346
|
v.name,
|
|
4331
4347
|
" ",
|
|
@@ -4636,13 +4652,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4636
4652
|
if (!u) return;
|
|
4637
4653
|
const m = `{{${h}}}`;
|
|
4638
4654
|
u.commands.focus();
|
|
4639
|
-
const { from:
|
|
4640
|
-
if (
|
|
4655
|
+
const { from: x, to: f } = u.state.selection;
|
|
4656
|
+
if (x !== f)
|
|
4641
4657
|
u.chain().deleteSelection().insertContent(m).run();
|
|
4642
4658
|
else {
|
|
4643
|
-
const { state: b } = u, A = b.selection.from,
|
|
4659
|
+
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));
|
|
4644
4660
|
let N = "";
|
|
4645
|
-
A > 0 &&
|
|
4661
|
+
A > 0 && E !== " " && !/[.,!?;:]/.test(E) && (N = " ");
|
|
4646
4662
|
let w = "";
|
|
4647
4663
|
_ && _ !== " " && !/[.,!?;:]/.test(_) && (w = " "), u.chain().insertContent(N + m + w).run();
|
|
4648
4664
|
}
|
|
@@ -4683,13 +4699,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4683
4699
|
})
|
|
4684
4700
|
],
|
|
4685
4701
|
content: n || "",
|
|
4686
|
-
onUpdate: ({ editor:
|
|
4687
|
-
const
|
|
4688
|
-
a(
|
|
4702
|
+
onUpdate: ({ editor: x }) => {
|
|
4703
|
+
const f = x.getHTML();
|
|
4704
|
+
a(f), c || u(f);
|
|
4689
4705
|
},
|
|
4690
|
-
onBlur: ({ editor:
|
|
4691
|
-
const
|
|
4692
|
-
l(o,
|
|
4706
|
+
onBlur: ({ editor: x }) => {
|
|
4707
|
+
const f = x.getHTML();
|
|
4708
|
+
l(o, f);
|
|
4693
4709
|
},
|
|
4694
4710
|
editorProps: {
|
|
4695
4711
|
attributes: {
|
|
@@ -4702,8 +4718,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4702
4718
|
}, [g]), useEffect(() => {
|
|
4703
4719
|
u(n || "");
|
|
4704
4720
|
}, [n]);
|
|
4705
|
-
const h = (
|
|
4706
|
-
a(
|
|
4721
|
+
const h = (x) => {
|
|
4722
|
+
a(x);
|
|
4707
4723
|
}, m = () => {
|
|
4708
4724
|
d(!1), g && g.commands.setContent(p);
|
|
4709
4725
|
};
|
|
@@ -4736,24 +4752,24 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4736
4752
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
|
|
4737
4753
|
}, [o, u]);
|
|
4738
4754
|
const h = () => {
|
|
4739
|
-
const
|
|
4740
|
-
if (
|
|
4741
|
-
const k = (
|
|
4755
|
+
const f = findIndex(u, { _id: g });
|
|
4756
|
+
if (f > -1) {
|
|
4757
|
+
const k = (f + 1) % u.length, b = get(u, [k, "_id"]);
|
|
4742
4758
|
if (!b) return;
|
|
4743
4759
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4744
4760
|
}
|
|
4745
4761
|
}, m = () => {
|
|
4746
|
-
const
|
|
4747
|
-
if (
|
|
4748
|
-
const k = (
|
|
4762
|
+
const f = findIndex(u, { _id: g });
|
|
4763
|
+
if (f > -1) {
|
|
4764
|
+
const k = (f - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
|
|
4749
4765
|
if (!b) return;
|
|
4750
4766
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4751
4767
|
}
|
|
4752
|
-
},
|
|
4753
|
-
const
|
|
4768
|
+
}, x = () => {
|
|
4769
|
+
const f = i(
|
|
4754
4770
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4755
4771
|
p == null ? void 0 : p._id
|
|
4756
|
-
), k =
|
|
4772
|
+
), k = f == null ? void 0 : f._id;
|
|
4757
4773
|
k && (r({ ...o, currentSlide: k }), c([k]));
|
|
4758
4774
|
};
|
|
4759
4775
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
@@ -4771,7 +4787,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4771
4787
|
/* @__PURE__ */ jsxs(
|
|
4772
4788
|
"button",
|
|
4773
4789
|
{
|
|
4774
|
-
onClick:
|
|
4790
|
+
onClick: x,
|
|
4775
4791
|
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",
|
|
4776
4792
|
children: [
|
|
4777
4793
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4832,8 +4848,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4832
4848
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4833
4849
|
className: "text-xs",
|
|
4834
4850
|
pattern: "[0-9]*",
|
|
4835
|
-
onChange: (
|
|
4836
|
-
let k =
|
|
4851
|
+
onChange: (f) => {
|
|
4852
|
+
let k = f.target.value;
|
|
4837
4853
|
k.length && (k = k.replace("-", "")), r({ ...o, autoplayInterval: k });
|
|
4838
4854
|
}
|
|
4839
4855
|
}
|
|
@@ -4935,44 +4951,53 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4935
4951
|
children: a,
|
|
4936
4952
|
errors: l,
|
|
4937
4953
|
help: i,
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
onChange: h
|
|
4954
|
+
hidden: c,
|
|
4955
|
+
required: d,
|
|
4956
|
+
schema: p,
|
|
4957
|
+
formData: u,
|
|
4958
|
+
onChange: g
|
|
4944
4959
|
}) => {
|
|
4945
|
-
const { selectedLang:
|
|
4946
|
-
() => isEmpty(x) ? "" : isEmpty(
|
|
4947
|
-
[x,
|
|
4948
|
-
),
|
|
4949
|
-
() => get(
|
|
4950
|
-
[
|
|
4951
|
-
), [
|
|
4952
|
-
if (
|
|
4960
|
+
const { selectedLang: h, fallbackLang: m, languages: x } = useLanguages(), f = useMemo(
|
|
4961
|
+
() => isEmpty(x) ? "" : isEmpty(h) ? m : h,
|
|
4962
|
+
[x, h, m]
|
|
4963
|
+
), k = useMemo(() => get(LANGUAGES, f, f), [f]), b = usePageExternalData(), A = useSelectedBlock(), E = useRegisteredChaiBlocks(), _ = useMemo(
|
|
4964
|
+
() => get(E, [A == null ? void 0 : A._type, "i18nProps"], []),
|
|
4965
|
+
[E, A == null ? void 0 : A._type]
|
|
4966
|
+
), [N, w] = useState(null);
|
|
4967
|
+
if (c)
|
|
4953
4968
|
return null;
|
|
4954
|
-
if (
|
|
4955
|
-
const
|
|
4956
|
-
if (
|
|
4957
|
-
const
|
|
4969
|
+
if (p.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
|
|
4970
|
+
const S = _ == null ? void 0 : _.includes(o.replace("root.", ""));
|
|
4971
|
+
if (p.type === "array") {
|
|
4972
|
+
const B = N === o;
|
|
4958
4973
|
return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
|
|
4959
|
-
|
|
4974
|
+
p.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
|
|
4960
4975
|
"label",
|
|
4961
4976
|
{
|
|
4962
4977
|
htmlFor: o,
|
|
4963
|
-
onClick: () =>
|
|
4978
|
+
onClick: () => w(B ? null : o),
|
|
4964
4979
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4965
4980
|
children: [
|
|
4966
|
-
|
|
4981
|
+
B ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
4967
4982
|
/* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
|
|
4968
4983
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
|
|
4969
4984
|
" ",
|
|
4970
|
-
/* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children:
|
|
4985
|
+
/* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: u == null ? void 0 : u.length }) }),
|
|
4986
|
+
p.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4987
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
4988
|
+
Info,
|
|
4989
|
+
{
|
|
4990
|
+
className: "h-3 w-3 text-muted-foreground/70",
|
|
4991
|
+
onClick: (v) => v.stopPropagation(),
|
|
4992
|
+
onMouseDown: (v) => v.stopPropagation()
|
|
4993
|
+
}
|
|
4994
|
+
) }),
|
|
4995
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: p.description })
|
|
4996
|
+
] }) })
|
|
4971
4997
|
]
|
|
4972
4998
|
}
|
|
4973
|
-
),
|
|
4974
|
-
(
|
|
4975
|
-
c,
|
|
4999
|
+
) }),
|
|
5000
|
+
(u == null ? void 0 : u.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${B ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
4976
5001
|
a,
|
|
4977
5002
|
l,
|
|
4978
5003
|
i
|
|
@@ -4980,35 +5005,34 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4980
5005
|
] });
|
|
4981
5006
|
}
|
|
4982
5007
|
return /* @__PURE__ */ jsxs("div", { className: r, children: [
|
|
4983
|
-
|
|
5008
|
+
p.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
4984
5009
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4985
|
-
/* @__PURE__ */ jsxs("label", { htmlFor: o, className:
|
|
5010
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: o, className: p.type === "object" ? "pb-2" : "", children: [
|
|
4986
5011
|
n,
|
|
4987
5012
|
" ",
|
|
4988
|
-
|
|
5013
|
+
S && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
4989
5014
|
" ",
|
|
4990
|
-
|
|
5015
|
+
k
|
|
4991
5016
|
] }),
|
|
4992
|
-
|
|
5017
|
+
d && p.type !== "object" ? " *" : null
|
|
4993
5018
|
] }),
|
|
4994
|
-
|
|
5019
|
+
p.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4995
5020
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Info, { className: "h-3 w-3 text-muted-foreground/70" }) }),
|
|
4996
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children:
|
|
5021
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: p.description })
|
|
4997
5022
|
] }) })
|
|
4998
5023
|
] }),
|
|
4999
|
-
!
|
|
5024
|
+
!p.enum && !p.oneOf && b && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
5000
5025
|
DataBindingSelector,
|
|
5001
5026
|
{
|
|
5002
|
-
schema:
|
|
5003
|
-
onChange: (
|
|
5004
|
-
|
|
5027
|
+
schema: p,
|
|
5028
|
+
onChange: (B) => {
|
|
5029
|
+
g(B, u, o);
|
|
5005
5030
|
},
|
|
5006
5031
|
id: o,
|
|
5007
|
-
formData:
|
|
5032
|
+
formData: u
|
|
5008
5033
|
}
|
|
5009
5034
|
) })
|
|
5010
5035
|
] }),
|
|
5011
|
-
c,
|
|
5012
5036
|
a,
|
|
5013
5037
|
l,
|
|
5014
5038
|
i
|
|
@@ -5108,36 +5132,36 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
5108
5132
|
}), a;
|
|
5109
5133
|
};
|
|
5110
5134
|
function BlockSettings() {
|
|
5111
|
-
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),
|
|
5112
|
-
y && (c == null ? void 0 : c._id) === r._id && a([r._id], { [y]: get(w, y) },
|
|
5113
|
-
},
|
|
5114
|
-
debounce(({ formData: w }, y,
|
|
5115
|
-
|
|
5135
|
+
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, S) => {
|
|
5136
|
+
y && (c == null ? void 0 : c._id) === r._id && a([r._id], { [y]: get(w, y) }, S);
|
|
5137
|
+
}, f = useCallback(
|
|
5138
|
+
debounce(({ formData: w }, y, S) => {
|
|
5139
|
+
x({ formData: w }, y, S), d(w);
|
|
5116
5140
|
}, 1500),
|
|
5117
5141
|
[r == null ? void 0 : r._id, o]
|
|
5118
5142
|
), k = ({ formData: w }, y) => {
|
|
5119
|
-
y && (n([r._id], { [y]: get(w, y) }),
|
|
5143
|
+
y && (n([r._id], { [y]: get(w, y) }), f({ formData: w }, y, { [y]: get(c, y) }));
|
|
5120
5144
|
}, b = ({ formData: w }, y) => {
|
|
5121
|
-
y && (n([g._id], { [y]: get(w, y) }),
|
|
5122
|
-
}, { schema: A, uiSchema:
|
|
5145
|
+
y && (n([g._id], { [y]: get(w, y) }), f({ formData: w }, y, { [y]: get(c, y) }));
|
|
5146
|
+
}, { schema: A, uiSchema: E } = useMemo(() => {
|
|
5123
5147
|
const w = r == null ? void 0 : r._type;
|
|
5124
5148
|
if (!w)
|
|
5125
5149
|
return { schema: {}, uiSchema: {} };
|
|
5126
5150
|
try {
|
|
5127
|
-
const { schema: y, uiSchema:
|
|
5151
|
+
const { schema: y, uiSchema: S } = getBlockFormSchemas(w);
|
|
5128
5152
|
if (w === "Repeater") {
|
|
5129
|
-
const
|
|
5130
|
-
startsWith(
|
|
5153
|
+
const B = get(r, "repeaterItems", "");
|
|
5154
|
+
startsWith(B, `{{${COLLECTION_PREFIX}`) ? (set(S, "filter", { "ui:widget": "collectionSelect" }), set(S, "sort", { "ui:widget": "collectionSelect" })) : (set(S, "filter", { "ui:widget": "hidden" }), set(S, "sort", { "ui:widget": "hidden" }));
|
|
5131
5155
|
}
|
|
5132
|
-
return { schema: y, uiSchema:
|
|
5156
|
+
return { schema: y, uiSchema: S };
|
|
5133
5157
|
} catch {
|
|
5134
5158
|
return { schema: {}, uiSchema: {} };
|
|
5135
5159
|
}
|
|
5136
5160
|
}, [r]), { wrapperSchema: _, wrapperUiSchema: N } = useMemo(() => {
|
|
5137
5161
|
if (!g || !(g != null && g._type))
|
|
5138
5162
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5139
|
-
const w = g == null ? void 0 : g._type, { schema: y = {}, uiSchema:
|
|
5140
|
-
return { wrapperSchema: y, wrapperUiSchema:
|
|
5163
|
+
const w = g == null ? void 0 : g._type, { schema: y = {}, uiSchema: S = {} } = getBlockFormSchemas(w);
|
|
5164
|
+
return { wrapperSchema: y, wrapperUiSchema: S };
|
|
5141
5165
|
}, [g]);
|
|
5142
5166
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5143
5167
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
@@ -5177,33 +5201,33 @@ function BlockSettings() {
|
|
|
5177
5201
|
onChange: k,
|
|
5178
5202
|
formData: i,
|
|
5179
5203
|
schema: A,
|
|
5180
|
-
uiSchema:
|
|
5204
|
+
uiSchema: E
|
|
5181
5205
|
}
|
|
5182
5206
|
)
|
|
5183
5207
|
] });
|
|
5184
5208
|
}
|
|
5185
5209
|
const BlockStylingProps = () => {
|
|
5186
|
-
var
|
|
5210
|
+
var x;
|
|
5187
5211
|
const o = useSelectedBlock(), [r, n] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
|
|
5188
5212
|
if (!o) return null;
|
|
5189
5213
|
const c = Object.keys(o).filter(
|
|
5190
|
-
(
|
|
5191
|
-
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (
|
|
5214
|
+
(f) => typeof o[f] == "string" && o[f].startsWith("#styles:")
|
|
5215
|
+
), { 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);
|
|
5192
5216
|
return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5193
5217
|
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5194
5218
|
i("Style element"),
|
|
5195
5219
|
":"
|
|
5196
5220
|
] }),
|
|
5197
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (
|
|
5221
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (f) => /* @__PURE__ */ jsxs(
|
|
5198
5222
|
Badge,
|
|
5199
5223
|
{
|
|
5200
5224
|
className: "flex cursor-pointer items-center gap-1 pr-1",
|
|
5201
|
-
variant: m(
|
|
5225
|
+
variant: m(f) ? "default" : "secondary",
|
|
5202
5226
|
onClick: () => {
|
|
5203
|
-
n([{ id: `${
|
|
5227
|
+
n([{ id: `${f}-${o._id}`, blockId: o._id, prop: f }]);
|
|
5204
5228
|
},
|
|
5205
5229
|
children: [
|
|
5206
|
-
startCase(
|
|
5230
|
+
startCase(f),
|
|
5207
5231
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5208
5232
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5209
5233
|
"button",
|
|
@@ -5220,7 +5244,7 @@ const BlockStylingProps = () => {
|
|
|
5220
5244
|
{
|
|
5221
5245
|
className: "text-xs",
|
|
5222
5246
|
onClick: () => {
|
|
5223
|
-
d(
|
|
5247
|
+
d(f);
|
|
5224
5248
|
},
|
|
5225
5249
|
children: i("Reset style")
|
|
5226
5250
|
}
|
|
@@ -5239,7 +5263,7 @@ const BlockStylingProps = () => {
|
|
|
5239
5263
|
] })
|
|
5240
5264
|
]
|
|
5241
5265
|
},
|
|
5242
|
-
|
|
5266
|
+
f
|
|
5243
5267
|
)) }),
|
|
5244
5268
|
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5245
5269
|
] }) });
|
|
@@ -5388,47 +5412,47 @@ const BlockStylingProps = () => {
|
|
|
5388
5412
|
},
|
|
5389
5413
|
a
|
|
5390
5414
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5391
|
-
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]), [
|
|
5415
|
+
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);
|
|
5392
5416
|
useEffect(() => {
|
|
5393
|
-
const { value: v, unit:
|
|
5394
|
-
if (
|
|
5417
|
+
const { value: v, unit: C } = getClassValueAndUnit(i);
|
|
5418
|
+
if (C === "") {
|
|
5395
5419
|
l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5396
5420
|
return;
|
|
5397
5421
|
}
|
|
5398
|
-
m(
|
|
5422
|
+
m(C), l(C === "class" || isEmpty(v) ? "" : v);
|
|
5399
5423
|
}, [i, p, u]);
|
|
5400
|
-
const w = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), y = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME),
|
|
5424
|
+
const w = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), y = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), S = useCallback(
|
|
5401
5425
|
(v = !1) => {
|
|
5402
|
-
const
|
|
5403
|
-
if (get(
|
|
5404
|
-
|
|
5426
|
+
const C = getUserInputValues(`${a}`, u);
|
|
5427
|
+
if (get(C, "error", !1)) {
|
|
5428
|
+
f(!0);
|
|
5405
5429
|
return;
|
|
5406
5430
|
}
|
|
5407
|
-
const j = get(
|
|
5431
|
+
const j = get(C, "unit") !== "" ? get(C, "unit") : h;
|
|
5408
5432
|
if (j === "auto" || j === "none") {
|
|
5409
5433
|
w(`${d}${j}`);
|
|
5410
5434
|
return;
|
|
5411
5435
|
}
|
|
5412
|
-
if (get(
|
|
5436
|
+
if (get(C, "value") === "")
|
|
5413
5437
|
return;
|
|
5414
|
-
const L = `${get(
|
|
5438
|
+
const L = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5415
5439
|
v ? y(L) : w(L);
|
|
5416
5440
|
},
|
|
5417
5441
|
[w, y, a, h, d, u]
|
|
5418
|
-
),
|
|
5442
|
+
), B = useCallback(
|
|
5419
5443
|
(v) => {
|
|
5420
|
-
const
|
|
5421
|
-
if (get(
|
|
5422
|
-
|
|
5444
|
+
const C = getUserInputValues(`${a}`, u);
|
|
5445
|
+
if (get(C, "error", !1)) {
|
|
5446
|
+
f(!0);
|
|
5423
5447
|
return;
|
|
5424
5448
|
}
|
|
5425
5449
|
if (v === "auto" || v === "none") {
|
|
5426
5450
|
w(`${d}${v}`);
|
|
5427
5451
|
return;
|
|
5428
5452
|
}
|
|
5429
|
-
if (get(
|
|
5453
|
+
if (get(C, "value") === "")
|
|
5430
5454
|
return;
|
|
5431
|
-
const j = get(
|
|
5455
|
+
const j = get(C, "unit") !== "" ? get(C, "unit") : v, L = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5432
5456
|
w(L);
|
|
5433
5457
|
},
|
|
5434
5458
|
[w, a, d, u]
|
|
@@ -5453,14 +5477,14 @@ const BlockStylingProps = () => {
|
|
|
5453
5477
|
{
|
|
5454
5478
|
readOnly: h === "class",
|
|
5455
5479
|
onKeyPress: (v) => {
|
|
5456
|
-
v.key === "Enter" &&
|
|
5480
|
+
v.key === "Enter" && S();
|
|
5457
5481
|
},
|
|
5458
5482
|
onKeyDown: (v) => {
|
|
5459
5483
|
if (v.keyCode !== 38 && v.keyCode !== 40)
|
|
5460
5484
|
return;
|
|
5461
5485
|
v.preventDefault(), N(!0);
|
|
5462
|
-
const
|
|
5463
|
-
let j = isNaN$1(
|
|
5486
|
+
const C = parseInt$1(v.target.value);
|
|
5487
|
+
let j = isNaN$1(C) ? 0 : C;
|
|
5464
5488
|
v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
|
|
5465
5489
|
const T = `${j}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5466
5490
|
y(R);
|
|
@@ -5468,18 +5492,18 @@ const BlockStylingProps = () => {
|
|
|
5468
5492
|
onKeyUp: (v) => {
|
|
5469
5493
|
_ && (v.preventDefault(), N(!1));
|
|
5470
5494
|
},
|
|
5471
|
-
onBlur: () =>
|
|
5495
|
+
onBlur: () => S(),
|
|
5472
5496
|
onChange: (v) => {
|
|
5473
|
-
|
|
5497
|
+
f(!1), l(v.target.value);
|
|
5474
5498
|
},
|
|
5475
5499
|
onClick: (v) => {
|
|
5476
|
-
var
|
|
5477
|
-
(
|
|
5500
|
+
var C;
|
|
5501
|
+
(C = v == null ? void 0 : v.target) == null || C.select(), n(!1);
|
|
5478
5502
|
},
|
|
5479
5503
|
value: A ? k : a,
|
|
5480
5504
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5481
5505
|
" ",
|
|
5482
|
-
|
|
5506
|
+
x ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
5483
5507
|
)
|
|
5484
5508
|
}
|
|
5485
5509
|
),
|
|
@@ -5502,7 +5526,7 @@ const BlockStylingProps = () => {
|
|
|
5502
5526
|
units: u,
|
|
5503
5527
|
current: h,
|
|
5504
5528
|
onSelect: (v) => {
|
|
5505
|
-
n(!1), m(v),
|
|
5529
|
+
n(!1), m(v), B(v);
|
|
5506
5530
|
}
|
|
5507
5531
|
}
|
|
5508
5532
|
) })
|
|
@@ -5511,18 +5535,18 @@ const BlockStylingProps = () => {
|
|
|
5511
5535
|
["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
|
|
5512
5536
|
DragStyleButton,
|
|
5513
5537
|
{
|
|
5514
|
-
onDragStart: () =>
|
|
5538
|
+
onDragStart: () => E(!0),
|
|
5515
5539
|
onDragEnd: (v) => {
|
|
5516
|
-
if (b(() => ""),
|
|
5540
|
+
if (b(() => ""), E(!1), isEmpty(v))
|
|
5517
5541
|
return;
|
|
5518
|
-
const
|
|
5542
|
+
const C = `${v}`, T = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5519
5543
|
w(T);
|
|
5520
5544
|
},
|
|
5521
5545
|
onDrag: (v) => {
|
|
5522
5546
|
if (isEmpty(v))
|
|
5523
5547
|
return;
|
|
5524
5548
|
b(v);
|
|
5525
|
-
const
|
|
5549
|
+
const C = `${v}`, T = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5526
5550
|
y(T);
|
|
5527
5551
|
},
|
|
5528
5552
|
currentValue: a,
|
|
@@ -5598,7 +5622,7 @@ const COLOR_PROP = {
|
|
|
5598
5622
|
return c([]);
|
|
5599
5623
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5600
5624
|
}, [g]);
|
|
5601
|
-
const
|
|
5625
|
+
const x = useCallback(
|
|
5602
5626
|
// eslint-disable-next-line no-shadow
|
|
5603
5627
|
(k) => {
|
|
5604
5628
|
p({ color: g, shade: k });
|
|
@@ -5608,11 +5632,11 @@ const COLOR_PROP = {
|
|
|
5608
5632
|
useEffect(() => {
|
|
5609
5633
|
p({ color: "", shade: "" });
|
|
5610
5634
|
}, [n]);
|
|
5611
|
-
const { match:
|
|
5635
|
+
const { match: f } = useTailwindClassList();
|
|
5612
5636
|
return useEffect(() => {
|
|
5613
5637
|
const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5614
|
-
|
|
5615
|
-
}, [
|
|
5638
|
+
f(o, b) && r(b, o);
|
|
5639
|
+
}, [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: [
|
|
5616
5640
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5617
5641
|
DropDown,
|
|
5618
5642
|
{
|
|
@@ -5652,7 +5676,7 @@ const COLOR_PROP = {
|
|
|
5652
5676
|
]
|
|
5653
5677
|
}
|
|
5654
5678
|
) }),
|
|
5655
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange:
|
|
5679
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: x, options: i }) })
|
|
5656
5680
|
] });
|
|
5657
5681
|
}, EDITOR_ICONS = {
|
|
5658
5682
|
"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" }) }),
|
|
@@ -5986,20 +6010,20 @@ const COLOR_PROP = {
|
|
|
5986
6010
|
"2xl": "1536px"
|
|
5987
6011
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
5988
6012
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
5989
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(),
|
|
5990
|
-
(y,
|
|
5991
|
-
const
|
|
5992
|
-
(p || u !== "") && (
|
|
5993
|
-
const v = generateFullClsName(
|
|
5994
|
-
m(
|
|
6013
|
+
}, 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(
|
|
6014
|
+
(y, S = !0) => {
|
|
6015
|
+
const B = { dark: p, mq: g, mod: u, cls: y, property: l, fullCls: "" };
|
|
6016
|
+
(p || u !== "") && (B.mq = "xs");
|
|
6017
|
+
const v = generateFullClsName(B);
|
|
6018
|
+
m(f, [v], S);
|
|
5995
6019
|
},
|
|
5996
|
-
[
|
|
6020
|
+
[f, p, g, u, l, m]
|
|
5997
6021
|
), A = useCallback(() => {
|
|
5998
|
-
f
|
|
5999
|
-
}, [
|
|
6022
|
+
x(f, [k], !0);
|
|
6023
|
+
}, [f, k, x]), E = useMemo(() => canChangeClass(h, g), [h, g]);
|
|
6000
6024
|
useEffect(() => {
|
|
6001
|
-
i(
|
|
6002
|
-
}, [
|
|
6025
|
+
i(E, h);
|
|
6026
|
+
}, [E, i, h]);
|
|
6003
6027
|
const [, , _] = useScreenSizeWidth(), N = useCallback(
|
|
6004
6028
|
(y) => {
|
|
6005
6029
|
_({
|
|
@@ -6013,7 +6037,7 @@ const COLOR_PROP = {
|
|
|
6013
6037
|
},
|
|
6014
6038
|
[_]
|
|
6015
6039
|
), w = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
|
|
6016
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6040
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: h && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6017
6041
|
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !w ? "text-foreground" : ""}`, children: r(a) }) }),
|
|
6018
6042
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6019
6043
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
@@ -6033,7 +6057,7 @@ const COLOR_PROP = {
|
|
|
6033
6057
|
n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
6034
6058
|
n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
6035
6059
|
] }),
|
|
6036
|
-
/* @__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" }) }) :
|
|
6060
|
+
/* @__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: [
|
|
6037
6061
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6038
6062
|
"button",
|
|
6039
6063
|
{
|
|
@@ -6082,23 +6106,23 @@ const COLOR_PROP = {
|
|
|
6082
6106
|
children: [
|
|
6083
6107
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6084
6108
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6085
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key:
|
|
6109
|
+
/* @__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: [
|
|
6086
6110
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6087
6111
|
"button",
|
|
6088
6112
|
{
|
|
6089
6113
|
type: "button",
|
|
6090
|
-
onClick: () => u(
|
|
6091
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6114
|
+
onClick: () => u(x),
|
|
6115
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6092
6116
|
children: [
|
|
6093
6117
|
React__default.createElement("div", {
|
|
6094
|
-
className: h(
|
|
6118
|
+
className: h(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6095
6119
|
}),
|
|
6096
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6120
|
+
React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6097
6121
|
]
|
|
6098
6122
|
}
|
|
6099
6123
|
) }),
|
|
6100
6124
|
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
|
|
6101
|
-
] }) }, `option-${
|
|
6125
|
+
] }) }, `option-${f}`)) })
|
|
6102
6126
|
] }),
|
|
6103
6127
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6104
6128
|
BlockStyle,
|
|
@@ -6253,9 +6277,9 @@ const COLOR_PROP = {
|
|
|
6253
6277
|
canvas: r = !1,
|
|
6254
6278
|
tooltip: n = !0
|
|
6255
6279
|
}) => {
|
|
6256
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS),
|
|
6280
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
|
|
6257
6281
|
u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
|
|
6258
|
-
},
|
|
6282
|
+
}, f = (b) => {
|
|
6259
6283
|
r || l(b), c(b);
|
|
6260
6284
|
}, k = getBreakpointValue(r ? i : a).toLowerCase();
|
|
6261
6285
|
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
|
|
@@ -6263,7 +6287,7 @@ const COLOR_PROP = {
|
|
|
6263
6287
|
{
|
|
6264
6288
|
canvas: r,
|
|
6265
6289
|
...b,
|
|
6266
|
-
onClick:
|
|
6290
|
+
onClick: f,
|
|
6267
6291
|
key: b.breakpoint,
|
|
6268
6292
|
currentBreakpoint: k
|
|
6269
6293
|
}
|
|
@@ -6277,7 +6301,7 @@ const COLOR_PROP = {
|
|
|
6277
6301
|
openDelay: o,
|
|
6278
6302
|
tooltip: n,
|
|
6279
6303
|
...b,
|
|
6280
|
-
onClick:
|
|
6304
|
+
onClick: f,
|
|
6281
6305
|
key: b.breakpoint,
|
|
6282
6306
|
currentBreakpoint: k
|
|
6283
6307
|
}
|
|
@@ -6292,7 +6316,7 @@ const COLOR_PROP = {
|
|
|
6292
6316
|
DropdownMenuCheckboxItem,
|
|
6293
6317
|
{
|
|
6294
6318
|
disabled: b.breakpoint === "xs",
|
|
6295
|
-
onCheckedChange: () =>
|
|
6319
|
+
onCheckedChange: () => x(toUpper(b.breakpoint)),
|
|
6296
6320
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6297
6321
|
children: h(b.title)
|
|
6298
6322
|
},
|
|
@@ -6377,8 +6401,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6377
6401
|
(m = d.current) == null || m.focus();
|
|
6378
6402
|
}, []);
|
|
6379
6403
|
const h = (m) => {
|
|
6380
|
-
const { usage:
|
|
6381
|
-
!l &&
|
|
6404
|
+
const { usage: x } = m || {};
|
|
6405
|
+
!l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6382
6406
|
};
|
|
6383
6407
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6384
6408
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
|
|
@@ -6434,9 +6458,9 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6434
6458
|
};
|
|
6435
6459
|
function ManualClasses() {
|
|
6436
6460
|
var T;
|
|
6437
|
-
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), [
|
|
6438
|
-
const L =
|
|
6439
|
-
u(h, L, !0),
|
|
6461
|
+
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 = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), A = b.split(" ").filter((L) => !isEmpty(L)), E = () => {
|
|
6462
|
+
const L = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6463
|
+
u(h, L, !0), f("");
|
|
6440
6464
|
}, [_, N] = useState([]), w = ({ value: L }) => {
|
|
6441
6465
|
const R = L.trim().toLowerCase(), I = R.match(/.+:/g);
|
|
6442
6466
|
let D = [];
|
|
@@ -6451,7 +6475,7 @@ function ManualClasses() {
|
|
|
6451
6475
|
return N(map(D, "item"));
|
|
6452
6476
|
}, y = () => {
|
|
6453
6477
|
N([]);
|
|
6454
|
-
},
|
|
6478
|
+
}, S = (L) => L.name, B = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), v = useMemo(
|
|
6455
6479
|
() => ({
|
|
6456
6480
|
ref: o,
|
|
6457
6481
|
autoComplete: "off",
|
|
@@ -6459,20 +6483,20 @@ function ManualClasses() {
|
|
|
6459
6483
|
autoCapitalize: "off",
|
|
6460
6484
|
spellCheck: !1,
|
|
6461
6485
|
placeholder: c("Enter classes separated by space"),
|
|
6462
|
-
value:
|
|
6486
|
+
value: x,
|
|
6463
6487
|
onFocus: (L) => {
|
|
6464
6488
|
setTimeout(() => {
|
|
6465
6489
|
L.target && L.target.select();
|
|
6466
6490
|
}, 0);
|
|
6467
6491
|
},
|
|
6468
6492
|
onKeyDown: (L) => {
|
|
6469
|
-
L.key === "Enter" &&
|
|
6493
|
+
L.key === "Enter" && x.trim() !== "" && E();
|
|
6470
6494
|
},
|
|
6471
|
-
onChange: (L, { newValue: R }) =>
|
|
6495
|
+
onChange: (L, { newValue: R }) => f(R),
|
|
6472
6496
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6473
6497
|
}),
|
|
6474
|
-
[
|
|
6475
|
-
),
|
|
6498
|
+
[x, c, o]
|
|
6499
|
+
), C = (L) => {
|
|
6476
6500
|
debugger;
|
|
6477
6501
|
const R = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6478
6502
|
g(h, [L]), u(h, R, !0), n(""), l(-1);
|
|
@@ -6507,8 +6531,8 @@ function ManualClasses() {
|
|
|
6507
6531
|
suggestions: _,
|
|
6508
6532
|
onSuggestionsFetchRequested: w,
|
|
6509
6533
|
onSuggestionsClearRequested: y,
|
|
6510
|
-
getSuggestionValue:
|
|
6511
|
-
renderSuggestion:
|
|
6534
|
+
getSuggestionValue: S,
|
|
6535
|
+
renderSuggestion: B,
|
|
6512
6536
|
inputProps: v,
|
|
6513
6537
|
containerProps: {
|
|
6514
6538
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
@@ -6525,8 +6549,8 @@ function ManualClasses() {
|
|
|
6525
6549
|
{
|
|
6526
6550
|
variant: "outline",
|
|
6527
6551
|
className: "h-6 border-border",
|
|
6528
|
-
onClick:
|
|
6529
|
-
disabled:
|
|
6552
|
+
onClick: E,
|
|
6553
|
+
disabled: x.trim() === "",
|
|
6530
6554
|
size: "sm",
|
|
6531
6555
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
6532
6556
|
}
|
|
@@ -6540,10 +6564,10 @@ function ManualClasses() {
|
|
|
6540
6564
|
value: r,
|
|
6541
6565
|
onChange: (I) => n(I.target.value),
|
|
6542
6566
|
onBlur: () => {
|
|
6543
|
-
|
|
6567
|
+
C(L);
|
|
6544
6568
|
},
|
|
6545
6569
|
onKeyDown: (I) => {
|
|
6546
|
-
I.key === "Enter" &&
|
|
6570
|
+
I.key === "Enter" && C(L);
|
|
6547
6571
|
},
|
|
6548
6572
|
onFocus: (I) => {
|
|
6549
6573
|
setTimeout(() => {
|
|
@@ -6557,42 +6581,44 @@ function ManualClasses() {
|
|
|
6557
6581
|
"button",
|
|
6558
6582
|
{
|
|
6559
6583
|
onDoubleClick: () => {
|
|
6560
|
-
|
|
6584
|
+
f(L), g(h, [L]), setTimeout(() => {
|
|
6561
6585
|
o.current && o.current.focus();
|
|
6562
6586
|
}, 10);
|
|
6563
6587
|
},
|
|
6564
|
-
className: "flex cursor-default items-center gap-x-1 truncate break-words
|
|
6588
|
+
className: "flex h-max cursor-default items-center gap-x-1 truncate break-words rounded bg-gray-200 py-px pl-0.5 pr-1 text-[11px] text-gray-600 dark:bg-gray-800 dark:text-gray-300",
|
|
6565
6589
|
children: [
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6590
|
+
/* @__PURE__ */ jsxs("div", { className: "z-10 flex h-full w-max items-center justify-center", children: [
|
|
6591
|
+
/* @__PURE__ */ jsx(
|
|
6592
|
+
Cross2Icon,
|
|
6593
|
+
{
|
|
6594
|
+
onClick: () => g(h, [L], !0),
|
|
6595
|
+
className: "hidden h-max w-3.5 cursor-pointer rounded bg-gray-100 p-0.5 text-red-500 hover:bg-gray-50 group-hover:block"
|
|
6596
|
+
}
|
|
6597
|
+
),
|
|
6598
|
+
/* @__PURE__ */ jsxs(
|
|
6599
|
+
"svg",
|
|
6600
|
+
{
|
|
6601
|
+
className: "h-3.5 w-3.5 group-hover:hidden",
|
|
6602
|
+
fill: "rgba(55, 65, 81, 0.4)",
|
|
6603
|
+
viewBox: "0 0 24 24",
|
|
6604
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6605
|
+
xmlSpace: "preserve",
|
|
6606
|
+
children: [
|
|
6607
|
+
/* @__PURE__ */ jsx("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
6608
|
+
/* @__PURE__ */ jsx("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
6609
|
+
/* @__PURE__ */ jsx("g", { id: "SVGRepo_iconCarrier", children: /* @__PURE__ */ jsx(
|
|
6610
|
+
"path",
|
|
6611
|
+
{
|
|
6612
|
+
fillRule: "evenodd",
|
|
6613
|
+
clipRule: "evenodd",
|
|
6614
|
+
d: "M12 6.036c-2.667 0-4.333 1.325-5 3.976 1-1.325 2.167-1.822 3.5-1.491.761.189 1.305.738 1.906 1.345C13.387 10.855 14.522 12 17 12c2.667 0 4.333-1.325 5-3.976-1 1.325-2.166 1.822-3.5 1.491-.761-.189-1.305-.738-1.907-1.345-.98-.99-2.114-2.134-4.593-2.134zM7 12c-2.667 0-4.333 1.325-5 3.976 1-1.326 2.167-1.822 3.5-1.491.761.189 1.305.738 1.907 1.345.98.989 2.115 2.134 4.594 2.134 2.667 0 4.333-1.325 5-3.976-1 1.325-2.167 1.822-3.5 1.491-.761-.189-1.305-.738-1.906-1.345C10.613 13.145 9.478 12 7 12z"
|
|
6615
|
+
}
|
|
6616
|
+
) })
|
|
6617
|
+
]
|
|
6618
|
+
}
|
|
6619
|
+
)
|
|
6620
|
+
] }),
|
|
6621
|
+
/* @__PURE__ */ jsx("div", { children: L })
|
|
6596
6622
|
]
|
|
6597
6623
|
}
|
|
6598
6624
|
) }, L)
|
|
@@ -6711,9 +6737,9 @@ function BlockStyling() {
|
|
|
6711
6737
|
const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
|
|
6712
6738
|
let m = parseFloat(i.dragStartValue);
|
|
6713
6739
|
m = isNaN(m) ? 0 : m;
|
|
6714
|
-
let
|
|
6715
|
-
(startsWith(h, "scale") || h === "opacity") && (
|
|
6716
|
-
let k = (i.dragStartY - u.pageY) /
|
|
6740
|
+
let x = MAPPER[i.dragUnit];
|
|
6741
|
+
(startsWith(h, "scale") || h === "opacity") && (x = 10);
|
|
6742
|
+
let k = (i.dragStartY - u.pageY) / x + m;
|
|
6717
6743
|
g && k < 0 && (k = 0), h === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
|
|
6718
6744
|
},
|
|
6719
6745
|
[i],
|
|
@@ -6762,7 +6788,7 @@ const CoreBlock = ({
|
|
|
6762
6788
|
} else
|
|
6763
6789
|
p(o, n || null, a);
|
|
6764
6790
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6765
|
-
},
|
|
6791
|
+
}, x = useFeature("dnd"), { t: f } = useTranslation();
|
|
6766
6792
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6767
6793
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6768
6794
|
"button",
|
|
@@ -6775,15 +6801,15 @@ const CoreBlock = ({
|
|
|
6775
6801
|
g([]), h();
|
|
6776
6802
|
}, 200);
|
|
6777
6803
|
},
|
|
6778
|
-
draggable:
|
|
6804
|
+
draggable: x ? "true" : "false",
|
|
6779
6805
|
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",
|
|
6780
6806
|
children: [
|
|
6781
6807
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6782
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6808
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(f(d || i)) })
|
|
6783
6809
|
]
|
|
6784
6810
|
}
|
|
6785
6811
|
) }),
|
|
6786
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6812
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f(d || i) }) })
|
|
6787
6813
|
] }) });
|
|
6788
6814
|
}, DefaultChaiBlocks = ({
|
|
6789
6815
|
parentId: o,
|
|
@@ -6986,7 +7012,7 @@ const CoreBlock = ({
|
|
|
6986
7012
|
}
|
|
6987
7013
|
}
|
|
6988
7014
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
6989
|
-
var h, m,
|
|
7015
|
+
var h, m, x, f, k, b, A, E, _, N;
|
|
6990
7016
|
if (n.type === "comment") return [];
|
|
6991
7017
|
let a = { _id: generateUUID() };
|
|
6992
7018
|
if (r && (a._parent = r.block._id), n.type === "text")
|
|
@@ -7028,8 +7054,8 @@ const CoreBlock = ({
|
|
|
7028
7054
|
...a,
|
|
7029
7055
|
href: ((h = l.find((y) => y.key === "href")) == null ? void 0 : h.value) || "",
|
|
7030
7056
|
hrefType: ((m = l.find((y) => y.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
|
|
7031
|
-
autoplay: ((
|
|
7032
|
-
maxWidth: ((k = (
|
|
7057
|
+
autoplay: ((x = l.find((y) => y.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
|
|
7058
|
+
maxWidth: ((k = (f = l.find((y) => y.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : k.replace("px", "")) || "",
|
|
7033
7059
|
backdropColor: ((b = l.find((y) => y.key === "data-overlay")) == null ? void 0 : b.value) || "",
|
|
7034
7060
|
galleryName: ((A = l.find((y) => y.key === "data-gall")) == null ? void 0 : A.value) || ""
|
|
7035
7061
|
}, forEach(w, (y) => {
|
|
@@ -7038,18 +7064,18 @@ const CoreBlock = ({
|
|
|
7038
7064
|
}
|
|
7039
7065
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
7040
7066
|
delete a.styles_attrs;
|
|
7041
|
-
const w = filter(n.children || [], (
|
|
7067
|
+
const w = filter(n.children || [], (S) => (S == null ? void 0 : S.tagName) !== "span");
|
|
7042
7068
|
a.content = getTextContent(w);
|
|
7043
7069
|
const y = find(
|
|
7044
7070
|
n.children || [],
|
|
7045
|
-
(
|
|
7071
|
+
(S) => (S == null ? void 0 : S.tagName) === "span" && some(S.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg")
|
|
7046
7072
|
);
|
|
7047
7073
|
if (y) {
|
|
7048
|
-
const
|
|
7049
|
-
if (
|
|
7050
|
-
a.icon = stringify([
|
|
7051
|
-
const { height:
|
|
7052
|
-
a.iconHeight =
|
|
7074
|
+
const S = find(y.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg");
|
|
7075
|
+
if (S) {
|
|
7076
|
+
a.icon = stringify([S]);
|
|
7077
|
+
const { height: B, width: v } = getSvgDimensions(S, "16px", "16px");
|
|
7078
|
+
a.iconHeight = B, a.iconWidth = v;
|
|
7053
7079
|
}
|
|
7054
7080
|
}
|
|
7055
7081
|
return [a];
|
|
@@ -7061,14 +7087,14 @@ const CoreBlock = ({
|
|
|
7061
7087
|
const w = stringify([n]);
|
|
7062
7088
|
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];
|
|
7063
7089
|
} else if (n.tagName === "svg") {
|
|
7064
|
-
const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: y, width:
|
|
7065
|
-
if (y &&
|
|
7066
|
-
a.styles = `${STYLES_KEY}, ${cn$2(`w-${
|
|
7090
|
+
const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: y, width: S } = getHeightAndWidthFromClass(w);
|
|
7091
|
+
if (y && S)
|
|
7092
|
+
a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${y}`, w)}`.trim(), a.height = y == null ? void 0 : y.replace("px", ""), a.width = S == null ? void 0 : S.replace("px", "");
|
|
7067
7093
|
else {
|
|
7068
|
-
const
|
|
7069
|
-
|
|
7094
|
+
const B = (E = find(n.attributes, { key: "height" })) == null ? void 0 : E.value, v = (_ = find(n.attributes, { key: "width" })) == null ? void 0 : _.value;
|
|
7095
|
+
B && v ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${v}px] h-[${B}px]`, w)}`.trim(), a.height = B, a.width = v) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
|
|
7070
7096
|
}
|
|
7071
|
-
return n.attributes = filter(n.attributes, (
|
|
7097
|
+
return n.attributes = filter(n.attributes, (B) => !includes(["style", "width", "height", "class"], B.key)), a.icon = stringify([n]), [a];
|
|
7072
7098
|
} else if (n.tagName == "option" && r && ((N = r.block) == null ? void 0 : N._type) === "Select")
|
|
7073
7099
|
return r.block.options.push({
|
|
7074
7100
|
label: getTextContent(n.children),
|
|
@@ -7185,12 +7211,12 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7185
7211
|
parentId: n = void 0,
|
|
7186
7212
|
position: a = -1
|
|
7187
7213
|
}) => {
|
|
7188
|
-
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", ""),
|
|
7189
|
-
const _ = has(
|
|
7190
|
-
return
|
|
7214
|
+
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) => {
|
|
7215
|
+
const _ = has(E, "styles_attrs.data-page-section");
|
|
7216
|
+
return E._type === "Box" && _;
|
|
7191
7217
|
}, b = useCallback(
|
|
7192
|
-
async (
|
|
7193
|
-
if (
|
|
7218
|
+
async (E) => {
|
|
7219
|
+
if (E.stopPropagation(), has(o, "component")) {
|
|
7194
7220
|
d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7195
7221
|
return;
|
|
7196
7222
|
}
|
|
@@ -7206,20 +7232,20 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7206
7232
|
{
|
|
7207
7233
|
onClick: l ? () => {
|
|
7208
7234
|
} : b,
|
|
7209
|
-
draggable:
|
|
7210
|
-
onDragStart: async (
|
|
7235
|
+
draggable: x ? "true" : "false",
|
|
7236
|
+
onDragStart: async (E) => {
|
|
7211
7237
|
const _ = await c({ library: r, block: o });
|
|
7212
7238
|
let N = n;
|
|
7213
7239
|
if (k(first(_)) && (N = null), !isEmpty(_)) {
|
|
7214
7240
|
const w = { blocks: _, uiLibrary: !0, parent: N };
|
|
7215
|
-
if (
|
|
7241
|
+
if (E.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
|
|
7216
7242
|
const y = new Image();
|
|
7217
7243
|
y.src = o.preview, y.onload = () => {
|
|
7218
|
-
|
|
7244
|
+
E.dataTransfer.setDragImage(y, 0, 0);
|
|
7219
7245
|
};
|
|
7220
7246
|
} else
|
|
7221
|
-
|
|
7222
|
-
|
|
7247
|
+
E.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7248
|
+
f(w), setTimeout(() => {
|
|
7223
7249
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7224
7250
|
}, 200);
|
|
7225
7251
|
}
|
|
@@ -7245,22 +7271,22 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7245
7271
|
] }) })
|
|
7246
7272
|
] });
|
|
7247
7273
|
}, UILibrarySection = ({ parentId: o, position: r }) => {
|
|
7248
|
-
const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((
|
|
7274
|
+
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);
|
|
7249
7275
|
useEffect(() => {
|
|
7250
|
-
c && c.length > 0 && (
|
|
7276
|
+
c && c.length > 0 && (x.current = new Fuse(c, {
|
|
7251
7277
|
keys: ["name", "label", "description", "group"],
|
|
7252
7278
|
threshold: 0.4,
|
|
7253
7279
|
ignoreLocation: !0
|
|
7254
7280
|
}));
|
|
7255
7281
|
}, [c]), useEffect(() => {
|
|
7256
|
-
if (!u.trim() || !
|
|
7282
|
+
if (!u.trim() || !x.current) {
|
|
7257
7283
|
m([]);
|
|
7258
7284
|
return;
|
|
7259
7285
|
}
|
|
7260
|
-
const
|
|
7261
|
-
m(
|
|
7286
|
+
const C = x.current.search(u).map((j) => j.item);
|
|
7287
|
+
m(C);
|
|
7262
7288
|
}, [u]);
|
|
7263
|
-
const
|
|
7289
|
+
const f = u.trim() && !isEmpty(h) ? h : c, k = groupBy(f, "group"), [b, A] = useState(null);
|
|
7264
7290
|
useEffect(() => {
|
|
7265
7291
|
if (isEmpty(keys(k))) {
|
|
7266
7292
|
A(null);
|
|
@@ -7271,13 +7297,13 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7271
7297
|
return;
|
|
7272
7298
|
}
|
|
7273
7299
|
}, [k, b]);
|
|
7274
|
-
const
|
|
7300
|
+
const E = get(k, b, []), _ = useRef(null), { t: N } = useTranslation(), w = (C) => {
|
|
7275
7301
|
_.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
|
|
7276
|
-
_.current && A(
|
|
7302
|
+
_.current && A(C);
|
|
7277
7303
|
}, 400);
|
|
7278
7304
|
}, y = () => {
|
|
7279
7305
|
i != null && i.id && p(i.id);
|
|
7280
|
-
},
|
|
7306
|
+
}, S = () => {
|
|
7281
7307
|
g("");
|
|
7282
7308
|
};
|
|
7283
7309
|
if (d)
|
|
@@ -7285,7 +7311,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7285
7311
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7286
7312
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7287
7313
|
] });
|
|
7288
|
-
const
|
|
7314
|
+
const B = filter(E, (C, j) => j % 2 === 0), v = filter(E, (C, j) => j % 2 === 1);
|
|
7289
7315
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7290
7316
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7291
7317
|
/* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
@@ -7294,14 +7320,14 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7294
7320
|
{
|
|
7295
7321
|
placeholder: N("Search blocks..."),
|
|
7296
7322
|
value: u,
|
|
7297
|
-
onChange: (
|
|
7323
|
+
onChange: (C) => g(C.target.value),
|
|
7298
7324
|
className: "w-full pl-8 pr-8"
|
|
7299
7325
|
}
|
|
7300
7326
|
),
|
|
7301
7327
|
u && /* @__PURE__ */ jsx(
|
|
7302
7328
|
"button",
|
|
7303
7329
|
{
|
|
7304
|
-
onClick:
|
|
7330
|
+
onClick: S,
|
|
7305
7331
|
className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
|
|
7306
7332
|
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
7307
7333
|
}
|
|
@@ -7319,7 +7345,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7319
7345
|
/* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
|
|
7320
7346
|
N("Retry")
|
|
7321
7347
|
] })
|
|
7322
|
-
] }) }) : map(k, (
|
|
7348
|
+
] }) }) : map(k, (C, j) => /* @__PURE__ */ jsxs(
|
|
7323
7349
|
"div",
|
|
7324
7350
|
{
|
|
7325
7351
|
onMouseEnter: () => w(j),
|
|
@@ -7345,23 +7371,23 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7345
7371
|
onMouseEnter: () => _.current ? clearTimeout(_.current) : null,
|
|
7346
7372
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7347
7373
|
children: [
|
|
7348
|
-
isEmpty(
|
|
7349
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7374
|
+
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: [
|
|
7375
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: B.map((C, j) => /* @__PURE__ */ jsx(
|
|
7350
7376
|
BlockCard,
|
|
7351
7377
|
{
|
|
7352
7378
|
parentId: o,
|
|
7353
7379
|
position: r,
|
|
7354
|
-
block:
|
|
7380
|
+
block: C,
|
|
7355
7381
|
library: i
|
|
7356
7382
|
},
|
|
7357
7383
|
`block-${j}`
|
|
7358
7384
|
)) }),
|
|
7359
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((
|
|
7385
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((C, j) => /* @__PURE__ */ jsx(
|
|
7360
7386
|
BlockCard,
|
|
7361
7387
|
{
|
|
7362
7388
|
parentId: o,
|
|
7363
7389
|
position: r,
|
|
7364
|
-
block:
|
|
7390
|
+
block: C,
|
|
7365
7391
|
library: i
|
|
7366
7392
|
},
|
|
7367
7393
|
`block-second-${j}`
|
|
@@ -7400,25 +7426,25 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7400
7426
|
error: c
|
|
7401
7427
|
}), g(!0);
|
|
7402
7428
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7403
|
-
const m = Object.entries(a).map(([
|
|
7404
|
-
const b = k, A = b.type || "partial",
|
|
7429
|
+
const m = Object.entries(a).map(([f, k]) => {
|
|
7430
|
+
const b = k, A = b.type || "partial", E = formatReadableName(A);
|
|
7405
7431
|
return {
|
|
7406
7432
|
type: "PartialBlock",
|
|
7407
7433
|
// Set the type to PartialBlock
|
|
7408
|
-
label: formatReadableName(b.name ||
|
|
7434
|
+
label: formatReadableName(b.name || f),
|
|
7409
7435
|
description: b.description || "",
|
|
7410
7436
|
icon: Globe,
|
|
7411
|
-
group:
|
|
7437
|
+
group: E,
|
|
7412
7438
|
// Use formatted type as group
|
|
7413
7439
|
category: "partial",
|
|
7414
|
-
partialBlockId:
|
|
7440
|
+
partialBlockId: f,
|
|
7415
7441
|
// Store the original ID as partialBlockId
|
|
7416
7442
|
_name: b.name
|
|
7417
7443
|
};
|
|
7418
|
-
}),
|
|
7444
|
+
}), x = uniq(map(m, "group"));
|
|
7419
7445
|
p({
|
|
7420
7446
|
blocks: m,
|
|
7421
|
-
groups:
|
|
7447
|
+
groups: x,
|
|
7422
7448
|
isLoading: !1,
|
|
7423
7449
|
error: null
|
|
7424
7450
|
}), g(!0);
|
|
@@ -7464,43 +7490,43 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7464
7490
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
|
|
7465
7491
|
}, 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" }) => {
|
|
7466
7492
|
var v;
|
|
7467
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (
|
|
7493
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (C) => C._id === n)) == null ? void 0 : v._type, [m, x] = useState("all"), [f, k] = useState(null), b = useRef(null);
|
|
7468
7494
|
useEffect(() => {
|
|
7469
|
-
const
|
|
7495
|
+
const C = setTimeout(() => {
|
|
7470
7496
|
var j;
|
|
7471
7497
|
(j = u.current) == null || j.focus();
|
|
7472
7498
|
}, 0);
|
|
7473
|
-
return () => clearTimeout(
|
|
7499
|
+
return () => clearTimeout(C);
|
|
7474
7500
|
}, [g]), useEffect(() => {
|
|
7475
|
-
d && (
|
|
7476
|
-
}, [d]), useEffect(() => (b.current = debounce((
|
|
7477
|
-
|
|
7501
|
+
d && (x("all"), k(null));
|
|
7502
|
+
}, [d]), useEffect(() => (b.current = debounce((C) => {
|
|
7503
|
+
x(C);
|
|
7478
7504
|
}, 500), () => {
|
|
7479
7505
|
b.current && b.current.cancel();
|
|
7480
7506
|
}), []);
|
|
7481
|
-
const A = useCallback((
|
|
7482
|
-
k(
|
|
7483
|
-
}, []),
|
|
7507
|
+
const A = useCallback((C) => {
|
|
7508
|
+
k(C), b.current && b.current(C);
|
|
7509
|
+
}, []), E = useCallback(() => {
|
|
7484
7510
|
k(null), b.current && b.current.cancel();
|
|
7485
|
-
}, []), _ = useCallback((
|
|
7486
|
-
b.current && b.current.cancel(),
|
|
7511
|
+
}, []), _ = useCallback((C) => {
|
|
7512
|
+
b.current && b.current.cancel(), x(C), k(null);
|
|
7487
7513
|
}, []), N = useMemo(
|
|
7488
7514
|
() => d ? values(r).filter(
|
|
7489
|
-
(
|
|
7515
|
+
(C) => {
|
|
7490
7516
|
var j, T;
|
|
7491
|
-
return (((j =
|
|
7517
|
+
return (((j = C.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = C.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
|
|
7492
7518
|
}
|
|
7493
7519
|
) : r,
|
|
7494
7520
|
[r, d]
|
|
7495
7521
|
), w = useMemo(
|
|
7496
7522
|
() => d ? o.filter(
|
|
7497
|
-
(
|
|
7498
|
-
) : o.filter((
|
|
7523
|
+
(C) => reject(filter(values(N), { group: C }), { hidden: !0 }).length > 0
|
|
7524
|
+
) : o.filter((C) => reject(filter(values(r), { group: C }), { hidden: !0 }).length > 0),
|
|
7499
7525
|
[r, N, o, d]
|
|
7500
7526
|
), y = useMemo(
|
|
7501
|
-
() => sortBy(w, (
|
|
7527
|
+
() => sortBy(w, (C) => CORE_GROUPS.indexOf(C) === -1 ? 99 : CORE_GROUPS.indexOf(C)),
|
|
7502
7528
|
[w]
|
|
7503
|
-
),
|
|
7529
|
+
), S = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), B = useMemo(() => m === "all" ? y : [m], [y, m]);
|
|
7504
7530
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7505
7531
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7506
7532
|
Input$1,
|
|
@@ -7510,7 +7536,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7510
7536
|
placeholder: i("Search blocks..."),
|
|
7511
7537
|
value: d,
|
|
7512
7538
|
className: "-ml-2",
|
|
7513
|
-
onChange: (
|
|
7539
|
+
onChange: (C) => p(C.target.value)
|
|
7514
7540
|
}
|
|
7515
7541
|
) }),
|
|
7516
7542
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
@@ -7520,22 +7546,22 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7520
7546
|
{
|
|
7521
7547
|
onClick: () => _("all"),
|
|
7522
7548
|
onMouseEnter: () => A("all"),
|
|
7523
|
-
onMouseLeave:
|
|
7524
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" ||
|
|
7549
|
+
onMouseLeave: E,
|
|
7550
|
+
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"}`,
|
|
7525
7551
|
children: i("All")
|
|
7526
7552
|
},
|
|
7527
7553
|
"sidebar-all"
|
|
7528
7554
|
),
|
|
7529
|
-
y.map((
|
|
7555
|
+
y.map((C) => /* @__PURE__ */ jsx(
|
|
7530
7556
|
"button",
|
|
7531
7557
|
{
|
|
7532
|
-
onClick: () => _(
|
|
7533
|
-
onMouseEnter: () => A(
|
|
7534
|
-
onMouseLeave:
|
|
7535
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m ===
|
|
7536
|
-
children: capitalize(i(
|
|
7558
|
+
onClick: () => _(C),
|
|
7559
|
+
onMouseEnter: () => A(C),
|
|
7560
|
+
onMouseLeave: E,
|
|
7561
|
+
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"}`,
|
|
7562
|
+
children: capitalize(i(C.toLowerCase()))
|
|
7537
7563
|
},
|
|
7538
|
-
`sidebar-${
|
|
7564
|
+
`sidebar-${C}`
|
|
7539
7565
|
))
|
|
7540
7566
|
] }) }) }),
|
|
7541
7567
|
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: w.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
@@ -7543,10 +7569,10 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7543
7569
|
' "',
|
|
7544
7570
|
d,
|
|
7545
7571
|
'"'
|
|
7546
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children:
|
|
7547
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7572
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: B.map((C) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7573
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(C.toLowerCase())) }),
|
|
7548
7574
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7549
|
-
m === "all" ? filter(values(
|
|
7575
|
+
m === "all" ? filter(values(S), { group: C }) : values(S),
|
|
7550
7576
|
{ hidden: !0 }
|
|
7551
7577
|
).map((j) => /* @__PURE__ */ jsx(
|
|
7552
7578
|
CoreBlock,
|
|
@@ -7558,7 +7584,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7558
7584
|
},
|
|
7559
7585
|
j.type
|
|
7560
7586
|
)) })
|
|
7561
|
-
] },
|
|
7587
|
+
] }, C)) }) }) })
|
|
7562
7588
|
] })
|
|
7563
7589
|
] });
|
|
7564
7590
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
@@ -7573,7 +7599,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7573
7599
|
}, [i, g, c]);
|
|
7574
7600
|
const m = useCallback(() => {
|
|
7575
7601
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7576
|
-
}, []),
|
|
7602
|
+
}, []), x = useChaiAddBlockTabs(), f = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
|
|
7577
7603
|
return useEffect(() => {
|
|
7578
7604
|
i === "library" && !b && c("core");
|
|
7579
7605
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7594,14 +7620,14 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7594
7620
|
b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7595
7621
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7596
7622
|
g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7597
|
-
|
|
7598
|
-
map(
|
|
7623
|
+
f ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7624
|
+
map(x, (A) => /* @__PURE__ */ jsx(TabsTrigger, { value: A.id, children: React__default.createElement(A.tab) }, `tab-add-block-${A.id}`))
|
|
7599
7625
|
] }),
|
|
7600
7626
|
/* @__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 }) }) }) }),
|
|
7601
7627
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
|
|
7602
7628
|
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 }) }) }) }),
|
|
7603
|
-
|
|
7604
|
-
map(
|
|
7629
|
+
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,
|
|
7630
|
+
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}`))
|
|
7605
7631
|
]
|
|
7606
7632
|
}
|
|
7607
7633
|
)
|
|
@@ -7911,19 +7937,19 @@ const Input = ({ node: o }) => {
|
|
|
7911
7937
|
var R;
|
|
7912
7938
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7913
7939
|
let p = null;
|
|
7914
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data:
|
|
7940
|
+
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, _ = (I) => {
|
|
7915
7941
|
I.stopPropagation(), !l.includes(m) && o.toggle();
|
|
7916
7942
|
}, N = (I) => {
|
|
7917
7943
|
I.isInternal && (p = I.isOpen, I.isOpen && I.close());
|
|
7918
7944
|
}, w = (I) => {
|
|
7919
7945
|
I.isInternal && p !== null && (p ? I.open() : I.close(), p = null);
|
|
7920
|
-
}, [y,
|
|
7946
|
+
}, [y, S] = useAtom$1(currentAddSelection), B = () => {
|
|
7921
7947
|
var I;
|
|
7922
|
-
v(), o.parent.isSelected ||
|
|
7948
|
+
v(), o.parent.isSelected || S((I = o == null ? void 0 : o.parent) == null ? void 0 : I.id);
|
|
7923
7949
|
}, v = () => {
|
|
7924
|
-
|
|
7925
|
-
},
|
|
7926
|
-
v(), I.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(),
|
|
7950
|
+
S(null);
|
|
7951
|
+
}, C = (I) => {
|
|
7952
|
+
v(), I.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), E(I);
|
|
7927
7953
|
};
|
|
7928
7954
|
useEffect(() => {
|
|
7929
7955
|
const I = setTimeout(() => {
|
|
@@ -7959,13 +7985,13 @@ const Input = ({ node: o }) => {
|
|
|
7959
7985
|
),
|
|
7960
7986
|
/* @__PURE__ */ jsx("br", {})
|
|
7961
7987
|
] });
|
|
7962
|
-
const L = useMemo(() => has(
|
|
7988
|
+
const L = useMemo(() => has(x, "_libBlockId") && !isEmpty(x._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [x, d]);
|
|
7963
7989
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7964
7990
|
"div",
|
|
7965
7991
|
{
|
|
7966
7992
|
onMouseEnter: () => g(m),
|
|
7967
7993
|
onMouseLeave: () => h(),
|
|
7968
|
-
onClick:
|
|
7994
|
+
onClick: C,
|
|
7969
7995
|
style: r,
|
|
7970
7996
|
"data-node-id": m,
|
|
7971
7997
|
ref: l.includes(m) ? null : n,
|
|
@@ -7987,7 +8013,7 @@ const Input = ({ node: o }) => {
|
|
|
7987
8013
|
onClick: (I) => {
|
|
7988
8014
|
I.stopPropagation(), T(o.childIndex);
|
|
7989
8015
|
},
|
|
7990
|
-
onMouseEnter:
|
|
8016
|
+
onMouseEnter: B,
|
|
7991
8017
|
onMouseLeave: v,
|
|
7992
8018
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7993
8019
|
children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
|
|
@@ -7998,12 +8024,12 @@ const Input = ({ node: o }) => {
|
|
|
7998
8024
|
{
|
|
7999
8025
|
className: cn(
|
|
8000
8026
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
|
|
8001
|
-
|
|
8002
|
-
k && canAcceptChildBlock(
|
|
8027
|
+
f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
|
|
8028
|
+
k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
|
|
8003
8029
|
(o == null ? void 0 : o.id) === y ? "bg-primary/10" : "",
|
|
8004
8030
|
b && "opacity-20",
|
|
8005
8031
|
l.includes(m) ? "opacity-50" : "",
|
|
8006
|
-
L &&
|
|
8032
|
+
L && f && "bg-primary/20 text-primary"
|
|
8007
8033
|
),
|
|
8008
8034
|
children: [
|
|
8009
8035
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -8011,7 +8037,7 @@ const Input = ({ node: o }) => {
|
|
|
8011
8037
|
"div",
|
|
8012
8038
|
{
|
|
8013
8039
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
8014
|
-
children: u && /* @__PURE__ */ jsx("button", { onClick: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${
|
|
8040
|
+
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"}` }) })
|
|
8015
8041
|
}
|
|
8016
8042
|
),
|
|
8017
8043
|
/* @__PURE__ */ jsxs(
|
|
@@ -8020,10 +8046,10 @@ const Input = ({ node: o }) => {
|
|
|
8020
8046
|
className: cn(
|
|
8021
8047
|
"leading-1 flex items-center",
|
|
8022
8048
|
L && "text-primary/60",
|
|
8023
|
-
L &&
|
|
8049
|
+
L && f && "text-primary/80"
|
|
8024
8050
|
),
|
|
8025
8051
|
children: [
|
|
8026
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
8052
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
|
|
8027
8053
|
A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
|
|
8028
8054
|
"div",
|
|
8029
8055
|
{
|
|
@@ -8031,7 +8057,7 @@ const Input = ({ node: o }) => {
|
|
|
8031
8057
|
onDoubleClick: (I) => {
|
|
8032
8058
|
I.stopPropagation(), o.edit(), o.deselect();
|
|
8033
8059
|
},
|
|
8034
|
-
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(
|
|
8060
|
+
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(x) })
|
|
8035
8061
|
}
|
|
8036
8062
|
)
|
|
8037
8063
|
]
|
|
@@ -8039,7 +8065,7 @@ const Input = ({ node: o }) => {
|
|
|
8039
8065
|
)
|
|
8040
8066
|
] }),
|
|
8041
8067
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
8042
|
-
canAddChildBlock(
|
|
8068
|
+
canAddChildBlock(x == null ? void 0 : x._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8043
8069
|
/* @__PURE__ */ jsx(
|
|
8044
8070
|
TooltipTrigger,
|
|
8045
8071
|
{
|
|
@@ -8344,7 +8370,7 @@ const Input = ({ node: o }) => {
|
|
|
8344
8370
|
console.warn("Failed to clear previous theme from localStorage:", o);
|
|
8345
8371
|
}
|
|
8346
8372
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8347
|
-
const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), [g, h] = useTheme(), m = useThemeOptions(), { t:
|
|
8373
|
+
const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), [g, h] = useTheme(), m = useThemeOptions(), { t: x } = useTranslation(), f = React.useCallback(
|
|
8348
8374
|
(w) => {
|
|
8349
8375
|
const y = { ...g };
|
|
8350
8376
|
setPreviousTheme(y), h(w), toast.success("Theme updated", {
|
|
@@ -8366,11 +8392,11 @@ const Input = ({ node: o }) => {
|
|
|
8366
8392
|
const w = d.find((y) => Object.keys(y)[0] === a);
|
|
8367
8393
|
if (w) {
|
|
8368
8394
|
const y = Object.values(w)[0];
|
|
8369
|
-
y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? (
|
|
8395
|
+
y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? (f(y), l("")) : console.error("Invalid preset structure:", y);
|
|
8370
8396
|
} else
|
|
8371
8397
|
console.error("Preset not found:", a);
|
|
8372
8398
|
}, b = (w) => {
|
|
8373
|
-
|
|
8399
|
+
f(w), l("");
|
|
8374
8400
|
}, A = useDebouncedCallback(
|
|
8375
8401
|
(w, y) => {
|
|
8376
8402
|
h(() => ({
|
|
@@ -8383,7 +8409,7 @@ const Input = ({ node: o }) => {
|
|
|
8383
8409
|
},
|
|
8384
8410
|
[g],
|
|
8385
8411
|
200
|
|
8386
|
-
),
|
|
8412
|
+
), E = React.useCallback(
|
|
8387
8413
|
(w) => {
|
|
8388
8414
|
h(() => ({
|
|
8389
8415
|
...g,
|
|
@@ -8394,12 +8420,12 @@ const Input = ({ node: o }) => {
|
|
|
8394
8420
|
), _ = useDebouncedCallback(
|
|
8395
8421
|
(w, y) => {
|
|
8396
8422
|
h(() => {
|
|
8397
|
-
const
|
|
8398
|
-
return r ? set(
|
|
8423
|
+
const S = get(g, `colors.${w}`);
|
|
8424
|
+
return r ? set(S, 1, y) : set(S, 0, y), {
|
|
8399
8425
|
...g,
|
|
8400
8426
|
colors: {
|
|
8401
8427
|
...g.colors,
|
|
8402
|
-
[w]:
|
|
8428
|
+
[w]: S
|
|
8403
8429
|
}
|
|
8404
8430
|
};
|
|
8405
8431
|
});
|
|
@@ -8407,37 +8433,37 @@ const Input = ({ node: o }) => {
|
|
|
8407
8433
|
[g],
|
|
8408
8434
|
200
|
|
8409
8435
|
), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([y]) => {
|
|
8410
|
-
const
|
|
8411
|
-
return
|
|
8436
|
+
const S = get(g, `colors.${y}.${r ? 1 : 0}`);
|
|
8437
|
+
return S ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8412
8438
|
/* @__PURE__ */ jsx(
|
|
8413
8439
|
ColorPickerInput,
|
|
8414
8440
|
{
|
|
8415
|
-
value:
|
|
8416
|
-
onChange: (
|
|
8441
|
+
value: S,
|
|
8442
|
+
onChange: (B) => _(y, B)
|
|
8417
8443
|
}
|
|
8418
8444
|
),
|
|
8419
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: y.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((
|
|
8445
|
+
/* @__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" : "") })
|
|
8420
8446
|
] }, y) : null;
|
|
8421
8447
|
}) });
|
|
8422
8448
|
return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8423
8449
|
/* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8424
8450
|
d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
|
|
8425
8451
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
8426
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8452
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: x("Presets") }),
|
|
8427
8453
|
/* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
|
|
8428
8454
|
/* @__PURE__ */ jsx(ImportIcon, { className: "h-4 w-4" }),
|
|
8429
|
-
|
|
8455
|
+
x("Import theme")
|
|
8430
8456
|
] }) })
|
|
8431
8457
|
] }),
|
|
8432
8458
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
|
|
8433
8459
|
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
|
|
8434
8460
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
|
|
8435
8461
|
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
|
|
8436
|
-
const y = Object.keys(w)[0],
|
|
8437
|
-
return /* @__PURE__ */ jsx(SelectItem, { value: y, children: capitalize(
|
|
8462
|
+
const y = Object.keys(w)[0], S = y.replaceAll("_", " ");
|
|
8463
|
+
return /* @__PURE__ */ jsx(SelectItem, { value: y, children: capitalize(S) }, y);
|
|
8438
8464
|
}) })
|
|
8439
8465
|
] }) }),
|
|
8440
|
-
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children:
|
|
8466
|
+
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children: x("Apply") }) })
|
|
8441
8467
|
] })
|
|
8442
8468
|
] }),
|
|
8443
8469
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
@@ -8451,7 +8477,7 @@ const Input = ({ node: o }) => {
|
|
|
8451
8477
|
{
|
|
8452
8478
|
label: w,
|
|
8453
8479
|
value: g.fontFamily[w.replace(/font-/g, "")] || y[Object.keys(y)[0]],
|
|
8454
|
-
onChange: (
|
|
8480
|
+
onChange: (S) => A(w, S)
|
|
8455
8481
|
},
|
|
8456
8482
|
w
|
|
8457
8483
|
)) }),
|
|
@@ -8464,7 +8490,7 @@ const Input = ({ node: o }) => {
|
|
|
8464
8490
|
] }),
|
|
8465
8491
|
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: g.borderRadius })
|
|
8466
8492
|
] }),
|
|
8467
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange:
|
|
8493
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: E }) })
|
|
8468
8494
|
] }),
|
|
8469
8495
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
8470
8496
|
(m == null ? void 0 : m.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
@@ -8989,11 +9015,11 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8989
9015
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8990
9016
|
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
|
|
8991
9017
|
useEffect(() => {
|
|
8992
|
-
var
|
|
8993
|
-
(
|
|
9018
|
+
var f;
|
|
9019
|
+
(f = h.current) == null || f.focus();
|
|
8994
9020
|
}, []);
|
|
8995
|
-
const
|
|
8996
|
-
const { usage: k } =
|
|
9021
|
+
const x = (f) => {
|
|
9022
|
+
const { usage: k } = f || {};
|
|
8997
9023
|
!l && k && g(k), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8998
9024
|
};
|
|
8999
9025
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -9014,12 +9040,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9014
9040
|
{
|
|
9015
9041
|
ref: h,
|
|
9016
9042
|
value: i,
|
|
9017
|
-
onChange: (
|
|
9043
|
+
onChange: (f) => c(f.target.value),
|
|
9018
9044
|
placeholder: r("Ask AI to edit content"),
|
|
9019
9045
|
className: "w-full",
|
|
9020
9046
|
rows: 3,
|
|
9021
|
-
onKeyDown: (
|
|
9022
|
-
|
|
9047
|
+
onKeyDown: (f) => {
|
|
9048
|
+
f.key === "Enter" && (f.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, x));
|
|
9023
9049
|
}
|
|
9024
9050
|
}
|
|
9025
9051
|
),
|
|
@@ -9029,7 +9055,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9029
9055
|
{
|
|
9030
9056
|
disabled: i.trim().length < 5 || a,
|
|
9031
9057
|
onClick: () => {
|
|
9032
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o, i,
|
|
9058
|
+
m.current && clearTimeout(m.current), g(void 0), n("content", o, i, x);
|
|
9033
9059
|
},
|
|
9034
9060
|
variant: "default",
|
|
9035
9061
|
className: "w-fit",
|
|
@@ -9061,8 +9087,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9061
9087
|
/* @__PURE__ */ jsx(
|
|
9062
9088
|
QuickPrompts,
|
|
9063
9089
|
{
|
|
9064
|
-
onClick: (
|
|
9065
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o,
|
|
9090
|
+
onClick: (f) => {
|
|
9091
|
+
m.current && clearTimeout(m.current), g(void 0), n("content", o, f, x);
|
|
9066
9092
|
}
|
|
9067
9093
|
}
|
|
9068
9094
|
)
|
|
@@ -9079,8 +9105,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9079
9105
|
const m = async () => {
|
|
9080
9106
|
try {
|
|
9081
9107
|
d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
|
|
9082
|
-
} catch (
|
|
9083
|
-
u(
|
|
9108
|
+
} catch (x) {
|
|
9109
|
+
u(x);
|
|
9084
9110
|
} finally {
|
|
9085
9111
|
d(!1);
|
|
9086
9112
|
}
|
|
@@ -9088,8 +9114,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9088
9114
|
return /* @__PURE__ */ jsx(
|
|
9089
9115
|
Accordion,
|
|
9090
9116
|
{
|
|
9091
|
-
onValueChange: (
|
|
9092
|
-
g(
|
|
9117
|
+
onValueChange: (x) => {
|
|
9118
|
+
g(x !== "");
|
|
9093
9119
|
},
|
|
9094
9120
|
type: "single",
|
|
9095
9121
|
collapsible: !0,
|
|
@@ -9101,12 +9127,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9101
9127
|
{
|
|
9102
9128
|
ref: l,
|
|
9103
9129
|
value: n,
|
|
9104
|
-
onChange: (
|
|
9130
|
+
onChange: (x) => a(x.target.value),
|
|
9105
9131
|
placeholder: o("Tell about this page eg this page is about"),
|
|
9106
9132
|
className: "mt-1 w-full",
|
|
9107
9133
|
rows: 10,
|
|
9108
|
-
onKeyDown: (
|
|
9109
|
-
|
|
9134
|
+
onKeyDown: (x) => {
|
|
9135
|
+
x.key === "Enter" && (x.preventDefault(), m());
|
|
9110
9136
|
}
|
|
9111
9137
|
}
|
|
9112
9138
|
),
|
|
@@ -9223,13 +9249,13 @@ function AIChatPanel() {
|
|
|
9223
9249
|
content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
|
|
9224
9250
|
timestamp: /* @__PURE__ */ new Date()
|
|
9225
9251
|
};
|
|
9226
|
-
r((
|
|
9252
|
+
r((E) => [...E, A]), i(!1), d(null);
|
|
9227
9253
|
}, 1500);
|
|
9228
9254
|
}, m = (b) => {
|
|
9229
9255
|
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
|
|
9230
|
-
},
|
|
9231
|
-
var
|
|
9232
|
-
const A = (
|
|
9256
|
+
}, x = (b) => {
|
|
9257
|
+
var E;
|
|
9258
|
+
const A = (E = b.target.files) == null ? void 0 : E[0];
|
|
9233
9259
|
if (A) {
|
|
9234
9260
|
const _ = new FileReader();
|
|
9235
9261
|
_.onload = (N) => {
|
|
@@ -9237,7 +9263,7 @@ function AIChatPanel() {
|
|
|
9237
9263
|
d((w = N.target) == null ? void 0 : w.result);
|
|
9238
9264
|
}, _.readAsDataURL(A);
|
|
9239
9265
|
}
|
|
9240
|
-
},
|
|
9266
|
+
}, f = () => {
|
|
9241
9267
|
var b;
|
|
9242
9268
|
(b = p.current) == null || b.click();
|
|
9243
9269
|
}, k = () => {
|
|
@@ -9304,14 +9330,14 @@ function AIChatPanel() {
|
|
|
9304
9330
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9305
9331
|
}
|
|
9306
9332
|
),
|
|
9307
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange:
|
|
9333
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: x, accept: "image/*", className: "hidden" }),
|
|
9308
9334
|
/* @__PURE__ */ jsx(
|
|
9309
9335
|
Button,
|
|
9310
9336
|
{
|
|
9311
9337
|
size: "icon",
|
|
9312
9338
|
variant: "ghost",
|
|
9313
9339
|
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9314
|
-
onClick:
|
|
9340
|
+
onClick: f,
|
|
9315
9341
|
children: /* @__PURE__ */ jsx(Image$1, { className: "h-4 w-4 text-muted-foreground" })
|
|
9316
9342
|
}
|
|
9317
9343
|
)
|
|
@@ -9429,7 +9455,7 @@ const AiAssistant = () => {
|
|
|
9429
9455
|
preloadedAttributes: r = [],
|
|
9430
9456
|
onAttributesChange: n
|
|
9431
9457
|
}) {
|
|
9432
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""),
|
|
9458
|
+
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();
|
|
9433
9459
|
useEffect(() => {
|
|
9434
9460
|
l(r);
|
|
9435
9461
|
}, [r]);
|
|
@@ -9443,9 +9469,9 @@ const AiAssistant = () => {
|
|
|
9443
9469
|
n(y), l(a), c(""), p(""), m("");
|
|
9444
9470
|
}
|
|
9445
9471
|
}, A = (y) => {
|
|
9446
|
-
const
|
|
9447
|
-
n(
|
|
9448
|
-
},
|
|
9472
|
+
const S = a.filter((B, v) => v !== y);
|
|
9473
|
+
n(S), l(S);
|
|
9474
|
+
}, E = (y) => {
|
|
9449
9475
|
g(y), c(a[y].key), p(a[y].value);
|
|
9450
9476
|
}, _ = () => {
|
|
9451
9477
|
if (i.startsWith("@")) {
|
|
@@ -9459,23 +9485,23 @@ const AiAssistant = () => {
|
|
|
9459
9485
|
}, N = (y) => {
|
|
9460
9486
|
y.key === "Enter" && !y.shiftKey && (y.preventDefault(), u !== null ? _() : b());
|
|
9461
9487
|
}, w = useCallback((y) => {
|
|
9462
|
-
const
|
|
9488
|
+
const S = (C) => /[.,!?;:]/.test(C), B = (C, j, T) => {
|
|
9463
9489
|
let L = "", R = "";
|
|
9464
|
-
const I = j > 0 ?
|
|
9465
|
-
return j > 0 && (I === "." || !
|
|
9490
|
+
const I = j > 0 ? C[j - 1] : "", D = j < C.length ? C[j] : "";
|
|
9491
|
+
return j > 0 && (I === "." || !S(I) && I !== " ") && (L = " "), j < C.length && !S(D) && D !== " " && (R = " "), {
|
|
9466
9492
|
text: L + T + R,
|
|
9467
9493
|
prefixLength: L.length,
|
|
9468
9494
|
suffixLength: R.length
|
|
9469
9495
|
};
|
|
9470
|
-
}, v =
|
|
9496
|
+
}, v = f.current;
|
|
9471
9497
|
if (v) {
|
|
9472
|
-
const
|
|
9473
|
-
if (T >
|
|
9474
|
-
const O = `{{${y}}}`, { text: P } =
|
|
9498
|
+
const C = v.selectionStart || 0, j = v.value || "", T = v.selectionEnd || C;
|
|
9499
|
+
if (T > C) {
|
|
9500
|
+
const O = `{{${y}}}`, { text: P } = B(j, C, O), $ = j.slice(0, C) + P + j.slice(T);
|
|
9475
9501
|
p($);
|
|
9476
9502
|
return;
|
|
9477
9503
|
}
|
|
9478
|
-
const R = `{{${y}}}`, { text: I } =
|
|
9504
|
+
const R = `{{${y}}}`, { text: I } = B(j, C, R), D = j.slice(0, C) + I + j.slice(C);
|
|
9479
9505
|
p(D);
|
|
9480
9506
|
}
|
|
9481
9507
|
}, []);
|
|
@@ -9498,7 +9524,7 @@ const AiAssistant = () => {
|
|
|
9498
9524
|
autoCorrect: "off",
|
|
9499
9525
|
spellCheck: "false",
|
|
9500
9526
|
id: "attrKey",
|
|
9501
|
-
ref:
|
|
9527
|
+
ref: x,
|
|
9502
9528
|
value: i,
|
|
9503
9529
|
onChange: (y) => c(y.target.value),
|
|
9504
9530
|
placeholder: "Enter Key",
|
|
@@ -9519,7 +9545,7 @@ const AiAssistant = () => {
|
|
|
9519
9545
|
spellCheck: "false",
|
|
9520
9546
|
id: "attrValue",
|
|
9521
9547
|
rows: 2,
|
|
9522
|
-
ref:
|
|
9548
|
+
ref: f,
|
|
9523
9549
|
value: d,
|
|
9524
9550
|
onChange: (y) => p(y.target.value),
|
|
9525
9551
|
onKeyDown: N,
|
|
@@ -9534,16 +9560,16 @@ const AiAssistant = () => {
|
|
|
9534
9560
|
]
|
|
9535
9561
|
}
|
|
9536
9562
|
),
|
|
9537
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((y,
|
|
9563
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((y, S) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9538
9564
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9539
9565
|
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: y.key }),
|
|
9540
9566
|
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: y.value.toString() })
|
|
9541
9567
|
] }),
|
|
9542
9568
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9543
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9544
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(
|
|
9569
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(S), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9570
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(S), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9545
9571
|
] })
|
|
9546
|
-
] },
|
|
9572
|
+
] }, S)) })
|
|
9547
9573
|
] });
|
|
9548
9574
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9549
9575
|
const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -9712,28 +9738,28 @@ const RootLayout = () => {
|
|
|
9712
9738
|
n(r === y ? null : y);
|
|
9713
9739
|
},
|
|
9714
9740
|
[r]
|
|
9715
|
-
), { t:
|
|
9741
|
+
), { t: x } = useTranslation(), f = useMemo(
|
|
9716
9742
|
() => [...p, ...u, ...g],
|
|
9717
9743
|
[p, u, g]
|
|
9718
|
-
), k = useBuilderProp("htmlDir", "ltr"), b = find(
|
|
9744
|
+
), k = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: r }) ?? first(f), A = get(b, "width", DEFAULT_PANEL_WIDTH);
|
|
9719
9745
|
useEffect(() => {
|
|
9720
9746
|
if (r !== null) {
|
|
9721
|
-
const y = find(
|
|
9747
|
+
const y = find(f, { id: r });
|
|
9722
9748
|
y && get(y, "view", "standard") === "standard" && (a.current = r, i(get(y, "width", DEFAULT_PANEL_WIDTH)));
|
|
9723
9749
|
}
|
|
9724
|
-
}, [r,
|
|
9725
|
-
const
|
|
9750
|
+
}, [r, f]);
|
|
9751
|
+
const E = useMemo(() => {
|
|
9726
9752
|
if (r === null) return 0;
|
|
9727
|
-
const y = find(
|
|
9753
|
+
const y = find(f, { id: r });
|
|
9728
9754
|
return get(y, "view", "standard") === "standard" ? A : l;
|
|
9729
|
-
}, [r, A, l,
|
|
9755
|
+
}, [r, A, l, f]), _ = useCallback(() => {
|
|
9730
9756
|
n(a.current);
|
|
9731
9757
|
}, [n]), N = useCallback(() => {
|
|
9732
9758
|
n("outline");
|
|
9733
9759
|
}, [n]);
|
|
9734
9760
|
useEffect(() => {
|
|
9735
|
-
find(
|
|
9736
|
-
}, [r,
|
|
9761
|
+
find(f, { id: r }) || n("outline");
|
|
9762
|
+
}, [r, f]);
|
|
9737
9763
|
const w = useCallback(
|
|
9738
9764
|
(y) => {
|
|
9739
9765
|
m(y);
|
|
@@ -9750,40 +9776,40 @@ const RootLayout = () => {
|
|
|
9750
9776
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9751
9777
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9752
9778
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9753
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((y,
|
|
9779
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((y, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9754
9780
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
|
|
9755
9781
|
position: "top",
|
|
9756
9782
|
panelId: y.id,
|
|
9757
9783
|
isActive: r === y.id,
|
|
9758
9784
|
show: () => w(y.id)
|
|
9759
9785
|
}) }),
|
|
9760
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9761
|
-
] }, "button-top-" +
|
|
9786
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
|
|
9787
|
+
] }, "button-top-" + S)) }),
|
|
9762
9788
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9763
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y,
|
|
9789
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9764
9790
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
|
|
9765
9791
|
position: "bottom",
|
|
9766
9792
|
panelId: y.id,
|
|
9767
9793
|
isActive: r === y.id,
|
|
9768
9794
|
show: () => w(y.id)
|
|
9769
9795
|
}) }),
|
|
9770
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9771
|
-
] }, "button-bottom-" +
|
|
9796
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
|
|
9797
|
+
] }, "button-bottom-" + S)) })
|
|
9772
9798
|
] }),
|
|
9773
9799
|
/* @__PURE__ */ jsx(
|
|
9774
9800
|
motion.div,
|
|
9775
9801
|
{
|
|
9776
9802
|
id: "left-panel",
|
|
9777
9803
|
className: "h-full max-h-full border-r border-border",
|
|
9778
|
-
initial: { width:
|
|
9779
|
-
animate: { width:
|
|
9804
|
+
initial: { width: E },
|
|
9805
|
+
animate: { width: E },
|
|
9780
9806
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
9781
9807
|
children: r !== null && get(b, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
|
|
9782
9808
|
/* @__PURE__ */ jsx(
|
|
9783
9809
|
"div",
|
|
9784
9810
|
{
|
|
9785
9811
|
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
|
|
9786
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9812
|
+
children: /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9787
9813
|
}
|
|
9788
9814
|
),
|
|
9789
9815
|
/* @__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), {}) }) })
|
|
@@ -9806,11 +9832,11 @@ const RootLayout = () => {
|
|
|
9806
9832
|
/* @__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: [
|
|
9807
9833
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9808
9834
|
" ",
|
|
9809
|
-
|
|
9835
|
+
x("AI Assistant")
|
|
9810
9836
|
] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9811
9837
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9812
9838
|
/* @__PURE__ */ jsx(Palette, { className: "w-4 h-4 text-gray-600" }),
|
|
9813
|
-
|
|
9839
|
+
x("Theme Settings")
|
|
9814
9840
|
] }),
|
|
9815
9841
|
/* @__PURE__ */ jsx(
|
|
9816
9842
|
Button,
|
|
@@ -9841,7 +9867,7 @@ const RootLayout = () => {
|
|
|
9841
9867
|
children: [
|
|
9842
9868
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
9843
9869
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9844
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9870
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9845
9871
|
] }) }),
|
|
9846
9872
|
/* @__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), {
|
|
9847
9873
|
close: N
|
|
@@ -9853,7 +9879,7 @@ const RootLayout = () => {
|
|
|
9853
9879
|
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: [
|
|
9854
9880
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
9855
9881
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9856
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9882
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9857
9883
|
] }) }),
|
|
9858
9884
|
/* @__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), {
|
|
9859
9885
|
close: N
|
|
@@ -9879,7 +9905,7 @@ const RootLayout = () => {
|
|
|
9879
9905
|
/* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
|
|
9880
9906
|
/* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
|
|
9881
9907
|
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
|
|
9882
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9908
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9883
9909
|
] }),
|
|
9884
9910
|
/* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
|
|
9885
9911
|
] }),
|
|
@@ -9923,36 +9949,36 @@ const RootLayout = () => {
|
|
|
9923
9949
|
}) => {
|
|
9924
9950
|
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
|
|
9925
9951
|
if (!l.trim()) return a;
|
|
9926
|
-
const
|
|
9952
|
+
const f = l.toLowerCase();
|
|
9927
9953
|
return Object.fromEntries(
|
|
9928
9954
|
Object.entries(a).filter(([k, b]) => {
|
|
9929
9955
|
var A;
|
|
9930
|
-
return (k == null ? void 0 : k.toLowerCase().includes(
|
|
9956
|
+
return (k == null ? void 0 : k.toLowerCase().includes(f)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(f));
|
|
9931
9957
|
})
|
|
9932
9958
|
);
|
|
9933
|
-
}, [a, l]), h = (
|
|
9959
|
+
}, [a, l]), h = (f) => {
|
|
9934
9960
|
d(!0), u({
|
|
9935
|
-
x:
|
|
9936
|
-
y:
|
|
9961
|
+
x: f.clientX - r.x,
|
|
9962
|
+
y: f.clientY - r.y
|
|
9937
9963
|
});
|
|
9938
|
-
}, m = (
|
|
9964
|
+
}, m = (f) => {
|
|
9939
9965
|
if (!c) return;
|
|
9940
|
-
const k =
|
|
9941
|
-
n(y,
|
|
9942
|
-
},
|
|
9966
|
+
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)), S = Math.max(0, Math.min(b, w));
|
|
9967
|
+
n(y, S);
|
|
9968
|
+
}, x = () => {
|
|
9943
9969
|
d(!1);
|
|
9944
9970
|
};
|
|
9945
9971
|
return useEffect(() => {
|
|
9946
|
-
const
|
|
9972
|
+
const f = () => {
|
|
9947
9973
|
c && d(!1);
|
|
9948
9974
|
};
|
|
9949
|
-
return window.addEventListener("mouseup",
|
|
9975
|
+
return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
|
|
9950
9976
|
}, [c]), !r || r.x < 0 || r.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
9951
9977
|
"div",
|
|
9952
9978
|
{
|
|
9953
9979
|
onMouseDown: h,
|
|
9954
9980
|
onMouseMove: m,
|
|
9955
|
-
onMouseUp:
|
|
9981
|
+
onMouseUp: x,
|
|
9956
9982
|
className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
|
|
9957
9983
|
style: {
|
|
9958
9984
|
left: r.x,
|
|
@@ -9994,13 +10020,13 @@ const RootLayout = () => {
|
|
|
9994
10020
|
placeholder: "Search features...",
|
|
9995
10021
|
className: "w-full pl-8",
|
|
9996
10022
|
value: l,
|
|
9997
|
-
onChange: (
|
|
10023
|
+
onChange: (f) => i(f.target.value),
|
|
9998
10024
|
autoFocus: !0
|
|
9999
10025
|
}
|
|
10000
10026
|
)
|
|
10001
10027
|
] })
|
|
10002
10028
|
] }),
|
|
10003
|
-
/* @__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(([
|
|
10029
|
+
/* @__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: [
|
|
10004
10030
|
'No features found matching "',
|
|
10005
10031
|
l,
|
|
10006
10032
|
'"'
|
|
@@ -10111,79 +10137,79 @@ const RootLayout = () => {
|
|
|
10111
10137
|
for (const i of r.p)
|
|
10112
10138
|
l.add(i);
|
|
10113
10139
|
return l;
|
|
10114
|
-
}, 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, ...
|
|
10115
|
-
var
|
|
10116
|
-
return (
|
|
10117
|
-
}, g = (m,
|
|
10118
|
-
var
|
|
10119
|
-
return (
|
|
10140
|
+
}, 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) => {
|
|
10141
|
+
var f;
|
|
10142
|
+
return (f = m.unstable_onInit) == null ? void 0 : f.call(m, x);
|
|
10143
|
+
}, g = (m, x) => {
|
|
10144
|
+
var f;
|
|
10145
|
+
return (f = m.onMount) == null ? void 0 : f.call(m, x);
|
|
10120
10146
|
}, ...h) => {
|
|
10121
|
-
const m = h[0] || ((
|
|
10122
|
-
let
|
|
10123
|
-
return
|
|
10124
|
-
}),
|
|
10125
|
-
let
|
|
10126
|
-
const v = (
|
|
10147
|
+
const m = h[0] || ((S) => {
|
|
10148
|
+
let B = o.get(S);
|
|
10149
|
+
return B || (B = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(S, B), u == null || u(S, y)), B;
|
|
10150
|
+
}), x = h[1] || (() => {
|
|
10151
|
+
let S, B;
|
|
10152
|
+
const v = (C) => {
|
|
10127
10153
|
try {
|
|
10128
|
-
|
|
10154
|
+
C();
|
|
10129
10155
|
} catch (j) {
|
|
10130
|
-
|
|
10156
|
+
S || (S = !0, B = j);
|
|
10131
10157
|
}
|
|
10132
10158
|
};
|
|
10133
10159
|
do {
|
|
10134
10160
|
c.f && v(c.f);
|
|
10135
|
-
const
|
|
10161
|
+
const C = /* @__PURE__ */ new Set(), j = C.add.bind(C);
|
|
10136
10162
|
a.forEach((T) => {
|
|
10137
10163
|
var L;
|
|
10138
10164
|
return (L = r.get(T)) == null ? void 0 : L.l.forEach(j);
|
|
10139
|
-
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(),
|
|
10165
|
+
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), C.forEach(v), a.size && f();
|
|
10140
10166
|
} while (a.size || i.size || l.size);
|
|
10141
|
-
if (
|
|
10142
|
-
throw
|
|
10143
|
-
}),
|
|
10144
|
-
const
|
|
10145
|
-
for (;
|
|
10146
|
-
const j =
|
|
10167
|
+
if (S)
|
|
10168
|
+
throw B;
|
|
10169
|
+
}), f = h[2] || (() => {
|
|
10170
|
+
const S = [], B = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), C = Array.from(a);
|
|
10171
|
+
for (; C.length; ) {
|
|
10172
|
+
const j = C[C.length - 1], T = m(j);
|
|
10147
10173
|
if (v.has(j)) {
|
|
10148
|
-
|
|
10174
|
+
C.pop();
|
|
10149
10175
|
continue;
|
|
10150
10176
|
}
|
|
10151
|
-
if (
|
|
10152
|
-
n.get(j) === T.n &&
|
|
10177
|
+
if (B.has(j)) {
|
|
10178
|
+
n.get(j) === T.n && S.push([j, T]), v.add(j), C.pop();
|
|
10153
10179
|
continue;
|
|
10154
10180
|
}
|
|
10155
|
-
|
|
10181
|
+
B.add(j);
|
|
10156
10182
|
for (const L of getMountedOrPendingDependents(j, T, r))
|
|
10157
|
-
|
|
10183
|
+
B.has(L) || C.push(L);
|
|
10158
10184
|
}
|
|
10159
|
-
for (let j =
|
|
10160
|
-
const [T, L] =
|
|
10185
|
+
for (let j = S.length - 1; j >= 0; --j) {
|
|
10186
|
+
const [T, L] = S[j];
|
|
10161
10187
|
let R = !1;
|
|
10162
10188
|
for (const I of L.d.keys())
|
|
10163
10189
|
if (I !== T && a.has(I)) {
|
|
10164
10190
|
R = !0;
|
|
10165
10191
|
break;
|
|
10166
10192
|
}
|
|
10167
|
-
R && (k(T),
|
|
10193
|
+
R && (k(T), E(T)), n.delete(T);
|
|
10168
10194
|
}
|
|
10169
|
-
}), k = h[3] || ((
|
|
10170
|
-
var
|
|
10171
|
-
const
|
|
10172
|
-
if (isAtomStateInitialized(
|
|
10195
|
+
}), k = h[3] || ((S) => {
|
|
10196
|
+
var B, v;
|
|
10197
|
+
const C = m(S);
|
|
10198
|
+
if (isAtomStateInitialized(C) && (r.has(S) && n.get(S) !== C.n || Array.from(C.d).every(
|
|
10173
10199
|
([P, $]) => (
|
|
10174
10200
|
// Recursively, read the atom state of the dependency, and
|
|
10175
10201
|
// check if the atom epoch number is unchanged
|
|
10176
10202
|
k(P).n === $
|
|
10177
10203
|
)
|
|
10178
10204
|
)))
|
|
10179
|
-
return
|
|
10180
|
-
|
|
10205
|
+
return C;
|
|
10206
|
+
C.d.clear();
|
|
10181
10207
|
let j = !0;
|
|
10182
10208
|
const T = () => {
|
|
10183
|
-
r.has(
|
|
10209
|
+
r.has(S) && (E(S), f(), x());
|
|
10184
10210
|
}, L = (P) => {
|
|
10185
10211
|
var $;
|
|
10186
|
-
if (isSelfAtom(
|
|
10212
|
+
if (isSelfAtom(S, P)) {
|
|
10187
10213
|
const H = m(P);
|
|
10188
10214
|
if (!isAtomStateInitialized(H))
|
|
10189
10215
|
if (hasInitialValue(P))
|
|
@@ -10196,7 +10222,7 @@ const RootLayout = () => {
|
|
|
10196
10222
|
try {
|
|
10197
10223
|
return returnAtomValue(M);
|
|
10198
10224
|
} finally {
|
|
10199
|
-
|
|
10225
|
+
C.d.set(P, M.n), isPendingPromise(C.v) && addPendingPromiseToDependency(S, C.v, M), ($ = r.get(P)) == null || $.t.add(S), j || T();
|
|
10200
10226
|
}
|
|
10201
10227
|
};
|
|
10202
10228
|
let R, I;
|
|
@@ -10205,100 +10231,100 @@ const RootLayout = () => {
|
|
|
10205
10231
|
return R || (R = new AbortController()), R.signal;
|
|
10206
10232
|
},
|
|
10207
10233
|
get setSelf() {
|
|
10208
|
-
return !I && isActuallyWritableAtom(
|
|
10234
|
+
return !I && isActuallyWritableAtom(S) && (I = (...P) => {
|
|
10209
10235
|
if (!j)
|
|
10210
10236
|
try {
|
|
10211
|
-
return A(
|
|
10237
|
+
return A(S, ...P);
|
|
10212
10238
|
} finally {
|
|
10213
|
-
|
|
10239
|
+
f(), x();
|
|
10214
10240
|
}
|
|
10215
10241
|
}), I;
|
|
10216
10242
|
}
|
|
10217
|
-
}, O =
|
|
10243
|
+
}, O = C.n;
|
|
10218
10244
|
try {
|
|
10219
|
-
const P = d(
|
|
10220
|
-
return setAtomStateValueOrPromise(
|
|
10245
|
+
const P = d(S, L, D);
|
|
10246
|
+
return setAtomStateValueOrPromise(S, P, m), isPromiseLike$1(P) && ((B = P.onCancel) == null || B.call(P, () => R == null ? void 0 : R.abort()), P.then(
|
|
10221
10247
|
T,
|
|
10222
10248
|
T
|
|
10223
|
-
)),
|
|
10249
|
+
)), C;
|
|
10224
10250
|
} catch (P) {
|
|
10225
|
-
return delete
|
|
10251
|
+
return delete C.v, C.e = P, ++C.n, C;
|
|
10226
10252
|
} finally {
|
|
10227
|
-
j = !1, O !==
|
|
10253
|
+
j = !1, O !== C.n && n.get(S) === O && (n.set(S, C.n), a.add(S), (v = c.c) == null || v.call(c, S));
|
|
10228
10254
|
}
|
|
10229
|
-
}), b = h[4] || ((
|
|
10230
|
-
const
|
|
10231
|
-
for (;
|
|
10232
|
-
const v =
|
|
10233
|
-
for (const j of getMountedOrPendingDependents(v,
|
|
10255
|
+
}), b = h[4] || ((S) => {
|
|
10256
|
+
const B = [S];
|
|
10257
|
+
for (; B.length; ) {
|
|
10258
|
+
const v = B.pop(), C = m(v);
|
|
10259
|
+
for (const j of getMountedOrPendingDependents(v, C, r)) {
|
|
10234
10260
|
const T = m(j);
|
|
10235
|
-
n.set(j, T.n),
|
|
10261
|
+
n.set(j, T.n), B.push(j);
|
|
10236
10262
|
}
|
|
10237
10263
|
}
|
|
10238
|
-
}), A = h[5] || ((
|
|
10264
|
+
}), A = h[5] || ((S, ...B) => {
|
|
10239
10265
|
let v = !0;
|
|
10240
|
-
const
|
|
10266
|
+
const C = (T) => returnAtomValue(k(T)), j = (T, ...L) => {
|
|
10241
10267
|
var R;
|
|
10242
10268
|
const I = m(T);
|
|
10243
10269
|
try {
|
|
10244
|
-
if (isSelfAtom(
|
|
10270
|
+
if (isSelfAtom(S, T)) {
|
|
10245
10271
|
if (!hasInitialValue(T))
|
|
10246
10272
|
throw new Error("atom not writable");
|
|
10247
10273
|
const D = I.n, O = L[0];
|
|
10248
|
-
setAtomStateValueOrPromise(T, O, m),
|
|
10274
|
+
setAtomStateValueOrPromise(T, O, m), E(T), D !== I.n && (a.add(T), (R = c.c) == null || R.call(c, T), b(T));
|
|
10249
10275
|
return;
|
|
10250
10276
|
} else
|
|
10251
10277
|
return A(T, ...L);
|
|
10252
10278
|
} finally {
|
|
10253
|
-
v || (
|
|
10279
|
+
v || (f(), x());
|
|
10254
10280
|
}
|
|
10255
10281
|
};
|
|
10256
10282
|
try {
|
|
10257
|
-
return p(
|
|
10283
|
+
return p(S, C, j, ...B);
|
|
10258
10284
|
} finally {
|
|
10259
10285
|
v = !1;
|
|
10260
10286
|
}
|
|
10261
|
-
}),
|
|
10262
|
-
var
|
|
10263
|
-
const v = m(
|
|
10264
|
-
if (
|
|
10287
|
+
}), E = h[6] || ((S) => {
|
|
10288
|
+
var B;
|
|
10289
|
+
const v = m(S), C = r.get(S);
|
|
10290
|
+
if (C && !isPendingPromise(v.v)) {
|
|
10265
10291
|
for (const [j, T] of v.d)
|
|
10266
|
-
if (!
|
|
10292
|
+
if (!C.d.has(j)) {
|
|
10267
10293
|
const L = m(j);
|
|
10268
|
-
_(j).t.add(
|
|
10294
|
+
_(j).t.add(S), C.d.add(j), T !== L.n && (a.add(j), (B = c.c) == null || B.call(c, j), b(j));
|
|
10269
10295
|
}
|
|
10270
|
-
for (const j of
|
|
10296
|
+
for (const j of C.d || [])
|
|
10271
10297
|
if (!v.d.has(j)) {
|
|
10272
|
-
|
|
10298
|
+
C.d.delete(j);
|
|
10273
10299
|
const T = N(j);
|
|
10274
|
-
T == null || T.t.delete(
|
|
10300
|
+
T == null || T.t.delete(S);
|
|
10275
10301
|
}
|
|
10276
10302
|
}
|
|
10277
|
-
}), _ = h[7] || ((
|
|
10278
|
-
var
|
|
10279
|
-
const v = m(
|
|
10280
|
-
let
|
|
10281
|
-
if (!
|
|
10282
|
-
k(
|
|
10303
|
+
}), _ = h[7] || ((S) => {
|
|
10304
|
+
var B;
|
|
10305
|
+
const v = m(S);
|
|
10306
|
+
let C = r.get(S);
|
|
10307
|
+
if (!C) {
|
|
10308
|
+
k(S);
|
|
10283
10309
|
for (const j of v.d.keys())
|
|
10284
|
-
_(j).t.add(
|
|
10285
|
-
if (
|
|
10310
|
+
_(j).t.add(S);
|
|
10311
|
+
if (C = {
|
|
10286
10312
|
l: /* @__PURE__ */ new Set(),
|
|
10287
10313
|
d: new Set(v.d.keys()),
|
|
10288
10314
|
t: /* @__PURE__ */ new Set()
|
|
10289
|
-
}, r.set(
|
|
10315
|
+
}, r.set(S, C), (B = c.m) == null || B.call(c, S), isActuallyWritableAtom(S)) {
|
|
10290
10316
|
const j = () => {
|
|
10291
10317
|
let T = !0;
|
|
10292
10318
|
const L = (...R) => {
|
|
10293
10319
|
try {
|
|
10294
|
-
return A(
|
|
10320
|
+
return A(S, ...R);
|
|
10295
10321
|
} finally {
|
|
10296
|
-
T || (
|
|
10322
|
+
T || (f(), x());
|
|
10297
10323
|
}
|
|
10298
10324
|
};
|
|
10299
10325
|
try {
|
|
10300
|
-
const R = g(
|
|
10301
|
-
R && (
|
|
10326
|
+
const R = g(S, L);
|
|
10327
|
+
R && (C.u = () => {
|
|
10302
10328
|
T = !0;
|
|
10303
10329
|
try {
|
|
10304
10330
|
R();
|
|
@@ -10313,23 +10339,23 @@ const RootLayout = () => {
|
|
|
10313
10339
|
l.add(j);
|
|
10314
10340
|
}
|
|
10315
10341
|
}
|
|
10316
|
-
return
|
|
10317
|
-
}), N = h[8] || ((
|
|
10318
|
-
var
|
|
10319
|
-
const v = m(
|
|
10320
|
-
let
|
|
10321
|
-
if (
|
|
10342
|
+
return C;
|
|
10343
|
+
}), N = h[8] || ((S) => {
|
|
10344
|
+
var B;
|
|
10345
|
+
const v = m(S);
|
|
10346
|
+
let C = r.get(S);
|
|
10347
|
+
if (C && !C.l.size && !Array.from(C.t).some((j) => {
|
|
10322
10348
|
var T;
|
|
10323
|
-
return (T = r.get(j)) == null ? void 0 : T.d.has(
|
|
10349
|
+
return (T = r.get(j)) == null ? void 0 : T.d.has(S);
|
|
10324
10350
|
})) {
|
|
10325
|
-
|
|
10351
|
+
C.u && i.add(C.u), C = void 0, r.delete(S), (B = c.u) == null || B.call(c, S);
|
|
10326
10352
|
for (const j of v.d.keys()) {
|
|
10327
10353
|
const T = N(j);
|
|
10328
|
-
T == null || T.t.delete(
|
|
10354
|
+
T == null || T.t.delete(S);
|
|
10329
10355
|
}
|
|
10330
10356
|
return;
|
|
10331
10357
|
}
|
|
10332
|
-
return
|
|
10358
|
+
return C;
|
|
10333
10359
|
}), w = [
|
|
10334
10360
|
// store state
|
|
10335
10361
|
o,
|
|
@@ -10346,27 +10372,27 @@ const RootLayout = () => {
|
|
|
10346
10372
|
g,
|
|
10347
10373
|
// building-block functions
|
|
10348
10374
|
m,
|
|
10349
|
-
f,
|
|
10350
10375
|
x,
|
|
10376
|
+
f,
|
|
10351
10377
|
k,
|
|
10352
10378
|
b,
|
|
10353
10379
|
A,
|
|
10354
|
-
|
|
10380
|
+
E,
|
|
10355
10381
|
_,
|
|
10356
10382
|
N
|
|
10357
10383
|
], y = {
|
|
10358
|
-
get: (
|
|
10359
|
-
set: (
|
|
10384
|
+
get: (S) => returnAtomValue(k(S)),
|
|
10385
|
+
set: (S, ...B) => {
|
|
10360
10386
|
try {
|
|
10361
|
-
return A(
|
|
10387
|
+
return A(S, ...B);
|
|
10362
10388
|
} finally {
|
|
10363
|
-
|
|
10389
|
+
f(), x();
|
|
10364
10390
|
}
|
|
10365
10391
|
},
|
|
10366
|
-
sub: (
|
|
10367
|
-
const
|
|
10368
|
-
return
|
|
10369
|
-
|
|
10392
|
+
sub: (S, B) => {
|
|
10393
|
+
const C = _(S).l;
|
|
10394
|
+
return C.add(B), x(), () => {
|
|
10395
|
+
C.delete(B), N(S), x();
|
|
10370
10396
|
};
|
|
10371
10397
|
}
|
|
10372
10398
|
};
|
|
@@ -10517,7 +10543,7 @@ export {
|
|
|
10517
10543
|
getBlocksFromHTML as convertHTMLToChaiBlocks,
|
|
10518
10544
|
generateUUID as generateBlockId,
|
|
10519
10545
|
getBlocksFromHTML,
|
|
10520
|
-
|
|
10546
|
+
ze as i18n,
|
|
10521
10547
|
cn$2 as mergeClasses,
|
|
10522
10548
|
registerBlockSettingField,
|
|
10523
10549
|
registerBlockSettingTemplate,
|