@chaibuilder/sdk 2.2.36 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +3 -3
- package/dist/core.d.ts +22 -0
- package/dist/core.js +634 -593
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +90 -105
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var V = (o, n, r) => n in o ? U(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
|
|
3
|
+
var F = (o, n, r) => V(o, typeof n != "symbol" ? n + "" : n, r);
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
6
6
|
import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, ResetIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
|
|
@@ -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, b9 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b5 as Tooltip, b8 as TooltipTrigger, ay as PopoverTrigger, b6 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b2 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, a_ as Tabs, b0 as TabsList, b1 as TabsTrigger, a$ as TabsContent, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, aZ as Switch, r as Avatar, aL as Separator, b7 as TooltipProvider, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle, aY as Toaster } from "./toggle-BFR6fqvM.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, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
|
|
14
|
+
import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers, Settings as Settings$1 } 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";
|
|
@@ -21,7 +21,7 @@ import { isObject } from "@rjsf/utils";
|
|
|
21
21
|
import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
|
|
22
22
|
import { toast } from "sonner";
|
|
23
23
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
24
|
-
import { useTranslation as
|
|
24
|
+
import { useTranslation as Ve } from "react-i18next";
|
|
25
25
|
import Fuse from "fuse.js";
|
|
26
26
|
import UndoManager from "undo-manager";
|
|
27
27
|
import Link from "@tiptap/extension-link";
|
|
@@ -34,7 +34,7 @@ import RjForm from "@rjsf/core";
|
|
|
34
34
|
import validator from "@rjsf/validator-ajv8";
|
|
35
35
|
import "next-themes";
|
|
36
36
|
import Autosuggest from "react-autosuggest";
|
|
37
|
-
import { useFeature
|
|
37
|
+
import { useFeature } from "flagged";
|
|
38
38
|
import { parse, stringify } from "himalaya";
|
|
39
39
|
import { Tree } from "react-arborist";
|
|
40
40
|
import i18n from "i18next";
|
|
@@ -283,7 +283,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
|
|
|
283
283
|
});
|
|
284
284
|
class PubSub {
|
|
285
285
|
constructor() {
|
|
286
|
-
|
|
286
|
+
F(this, "subscribers", /* @__PURE__ */ new Map());
|
|
287
287
|
}
|
|
288
288
|
subscribe(n, r) {
|
|
289
289
|
return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
|
|
@@ -344,16 +344,16 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
344
344
|
_type: "Text",
|
|
345
345
|
content: u.content
|
|
346
346
|
};
|
|
347
|
-
Object.keys(u).forEach((
|
|
348
|
-
|
|
349
|
-
}), l.unshift(h), i = i.map((
|
|
350
|
-
if (
|
|
351
|
-
const
|
|
352
|
-
return Object.keys(
|
|
353
|
-
k.startsWith("content-") && (
|
|
354
|
-
}),
|
|
347
|
+
Object.keys(u).forEach((x) => {
|
|
348
|
+
x.startsWith("content-") && (h[x] = u[x]);
|
|
349
|
+
}), l.unshift(h), i = i.map((x) => {
|
|
350
|
+
if (x._id === r) {
|
|
351
|
+
const f = { ...x, content: "" };
|
|
352
|
+
return Object.keys(f).forEach((k) => {
|
|
353
|
+
k.startsWith("content-") && (f[k] = "");
|
|
354
|
+
}), f;
|
|
355
355
|
}
|
|
356
|
-
return
|
|
356
|
+
return x;
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
359
|
}
|
|
@@ -481,15 +481,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
481
481
|
if (g.length === 2) {
|
|
482
482
|
const m = g.find((h) => h._id !== d);
|
|
483
483
|
if (m && m._type === "Text") {
|
|
484
|
-
const h = r.find((
|
|
485
|
-
h && "content" in h && (r = r.map((
|
|
486
|
-
if (
|
|
487
|
-
const
|
|
484
|
+
const h = r.find((x) => x._id === u);
|
|
485
|
+
h && "content" in h && (r = r.map((x) => {
|
|
486
|
+
if (x._id === u) {
|
|
487
|
+
const f = { ...x, content: m.content };
|
|
488
488
|
return Object.keys(m).forEach((k) => {
|
|
489
|
-
k.startsWith("content-") && (
|
|
490
|
-
}),
|
|
489
|
+
k.startsWith("content-") && (f[k] = m[k]);
|
|
490
|
+
}), f;
|
|
491
491
|
}
|
|
492
|
-
return
|
|
492
|
+
return x;
|
|
493
493
|
}), a.push(m._id));
|
|
494
494
|
}
|
|
495
495
|
}
|
|
@@ -572,32 +572,32 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
572
572
|
status: "idle",
|
|
573
573
|
props: {},
|
|
574
574
|
error: void 0
|
|
575
|
-
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (
|
|
575
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
|
|
576
576
|
return useEffect(() => {
|
|
577
577
|
if (n === "mock") {
|
|
578
578
|
if (isFunction(a)) {
|
|
579
|
-
i((
|
|
580
|
-
const
|
|
581
|
-
if (!isObject(
|
|
579
|
+
i((f) => ({ ...f, status: "loading", props: {} }));
|
|
580
|
+
const x = a({ block: o });
|
|
581
|
+
if (!isObject(x))
|
|
582
582
|
throw new Error("mockDataProvider should return an object");
|
|
583
|
-
i((
|
|
583
|
+
i((f) => ({ ...f, status: "loaded", props: x }));
|
|
584
584
|
}
|
|
585
585
|
return;
|
|
586
586
|
}
|
|
587
|
-
n === "live" && (!g && !m || (i((
|
|
588
|
-
g ? (p((
|
|
589
|
-
...
|
|
587
|
+
n === "live" && (!g && !m || (i((x) => ({ ...x, status: "loading", props: {} })), d({ block: o }).then((x = {}) => {
|
|
588
|
+
g ? (p((f) => ({
|
|
589
|
+
...f,
|
|
590
590
|
[o._id]: {
|
|
591
591
|
status: "loaded",
|
|
592
|
-
props: get(
|
|
592
|
+
props: get(x, "items", []),
|
|
593
593
|
repeaterItems: o.repeaterItems
|
|
594
594
|
}
|
|
595
|
-
})), i((
|
|
596
|
-
}).catch((
|
|
597
|
-
g ? (p((
|
|
598
|
-
...
|
|
599
|
-
[o._id]: { status: "error", error:
|
|
600
|
-
})), i((
|
|
595
|
+
})), 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 : {} }));
|
|
596
|
+
}).catch((x) => {
|
|
597
|
+
g ? (p((f) => ({
|
|
598
|
+
...f,
|
|
599
|
+
[o._id]: { status: "error", error: x, props: [] }
|
|
600
|
+
})), i((f) => ({ ...f, status: "error", error: x, props: {} }))) : i((f) => ({ ...f, status: "error", error: x, props: {} }));
|
|
601
601
|
})));
|
|
602
602
|
}, [o == null ? void 0 : o._id, u, g, m, a, n]), {
|
|
603
603
|
$loading: get(l, "status") === "loading",
|
|
@@ -799,65 +799,65 @@ const undoRedoStateAtom = atom({
|
|
|
799
799
|
updateBlocksProps: c
|
|
800
800
|
} = useBlocksStoreManager();
|
|
801
801
|
return {
|
|
802
|
-
moveBlocks: (
|
|
803
|
-
const v = map(
|
|
802
|
+
moveBlocks: (f, k, b) => {
|
|
803
|
+
const v = map(f, (w) => {
|
|
804
804
|
const E = n.find((N) => N._id === w)._parent || null, A = n.filter((N) => E ? N._parent === E : !N._parent).map((N) => N._id).indexOf(w);
|
|
805
805
|
return { _id: w, oldParent: E, oldPosition: A };
|
|
806
|
-
}), B = v.find(({ _id: w }) => w ===
|
|
807
|
-
B && B.oldParent === k && B.oldPosition === b || (i(
|
|
806
|
+
}), B = v.find(({ _id: w }) => w === f[0]);
|
|
807
|
+
B && B.oldParent === k && B.oldPosition === b || (i(f, k, b), o({
|
|
808
808
|
undo: () => each(v, ({ _id: w, oldParent: _, oldPosition: E }) => {
|
|
809
809
|
i([w], _, E);
|
|
810
810
|
}),
|
|
811
|
-
redo: () => i(
|
|
811
|
+
redo: () => i(f, k, b)
|
|
812
812
|
}));
|
|
813
813
|
},
|
|
814
|
-
addBlocks: (
|
|
815
|
-
a(
|
|
816
|
-
undo: () => l(map(
|
|
817
|
-
redo: () => a(
|
|
814
|
+
addBlocks: (f, k, b) => {
|
|
815
|
+
a(f, k, b), o({
|
|
816
|
+
undo: () => l(map(f, "_id")),
|
|
817
|
+
redo: () => a(f, k, b)
|
|
818
818
|
});
|
|
819
819
|
},
|
|
820
|
-
removeBlocks: (
|
|
820
|
+
removeBlocks: (f) => {
|
|
821
821
|
var B;
|
|
822
|
-
const k = (B = first(
|
|
823
|
-
l(map(
|
|
824
|
-
undo: () => a(
|
|
825
|
-
redo: () => l(map(
|
|
822
|
+
const k = (B = first(f)) == null ? void 0 : B._parent, v = n.filter((w) => k ? w._parent === k : !w._parent).indexOf(first(f));
|
|
823
|
+
l(map(f, "_id")), o({
|
|
824
|
+
undo: () => a(f, k, v),
|
|
825
|
+
redo: () => l(map(f, "_id"))
|
|
826
826
|
});
|
|
827
827
|
},
|
|
828
|
-
updateBlocks: (
|
|
828
|
+
updateBlocks: (f, k, b) => {
|
|
829
829
|
let v = [];
|
|
830
830
|
if (b)
|
|
831
|
-
v = map(
|
|
831
|
+
v = map(f, (B) => ({ _id: B, ...b }));
|
|
832
832
|
else {
|
|
833
833
|
const B = keys(k);
|
|
834
|
-
v = map(
|
|
835
|
-
const _ = n.find((
|
|
836
|
-
return each(B, (
|
|
834
|
+
v = map(f, (w) => {
|
|
835
|
+
const _ = n.find((S) => S._id === w), E = { _id: w };
|
|
836
|
+
return each(B, (S) => E[S] = _[S]), E;
|
|
837
837
|
});
|
|
838
838
|
}
|
|
839
|
-
c(map(
|
|
839
|
+
c(map(f, (B) => ({ _id: B, ...k }))), o({
|
|
840
840
|
undo: () => c(v),
|
|
841
|
-
redo: () => c(map(
|
|
841
|
+
redo: () => c(map(f, (B) => ({ _id: B, ...k })))
|
|
842
842
|
});
|
|
843
843
|
},
|
|
844
|
-
updateBlocksRuntime: (
|
|
845
|
-
c(map(
|
|
844
|
+
updateBlocksRuntime: (f, k) => {
|
|
845
|
+
c(map(f, (b) => ({ _id: b, ...k })));
|
|
846
846
|
},
|
|
847
|
-
setNewBlocks: (
|
|
848
|
-
r(
|
|
847
|
+
setNewBlocks: (f) => {
|
|
848
|
+
r(f), o({
|
|
849
849
|
undo: () => r(n),
|
|
850
|
-
redo: () => r(
|
|
850
|
+
redo: () => r(f)
|
|
851
851
|
});
|
|
852
852
|
},
|
|
853
|
-
updateMultipleBlocksProps: (
|
|
853
|
+
updateMultipleBlocksProps: (f) => {
|
|
854
854
|
let k = [];
|
|
855
|
-
k = map(
|
|
855
|
+
k = map(f, (b) => {
|
|
856
856
|
const v = keys(b), B = n.find((_) => _._id === b._id), w = {};
|
|
857
857
|
return each(v, (_) => w[_] = B[_]), w;
|
|
858
|
-
}), c(
|
|
858
|
+
}), c(f), o({
|
|
859
859
|
undo: () => c(k),
|
|
860
|
-
redo: () => c(
|
|
860
|
+
redo: () => c(f)
|
|
861
861
|
});
|
|
862
862
|
}
|
|
863
863
|
};
|
|
@@ -865,12 +865,12 @@ const undoRedoStateAtom = atom({
|
|
|
865
865
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
866
866
|
(i, c, d) => {
|
|
867
867
|
var h;
|
|
868
|
-
for (let
|
|
869
|
-
const { _id:
|
|
870
|
-
i[
|
|
871
|
-
const k = filter(i, { _parent:
|
|
868
|
+
for (let x = 0; x < i.length; x++) {
|
|
869
|
+
const { _id: f } = i[x];
|
|
870
|
+
i[x]._id = generateUUID();
|
|
871
|
+
const k = filter(i, { _parent: f });
|
|
872
872
|
for (let b = 0; b < k.length; b++)
|
|
873
|
-
k[b]._parent = i[
|
|
873
|
+
k[b]._parent = i[x]._id;
|
|
874
874
|
}
|
|
875
875
|
const p = first(i);
|
|
876
876
|
let u, g;
|
|
@@ -2332,34 +2332,34 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2332
2332
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2333
2333
|
})
|
|
2334
2334
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2335
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h,
|
|
2336
|
-
const
|
|
2337
|
-
for (const k in
|
|
2338
|
-
const b =
|
|
2335
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, x) => {
|
|
2336
|
+
const f = cloneDeep(x.find((k) => k._id === h));
|
|
2337
|
+
for (const k in f) {
|
|
2338
|
+
const b = f[k];
|
|
2339
2339
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
2340
2340
|
const { baseClasses: v, classes: B } = getSplitChaiClasses(b);
|
|
2341
|
-
|
|
2341
|
+
f[k] = compact(flattenDeep([v, B])).join(" ");
|
|
2342
2342
|
} else
|
|
2343
|
-
k !== "_id" && delete
|
|
2343
|
+
k !== "_id" && delete f[k];
|
|
2344
2344
|
}
|
|
2345
|
-
return
|
|
2345
|
+
return f;
|
|
2346
2346
|
};
|
|
2347
2347
|
return {
|
|
2348
2348
|
askAi: useCallback(
|
|
2349
|
-
async (h,
|
|
2349
|
+
async (h, x, f, k) => {
|
|
2350
2350
|
if (l) {
|
|
2351
2351
|
n(!0), a(null);
|
|
2352
2352
|
try {
|
|
2353
|
-
const b = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(
|
|
2353
|
+
const b = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p) : [m(x, d)], B = await l(h, addLangToPrompt(f, g, h), v, b), { blocks: w, error: _ } = B;
|
|
2354
2354
|
if (_) {
|
|
2355
2355
|
a(_);
|
|
2356
2356
|
return;
|
|
2357
2357
|
}
|
|
2358
2358
|
if (h === "styles") {
|
|
2359
|
-
const E = w.map((
|
|
2360
|
-
for (const A in
|
|
2361
|
-
A !== "_id" && (
|
|
2362
|
-
return
|
|
2359
|
+
const E = w.map((S) => {
|
|
2360
|
+
for (const A in S)
|
|
2361
|
+
A !== "_id" && (S[A] = `${STYLES_KEY},${S[A]}`);
|
|
2362
|
+
return S;
|
|
2363
2363
|
});
|
|
2364
2364
|
c(E);
|
|
2365
2365
|
} else
|
|
@@ -2462,12 +2462,12 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2462
2462
|
if (!p)
|
|
2463
2463
|
return m;
|
|
2464
2464
|
let h = [];
|
|
2465
|
-
for (const
|
|
2466
|
-
if (
|
|
2467
|
-
let
|
|
2468
|
-
|
|
2465
|
+
for (const x of m)
|
|
2466
|
+
if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
|
|
2467
|
+
let f = l(x.partialBlockId);
|
|
2468
|
+
x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((k) => (isEmpty(k._parent) && set(k, "_parent", x._parent), k))), h = [...h, ...f];
|
|
2469
2469
|
} else
|
|
2470
|
-
h.push(
|
|
2470
|
+
h.push(x);
|
|
2471
2471
|
return h;
|
|
2472
2472
|
})
|
|
2473
2473
|
};
|
|
@@ -2650,13 +2650,13 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2650
2650
|
const d = o(c), p = a;
|
|
2651
2651
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2652
2652
|
return each(p, (m) => {
|
|
2653
|
-
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2654
|
-
u = u.replace(
|
|
2655
|
-
const
|
|
2656
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2653
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2654
|
+
u = u.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2655
|
+
const f = first(m.split(":"));
|
|
2656
|
+
includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(m.split(":").pop().trim());
|
|
2657
2657
|
}), each(p, (m) => {
|
|
2658
|
-
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2659
|
-
g = g.replace(
|
|
2658
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2659
|
+
g = g.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2660
2660
|
}), {
|
|
2661
2661
|
ids: [d._id],
|
|
2662
2662
|
props: {
|
|
@@ -2789,21 +2789,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2789
2789
|
return "VERTICAL";
|
|
2790
2790
|
}
|
|
2791
2791
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
2792
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (
|
|
2793
|
-
(
|
|
2794
|
-
isDisabledControl(g, m,
|
|
2792
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (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, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), x = useCallback(
|
|
2793
|
+
(f) => {
|
|
2794
|
+
isDisabledControl(g, m, f) || p || (f === "UP" || f === "LEFT" ? l([i], c || null, u - 1) : (f === "DOWN" || f === "RIGHT") && l([i], c || null, u + 2), n());
|
|
2795
2795
|
},
|
|
2796
2796
|
[g, m, p, u, i, c, n]
|
|
2797
2797
|
);
|
|
2798
2798
|
return useHotkeys(
|
|
2799
2799
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2800
|
-
({ key:
|
|
2800
|
+
({ key: f }) => {
|
|
2801
2801
|
var k;
|
|
2802
|
-
|
|
2802
|
+
x((k = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
|
|
2803
2803
|
},
|
|
2804
2804
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2805
|
-
[
|
|
2806
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock:
|
|
2805
|
+
[x]
|
|
2806
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: x, orientation: h };
|
|
2807
2807
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
2808
2808
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2809
2809
|
o,
|
|
@@ -2949,7 +2949,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2949
2949
|
elements: { reference: n }
|
|
2950
2950
|
});
|
|
2951
2951
|
useResizeObserver(n, () => h(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => h(), (u == null ? void 0 : u.body) !== null);
|
|
2952
|
-
const
|
|
2952
|
+
const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
2953
2953
|
return !n || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
2954
2954
|
"div",
|
|
2955
2955
|
{
|
|
@@ -2966,16 +2966,16 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2966
2966
|
onKeyDown: (k) => k.stopPropagation(),
|
|
2967
2967
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
2968
2968
|
children: [
|
|
2969
|
-
|
|
2969
|
+
x && /* @__PURE__ */ jsx(
|
|
2970
2970
|
ArrowUpIcon,
|
|
2971
2971
|
{
|
|
2972
2972
|
className: "hover:scale-105",
|
|
2973
2973
|
onClick: () => {
|
|
2974
|
-
c([]), l([
|
|
2974
|
+
c([]), l([x]);
|
|
2975
2975
|
}
|
|
2976
2976
|
}
|
|
2977
2977
|
),
|
|
2978
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
2978
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: o }),
|
|
2979
2979
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
2980
2980
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
2981
2981
|
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
|
|
@@ -3056,17 +3056,17 @@ class Content extends Component {
|
|
|
3056
3056
|
class Frame extends Component {
|
|
3057
3057
|
constructor(r, a) {
|
|
3058
3058
|
super(r, a);
|
|
3059
|
-
|
|
3059
|
+
F(this, "setRef", (r) => {
|
|
3060
3060
|
this.nodeRef.current = r;
|
|
3061
3061
|
const { forwardedRef: a } = this.props;
|
|
3062
3062
|
typeof a == "function" ? a(r) : a && (a.current = r);
|
|
3063
3063
|
});
|
|
3064
|
-
|
|
3064
|
+
F(this, "handleLoad", () => {
|
|
3065
3065
|
clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
|
|
3066
3066
|
});
|
|
3067
3067
|
// In certain situations on a cold cache DOMContentLoaded never gets called
|
|
3068
3068
|
// fallback to an interval to check if that's the case
|
|
3069
|
-
|
|
3069
|
+
F(this, "loadCheck", () => setInterval(() => {
|
|
3070
3070
|
this.handleLoad();
|
|
3071
3071
|
}, 500));
|
|
3072
3072
|
this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
|
|
@@ -3103,7 +3103,7 @@ class Frame extends Component {
|
|
|
3103
3103
|
return delete r.head, delete r.initialContent, delete r.mountTarget, delete r.contentDidMount, delete r.contentDidUpdate, delete r.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...r, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
|
|
3104
3104
|
}
|
|
3105
3105
|
}
|
|
3106
|
-
|
|
3106
|
+
F(Frame, "defaultProps", {
|
|
3107
3107
|
style: {},
|
|
3108
3108
|
head: null,
|
|
3109
3109
|
children: void 0,
|
|
@@ -3133,8 +3133,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3133
3133
|
i
|
|
3134
3134
|
]), useHotkeys(
|
|
3135
3135
|
"del, backspace",
|
|
3136
|
-
(
|
|
3137
|
-
|
|
3136
|
+
(x) => {
|
|
3137
|
+
x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3138
3138
|
},
|
|
3139
3139
|
h,
|
|
3140
3140
|
[n, l]
|
|
@@ -3427,8 +3427,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3427
3427
|
],
|
|
3428
3428
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3429
3429
|
onBlur: ({ editor: u, event: g }) => {
|
|
3430
|
-
const m = g.relatedTarget, h = i.querySelector(".ProseMirror"),
|
|
3431
|
-
if (!
|
|
3430
|
+
const m = g.relatedTarget, h = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = h == null ? void 0 : h.contains(m), k = x == null ? void 0 : x.contains(m);
|
|
3431
|
+
if (!f && !k) {
|
|
3432
3432
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3433
3433
|
r(b);
|
|
3434
3434
|
}
|
|
@@ -3483,14 +3483,14 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3483
3483
|
useEffect(() => {
|
|
3484
3484
|
if (a.current) {
|
|
3485
3485
|
a.current.innerText = n, a.current.focus();
|
|
3486
|
-
const h = c.createRange(),
|
|
3487
|
-
h.selectNodeContents(a.current), h.collapse(!1),
|
|
3486
|
+
const h = c.createRange(), x = d.getSelection();
|
|
3487
|
+
h.selectNodeContents(a.current), h.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(h), a.current.focus();
|
|
3488
3488
|
} else
|
|
3489
3489
|
r();
|
|
3490
3490
|
}, [c, d]);
|
|
3491
3491
|
const p = useMemo(() => {
|
|
3492
|
-
var
|
|
3493
|
-
const h = ((
|
|
3492
|
+
var x;
|
|
3493
|
+
const h = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
|
|
3494
3494
|
return h === "button" ? "div" : h;
|
|
3495
3495
|
}, [o]), u = useCallback(
|
|
3496
3496
|
(h) => {
|
|
@@ -3506,12 +3506,12 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3506
3506
|
contentEditable: !0,
|
|
3507
3507
|
className: `${((h = o == null ? void 0 : o.className) == null ? void 0 : h.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]`,
|
|
3508
3508
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
3509
|
-
onInput: (
|
|
3510
|
-
const
|
|
3511
|
-
|
|
3509
|
+
onInput: (x) => {
|
|
3510
|
+
const f = x.target;
|
|
3511
|
+
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));
|
|
3512
3512
|
},
|
|
3513
|
-
onClick: (
|
|
3514
|
-
|
|
3513
|
+
onClick: (x) => {
|
|
3514
|
+
x.stopPropagation(), x.preventDefault();
|
|
3515
3515
|
}
|
|
3516
3516
|
};
|
|
3517
3517
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
@@ -3524,41 +3524,41 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3524
3524
|
}
|
|
3525
3525
|
), WithBlockTextEditor = memo(
|
|
3526
3526
|
({ block: o, children: n }) => {
|
|
3527
|
-
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang:
|
|
3527
|
+
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), k = useRef(null), b = l, { blockContent: v, blockType: B } = useMemo(() => {
|
|
3528
3528
|
var j;
|
|
3529
3529
|
const A = o._type;
|
|
3530
3530
|
let N = o[r];
|
|
3531
|
-
const
|
|
3532
|
-
return
|
|
3533
|
-
}, [o,
|
|
3531
|
+
const C = getRegisteredChaiBlock(o._type);
|
|
3532
|
+
return x && ((j = C == null ? void 0 : C.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${x}`) && (N = get(o, `${r}-${x}`)), { blockContent: N, blockType: A };
|
|
3533
|
+
}, [o, x]), w = useCallback(
|
|
3534
3534
|
(A) => {
|
|
3535
|
-
var
|
|
3536
|
-
const N = A || ((
|
|
3537
|
-
h([b], { [r]: N }), u(null), c(null), d(-1),
|
|
3535
|
+
var C;
|
|
3536
|
+
const N = A || ((C = g.current) == null ? void 0 : C.innerText);
|
|
3537
|
+
h([b], { [r]: N }), u(null), c(null), d(-1), f([]);
|
|
3538
3538
|
},
|
|
3539
|
-
[b, h, c,
|
|
3539
|
+
[b, h, c, f, x]
|
|
3540
3540
|
), _ = useDebouncedCallback(
|
|
3541
3541
|
(A) => {
|
|
3542
3542
|
h([b], { [r]: A });
|
|
3543
3543
|
},
|
|
3544
|
-
[b, o, h,
|
|
3544
|
+
[b, o, h, x],
|
|
3545
3545
|
1e3
|
|
3546
3546
|
), E = useCallback(
|
|
3547
3547
|
(A) => {
|
|
3548
3548
|
A.preventDefault(), b && (k.current = b), w(), setTimeout(() => {
|
|
3549
3549
|
const N = k.current;
|
|
3550
|
-
k.current = null,
|
|
3550
|
+
k.current = null, f([N]);
|
|
3551
3551
|
}, 100);
|
|
3552
3552
|
},
|
|
3553
|
-
[
|
|
3553
|
+
[f, b, x]
|
|
3554
3554
|
);
|
|
3555
3555
|
useEffect(() => {
|
|
3556
3556
|
var y;
|
|
3557
3557
|
if (!b) return;
|
|
3558
|
-
const A = `[data-block-id="${b}"]`, N = i >= 0 ? `[data-block-index="${i}"]` : "",
|
|
3559
|
-
|
|
3558
|
+
const A = `[data-block-id="${b}"]`, N = i >= 0 ? `[data-block-index="${i}"]` : "", C = a.querySelector(`${A}${N}`);
|
|
3559
|
+
C && ((y = C == null ? void 0 : C.classList) == null || y.add("sr-only"), u(C));
|
|
3560
3560
|
}, [b, B, a, i]);
|
|
3561
|
-
const
|
|
3561
|
+
const S = useMemo(() => p ? (m(), B === "RichText" ? /* @__PURE__ */ jsx(
|
|
3562
3562
|
RichTextEditor,
|
|
3563
3563
|
{
|
|
3564
3564
|
blockContent: v,
|
|
@@ -3577,9 +3577,9 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3577
3577
|
onChange: _,
|
|
3578
3578
|
onEscape: E
|
|
3579
3579
|
}
|
|
3580
|
-
)) : null, [p, b, B, v, w,
|
|
3580
|
+
)) : null, [p, b, B, v, w, x]);
|
|
3581
3581
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3582
|
-
|
|
3582
|
+
S,
|
|
3583
3583
|
n
|
|
3584
3584
|
] });
|
|
3585
3585
|
},
|
|
@@ -3612,18 +3612,18 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3612
3612
|
blockAtom: n,
|
|
3613
3613
|
children: r
|
|
3614
3614
|
}) => {
|
|
3615
|
-
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useHiddenBlockIds(), [h] = useAtom$1(dataBindingActiveAtom),
|
|
3615
|
+
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useHiddenBlockIds(), [h] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: k } = useContext(RepeaterContext), b = useMemo(
|
|
3616
3616
|
() => h ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
3617
|
-
index:
|
|
3617
|
+
index: f,
|
|
3618
3618
|
key: k
|
|
3619
3619
|
}) : applyLanguage(i, d, c),
|
|
3620
|
-
[i, d, c, g, h,
|
|
3620
|
+
[i, d, c, g, h, f, k]
|
|
3621
3621
|
), v = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
|
|
3622
3622
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
3623
3623
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
3624
3624
|
), w = useMemo(
|
|
3625
3625
|
() => ({
|
|
3626
|
-
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index":
|
|
3626
|
+
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
|
|
3627
3627
|
inBuilder: !0,
|
|
3628
3628
|
lang: d || p,
|
|
3629
3629
|
...b,
|
|
@@ -3642,8 +3642,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3642
3642
|
o
|
|
3643
3643
|
]
|
|
3644
3644
|
), _ = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
|
|
3645
|
-
if (isNull(
|
|
3646
|
-
let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(
|
|
3645
|
+
if (isNull(x) || m.includes(i._id)) return null;
|
|
3646
|
+
let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
|
|
3647
3647
|
...w,
|
|
3648
3648
|
children: r({
|
|
3649
3649
|
_id: i._id,
|
|
@@ -3656,8 +3656,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3656
3656
|
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
3657
3657
|
})
|
|
3658
3658
|
}) });
|
|
3659
|
-
const
|
|
3660
|
-
return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children:
|
|
3659
|
+
const S = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: E }) : E;
|
|
3660
|
+
return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: S }) : S;
|
|
3661
3661
|
}, PartialWrapper = ({ children: o, partialBlockId: n }) => {
|
|
3662
3662
|
const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
3663
3663
|
(d) => {
|
|
@@ -3697,7 +3697,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3697
3697
|
);
|
|
3698
3698
|
return map(l, (c) => {
|
|
3699
3699
|
const d = a(c._id);
|
|
3700
|
-
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: m, repeaterItems: h, $repeaterItemsKey:
|
|
3700
|
+
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: m, repeaterItems: h, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(h) && h.map((f, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) }, `${u}-${k}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: m }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
|
|
3701
3701
|
});
|
|
3702
3702
|
}, PageBlocksRenderer = () => {
|
|
3703
3703
|
const [o] = useBlocksStore();
|
|
@@ -3765,14 +3765,14 @@ const CanvasEventsWatcher = () => {
|
|
|
3765
3765
|
}, StaticCanvas = () => {
|
|
3766
3766
|
const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = 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(
|
|
3767
3767
|
(h) => {
|
|
3768
|
-
i((
|
|
3768
|
+
i((x) => ({ ...x, width: h }));
|
|
3769
3769
|
},
|
|
3770
3770
|
[i]
|
|
3771
3771
|
);
|
|
3772
3772
|
useEffect(() => {
|
|
3773
3773
|
if (!a.current) return;
|
|
3774
|
-
const { clientWidth: h, clientHeight:
|
|
3775
|
-
i({ width: h, height:
|
|
3774
|
+
const { clientWidth: h, clientHeight: x } = a.current;
|
|
3775
|
+
i({ width: h, height: x });
|
|
3776
3776
|
}, [a, o]);
|
|
3777
3777
|
const m = useMemo(() => {
|
|
3778
3778
|
let h = IframeInitialContent;
|
|
@@ -3887,8 +3887,8 @@ const CanvasEventsWatcher = () => {
|
|
|
3887
3887
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3888
3888
|
] });
|
|
3889
3889
|
}, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
|
|
3890
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (
|
|
3891
|
-
if (!
|
|
3890
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (x) => {
|
|
3891
|
+
if (!x.trim()) {
|
|
3892
3892
|
p(!1), g("Please enter a URL");
|
|
3893
3893
|
return;
|
|
3894
3894
|
}
|
|
@@ -3912,7 +3912,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3912
3912
|
{
|
|
3913
3913
|
placeholder: h(`Enter ${r} URL`),
|
|
3914
3914
|
value: a,
|
|
3915
|
-
onChange: (
|
|
3915
|
+
onChange: (x) => l(x.target.value),
|
|
3916
3916
|
onKeyUp: () => m(a)
|
|
3917
3917
|
}
|
|
3918
3918
|
),
|
|
@@ -3953,16 +3953,16 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
3953
3953
|
const m = isArray(g) ? first(g) : g;
|
|
3954
3954
|
if (m) {
|
|
3955
3955
|
n(m == null ? void 0 : m.url);
|
|
3956
|
-
const h = m == null ? void 0 : m.width,
|
|
3956
|
+
const h = m == null ? void 0 : m.width, x = m == null ? void 0 : m.height;
|
|
3957
3957
|
if (i != null && i._id) {
|
|
3958
|
-
const
|
|
3958
|
+
const f = {
|
|
3959
3959
|
...h && { width: h },
|
|
3960
|
-
...
|
|
3960
|
+
...x && { height: x },
|
|
3961
3961
|
...m.description && { alt: m.description },
|
|
3962
3962
|
...m.id && { assetId: m.id }
|
|
3963
3963
|
};
|
|
3964
|
-
if (isEmpty(
|
|
3965
|
-
c([i._id],
|
|
3964
|
+
if (isEmpty(f)) return;
|
|
3965
|
+
c([i._id], f);
|
|
3966
3966
|
}
|
|
3967
3967
|
}
|
|
3968
3968
|
}, p = useCallback(() => {
|
|
@@ -4006,14 +4006,14 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4006
4006
|
}, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
|
|
4007
4007
|
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
|
|
4008
4008
|
(m) => {
|
|
4009
|
-
const h = (
|
|
4010
|
-
m.type === "object" ? (l((
|
|
4009
|
+
const h = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
|
|
4010
|
+
m.type === "object" ? (l((x) => [...x, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
|
|
4011
4011
|
},
|
|
4012
4012
|
[a, n, r]
|
|
4013
4013
|
), u = React__default.useCallback(() => {
|
|
4014
4014
|
if (a.length > 0) {
|
|
4015
4015
|
const m = a.slice(0, -1);
|
|
4016
|
-
l(m), c(m.reduce((h,
|
|
4016
|
+
l(m), c(m.reduce((h, x) => h[x], o));
|
|
4017
4017
|
}
|
|
4018
4018
|
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: d(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
|
|
4019
4019
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
@@ -4106,7 +4106,7 @@ const DataBindingSelector = ({
|
|
|
4106
4106
|
}) => {
|
|
4107
4107
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4108
4108
|
if (i.length === 1) return "";
|
|
4109
|
-
const g = i.find((
|
|
4109
|
+
const g = i.find((x) => x._type === "Repeater"), h = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4110
4110
|
return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${g._id}` : h}`;
|
|
4111
4111
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4112
4112
|
(g, m) => {
|
|
@@ -4114,16 +4114,16 @@ const DataBindingSelector = ({
|
|
|
4114
4114
|
n(`{{${g}}}`, {}, r);
|
|
4115
4115
|
return;
|
|
4116
4116
|
}
|
|
4117
|
-
const h = (b) => /[.,!?;:]/.test(b),
|
|
4117
|
+
const h = (b) => /[.,!?;:]/.test(b), x = (b, v, B) => {
|
|
4118
4118
|
let w = "", _ = "";
|
|
4119
|
-
const E = v > 0 ? b[v - 1] : "",
|
|
4120
|
-
return v > 0 && (E === "." || !h(E) && E !== " ") && (w = " "), v < b.length && !h(
|
|
4119
|
+
const E = v > 0 ? b[v - 1] : "", S = v < b.length ? b[v] : "";
|
|
4120
|
+
return v > 0 && (E === "." || !h(E) && E !== " ") && (w = " "), v < b.length && !h(S) && S !== " " && (_ = " "), {
|
|
4121
4121
|
text: w + B + _,
|
|
4122
4122
|
prefixLength: w.length,
|
|
4123
4123
|
suffixLength: _.length
|
|
4124
4124
|
};
|
|
4125
|
-
},
|
|
4126
|
-
if (!
|
|
4125
|
+
}, f = document.getElementById(r);
|
|
4126
|
+
if (!f) return;
|
|
4127
4127
|
const k = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
|
|
4128
4128
|
if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
|
|
4129
4129
|
const b = k.__chaiRTE;
|
|
@@ -4134,23 +4134,23 @@ const DataBindingSelector = ({
|
|
|
4134
4134
|
if (B !== w)
|
|
4135
4135
|
b.chain().deleteSelection().insertContent(v).run();
|
|
4136
4136
|
else {
|
|
4137
|
-
const { state: E } = b,
|
|
4138
|
-
let
|
|
4139
|
-
|
|
4137
|
+
const { state: E } = b, S = E.selection.from, A = E.doc.textBetween(Math.max(0, S - 1), S), N = E.doc.textBetween(S, Math.min(S + 1, E.doc.content.size));
|
|
4138
|
+
let C = "";
|
|
4139
|
+
S > 0 && A !== " " && !h(A) && (C = " ");
|
|
4140
4140
|
let y = "";
|
|
4141
|
-
N && N !== " " && !h(N) && (y = " "), b.chain().insertContent(
|
|
4141
|
+
N && N !== " " && !h(N) && (y = " "), b.chain().insertContent(C + v + y).run();
|
|
4142
4142
|
}
|
|
4143
4143
|
setTimeout(() => n(b.getHTML(), {}, r), 100);
|
|
4144
4144
|
return;
|
|
4145
4145
|
}
|
|
4146
4146
|
} else {
|
|
4147
|
-
const b =
|
|
4147
|
+
const b = f, v = b.selectionStart || 0, B = b.value || "", w = b.selectionEnd || v;
|
|
4148
4148
|
if (w > v) {
|
|
4149
|
-
const N = `{{${g}}}`, { text:
|
|
4149
|
+
const N = `{{${g}}}`, { text: C } = x(B, v, N), y = B.slice(0, v) + C + B.slice(w);
|
|
4150
4150
|
n(y, {}, r);
|
|
4151
4151
|
return;
|
|
4152
4152
|
}
|
|
4153
|
-
const E = `{{${g}}}`, { text:
|
|
4153
|
+
const E = `{{${g}}}`, { text: S } = x(B, v, E), A = B.slice(0, v) + S + B.slice(v);
|
|
4154
4154
|
n(A, {}, r);
|
|
4155
4155
|
}
|
|
4156
4156
|
},
|
|
@@ -4173,98 +4173,98 @@ const DataBindingSelector = ({
|
|
|
4173
4173
|
onChange: r
|
|
4174
4174
|
}) => {
|
|
4175
4175
|
var N;
|
|
4176
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (
|
|
4176
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [x, f] = useState([]), [k, b] = useState(-1), v = useRef(null), B = (N = n == null ? void 0 : n.find((C) => C.key === u)) == null ? void 0 : N.name;
|
|
4177
4177
|
useEffect(() => {
|
|
4178
|
-
if (h(""),
|
|
4179
|
-
const
|
|
4178
|
+
if (h(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4179
|
+
const C = split(o, ":"), y = get(C, 1, "page") || "page";
|
|
4180
4180
|
g(y), (async () => {
|
|
4181
|
-
const j = await l(y, [get(
|
|
4181
|
+
const j = await l(y, [get(C, 2, "page")]);
|
|
4182
4182
|
j && Array.isArray(j) && h(get(j, [0, "name"], ""));
|
|
4183
4183
|
})();
|
|
4184
4184
|
}, [o]);
|
|
4185
4185
|
const w = useDebouncedCallback(
|
|
4186
|
-
async (
|
|
4187
|
-
if (isEmpty(
|
|
4188
|
-
|
|
4186
|
+
async (C) => {
|
|
4187
|
+
if (isEmpty(C))
|
|
4188
|
+
f([]);
|
|
4189
4189
|
else {
|
|
4190
|
-
const y = await l(u,
|
|
4191
|
-
|
|
4190
|
+
const y = await l(u, C);
|
|
4191
|
+
f(y);
|
|
4192
4192
|
}
|
|
4193
4193
|
c(!1), b(-1);
|
|
4194
4194
|
},
|
|
4195
4195
|
[u],
|
|
4196
4196
|
300
|
|
4197
|
-
), _ = (
|
|
4198
|
-
const y = ["pageType", u,
|
|
4199
|
-
y[1] && (r(y.join(":")), h(
|
|
4200
|
-
}, E = (
|
|
4201
|
-
switch (
|
|
4197
|
+
), _ = (C) => {
|
|
4198
|
+
const y = ["pageType", u, C.id];
|
|
4199
|
+
y[1] && (r(y.join(":")), h(C.name), p(!1), f([]), b(-1));
|
|
4200
|
+
}, E = (C) => {
|
|
4201
|
+
switch (C.key) {
|
|
4202
4202
|
case "ArrowDown":
|
|
4203
|
-
|
|
4203
|
+
C.preventDefault(), b((y) => y < x.length - 1 ? y + 1 : y);
|
|
4204
4204
|
break;
|
|
4205
4205
|
case "ArrowUp":
|
|
4206
|
-
|
|
4206
|
+
C.preventDefault(), b((y) => y > 0 ? y - 1 : y);
|
|
4207
4207
|
break;
|
|
4208
4208
|
case "Enter":
|
|
4209
|
-
if (
|
|
4210
|
-
k >= 0 && _(
|
|
4209
|
+
if (C.preventDefault(), x.length === 0) return;
|
|
4210
|
+
k >= 0 && _(x[k]);
|
|
4211
4211
|
break;
|
|
4212
4212
|
case "Escape":
|
|
4213
|
-
|
|
4213
|
+
C.preventDefault(), S();
|
|
4214
4214
|
break;
|
|
4215
4215
|
}
|
|
4216
4216
|
};
|
|
4217
4217
|
useEffect(() => {
|
|
4218
4218
|
if (k >= 0 && v.current) {
|
|
4219
|
-
const
|
|
4220
|
-
|
|
4219
|
+
const C = v.current.children[k];
|
|
4220
|
+
C == null || C.scrollIntoView({ block: "nearest" });
|
|
4221
4221
|
}
|
|
4222
4222
|
}, [k]);
|
|
4223
|
-
const
|
|
4224
|
-
h(""),
|
|
4225
|
-
}, A = (
|
|
4226
|
-
h(
|
|
4223
|
+
const S = () => {
|
|
4224
|
+
h(""), f([]), b(-1), p(!1), r("");
|
|
4225
|
+
}, A = (C) => {
|
|
4226
|
+
h(C), p(!isEmpty(C)), c(!0), w(C);
|
|
4227
4227
|
};
|
|
4228
4228
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4229
|
-
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (
|
|
4229
|
+
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(n, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
|
|
4230
4230
|
u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
|
|
4231
4231
|
/* @__PURE__ */ jsx(
|
|
4232
4232
|
"input",
|
|
4233
4233
|
{
|
|
4234
4234
|
type: "text",
|
|
4235
4235
|
value: m,
|
|
4236
|
-
onChange: (
|
|
4236
|
+
onChange: (C) => A(C.target.value),
|
|
4237
4237
|
onKeyDown: E,
|
|
4238
4238
|
placeholder: a(`Search ${B ?? ""}`),
|
|
4239
4239
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4240
4240
|
}
|
|
4241
4241
|
),
|
|
4242
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick:
|
|
4242
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4243
4243
|
] }),
|
|
4244
|
-
(i || !isEmpty(
|
|
4244
|
+
(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: [
|
|
4245
4245
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4246
4246
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4247
|
-
] }) : d && isEmpty(
|
|
4247
|
+
] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4248
4248
|
a("No results found for"),
|
|
4249
4249
|
' "',
|
|
4250
4250
|
m,
|
|
4251
4251
|
'"'
|
|
4252
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(
|
|
4252
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(x == null ? void 0 : x.slice(0, 20), (C, y) => /* @__PURE__ */ jsxs(
|
|
4253
4253
|
"li",
|
|
4254
4254
|
{
|
|
4255
|
-
onClick: () => _(
|
|
4256
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(
|
|
4255
|
+
onClick: () => _(C),
|
|
4256
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(C.id) ? "bg-blue-200" : y === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4257
4257
|
children: [
|
|
4258
|
-
|
|
4258
|
+
C.name,
|
|
4259
4259
|
" ",
|
|
4260
|
-
|
|
4260
|
+
C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
|
|
4261
4261
|
"( ",
|
|
4262
|
-
|
|
4262
|
+
C.slug,
|
|
4263
4263
|
" )"
|
|
4264
4264
|
] })
|
|
4265
4265
|
]
|
|
4266
4266
|
},
|
|
4267
|
-
|
|
4267
|
+
C.id
|
|
4268
4268
|
)) }) })
|
|
4269
4269
|
] });
|
|
4270
4270
|
}, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
|
|
@@ -4564,8 +4564,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4564
4564
|
if (!u) return;
|
|
4565
4565
|
const h = `{{${m}}}`;
|
|
4566
4566
|
u.commands.focus();
|
|
4567
|
-
const { from:
|
|
4568
|
-
if (
|
|
4567
|
+
const { from: x, to: f } = u.state.selection;
|
|
4568
|
+
if (x !== f)
|
|
4569
4569
|
u.chain().deleteSelection().insertContent(h).run();
|
|
4570
4570
|
else {
|
|
4571
4571
|
const { state: b } = u, v = b.selection.from, B = b.doc.textBetween(Math.max(0, v - 1), v), w = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
|
|
@@ -4611,13 +4611,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4611
4611
|
})
|
|
4612
4612
|
],
|
|
4613
4613
|
content: r || "",
|
|
4614
|
-
onUpdate: ({ editor:
|
|
4615
|
-
const
|
|
4616
|
-
a(
|
|
4614
|
+
onUpdate: ({ editor: x }) => {
|
|
4615
|
+
const f = x.getHTML();
|
|
4616
|
+
a(f), c || u(f);
|
|
4617
4617
|
},
|
|
4618
|
-
onBlur: ({ editor:
|
|
4619
|
-
const
|
|
4620
|
-
l(o,
|
|
4618
|
+
onBlur: ({ editor: x }) => {
|
|
4619
|
+
const f = x.getHTML();
|
|
4620
|
+
l(o, f);
|
|
4621
4621
|
},
|
|
4622
4622
|
editorProps: {
|
|
4623
4623
|
attributes: {
|
|
@@ -4630,8 +4630,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4630
4630
|
}, [g]), useEffect(() => {
|
|
4631
4631
|
u(r || "");
|
|
4632
4632
|
}, [r]);
|
|
4633
|
-
const m = (
|
|
4634
|
-
a(
|
|
4633
|
+
const m = (x) => {
|
|
4634
|
+
a(x);
|
|
4635
4635
|
}, h = () => {
|
|
4636
4636
|
d(!1), g && g.commands.setContent(p);
|
|
4637
4637
|
};
|
|
@@ -4664,24 +4664,24 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4664
4664
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4665
4665
|
}, [o, u]);
|
|
4666
4666
|
const m = () => {
|
|
4667
|
-
const
|
|
4668
|
-
if (
|
|
4669
|
-
const k = (
|
|
4667
|
+
const f = findIndex(u, { _id: g });
|
|
4668
|
+
if (f > -1) {
|
|
4669
|
+
const k = (f + 1) % u.length, b = get(u, [k, "_id"]);
|
|
4670
4670
|
if (!b) return;
|
|
4671
4671
|
n({ ...o, currentSlide: b }), c([b]);
|
|
4672
4672
|
}
|
|
4673
4673
|
}, h = () => {
|
|
4674
|
-
const
|
|
4675
|
-
if (
|
|
4676
|
-
const k = (
|
|
4674
|
+
const f = findIndex(u, { _id: g });
|
|
4675
|
+
if (f > -1) {
|
|
4676
|
+
const k = (f - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
|
|
4677
4677
|
if (!b) return;
|
|
4678
4678
|
n({ ...o, currentSlide: b }), c([b]);
|
|
4679
4679
|
}
|
|
4680
|
-
},
|
|
4681
|
-
const
|
|
4680
|
+
}, x = () => {
|
|
4681
|
+
const f = i(
|
|
4682
4682
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4683
4683
|
p == null ? void 0 : p._id
|
|
4684
|
-
), k =
|
|
4684
|
+
), k = f == null ? void 0 : f._id;
|
|
4685
4685
|
k && (n({ ...o, currentSlide: k }), c([k]));
|
|
4686
4686
|
};
|
|
4687
4687
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
@@ -4699,7 +4699,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4699
4699
|
/* @__PURE__ */ jsxs(
|
|
4700
4700
|
"button",
|
|
4701
4701
|
{
|
|
4702
|
-
onClick:
|
|
4702
|
+
onClick: x,
|
|
4703
4703
|
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",
|
|
4704
4704
|
children: [
|
|
4705
4705
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4760,8 +4760,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4760
4760
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4761
4761
|
className: "text-xs",
|
|
4762
4762
|
pattern: "[0-9]*",
|
|
4763
|
-
onChange: (
|
|
4764
|
-
let k =
|
|
4763
|
+
onChange: (f) => {
|
|
4764
|
+
let k = f.target.value;
|
|
4765
4765
|
k.length && (k = k.replace("-", "")), n({ ...o, autoplayInterval: k });
|
|
4766
4766
|
}
|
|
4767
4767
|
}
|
|
@@ -4870,28 +4870,28 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4870
4870
|
formData: g,
|
|
4871
4871
|
onChange: m
|
|
4872
4872
|
}) => {
|
|
4873
|
-
const { selectedLang: h, fallbackLang:
|
|
4874
|
-
() => isEmpty(
|
|
4875
|
-
[
|
|
4873
|
+
const { selectedLang: h, fallbackLang: x, languages: f } = useLanguages(), k = useMemo(
|
|
4874
|
+
() => isEmpty(f) ? "" : isEmpty(h) ? x : h,
|
|
4875
|
+
[f, h, x]
|
|
4876
4876
|
), b = useMemo(() => get(LANGUAGES, k, k), [k]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
|
|
4877
4877
|
() => get(w, [B == null ? void 0 : B._type, "i18nProps"], []),
|
|
4878
4878
|
[w, B == null ? void 0 : B._type]
|
|
4879
|
-
), [E,
|
|
4879
|
+
), [E, S] = useState(null);
|
|
4880
4880
|
if (d)
|
|
4881
4881
|
return null;
|
|
4882
4882
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
4883
4883
|
const N = _ == null ? void 0 : _.includes(o.replace("root.", ""));
|
|
4884
4884
|
if (u.type === "array") {
|
|
4885
|
-
const
|
|
4885
|
+
const C = E === o;
|
|
4886
4886
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
4887
4887
|
u.title && /* @__PURE__ */ jsxs(
|
|
4888
4888
|
"label",
|
|
4889
4889
|
{
|
|
4890
4890
|
htmlFor: o,
|
|
4891
|
-
onClick: () => C
|
|
4891
|
+
onClick: () => S(C ? null : o),
|
|
4892
4892
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4893
4893
|
children: [
|
|
4894
|
-
|
|
4894
|
+
C ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
4895
4895
|
/* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
|
|
4896
4896
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
|
|
4897
4897
|
" ",
|
|
@@ -4899,7 +4899,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4899
4899
|
]
|
|
4900
4900
|
}
|
|
4901
4901
|
),
|
|
4902
|
-
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${
|
|
4902
|
+
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${C ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
4903
4903
|
c,
|
|
4904
4904
|
a,
|
|
4905
4905
|
l,
|
|
@@ -4922,8 +4922,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4922
4922
|
DataBindingSelector,
|
|
4923
4923
|
{
|
|
4924
4924
|
schema: u,
|
|
4925
|
-
onChange: (
|
|
4926
|
-
m(
|
|
4925
|
+
onChange: (C) => {
|
|
4926
|
+
m(C, g, o);
|
|
4927
4927
|
},
|
|
4928
4928
|
id: o,
|
|
4929
4929
|
formData: g
|
|
@@ -5027,36 +5027,36 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5027
5027
|
}), a;
|
|
5028
5028
|
};
|
|
5029
5029
|
function BlockSettings() {
|
|
5030
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m),
|
|
5031
|
-
|
|
5032
|
-
},
|
|
5033
|
-
debounce(({ formData: E },
|
|
5034
|
-
|
|
5030
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), x = ({ formData: E }, S, A) => {
|
|
5031
|
+
S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(E, S) }, A);
|
|
5032
|
+
}, f = useCallback(
|
|
5033
|
+
debounce(({ formData: E }, S, A) => {
|
|
5034
|
+
x({ formData: E }, S, A), d(E);
|
|
5035
5035
|
}, 1500),
|
|
5036
5036
|
[n == null ? void 0 : n._id, o]
|
|
5037
|
-
), k = ({ formData: E },
|
|
5038
|
-
|
|
5039
|
-
}, b = ({ formData: E },
|
|
5040
|
-
|
|
5037
|
+
), k = ({ formData: E }, S) => {
|
|
5038
|
+
S && (r([n._id], { [S]: get(E, S) }), f({ formData: E }, S, { [S]: get(c, S) }));
|
|
5039
|
+
}, b = ({ formData: E }, S) => {
|
|
5040
|
+
S && (r([g._id], { [S]: get(E, S) }), f({ formData: E }, S, { [S]: get(c, S) }));
|
|
5041
5041
|
}, { schema: v, uiSchema: B } = useMemo(() => {
|
|
5042
5042
|
const E = n == null ? void 0 : n._type;
|
|
5043
5043
|
if (!E)
|
|
5044
5044
|
return { schema: {}, uiSchema: {} };
|
|
5045
5045
|
try {
|
|
5046
|
-
const { schema:
|
|
5046
|
+
const { schema: S, uiSchema: A } = getBlockFormSchemas(E);
|
|
5047
5047
|
if (E === "Repeater") {
|
|
5048
5048
|
const N = get(n, "repeaterItems", "");
|
|
5049
5049
|
startsWith(N, `{{${COLLECTION_PREFIX}`) ? (set(A, "filter", { "ui:widget": "collectionSelect" }), set(A, "sort", { "ui:widget": "collectionSelect" })) : (set(A, "filter", { "ui:widget": "hidden" }), set(A, "sort", { "ui:widget": "hidden" }));
|
|
5050
5050
|
}
|
|
5051
|
-
return { schema:
|
|
5051
|
+
return { schema: S, uiSchema: A };
|
|
5052
5052
|
} catch {
|
|
5053
5053
|
return { schema: {}, uiSchema: {} };
|
|
5054
5054
|
}
|
|
5055
5055
|
}, [n]), { wrapperSchema: w, wrapperUiSchema: _ } = useMemo(() => {
|
|
5056
5056
|
if (!g || !(g != null && g._type))
|
|
5057
5057
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5058
|
-
const E = g == null ? void 0 : g._type, { schema:
|
|
5059
|
-
return { wrapperSchema:
|
|
5058
|
+
const E = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: A = {} } = getBlockFormSchemas(E);
|
|
5059
|
+
return { wrapperSchema: S, wrapperUiSchema: A };
|
|
5060
5060
|
}, [g]);
|
|
5061
5061
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5062
5062
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
@@ -5300,20 +5300,20 @@ const BlockStylingProps = () => {
|
|
|
5300
5300
|
},
|
|
5301
5301
|
a
|
|
5302
5302
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5303
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [
|
|
5303
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [k, b] = useState(""), [v, B] = useState(!1), [w, _] = useState(!1);
|
|
5304
5304
|
useEffect(() => {
|
|
5305
|
-
const { value:
|
|
5305
|
+
const { value: C, unit: y } = getClassValueAndUnit(i);
|
|
5306
5306
|
if (y === "") {
|
|
5307
|
-
l(
|
|
5307
|
+
l(C), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5308
5308
|
return;
|
|
5309
5309
|
}
|
|
5310
|
-
h(y), l(y === "class" || isEmpty(
|
|
5310
|
+
h(y), l(y === "class" || isEmpty(C) ? "" : C);
|
|
5311
5311
|
}, [i, p, u]);
|
|
5312
|
-
const E = useThrottledCallback((
|
|
5313
|
-
(
|
|
5312
|
+
const E = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
|
|
5313
|
+
(C = !1) => {
|
|
5314
5314
|
const y = getUserInputValues(`${a}`, u);
|
|
5315
5315
|
if (get(y, "error", !1)) {
|
|
5316
|
-
|
|
5316
|
+
f(!0);
|
|
5317
5317
|
return;
|
|
5318
5318
|
}
|
|
5319
5319
|
const j = get(y, "unit") !== "" ? get(y, "unit") : m;
|
|
@@ -5324,23 +5324,23 @@ const BlockStylingProps = () => {
|
|
|
5324
5324
|
if (get(y, "value") === "")
|
|
5325
5325
|
return;
|
|
5326
5326
|
const L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5327
|
-
|
|
5327
|
+
C ? S(L) : E(L);
|
|
5328
5328
|
},
|
|
5329
|
-
[E,
|
|
5329
|
+
[E, S, a, m, d, u]
|
|
5330
5330
|
), N = useCallback(
|
|
5331
|
-
(
|
|
5331
|
+
(C) => {
|
|
5332
5332
|
const y = getUserInputValues(`${a}`, u);
|
|
5333
5333
|
if (get(y, "error", !1)) {
|
|
5334
|
-
|
|
5334
|
+
f(!0);
|
|
5335
5335
|
return;
|
|
5336
5336
|
}
|
|
5337
|
-
if (
|
|
5338
|
-
E(`${d}${
|
|
5337
|
+
if (C === "auto" || C === "none") {
|
|
5338
|
+
E(`${d}${C}`);
|
|
5339
5339
|
return;
|
|
5340
5340
|
}
|
|
5341
5341
|
if (get(y, "value") === "")
|
|
5342
5342
|
return;
|
|
5343
|
-
const j = get(y, "unit") !== "" ? get(y, "unit") :
|
|
5343
|
+
const j = get(y, "unit") !== "" ? get(y, "unit") : C, L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5344
5344
|
E(L);
|
|
5345
5345
|
},
|
|
5346
5346
|
[E, a, d, u]
|
|
@@ -5364,34 +5364,34 @@ const BlockStylingProps = () => {
|
|
|
5364
5364
|
"input",
|
|
5365
5365
|
{
|
|
5366
5366
|
readOnly: m === "class",
|
|
5367
|
-
onKeyPress: (
|
|
5368
|
-
|
|
5367
|
+
onKeyPress: (C) => {
|
|
5368
|
+
C.key === "Enter" && A();
|
|
5369
5369
|
},
|
|
5370
|
-
onKeyDown: (
|
|
5371
|
-
if (
|
|
5370
|
+
onKeyDown: (C) => {
|
|
5371
|
+
if (C.keyCode !== 38 && C.keyCode !== 40)
|
|
5372
5372
|
return;
|
|
5373
|
-
|
|
5374
|
-
const y = parseInt$1(
|
|
5373
|
+
C.preventDefault(), _(!0);
|
|
5374
|
+
const y = parseInt$1(C.target.value);
|
|
5375
5375
|
let j = isNaN$1(y) ? 0 : y;
|
|
5376
|
-
|
|
5377
|
-
const I = `${j}`,
|
|
5378
|
-
|
|
5376
|
+
C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
|
|
5377
|
+
const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5378
|
+
S(R);
|
|
5379
5379
|
},
|
|
5380
|
-
onKeyUp: (
|
|
5381
|
-
w && (
|
|
5380
|
+
onKeyUp: (C) => {
|
|
5381
|
+
w && (C.preventDefault(), _(!1));
|
|
5382
5382
|
},
|
|
5383
5383
|
onBlur: () => A(),
|
|
5384
|
-
onChange: (
|
|
5385
|
-
|
|
5384
|
+
onChange: (C) => {
|
|
5385
|
+
f(!1), l(C.target.value);
|
|
5386
5386
|
},
|
|
5387
|
-
onClick: (
|
|
5387
|
+
onClick: (C) => {
|
|
5388
5388
|
var y;
|
|
5389
|
-
(y =
|
|
5389
|
+
(y = C == null ? void 0 : C.target) == null || y.select(), r(!1);
|
|
5390
5390
|
},
|
|
5391
5391
|
value: v ? k : a,
|
|
5392
5392
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5393
5393
|
" ",
|
|
5394
|
-
|
|
5394
|
+
x ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
5395
5395
|
)
|
|
5396
5396
|
}
|
|
5397
5397
|
),
|
|
@@ -5413,8 +5413,8 @@ const BlockStylingProps = () => {
|
|
|
5413
5413
|
{
|
|
5414
5414
|
units: u,
|
|
5415
5415
|
current: m,
|
|
5416
|
-
onSelect: (
|
|
5417
|
-
r(!1), h(
|
|
5416
|
+
onSelect: (C) => {
|
|
5417
|
+
r(!1), h(C), N(C);
|
|
5418
5418
|
}
|
|
5419
5419
|
}
|
|
5420
5420
|
) })
|
|
@@ -5424,18 +5424,18 @@ const BlockStylingProps = () => {
|
|
|
5424
5424
|
DragStyleButton,
|
|
5425
5425
|
{
|
|
5426
5426
|
onDragStart: () => B(!0),
|
|
5427
|
-
onDragEnd: (
|
|
5428
|
-
if (b(() => ""), B(!1), isEmpty(
|
|
5427
|
+
onDragEnd: (C) => {
|
|
5428
|
+
if (b(() => ""), B(!1), isEmpty(C))
|
|
5429
5429
|
return;
|
|
5430
|
-
const y = `${
|
|
5430
|
+
const y = `${C}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5431
5431
|
E(I);
|
|
5432
5432
|
},
|
|
5433
|
-
onDrag: (
|
|
5434
|
-
if (isEmpty(
|
|
5433
|
+
onDrag: (C) => {
|
|
5434
|
+
if (isEmpty(C))
|
|
5435
5435
|
return;
|
|
5436
|
-
b(
|
|
5437
|
-
const y = `${
|
|
5438
|
-
|
|
5436
|
+
b(C);
|
|
5437
|
+
const y = `${C}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5438
|
+
S(I);
|
|
5439
5439
|
},
|
|
5440
5440
|
currentValue: a,
|
|
5441
5441
|
unit: m,
|
|
@@ -5510,7 +5510,7 @@ const COLOR_PROP = {
|
|
|
5510
5510
|
return c([]);
|
|
5511
5511
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5512
5512
|
}, [g]);
|
|
5513
|
-
const
|
|
5513
|
+
const x = useCallback(
|
|
5514
5514
|
// eslint-disable-next-line no-shadow
|
|
5515
5515
|
(k) => {
|
|
5516
5516
|
p({ color: g, shade: k });
|
|
@@ -5520,11 +5520,11 @@ const COLOR_PROP = {
|
|
|
5520
5520
|
useEffect(() => {
|
|
5521
5521
|
p({ color: "", shade: "" });
|
|
5522
5522
|
}, [r]);
|
|
5523
|
-
const { match:
|
|
5523
|
+
const { match: f } = useTailwindClassList();
|
|
5524
5524
|
return useEffect(() => {
|
|
5525
5525
|
const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5526
|
-
|
|
5527
|
-
}, [
|
|
5526
|
+
f(o, b) && n(b, o);
|
|
5527
|
+
}, [f, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5528
5528
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5529
5529
|
DropDown,
|
|
5530
5530
|
{
|
|
@@ -5564,7 +5564,7 @@ const COLOR_PROP = {
|
|
|
5564
5564
|
]
|
|
5565
5565
|
}
|
|
5566
5566
|
) }),
|
|
5567
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange:
|
|
5567
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: x, options: i }) })
|
|
5568
5568
|
] });
|
|
5569
5569
|
}, EDITOR_ICONS = {
|
|
5570
5570
|
"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" }) }),
|
|
@@ -5898,22 +5898,22 @@ const COLOR_PROP = {
|
|
|
5898
5898
|
"2xl": "1536px"
|
|
5899
5899
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
5900
5900
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
5901
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(),
|
|
5902
|
-
(
|
|
5903
|
-
const N = { dark: p, mq: g, mod: u, cls:
|
|
5901
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), k = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
|
|
5902
|
+
(S, A = !0) => {
|
|
5903
|
+
const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
|
|
5904
5904
|
(p || u !== "") && (N.mq = "xs");
|
|
5905
|
-
const
|
|
5906
|
-
h(
|
|
5905
|
+
const C = generateFullClsName(N);
|
|
5906
|
+
h(f, [C], A);
|
|
5907
5907
|
},
|
|
5908
|
-
[
|
|
5908
|
+
[f, p, g, u, l, h]
|
|
5909
5909
|
), v = useCallback(() => {
|
|
5910
|
-
f
|
|
5911
|
-
}, [
|
|
5910
|
+
x(f, [k], !0);
|
|
5911
|
+
}, [f, k, x]), B = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
5912
5912
|
useEffect(() => {
|
|
5913
5913
|
i(B, m);
|
|
5914
5914
|
}, [B, i, m]);
|
|
5915
5915
|
const [, , w] = useScreenSizeWidth(), _ = useCallback(
|
|
5916
|
-
(
|
|
5916
|
+
(S) => {
|
|
5917
5917
|
w({
|
|
5918
5918
|
xs: 400,
|
|
5919
5919
|
sm: 640,
|
|
@@ -5921,7 +5921,7 @@ const COLOR_PROP = {
|
|
|
5921
5921
|
lg: 1024,
|
|
5922
5922
|
xl: 1420,
|
|
5923
5923
|
"2xl": 1920
|
|
5924
|
-
}[
|
|
5924
|
+
}[S]);
|
|
5925
5925
|
},
|
|
5926
5926
|
[w]
|
|
5927
5927
|
), E = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
@@ -5994,23 +5994,23 @@ const COLOR_PROP = {
|
|
|
5994
5994
|
children: [
|
|
5995
5995
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
5996
5996
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
5997
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key:
|
|
5997
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: x }, f) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5998
5998
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
5999
5999
|
"button",
|
|
6000
6000
|
{
|
|
6001
6001
|
type: "button",
|
|
6002
|
-
onClick: () => u(
|
|
6003
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6002
|
+
onClick: () => u(x),
|
|
6003
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6004
6004
|
children: [
|
|
6005
6005
|
React__default.createElement("div", {
|
|
6006
|
-
className: m(
|
|
6006
|
+
className: m(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6007
6007
|
}),
|
|
6008
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6008
|
+
React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6009
6009
|
]
|
|
6010
6010
|
}
|
|
6011
6011
|
) }),
|
|
6012
6012
|
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
|
|
6013
|
-
] }) }, `option-${
|
|
6013
|
+
] }) }, `option-${f}`)) })
|
|
6014
6014
|
] }),
|
|
6015
6015
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6016
6016
|
BlockStyle,
|
|
@@ -6165,9 +6165,9 @@ const COLOR_PROP = {
|
|
|
6165
6165
|
canvas: n = !1,
|
|
6166
6166
|
tooltip: r = !0
|
|
6167
6167
|
}) => {
|
|
6168
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS),
|
|
6168
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
|
|
6169
6169
|
u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
|
|
6170
|
-
},
|
|
6170
|
+
}, f = (b) => {
|
|
6171
6171
|
n || l(b), c(b);
|
|
6172
6172
|
}, k = getBreakpointValue(n ? i : a).toLowerCase();
|
|
6173
6173
|
return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (b) => /* @__PURE__ */ createElement(
|
|
@@ -6175,7 +6175,7 @@ const COLOR_PROP = {
|
|
|
6175
6175
|
{
|
|
6176
6176
|
canvas: n,
|
|
6177
6177
|
...b,
|
|
6178
|
-
onClick:
|
|
6178
|
+
onClick: f,
|
|
6179
6179
|
key: b.breakpoint,
|
|
6180
6180
|
currentBreakpoint: k
|
|
6181
6181
|
}
|
|
@@ -6189,7 +6189,7 @@ const COLOR_PROP = {
|
|
|
6189
6189
|
openDelay: o,
|
|
6190
6190
|
tooltip: r,
|
|
6191
6191
|
...b,
|
|
6192
|
-
onClick:
|
|
6192
|
+
onClick: f,
|
|
6193
6193
|
key: b.breakpoint,
|
|
6194
6194
|
currentBreakpoint: k
|
|
6195
6195
|
}
|
|
@@ -6204,7 +6204,7 @@ const COLOR_PROP = {
|
|
|
6204
6204
|
DropdownMenuCheckboxItem,
|
|
6205
6205
|
{
|
|
6206
6206
|
disabled: b.breakpoint === "xs",
|
|
6207
|
-
onCheckedChange: () =>
|
|
6207
|
+
onCheckedChange: () => x(toUpper(b.breakpoint)),
|
|
6208
6208
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6209
6209
|
children: m(b.title)
|
|
6210
6210
|
},
|
|
@@ -6289,8 +6289,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6289
6289
|
(h = d.current) == null || h.focus();
|
|
6290
6290
|
}, []);
|
|
6291
6291
|
const m = (h) => {
|
|
6292
|
-
const { usage:
|
|
6293
|
-
!l &&
|
|
6292
|
+
const { usage: x } = h || {};
|
|
6293
|
+
!l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6294
6294
|
};
|
|
6295
6295
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6296
6296
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -6346,24 +6346,24 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6346
6346
|
};
|
|
6347
6347
|
function ManualClasses() {
|
|
6348
6348
|
var I;
|
|
6349
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [
|
|
6350
|
-
const L =
|
|
6351
|
-
u(m, L, !0),
|
|
6349
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), k = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), v = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
|
|
6350
|
+
const L = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6351
|
+
u(m, L, !0), f("");
|
|
6352
6352
|
}, [w, _] = useState([]), E = ({ value: L }) => {
|
|
6353
|
-
const
|
|
6353
|
+
const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
|
|
6354
6354
|
let D = [];
|
|
6355
6355
|
if (T && T.length > 0) {
|
|
6356
|
-
const [O] = T,
|
|
6357
|
-
D = i.search(
|
|
6356
|
+
const [O] = T, P = R.replace(O, "");
|
|
6357
|
+
D = i.search(P).map((M) => ({
|
|
6358
6358
|
...M,
|
|
6359
6359
|
item: { ...M.item, name: O + M.item.name }
|
|
6360
6360
|
}));
|
|
6361
6361
|
} else
|
|
6362
|
-
D = i.search(
|
|
6362
|
+
D = i.search(R);
|
|
6363
6363
|
return _(map(D, "item"));
|
|
6364
|
-
},
|
|
6364
|
+
}, S = () => {
|
|
6365
6365
|
_([]);
|
|
6366
|
-
}, A = (L) => L.name, N = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }),
|
|
6366
|
+
}, A = (L) => L.name, N = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), C = useMemo(
|
|
6367
6367
|
() => ({
|
|
6368
6368
|
ref: o,
|
|
6369
6369
|
autoComplete: "off",
|
|
@@ -6371,23 +6371,23 @@ function ManualClasses() {
|
|
|
6371
6371
|
autoCapitalize: "off",
|
|
6372
6372
|
spellCheck: !1,
|
|
6373
6373
|
placeholder: c("Enter classes separated by space"),
|
|
6374
|
-
value:
|
|
6374
|
+
value: x,
|
|
6375
6375
|
onFocus: (L) => {
|
|
6376
6376
|
setTimeout(() => {
|
|
6377
6377
|
L.target && L.target.select();
|
|
6378
6378
|
}, 0);
|
|
6379
6379
|
},
|
|
6380
6380
|
onKeyDown: (L) => {
|
|
6381
|
-
L.key === "Enter" &&
|
|
6381
|
+
L.key === "Enter" && x.trim() !== "" && B();
|
|
6382
6382
|
},
|
|
6383
|
-
onChange: (L, { newValue:
|
|
6383
|
+
onChange: (L, { newValue: R }) => f(R),
|
|
6384
6384
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6385
6385
|
}),
|
|
6386
|
-
[
|
|
6386
|
+
[x, c, o]
|
|
6387
6387
|
), y = (L) => {
|
|
6388
6388
|
debugger;
|
|
6389
|
-
const
|
|
6390
|
-
g(m, [L]), u(m,
|
|
6389
|
+
const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6390
|
+
g(m, [L]), u(m, R, !0), r(""), l(-1);
|
|
6391
6391
|
}, j = () => {
|
|
6392
6392
|
if (navigator.clipboard === void 0) {
|
|
6393
6393
|
toast.error(c("Clipboard not supported"));
|
|
@@ -6418,10 +6418,10 @@ function ManualClasses() {
|
|
|
6418
6418
|
{
|
|
6419
6419
|
suggestions: w,
|
|
6420
6420
|
onSuggestionsFetchRequested: E,
|
|
6421
|
-
onSuggestionsClearRequested:
|
|
6421
|
+
onSuggestionsClearRequested: S,
|
|
6422
6422
|
getSuggestionValue: A,
|
|
6423
6423
|
renderSuggestion: N,
|
|
6424
|
-
inputProps:
|
|
6424
|
+
inputProps: C,
|
|
6425
6425
|
containerProps: {
|
|
6426
6426
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
6427
6427
|
},
|
|
@@ -6438,14 +6438,14 @@ function ManualClasses() {
|
|
|
6438
6438
|
variant: "outline",
|
|
6439
6439
|
className: "h-6 border-border",
|
|
6440
6440
|
onClick: B,
|
|
6441
|
-
disabled:
|
|
6441
|
+
disabled: x.trim() === "",
|
|
6442
6442
|
size: "sm",
|
|
6443
6443
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
6444
6444
|
}
|
|
6445
6445
|
)
|
|
6446
6446
|
] }),
|
|
6447
6447
|
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: v.map(
|
|
6448
|
-
(L,
|
|
6448
|
+
(L, R) => a === R ? /* @__PURE__ */ jsx(
|
|
6449
6449
|
"input",
|
|
6450
6450
|
{
|
|
6451
6451
|
ref: o,
|
|
@@ -6469,7 +6469,7 @@ function ManualClasses() {
|
|
|
6469
6469
|
"button",
|
|
6470
6470
|
{
|
|
6471
6471
|
onDoubleClick: () => {
|
|
6472
|
-
|
|
6472
|
+
f(L), g(m, [L]), setTimeout(() => {
|
|
6473
6473
|
o.current && o.current.focus();
|
|
6474
6474
|
}, 10);
|
|
6475
6475
|
},
|
|
@@ -6602,9 +6602,9 @@ function BlockStyling() {
|
|
|
6602
6602
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6603
6603
|
let h = parseFloat(i.dragStartValue);
|
|
6604
6604
|
h = isNaN(h) ? 0 : h;
|
|
6605
|
-
let
|
|
6606
|
-
(startsWith(m, "scale") || m === "opacity") && (
|
|
6607
|
-
let k = (i.dragStartY - u.pageY) /
|
|
6605
|
+
let x = MAPPER[i.dragUnit];
|
|
6606
|
+
(startsWith(m, "scale") || m === "opacity") && (x = 10);
|
|
6607
|
+
let k = (i.dragStartY - u.pageY) / x + h;
|
|
6608
6608
|
g && k < 0 && (k = 0), m === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
|
|
6609
6609
|
},
|
|
6610
6610
|
[i],
|
|
@@ -6653,7 +6653,7 @@ const CoreBlock = ({
|
|
|
6653
6653
|
} else
|
|
6654
6654
|
p(o, r || null, a);
|
|
6655
6655
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6656
|
-
},
|
|
6656
|
+
}, x = useFeature("dnd"), { t: f } = useTranslation();
|
|
6657
6657
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6658
6658
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6659
6659
|
"button",
|
|
@@ -6666,15 +6666,15 @@ const CoreBlock = ({
|
|
|
6666
6666
|
g([]), m();
|
|
6667
6667
|
}, 200);
|
|
6668
6668
|
},
|
|
6669
|
-
draggable:
|
|
6669
|
+
draggable: x ? "true" : "false",
|
|
6670
6670
|
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",
|
|
6671
6671
|
children: [
|
|
6672
6672
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6673
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6673
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(f(d || i)) })
|
|
6674
6674
|
]
|
|
6675
6675
|
}
|
|
6676
6676
|
) }),
|
|
6677
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6677
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f(d || i) }) })
|
|
6678
6678
|
] }) });
|
|
6679
6679
|
}, DefaultChaiBlocks = ({
|
|
6680
6680
|
parentId: o,
|
|
@@ -6862,7 +6862,7 @@ const CoreBlock = ({
|
|
|
6862
6862
|
}
|
|
6863
6863
|
}
|
|
6864
6864
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6865
|
-
var m, h,
|
|
6865
|
+
var m, h, x, f, k, b, v, B;
|
|
6866
6866
|
if (r.type === "comment") return [];
|
|
6867
6867
|
let a = { _id: generateUUID() };
|
|
6868
6868
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
@@ -6904,8 +6904,8 @@ const CoreBlock = ({
|
|
|
6904
6904
|
...a,
|
|
6905
6905
|
href: ((m = l.find((_) => _.key === "href")) == null ? void 0 : m.value) || "",
|
|
6906
6906
|
hrefType: ((h = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
|
|
6907
|
-
autoplay: ((
|
|
6908
|
-
maxWidth: ((k = (
|
|
6907
|
+
autoplay: ((x = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
|
|
6908
|
+
maxWidth: ((k = (f = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : k.replace("px", "")) || "",
|
|
6909
6909
|
backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
|
|
6910
6910
|
galleryName: ((v = l.find((_) => _.key === "data-gall")) == null ? void 0 : v.value) || ""
|
|
6911
6911
|
}, forEach(w, (_) => {
|
|
@@ -6918,14 +6918,14 @@ const CoreBlock = ({
|
|
|
6918
6918
|
a.content = getTextContent(w);
|
|
6919
6919
|
const _ = find(
|
|
6920
6920
|
r.children || [],
|
|
6921
|
-
(E) => (E == null ? void 0 : E.tagName) === "span" && some(E.children || [], (
|
|
6921
|
+
(E) => (E == null ? void 0 : E.tagName) === "span" && some(E.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
|
|
6922
6922
|
);
|
|
6923
6923
|
if (_) {
|
|
6924
|
-
const E = find(_.children || [], (
|
|
6924
|
+
const E = find(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
|
|
6925
6925
|
if (E) {
|
|
6926
6926
|
a.icon = stringify([E]);
|
|
6927
|
-
const { height:
|
|
6928
|
-
a.iconHeight =
|
|
6927
|
+
const { height: S, width: A } = getSvgDimensions(E, "16px", "16px");
|
|
6928
|
+
a.iconHeight = S, a.iconWidth = A;
|
|
6929
6929
|
}
|
|
6930
6930
|
}
|
|
6931
6931
|
return [a];
|
|
@@ -6937,8 +6937,8 @@ const CoreBlock = ({
|
|
|
6937
6937
|
const w = stringify([r]);
|
|
6938
6938
|
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];
|
|
6939
6939
|
} else if (r.tagName === "svg") {
|
|
6940
|
-
const w = find(r.attributes, { key: "height" }), _ = find(r.attributes, { key: "width" }), E = get(w, "value") ? `[${get(w, "value")}px]` : "24px",
|
|
6941
|
-
return a.styles = `${STYLES_KEY}, ${cn$2(`w-${
|
|
6940
|
+
const w = find(r.attributes, { key: "height" }), _ = find(r.attributes, { key: "width" }), E = get(w, "value") ? `[${get(w, "value")}px]` : "24px", S = get(_, "value") ? `[${get(_, "value")}px]` : "24px", A = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
6941
|
+
return a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${E}`, A)}`.trim(), r.attributes = filter(r.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([r]), [a];
|
|
6942
6942
|
} else if (r.tagName == "option" && n && ((B = n.block) == null ? void 0 : B._type) === "Select")
|
|
6943
6943
|
return n.block.options.push({
|
|
6944
6944
|
label: getTextContent(r.children),
|
|
@@ -7046,7 +7046,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7046
7046
|
parentId: r = void 0,
|
|
7047
7047
|
position: a = -1
|
|
7048
7048
|
}) => {
|
|
7049
|
-
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""),
|
|
7049
|
+
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), k = (B) => {
|
|
7050
7050
|
const w = has(B, "styles_attrs.data-page-section");
|
|
7051
7051
|
return B._type === "Box" && w;
|
|
7052
7052
|
}, b = useCallback(
|
|
@@ -7067,20 +7067,20 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7067
7067
|
{
|
|
7068
7068
|
onClick: l ? () => {
|
|
7069
7069
|
} : b,
|
|
7070
|
-
draggable:
|
|
7070
|
+
draggable: x ? "true" : "false",
|
|
7071
7071
|
onDragStart: async (B) => {
|
|
7072
7072
|
const w = await c({ library: n, block: o });
|
|
7073
7073
|
let _ = r;
|
|
7074
7074
|
if (k(first(w)) && (_ = null), !isEmpty(w)) {
|
|
7075
7075
|
const E = { blocks: w, uiLibrary: !0, parent: _ };
|
|
7076
7076
|
if (B.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
|
|
7077
|
-
const
|
|
7078
|
-
|
|
7079
|
-
B.dataTransfer.setDragImage(
|
|
7077
|
+
const S = new Image();
|
|
7078
|
+
S.src = o.preview, S.onload = () => {
|
|
7079
|
+
B.dataTransfer.setDragImage(S, 0, 0);
|
|
7080
7080
|
};
|
|
7081
7081
|
} else
|
|
7082
7082
|
B.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7083
|
-
|
|
7083
|
+
f(E), setTimeout(() => {
|
|
7084
7084
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7085
7085
|
}, 200);
|
|
7086
7086
|
}
|
|
@@ -7106,22 +7106,22 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7106
7106
|
] }) })
|
|
7107
7107
|
] });
|
|
7108
7108
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7109
|
-
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((y) => y.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]),
|
|
7109
|
+
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((y) => y.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), x = useRef(null);
|
|
7110
7110
|
useEffect(() => {
|
|
7111
|
-
c && c.length > 0 && (
|
|
7111
|
+
c && c.length > 0 && (x.current = new Fuse(c, {
|
|
7112
7112
|
keys: ["name", "label", "description", "group"],
|
|
7113
7113
|
threshold: 0.4,
|
|
7114
7114
|
ignoreLocation: !0
|
|
7115
7115
|
}));
|
|
7116
7116
|
}, [c]), useEffect(() => {
|
|
7117
|
-
if (!u.trim() || !
|
|
7117
|
+
if (!u.trim() || !x.current) {
|
|
7118
7118
|
h([]);
|
|
7119
7119
|
return;
|
|
7120
7120
|
}
|
|
7121
|
-
const y =
|
|
7121
|
+
const y = x.current.search(u).map((j) => j.item);
|
|
7122
7122
|
h(y);
|
|
7123
7123
|
}, [u]);
|
|
7124
|
-
const
|
|
7124
|
+
const f = u.trim() && !isEmpty(m) ? m : c, k = groupBy(f, "group"), [b, v] = useState(null);
|
|
7125
7125
|
useEffect(() => {
|
|
7126
7126
|
if (isEmpty(keys(k))) {
|
|
7127
7127
|
v(null);
|
|
@@ -7136,7 +7136,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7136
7136
|
w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
|
|
7137
7137
|
w.current && v(y);
|
|
7138
7138
|
}, 400);
|
|
7139
|
-
},
|
|
7139
|
+
}, S = () => {
|
|
7140
7140
|
i != null && i.id && p(i.id);
|
|
7141
7141
|
}, A = () => {
|
|
7142
7142
|
g("");
|
|
@@ -7146,7 +7146,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7146
7146
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7147
7147
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7148
7148
|
] });
|
|
7149
|
-
const N = filter(B, (y, j) => j % 2 === 0),
|
|
7149
|
+
const N = filter(B, (y, j) => j % 2 === 0), C = filter(B, (y, j) => j % 2 === 1);
|
|
7150
7150
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7151
7151
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7152
7152
|
/* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
@@ -7176,7 +7176,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7176
7176
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7177
7177
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7178
7178
|
/* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
|
|
7179
|
-
/* @__PURE__ */ jsxs(Button, { onClick:
|
|
7179
|
+
/* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7180
7180
|
/* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
|
|
7181
7181
|
_("Retry")
|
|
7182
7182
|
] })
|
|
@@ -7217,7 +7217,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7217
7217
|
},
|
|
7218
7218
|
`block-${j}`
|
|
7219
7219
|
)) }),
|
|
7220
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7220
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((y, j) => /* @__PURE__ */ jsx(
|
|
7221
7221
|
BlockCard,
|
|
7222
7222
|
{
|
|
7223
7223
|
parentId: o,
|
|
@@ -7261,25 +7261,25 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7261
7261
|
error: c
|
|
7262
7262
|
}), g(!0);
|
|
7263
7263
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7264
|
-
const h = Object.entries(a).map(([
|
|
7264
|
+
const h = Object.entries(a).map(([f, k]) => {
|
|
7265
7265
|
const b = k, v = b.type || "partial", B = formatReadableName(v);
|
|
7266
7266
|
return {
|
|
7267
7267
|
type: "PartialBlock",
|
|
7268
7268
|
// Set the type to PartialBlock
|
|
7269
|
-
label: formatReadableName(b.name ||
|
|
7269
|
+
label: formatReadableName(b.name || f),
|
|
7270
7270
|
description: b.description || "",
|
|
7271
7271
|
icon: Globe,
|
|
7272
7272
|
group: B,
|
|
7273
7273
|
// Use formatted type as group
|
|
7274
7274
|
category: "partial",
|
|
7275
|
-
partialBlockId:
|
|
7275
|
+
partialBlockId: f,
|
|
7276
7276
|
// Store the original ID as partialBlockId
|
|
7277
7277
|
_name: b.name
|
|
7278
7278
|
};
|
|
7279
|
-
}),
|
|
7279
|
+
}), x = uniq(map(h, "group"));
|
|
7280
7280
|
p({
|
|
7281
7281
|
blocks: h,
|
|
7282
|
-
groups:
|
|
7282
|
+
groups: x,
|
|
7283
7283
|
isLoading: !1,
|
|
7284
7284
|
error: null
|
|
7285
7285
|
}), g(!0);
|
|
@@ -7324,8 +7324,8 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7324
7324
|
}, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, n) => {
|
|
7325
7325
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
|
|
7326
7326
|
}, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7327
|
-
var
|
|
7328
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (
|
|
7327
|
+
var C;
|
|
7328
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (C = find(c, (y) => y._id === r)) == null ? void 0 : C._type, [h, x] = useState("all"), [f, k] = useState(null), b = useRef(null);
|
|
7329
7329
|
useEffect(() => {
|
|
7330
7330
|
const y = setTimeout(() => {
|
|
7331
7331
|
var j;
|
|
@@ -7333,9 +7333,9 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7333
7333
|
}, 0);
|
|
7334
7334
|
return () => clearTimeout(y);
|
|
7335
7335
|
}, [g]), useEffect(() => {
|
|
7336
|
-
d && (
|
|
7336
|
+
d && (x("all"), k(null));
|
|
7337
7337
|
}, [d]), useEffect(() => (b.current = debounce((y) => {
|
|
7338
|
-
|
|
7338
|
+
x(y);
|
|
7339
7339
|
}, 500), () => {
|
|
7340
7340
|
b.current && b.current.cancel();
|
|
7341
7341
|
}), []);
|
|
@@ -7344,7 +7344,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7344
7344
|
}, []), B = useCallback(() => {
|
|
7345
7345
|
k(null), b.current && b.current.cancel();
|
|
7346
7346
|
}, []), w = useCallback((y) => {
|
|
7347
|
-
b.current && b.current.cancel(),
|
|
7347
|
+
b.current && b.current.cancel(), x(y), k(null);
|
|
7348
7348
|
}, []), _ = useMemo(
|
|
7349
7349
|
() => d ? values(n).filter(
|
|
7350
7350
|
(y) => {
|
|
@@ -7358,10 +7358,10 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7358
7358
|
(y) => reject(filter(values(_), { group: y }), { hidden: !0 }).length > 0
|
|
7359
7359
|
) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
|
|
7360
7360
|
[n, _, o, d]
|
|
7361
|
-
),
|
|
7361
|
+
), S = useMemo(
|
|
7362
7362
|
() => sortBy(E, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
|
|
7363
7363
|
[E]
|
|
7364
|
-
), A = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), N = useMemo(() => h === "all" ?
|
|
7364
|
+
), A = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), N = useMemo(() => h === "all" ? S : [h], [S, h]);
|
|
7365
7365
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7366
7366
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7367
7367
|
Input$1,
|
|
@@ -7375,25 +7375,25 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7375
7375
|
}
|
|
7376
7376
|
) }),
|
|
7377
7377
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7378
|
-
|
|
7378
|
+
S.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
7379
7379
|
/* @__PURE__ */ jsx(
|
|
7380
7380
|
"button",
|
|
7381
7381
|
{
|
|
7382
7382
|
onClick: () => w("all"),
|
|
7383
7383
|
onMouseEnter: () => v("all"),
|
|
7384
7384
|
onMouseLeave: B,
|
|
7385
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" ||
|
|
7385
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7386
7386
|
children: i("All")
|
|
7387
7387
|
},
|
|
7388
7388
|
"sidebar-all"
|
|
7389
7389
|
),
|
|
7390
|
-
|
|
7390
|
+
S.map((y) => /* @__PURE__ */ jsx(
|
|
7391
7391
|
"button",
|
|
7392
7392
|
{
|
|
7393
7393
|
onClick: () => w(y),
|
|
7394
7394
|
onMouseEnter: () => v(y),
|
|
7395
7395
|
onMouseLeave: B,
|
|
7396
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === y ||
|
|
7396
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === y || f === y ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7397
7397
|
children: capitalize(i(y.toLowerCase()))
|
|
7398
7398
|
},
|
|
7399
7399
|
`sidebar-${y}`
|
|
@@ -7434,7 +7434,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7434
7434
|
}, [i, g, c]);
|
|
7435
7435
|
const h = useCallback(() => {
|
|
7436
7436
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7437
|
-
}, []),
|
|
7437
|
+
}, []), x = useChaiAddBlockTabs(), f = p && m(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
|
|
7438
7438
|
return useEffect(() => {
|
|
7439
7439
|
i === "library" && !b && c("core");
|
|
7440
7440
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7455,14 +7455,14 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7455
7455
|
b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7456
7456
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7457
7457
|
g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7458
|
-
|
|
7459
|
-
map(
|
|
7458
|
+
f ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7459
|
+
map(x, (v) => /* @__PURE__ */ jsx(TabsTrigger, { value: v.id, children: React__default.createElement(v.tab) }, `tab-add-block-${v.id}`))
|
|
7460
7460
|
] }),
|
|
7461
7461
|
/* @__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: r, position: a }) }) }) }),
|
|
7462
7462
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7463
7463
|
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: r, position: a }) }) }) }),
|
|
7464
|
-
|
|
7465
|
-
map(
|
|
7464
|
+
f ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7465
|
+
map(x, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${v.id}`))
|
|
7466
7466
|
]
|
|
7467
7467
|
}
|
|
7468
7468
|
)
|
|
@@ -7766,22 +7766,22 @@ const Input = ({ node: o }) => {
|
|
|
7766
7766
|
}
|
|
7767
7767
|
);
|
|
7768
7768
|
}, currentAddSelection = atom(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
7769
|
-
var
|
|
7769
|
+
var R;
|
|
7770
7770
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7771
7771
|
let p = null;
|
|
7772
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data:
|
|
7772
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: x, isSelected: f, willReceiveDrop: k, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
|
|
7773
7773
|
T.stopPropagation(), !l.includes(h) && o.toggle();
|
|
7774
7774
|
}, _ = (T) => {
|
|
7775
7775
|
T.isInternal && (p = T.isOpen, T.isOpen && T.close());
|
|
7776
7776
|
}, E = (T) => {
|
|
7777
7777
|
T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
|
|
7778
|
-
}, [
|
|
7778
|
+
}, [S, A] = useAtom$1(currentAddSelection), N = () => {
|
|
7779
7779
|
var T;
|
|
7780
|
-
|
|
7781
|
-
},
|
|
7780
|
+
C(), o.parent.isSelected || A((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
|
|
7781
|
+
}, C = () => {
|
|
7782
7782
|
A(null);
|
|
7783
7783
|
}, y = (T) => {
|
|
7784
|
-
|
|
7784
|
+
C(), T.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), B(T);
|
|
7785
7785
|
};
|
|
7786
7786
|
useEffect(() => {
|
|
7787
7787
|
const T = setTimeout(() => {
|
|
@@ -7790,12 +7790,12 @@ const Input = ({ node: o }) => {
|
|
|
7790
7790
|
return () => clearTimeout(T);
|
|
7791
7791
|
}, [k, o, b]);
|
|
7792
7792
|
const j = (T, D) => {
|
|
7793
|
-
const O = c.contentDocument || c.contentWindow.document,
|
|
7794
|
-
|
|
7795
|
-
const $ =
|
|
7796
|
-
$.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop =
|
|
7793
|
+
const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
|
|
7794
|
+
P && P.setAttribute("data-drop", D);
|
|
7795
|
+
const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
|
|
7796
|
+
$.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
|
|
7797
7797
|
}, I = (T) => {
|
|
7798
|
-
|
|
7798
|
+
C();
|
|
7799
7799
|
const D = get(o, "parent.id");
|
|
7800
7800
|
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
|
|
7801
7801
|
};
|
|
@@ -7817,7 +7817,7 @@ const Input = ({ node: o }) => {
|
|
|
7817
7817
|
),
|
|
7818
7818
|
/* @__PURE__ */ jsx("br", {})
|
|
7819
7819
|
] });
|
|
7820
|
-
const L = useMemo(() => has(
|
|
7820
|
+
const L = useMemo(() => has(x, "_libBlockId") && !isEmpty(x._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [x, d]);
|
|
7821
7821
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7822
7822
|
"div",
|
|
7823
7823
|
{
|
|
@@ -7839,14 +7839,14 @@ const Input = ({ node: o }) => {
|
|
|
7839
7839
|
T.preventDefault(), j(h, "no");
|
|
7840
7840
|
},
|
|
7841
7841
|
children: [
|
|
7842
|
-
d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((
|
|
7842
|
+
d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
7843
7843
|
"div",
|
|
7844
7844
|
{
|
|
7845
7845
|
onClick: (T) => {
|
|
7846
7846
|
T.stopPropagation(), I(o.childIndex);
|
|
7847
7847
|
},
|
|
7848
7848
|
onMouseEnter: N,
|
|
7849
|
-
onMouseLeave:
|
|
7849
|
+
onMouseLeave: C,
|
|
7850
7850
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7851
7851
|
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" }) })
|
|
7852
7852
|
}
|
|
@@ -7856,12 +7856,12 @@ const Input = ({ node: o }) => {
|
|
|
7856
7856
|
{
|
|
7857
7857
|
className: cn(
|
|
7858
7858
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
|
|
7859
|
-
|
|
7860
|
-
k && canAcceptChildBlock(
|
|
7861
|
-
(o == null ? void 0 : o.id) ===
|
|
7859
|
+
f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
|
|
7860
|
+
k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
|
|
7861
|
+
(o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
|
|
7862
7862
|
b && "opacity-20",
|
|
7863
7863
|
l.includes(h) ? "opacity-50" : "",
|
|
7864
|
-
L &&
|
|
7864
|
+
L && f && "bg-primary/20 text-primary"
|
|
7865
7865
|
),
|
|
7866
7866
|
children: [
|
|
7867
7867
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7869,7 +7869,7 @@ const Input = ({ node: o }) => {
|
|
|
7869
7869
|
"div",
|
|
7870
7870
|
{
|
|
7871
7871
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7872
|
-
children: u && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${
|
|
7872
|
+
children: u && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${f ? "text-white" : "text-slate-400"}` }) })
|
|
7873
7873
|
}
|
|
7874
7874
|
),
|
|
7875
7875
|
/* @__PURE__ */ jsxs(
|
|
@@ -7878,10 +7878,10 @@ const Input = ({ node: o }) => {
|
|
|
7878
7878
|
className: cn(
|
|
7879
7879
|
"leading-1 flex items-center",
|
|
7880
7880
|
L && "text-primary/60",
|
|
7881
|
-
L &&
|
|
7881
|
+
L && f && "text-primary/80"
|
|
7882
7882
|
),
|
|
7883
7883
|
children: [
|
|
7884
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7884
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
|
|
7885
7885
|
v ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
|
|
7886
7886
|
"div",
|
|
7887
7887
|
{
|
|
@@ -7889,7 +7889,7 @@ const Input = ({ node: o }) => {
|
|
|
7889
7889
|
onDoubleClick: (T) => {
|
|
7890
7890
|
T.stopPropagation(), o.edit(), o.deselect();
|
|
7891
7891
|
},
|
|
7892
|
-
children: /* @__PURE__ */ jsx("span", { children: (
|
|
7892
|
+
children: /* @__PURE__ */ jsx("span", { children: (x == null ? void 0 : x._name) || (x == null ? void 0 : x._type.split("/").pop()) })
|
|
7893
7893
|
}
|
|
7894
7894
|
)
|
|
7895
7895
|
]
|
|
@@ -7897,7 +7897,7 @@ const Input = ({ node: o }) => {
|
|
|
7897
7897
|
)
|
|
7898
7898
|
] }),
|
|
7899
7899
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7900
|
-
canAddChildBlock(
|
|
7900
|
+
canAddChildBlock(x == null ? void 0 : x._type) && !l.includes(h) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7901
7901
|
/* @__PURE__ */ jsx(
|
|
7902
7902
|
TooltipTrigger,
|
|
7903
7903
|
{
|
|
@@ -8197,7 +8197,7 @@ const Input = ({ node: o }) => {
|
|
|
8197
8197
|
B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? p(B) : console.error("Invalid preset structure:", B);
|
|
8198
8198
|
} else
|
|
8199
8199
|
console.error("Preset not found:", r);
|
|
8200
|
-
},
|
|
8200
|
+
}, x = useDebouncedCallback(
|
|
8201
8201
|
(v, B) => {
|
|
8202
8202
|
p(() => ({
|
|
8203
8203
|
...d,
|
|
@@ -8209,7 +8209,7 @@ const Input = ({ node: o }) => {
|
|
|
8209
8209
|
},
|
|
8210
8210
|
[d],
|
|
8211
8211
|
200
|
|
8212
|
-
),
|
|
8212
|
+
), f = useDebouncedCallback(
|
|
8213
8213
|
(v) => {
|
|
8214
8214
|
p(() => ({
|
|
8215
8215
|
...d,
|
|
@@ -8281,14 +8281,14 @@ const Input = ({ node: o }) => {
|
|
|
8281
8281
|
{
|
|
8282
8282
|
label: v,
|
|
8283
8283
|
value: d.fontFamily[v.replace(/font-/g, "")] || B[Object.keys(B)[0]],
|
|
8284
|
-
onChange: (w) =>
|
|
8284
|
+
onChange: (w) => x(v, w)
|
|
8285
8285
|
},
|
|
8286
8286
|
v
|
|
8287
8287
|
)) }),
|
|
8288
8288
|
(u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
8289
8289
|
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Border Radius") }),
|
|
8290
8290
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
8291
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange:
|
|
8291
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: f }),
|
|
8292
8292
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
|
|
8293
8293
|
] })
|
|
8294
8294
|
] }),
|
|
@@ -8766,11 +8766,11 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8766
8766
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8767
8767
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), h = useRef(null);
|
|
8768
8768
|
useEffect(() => {
|
|
8769
|
-
var
|
|
8770
|
-
(
|
|
8769
|
+
var f;
|
|
8770
|
+
(f = m.current) == null || f.focus();
|
|
8771
8771
|
}, []);
|
|
8772
|
-
const
|
|
8773
|
-
const { usage: k } =
|
|
8772
|
+
const x = (f) => {
|
|
8773
|
+
const { usage: k } = f || {};
|
|
8774
8774
|
!l && k && g(k), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8775
8775
|
};
|
|
8776
8776
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -8791,12 +8791,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8791
8791
|
{
|
|
8792
8792
|
ref: m,
|
|
8793
8793
|
value: i,
|
|
8794
|
-
onChange: (
|
|
8794
|
+
onChange: (f) => c(f.target.value),
|
|
8795
8795
|
placeholder: n("Ask AI to edit content"),
|
|
8796
8796
|
className: "w-full",
|
|
8797
8797
|
rows: 3,
|
|
8798
|
-
onKeyDown: (
|
|
8799
|
-
|
|
8798
|
+
onKeyDown: (f) => {
|
|
8799
|
+
f.key === "Enter" && (f.preventDefault(), h.current && clearTimeout(h.current), g(void 0), r("content", o, i, x));
|
|
8800
8800
|
}
|
|
8801
8801
|
}
|
|
8802
8802
|
),
|
|
@@ -8806,7 +8806,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8806
8806
|
{
|
|
8807
8807
|
disabled: i.trim().length < 5 || a,
|
|
8808
8808
|
onClick: () => {
|
|
8809
|
-
h.current && clearTimeout(h.current), g(void 0), r("content", o, i,
|
|
8809
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, i, x);
|
|
8810
8810
|
},
|
|
8811
8811
|
variant: "default",
|
|
8812
8812
|
className: "w-fit",
|
|
@@ -8838,8 +8838,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8838
8838
|
/* @__PURE__ */ jsx(
|
|
8839
8839
|
QuickPrompts,
|
|
8840
8840
|
{
|
|
8841
|
-
onClick: (
|
|
8842
|
-
h.current && clearTimeout(h.current), g(void 0), r("content", o,
|
|
8841
|
+
onClick: (f) => {
|
|
8842
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, f, x);
|
|
8843
8843
|
}
|
|
8844
8844
|
}
|
|
8845
8845
|
)
|
|
@@ -8856,8 +8856,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8856
8856
|
const h = async () => {
|
|
8857
8857
|
try {
|
|
8858
8858
|
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8859
|
-
} catch (
|
|
8860
|
-
u(
|
|
8859
|
+
} catch (x) {
|
|
8860
|
+
u(x);
|
|
8861
8861
|
} finally {
|
|
8862
8862
|
d(!1);
|
|
8863
8863
|
}
|
|
@@ -8865,8 +8865,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8865
8865
|
return /* @__PURE__ */ jsx(
|
|
8866
8866
|
Accordion,
|
|
8867
8867
|
{
|
|
8868
|
-
onValueChange: (
|
|
8869
|
-
g(
|
|
8868
|
+
onValueChange: (x) => {
|
|
8869
|
+
g(x !== "");
|
|
8870
8870
|
},
|
|
8871
8871
|
type: "single",
|
|
8872
8872
|
collapsible: !0,
|
|
@@ -8878,12 +8878,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8878
8878
|
{
|
|
8879
8879
|
ref: l,
|
|
8880
8880
|
value: r,
|
|
8881
|
-
onChange: (
|
|
8881
|
+
onChange: (x) => a(x.target.value),
|
|
8882
8882
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8883
8883
|
className: "mt-1 w-full",
|
|
8884
8884
|
rows: 10,
|
|
8885
|
-
onKeyDown: (
|
|
8886
|
-
|
|
8885
|
+
onKeyDown: (x) => {
|
|
8886
|
+
x.key === "Enter" && (x.preventDefault(), h());
|
|
8887
8887
|
}
|
|
8888
8888
|
}
|
|
8889
8889
|
),
|
|
@@ -9004,7 +9004,7 @@ function AIChatPanel() {
|
|
|
9004
9004
|
}, 1500);
|
|
9005
9005
|
}, h = (b) => {
|
|
9006
9006
|
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), m());
|
|
9007
|
-
},
|
|
9007
|
+
}, x = (b) => {
|
|
9008
9008
|
var B;
|
|
9009
9009
|
const v = (B = b.target.files) == null ? void 0 : B[0];
|
|
9010
9010
|
if (v) {
|
|
@@ -9014,7 +9014,7 @@ function AIChatPanel() {
|
|
|
9014
9014
|
d((E = _.target) == null ? void 0 : E.result);
|
|
9015
9015
|
}, w.readAsDataURL(v);
|
|
9016
9016
|
}
|
|
9017
|
-
},
|
|
9017
|
+
}, f = () => {
|
|
9018
9018
|
var b;
|
|
9019
9019
|
(b = p.current) == null || b.click();
|
|
9020
9020
|
}, k = () => {
|
|
@@ -9081,14 +9081,14 @@ function AIChatPanel() {
|
|
|
9081
9081
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9082
9082
|
}
|
|
9083
9083
|
),
|
|
9084
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange:
|
|
9084
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: x, accept: "image/*", className: "hidden" }),
|
|
9085
9085
|
/* @__PURE__ */ jsx(
|
|
9086
9086
|
Button,
|
|
9087
9087
|
{
|
|
9088
9088
|
size: "icon",
|
|
9089
9089
|
variant: "ghost",
|
|
9090
9090
|
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9091
|
-
onClick:
|
|
9091
|
+
onClick: f,
|
|
9092
9092
|
children: /* @__PURE__ */ jsx(Image$1, { className: "h-4 w-4 text-muted-foreground" })
|
|
9093
9093
|
}
|
|
9094
9094
|
)
|
|
@@ -9206,7 +9206,7 @@ const AiAssistant = () => {
|
|
|
9206
9206
|
preloadedAttributes: n = [],
|
|
9207
9207
|
onAttributesChange: r
|
|
9208
9208
|
}) {
|
|
9209
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""),
|
|
9209
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), x = useRef(null), f = useRef(null), k = usePageExternalData();
|
|
9210
9210
|
useEffect(() => {
|
|
9211
9211
|
l(n);
|
|
9212
9212
|
}, [n]);
|
|
@@ -9216,43 +9216,43 @@ const AiAssistant = () => {
|
|
|
9216
9216
|
return;
|
|
9217
9217
|
}
|
|
9218
9218
|
if (i) {
|
|
9219
|
-
const
|
|
9220
|
-
r(
|
|
9219
|
+
const S = [...a, { key: i, value: d }];
|
|
9220
|
+
r(S), l(a), c(""), p(""), h("");
|
|
9221
9221
|
}
|
|
9222
|
-
}, v = (
|
|
9223
|
-
const A = a.filter((N,
|
|
9222
|
+
}, v = (S) => {
|
|
9223
|
+
const A = a.filter((N, C) => C !== S);
|
|
9224
9224
|
r(A), l(A);
|
|
9225
|
-
}, B = (
|
|
9226
|
-
g(
|
|
9225
|
+
}, B = (S) => {
|
|
9226
|
+
g(S), c(a[S].key), p(a[S].value);
|
|
9227
9227
|
}, w = () => {
|
|
9228
9228
|
if (i.startsWith("@")) {
|
|
9229
9229
|
h("Attribute keys cannot start with '@'");
|
|
9230
9230
|
return;
|
|
9231
9231
|
}
|
|
9232
9232
|
if (u !== null && i) {
|
|
9233
|
-
const
|
|
9234
|
-
|
|
9233
|
+
const S = [...a];
|
|
9234
|
+
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), h("");
|
|
9235
9235
|
}
|
|
9236
|
-
}, _ = (
|
|
9237
|
-
|
|
9238
|
-
}, E = useCallback((
|
|
9236
|
+
}, _ = (S) => {
|
|
9237
|
+
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
|
|
9238
|
+
}, E = useCallback((S) => {
|
|
9239
9239
|
const A = (y) => /[.,!?;:]/.test(y), N = (y, j, I) => {
|
|
9240
|
-
let L = "",
|
|
9240
|
+
let L = "", R = "";
|
|
9241
9241
|
const T = j > 0 ? y[j - 1] : "", D = j < y.length ? y[j] : "";
|
|
9242
|
-
return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < y.length && !A(D) && D !== " " && (
|
|
9243
|
-
text: L + I +
|
|
9242
|
+
return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < y.length && !A(D) && D !== " " && (R = " "), {
|
|
9243
|
+
text: L + I + R,
|
|
9244
9244
|
prefixLength: L.length,
|
|
9245
|
-
suffixLength:
|
|
9245
|
+
suffixLength: R.length
|
|
9246
9246
|
};
|
|
9247
|
-
},
|
|
9248
|
-
if (
|
|
9249
|
-
const y =
|
|
9247
|
+
}, C = f.current;
|
|
9248
|
+
if (C) {
|
|
9249
|
+
const y = C.selectionStart || 0, j = C.value || "", I = C.selectionEnd || y;
|
|
9250
9250
|
if (I > y) {
|
|
9251
|
-
const O = `{{${
|
|
9251
|
+
const O = `{{${S}}}`, { text: P } = N(j, y, O), $ = j.slice(0, y) + P + j.slice(I);
|
|
9252
9252
|
p($);
|
|
9253
9253
|
return;
|
|
9254
9254
|
}
|
|
9255
|
-
const
|
|
9255
|
+
const R = `{{${S}}}`, { text: T } = N(j, y, R), D = j.slice(0, y) + T + j.slice(y);
|
|
9256
9256
|
p(D);
|
|
9257
9257
|
}
|
|
9258
9258
|
}, []);
|
|
@@ -9260,8 +9260,8 @@ const AiAssistant = () => {
|
|
|
9260
9260
|
/* @__PURE__ */ jsxs(
|
|
9261
9261
|
"form",
|
|
9262
9262
|
{
|
|
9263
|
-
onSubmit: (
|
|
9264
|
-
|
|
9263
|
+
onSubmit: (S) => {
|
|
9264
|
+
S.preventDefault(), u !== null ? w() : b();
|
|
9265
9265
|
},
|
|
9266
9266
|
className: "space-y-3",
|
|
9267
9267
|
children: [
|
|
@@ -9275,9 +9275,9 @@ const AiAssistant = () => {
|
|
|
9275
9275
|
autoCorrect: "off",
|
|
9276
9276
|
spellCheck: "false",
|
|
9277
9277
|
id: "attrKey",
|
|
9278
|
-
ref:
|
|
9278
|
+
ref: x,
|
|
9279
9279
|
value: i,
|
|
9280
|
-
onChange: (
|
|
9280
|
+
onChange: (S) => c(S.target.value),
|
|
9281
9281
|
placeholder: "Enter Key",
|
|
9282
9282
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9283
9283
|
}
|
|
@@ -9296,9 +9296,9 @@ const AiAssistant = () => {
|
|
|
9296
9296
|
spellCheck: "false",
|
|
9297
9297
|
id: "attrValue",
|
|
9298
9298
|
rows: 2,
|
|
9299
|
-
ref:
|
|
9299
|
+
ref: f,
|
|
9300
9300
|
value: d,
|
|
9301
|
-
onChange: (
|
|
9301
|
+
onChange: (S) => p(S.target.value),
|
|
9302
9302
|
onKeyDown: _,
|
|
9303
9303
|
placeholder: "Enter Value",
|
|
9304
9304
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
@@ -9311,10 +9311,10 @@ const AiAssistant = () => {
|
|
|
9311
9311
|
]
|
|
9312
9312
|
}
|
|
9313
9313
|
),
|
|
9314
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
9314
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9315
9315
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9316
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9317
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children:
|
|
9316
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
|
|
9317
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
|
|
9318
9318
|
] }),
|
|
9319
9319
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9320
9320
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
@@ -9438,38 +9438,38 @@ const RootLayout = () => {
|
|
|
9438
9438
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9439
9439
|
r("outline");
|
|
9440
9440
|
});
|
|
9441
|
-
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = useCallback((
|
|
9442
|
-
|
|
9441
|
+
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = useCallback((S) => {
|
|
9442
|
+
S.preventDefault();
|
|
9443
9443
|
}, []), h = useCallback(
|
|
9444
|
-
(
|
|
9445
|
-
r(n ===
|
|
9444
|
+
(S) => {
|
|
9445
|
+
r(n === S ? null : S);
|
|
9446
9446
|
},
|
|
9447
9447
|
[n]
|
|
9448
|
-
), { t:
|
|
9448
|
+
), { t: x } = useTranslation(), f = useMemo(
|
|
9449
9449
|
() => [...p, ...u, ...g],
|
|
9450
9450
|
[p, u, g]
|
|
9451
|
-
), k = useBuilderProp("htmlDir", "ltr"), b = find(
|
|
9451
|
+
), k = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: n }) ?? first(f), v = get(b, "width", DEFAULT_PANEL_WIDTH);
|
|
9452
9452
|
useEffect(() => {
|
|
9453
9453
|
if (n !== null) {
|
|
9454
|
-
const
|
|
9455
|
-
|
|
9454
|
+
const S = find(f, { id: n });
|
|
9455
|
+
S && get(S, "view", "standard") === "standard" && (a.current = n, i(get(S, "width", DEFAULT_PANEL_WIDTH)));
|
|
9456
9456
|
}
|
|
9457
|
-
}, [n,
|
|
9457
|
+
}, [n, f]);
|
|
9458
9458
|
const B = useMemo(() => {
|
|
9459
9459
|
if (n === null) return 0;
|
|
9460
|
-
const
|
|
9461
|
-
return get(
|
|
9462
|
-
}, [n, v, l,
|
|
9460
|
+
const S = find(f, { id: n });
|
|
9461
|
+
return get(S, "view", "standard") === "standard" ? v : l;
|
|
9462
|
+
}, [n, v, l, f]), w = useCallback(() => {
|
|
9463
9463
|
r(a.current);
|
|
9464
9464
|
}, [r]), _ = useCallback(() => {
|
|
9465
9465
|
r("outline");
|
|
9466
9466
|
}, [r]);
|
|
9467
9467
|
useEffect(() => {
|
|
9468
|
-
find(
|
|
9469
|
-
}, [n,
|
|
9468
|
+
find(f, { id: n }) || r("outline");
|
|
9469
|
+
}, [n, f]);
|
|
9470
9470
|
const E = useCallback(
|
|
9471
|
-
(
|
|
9472
|
-
h(
|
|
9471
|
+
(S) => {
|
|
9472
|
+
h(S);
|
|
9473
9473
|
},
|
|
9474
9474
|
[h]
|
|
9475
9475
|
);
|
|
@@ -9483,24 +9483,24 @@ const RootLayout = () => {
|
|
|
9483
9483
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9484
9484
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9485
9485
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9486
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((
|
|
9487
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9486
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((S, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9487
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
|
|
9488
9488
|
position: "top",
|
|
9489
|
-
panelId:
|
|
9490
|
-
isActive: n ===
|
|
9491
|
-
show: () => E(
|
|
9489
|
+
panelId: S.id,
|
|
9490
|
+
isActive: n === S.id,
|
|
9491
|
+
show: () => E(S.id)
|
|
9492
9492
|
}) }),
|
|
9493
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9493
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(S.label) }) })
|
|
9494
9494
|
] }, "button-top-" + A)) }),
|
|
9495
9495
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9496
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((
|
|
9497
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9496
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((S, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9497
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
|
|
9498
9498
|
position: "bottom",
|
|
9499
|
-
panelId:
|
|
9500
|
-
isActive: n ===
|
|
9501
|
-
show: () => E(
|
|
9499
|
+
panelId: S.id,
|
|
9500
|
+
isActive: n === S.id,
|
|
9501
|
+
show: () => E(S.id)
|
|
9502
9502
|
}) }),
|
|
9503
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9503
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(S.label) }) })
|
|
9504
9504
|
] }, "button-bottom-" + A)) })
|
|
9505
9505
|
] }),
|
|
9506
9506
|
/* @__PURE__ */ jsx(
|
|
@@ -9516,7 +9516,7 @@ const RootLayout = () => {
|
|
|
9516
9516
|
"div",
|
|
9517
9517
|
{
|
|
9518
9518
|
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
|
|
9519
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9519
|
+
children: /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9520
9520
|
}
|
|
9521
9521
|
),
|
|
9522
9522
|
/* @__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), {}) }) })
|
|
@@ -9539,11 +9539,11 @@ const RootLayout = () => {
|
|
|
9539
9539
|
/* @__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: [
|
|
9540
9540
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9541
9541
|
" ",
|
|
9542
|
-
|
|
9542
|
+
x("AI Assistant")
|
|
9543
9543
|
] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9544
9544
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9545
9545
|
/* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
|
|
9546
|
-
|
|
9546
|
+
x("Theme Settings")
|
|
9547
9547
|
] }),
|
|
9548
9548
|
/* @__PURE__ */ jsx(
|
|
9549
9549
|
Button,
|
|
@@ -9574,7 +9574,7 @@ const RootLayout = () => {
|
|
|
9574
9574
|
children: [
|
|
9575
9575
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
9576
9576
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9577
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9577
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9578
9578
|
] }) }),
|
|
9579
9579
|
/* @__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), {
|
|
9580
9580
|
close: _
|
|
@@ -9586,7 +9586,7 @@ const RootLayout = () => {
|
|
|
9586
9586
|
n !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => w(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${v}px` }, children: [
|
|
9587
9587
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
9588
9588
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9589
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9589
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9590
9590
|
] }) }),
|
|
9591
9591
|
/* @__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), {
|
|
9592
9592
|
close: _
|
|
@@ -9612,7 +9612,7 @@ const RootLayout = () => {
|
|
|
9612
9612
|
/* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
|
|
9613
9613
|
/* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
|
|
9614
9614
|
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
|
|
9615
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9615
|
+
/* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
|
|
9616
9616
|
] }),
|
|
9617
9617
|
/* @__PURE__ */ jsx(Button, { onClick: () => w(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
|
|
9618
9618
|
] }),
|
|
@@ -9634,6 +9634,48 @@ const RootLayout = () => {
|
|
|
9634
9634
|
] }),
|
|
9635
9635
|
/* @__PURE__ */ jsx("div", { children: a ? /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-96 w-full" }), children: React__default.createElement(a) }) : null })
|
|
9636
9636
|
] }) : null;
|
|
9637
|
+
}, CHAI_FEATURE_FLAGS = {}, registerChaiFeatureFlag = (o, n) => {
|
|
9638
|
+
if (CHAI_FEATURE_FLAGS[o])
|
|
9639
|
+
throw new Error(`Flag ${o} already exists`);
|
|
9640
|
+
CHAI_FEATURE_FLAGS[o] = { key: o, value: !1, ...n };
|
|
9641
|
+
}, registerChaiFeatureFlags = (o) => {
|
|
9642
|
+
Object.entries(o).forEach(([n, r]) => {
|
|
9643
|
+
if (CHAI_FEATURE_FLAGS[n])
|
|
9644
|
+
throw new Error(`Flag ${n} already exists`);
|
|
9645
|
+
registerChaiFeatureFlag(n, r);
|
|
9646
|
+
});
|
|
9647
|
+
}, useChaiFeatureFlags = () => CHAI_FEATURE_FLAGS, featureFlagsAtom = atomWithStorage("chai-feature-flags", []), useChaiFeatureFlag = (o) => {
|
|
9648
|
+
const [n] = useAtom$1(featureFlagsAtom);
|
|
9649
|
+
return n.includes(o);
|
|
9650
|
+
}, useToggleChaiFeatureFlag = (o) => {
|
|
9651
|
+
const [n, r] = useAtom$1(featureFlagsAtom);
|
|
9652
|
+
return () => {
|
|
9653
|
+
n.includes(o) ? r(n.filter((l) => l !== o)) : r([...n, o]);
|
|
9654
|
+
};
|
|
9655
|
+
}, IfChaiFeatureFlag = ({ flagKey: o, children: n }) => useChaiFeatureFlag(o) ? n : null, FeatureToggle = ({
|
|
9656
|
+
featureKey: o,
|
|
9657
|
+
options: n
|
|
9658
|
+
}) => {
|
|
9659
|
+
const r = useToggleChaiFeatureFlag(o), a = useChaiFeatureFlag(o);
|
|
9660
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
9661
|
+
/* @__PURE__ */ jsx(Switch, { checked: a, onCheckedChange: r }),
|
|
9662
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
9663
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: n.key }),
|
|
9664
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: n.description })
|
|
9665
|
+
] })
|
|
9666
|
+
] });
|
|
9667
|
+
}, showFeatureFlagAtom = atomWithStorage("show-feature-flag", !1), ChaiFeatureFlagsWidget = () => {
|
|
9668
|
+
const o = useChaiFeatureFlags(), [n, r] = useAtom$1(showFeatureFlagAtom);
|
|
9669
|
+
return useHotkeys("ctrl+shift+1,command+shift+1", () => r(!n)), n ? /* @__PURE__ */ jsxs(Popover, { open: !0, children: [
|
|
9670
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { children: /* @__PURE__ */ jsx(Settings$1, {}) }),
|
|
9671
|
+
/* @__PURE__ */ jsx(PopoverContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-1", children: [
|
|
9672
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-2 px-1", children: [
|
|
9673
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Feature Flags" }),
|
|
9674
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: "Enable or disable experimental features" })
|
|
9675
|
+
] }),
|
|
9676
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-3 pt-2", children: Object.entries(o).map(([a, l]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: a, options: l }, a)) })
|
|
9677
|
+
] }) })
|
|
9678
|
+
] }) : null;
|
|
9637
9679
|
}, setDebugLogs = (o) => {
|
|
9638
9680
|
}, getParentNodeIds = (o, n) => {
|
|
9639
9681
|
const r = [];
|
|
@@ -9677,15 +9719,7 @@ const RootLayout = () => {
|
|
|
9677
9719
|
) }),
|
|
9678
9720
|
"Minimum width: 1280px"
|
|
9679
9721
|
] }) })
|
|
9680
|
-
] }) }) })
|
|
9681
|
-
function getFromQueryParams(o) {
|
|
9682
|
-
var r;
|
|
9683
|
-
return (r = new URLSearchParams(window.location.search).get("flags")) == null ? void 0 : r.includes(o);
|
|
9684
|
-
}
|
|
9685
|
-
const FEATURE_TOGGLES = {
|
|
9686
|
-
dnd: getFromQueryParams("dnd"),
|
|
9687
|
-
aiChat: getFromQueryParams("ai-chat")
|
|
9688
|
-
}, isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
|
|
9722
|
+
] }) }) }), isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
|
|
9689
9723
|
if ("e" in o)
|
|
9690
9724
|
throw o.e;
|
|
9691
9725
|
return o.v;
|
|
@@ -9731,19 +9765,19 @@ const FEATURE_TOGGLES = {
|
|
|
9731
9765
|
for (const i of n.p)
|
|
9732
9766
|
l.add(i);
|
|
9733
9767
|
return l;
|
|
9734
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...
|
|
9735
|
-
var
|
|
9736
|
-
return (
|
|
9737
|
-
}, g = (h,
|
|
9738
|
-
var
|
|
9739
|
-
return (
|
|
9768
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...x) => h.read(...x), p = (h, ...x) => h.write(...x), u = (h, x) => {
|
|
9769
|
+
var f;
|
|
9770
|
+
return (f = h.unstable_onInit) == null ? void 0 : f.call(h, x);
|
|
9771
|
+
}, g = (h, x) => {
|
|
9772
|
+
var f;
|
|
9773
|
+
return (f = h.onMount) == null ? void 0 : f.call(h, x);
|
|
9740
9774
|
}, ...m) => {
|
|
9741
9775
|
const h = m[0] || ((A) => {
|
|
9742
9776
|
let N = o.get(A);
|
|
9743
|
-
return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A,
|
|
9744
|
-
}),
|
|
9777
|
+
return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, S)), N;
|
|
9778
|
+
}), x = m[1] || (() => {
|
|
9745
9779
|
let A, N;
|
|
9746
|
-
const
|
|
9780
|
+
const C = (y) => {
|
|
9747
9781
|
try {
|
|
9748
9782
|
y();
|
|
9749
9783
|
} catch (j) {
|
|
@@ -9751,25 +9785,25 @@ const FEATURE_TOGGLES = {
|
|
|
9751
9785
|
}
|
|
9752
9786
|
};
|
|
9753
9787
|
do {
|
|
9754
|
-
c.f &&
|
|
9788
|
+
c.f && C(c.f);
|
|
9755
9789
|
const y = /* @__PURE__ */ new Set(), j = y.add.bind(y);
|
|
9756
9790
|
a.forEach((I) => {
|
|
9757
9791
|
var L;
|
|
9758
9792
|
return (L = n.get(I)) == null ? void 0 : L.l.forEach(j);
|
|
9759
|
-
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), y.forEach(
|
|
9793
|
+
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), y.forEach(C), a.size && f();
|
|
9760
9794
|
} while (a.size || i.size || l.size);
|
|
9761
9795
|
if (A)
|
|
9762
9796
|
throw N;
|
|
9763
|
-
}),
|
|
9764
|
-
const A = [], N = /* @__PURE__ */ new WeakSet(),
|
|
9797
|
+
}), f = m[2] || (() => {
|
|
9798
|
+
const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
|
|
9765
9799
|
for (; y.length; ) {
|
|
9766
9800
|
const j = y[y.length - 1], I = h(j);
|
|
9767
|
-
if (
|
|
9801
|
+
if (C.has(j)) {
|
|
9768
9802
|
y.pop();
|
|
9769
9803
|
continue;
|
|
9770
9804
|
}
|
|
9771
9805
|
if (N.has(j)) {
|
|
9772
|
-
r.get(j) === I.n && A.push([j, I]),
|
|
9806
|
+
r.get(j) === I.n && A.push([j, I]), C.add(j), y.pop();
|
|
9773
9807
|
continue;
|
|
9774
9808
|
}
|
|
9775
9809
|
N.add(j);
|
|
@@ -9778,117 +9812,117 @@ const FEATURE_TOGGLES = {
|
|
|
9778
9812
|
}
|
|
9779
9813
|
for (let j = A.length - 1; j >= 0; --j) {
|
|
9780
9814
|
const [I, L] = A[j];
|
|
9781
|
-
let
|
|
9815
|
+
let R = !1;
|
|
9782
9816
|
for (const T of L.d.keys())
|
|
9783
9817
|
if (T !== I && a.has(T)) {
|
|
9784
|
-
|
|
9818
|
+
R = !0;
|
|
9785
9819
|
break;
|
|
9786
9820
|
}
|
|
9787
|
-
|
|
9821
|
+
R && (k(I), B(I)), r.delete(I);
|
|
9788
9822
|
}
|
|
9789
9823
|
}), k = m[3] || ((A) => {
|
|
9790
|
-
var N,
|
|
9824
|
+
var N, C;
|
|
9791
9825
|
const y = h(A);
|
|
9792
9826
|
if (isAtomStateInitialized(y) && (n.has(A) && r.get(A) !== y.n || Array.from(y.d).every(
|
|
9793
|
-
([
|
|
9827
|
+
([P, $]) => (
|
|
9794
9828
|
// Recursively, read the atom state of the dependency, and
|
|
9795
9829
|
// check if the atom epoch number is unchanged
|
|
9796
|
-
k(
|
|
9830
|
+
k(P).n === $
|
|
9797
9831
|
)
|
|
9798
9832
|
)))
|
|
9799
9833
|
return y;
|
|
9800
9834
|
y.d.clear();
|
|
9801
9835
|
let j = !0;
|
|
9802
9836
|
const I = () => {
|
|
9803
|
-
n.has(A) && (B(A),
|
|
9804
|
-
}, L = (
|
|
9837
|
+
n.has(A) && (B(A), f(), x());
|
|
9838
|
+
}, L = (P) => {
|
|
9805
9839
|
var $;
|
|
9806
|
-
if (isSelfAtom(A,
|
|
9807
|
-
const
|
|
9808
|
-
if (!isAtomStateInitialized(
|
|
9809
|
-
if (hasInitialValue(
|
|
9810
|
-
setAtomStateValueOrPromise(
|
|
9840
|
+
if (isSelfAtom(A, P)) {
|
|
9841
|
+
const H = h(P);
|
|
9842
|
+
if (!isAtomStateInitialized(H))
|
|
9843
|
+
if (hasInitialValue(P))
|
|
9844
|
+
setAtomStateValueOrPromise(P, P.init, h);
|
|
9811
9845
|
else
|
|
9812
9846
|
throw new Error("no atom init");
|
|
9813
|
-
return returnAtomValue(
|
|
9847
|
+
return returnAtomValue(H);
|
|
9814
9848
|
}
|
|
9815
|
-
const M = k(
|
|
9849
|
+
const M = k(P);
|
|
9816
9850
|
try {
|
|
9817
9851
|
return returnAtomValue(M);
|
|
9818
9852
|
} finally {
|
|
9819
|
-
y.d.set(
|
|
9853
|
+
y.d.set(P, M.n), isPendingPromise(y.v) && addPendingPromiseToDependency(A, y.v, M), ($ = n.get(P)) == null || $.t.add(A), j || I();
|
|
9820
9854
|
}
|
|
9821
9855
|
};
|
|
9822
|
-
let
|
|
9856
|
+
let R, T;
|
|
9823
9857
|
const D = {
|
|
9824
9858
|
get signal() {
|
|
9825
|
-
return
|
|
9859
|
+
return R || (R = new AbortController()), R.signal;
|
|
9826
9860
|
},
|
|
9827
9861
|
get setSelf() {
|
|
9828
|
-
return !T && isActuallyWritableAtom(A) && (T = (...
|
|
9862
|
+
return !T && isActuallyWritableAtom(A) && (T = (...P) => {
|
|
9829
9863
|
if (!j)
|
|
9830
9864
|
try {
|
|
9831
|
-
return v(A, ...
|
|
9865
|
+
return v(A, ...P);
|
|
9832
9866
|
} finally {
|
|
9833
|
-
|
|
9867
|
+
f(), x();
|
|
9834
9868
|
}
|
|
9835
9869
|
}), T;
|
|
9836
9870
|
}
|
|
9837
9871
|
}, O = y.n;
|
|
9838
9872
|
try {
|
|
9839
|
-
const
|
|
9840
|
-
return setAtomStateValueOrPromise(A,
|
|
9873
|
+
const P = d(A, L, D);
|
|
9874
|
+
return setAtomStateValueOrPromise(A, P, h), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
|
|
9841
9875
|
I,
|
|
9842
9876
|
I
|
|
9843
9877
|
)), y;
|
|
9844
|
-
} catch (
|
|
9845
|
-
return delete y.v, y.e =
|
|
9878
|
+
} catch (P) {
|
|
9879
|
+
return delete y.v, y.e = P, ++y.n, y;
|
|
9846
9880
|
} finally {
|
|
9847
|
-
j = !1, O !== y.n && r.get(A) === O && (r.set(A, y.n), a.add(A), (
|
|
9881
|
+
j = !1, O !== y.n && r.get(A) === O && (r.set(A, y.n), a.add(A), (C = c.c) == null || C.call(c, A));
|
|
9848
9882
|
}
|
|
9849
9883
|
}), b = m[4] || ((A) => {
|
|
9850
9884
|
const N = [A];
|
|
9851
9885
|
for (; N.length; ) {
|
|
9852
|
-
const
|
|
9853
|
-
for (const j of getMountedOrPendingDependents(
|
|
9886
|
+
const C = N.pop(), y = h(C);
|
|
9887
|
+
for (const j of getMountedOrPendingDependents(C, y, n)) {
|
|
9854
9888
|
const I = h(j);
|
|
9855
9889
|
r.set(j, I.n), N.push(j);
|
|
9856
9890
|
}
|
|
9857
9891
|
}
|
|
9858
9892
|
}), v = m[5] || ((A, ...N) => {
|
|
9859
|
-
let
|
|
9893
|
+
let C = !0;
|
|
9860
9894
|
const y = (I) => returnAtomValue(k(I)), j = (I, ...L) => {
|
|
9861
|
-
var
|
|
9895
|
+
var R;
|
|
9862
9896
|
const T = h(I);
|
|
9863
9897
|
try {
|
|
9864
9898
|
if (isSelfAtom(A, I)) {
|
|
9865
9899
|
if (!hasInitialValue(I))
|
|
9866
9900
|
throw new Error("atom not writable");
|
|
9867
9901
|
const D = T.n, O = L[0];
|
|
9868
|
-
setAtomStateValueOrPromise(I, O, h), B(I), D !== T.n && (a.add(I), (
|
|
9902
|
+
setAtomStateValueOrPromise(I, O, h), B(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
|
|
9869
9903
|
return;
|
|
9870
9904
|
} else
|
|
9871
9905
|
return v(I, ...L);
|
|
9872
9906
|
} finally {
|
|
9873
|
-
|
|
9907
|
+
C || (f(), x());
|
|
9874
9908
|
}
|
|
9875
9909
|
};
|
|
9876
9910
|
try {
|
|
9877
9911
|
return p(A, y, j, ...N);
|
|
9878
9912
|
} finally {
|
|
9879
|
-
|
|
9913
|
+
C = !1;
|
|
9880
9914
|
}
|
|
9881
9915
|
}), B = m[6] || ((A) => {
|
|
9882
9916
|
var N;
|
|
9883
|
-
const
|
|
9884
|
-
if (y && !isPendingPromise(
|
|
9885
|
-
for (const [j, I] of
|
|
9917
|
+
const C = h(A), y = n.get(A);
|
|
9918
|
+
if (y && !isPendingPromise(C.v)) {
|
|
9919
|
+
for (const [j, I] of C.d)
|
|
9886
9920
|
if (!y.d.has(j)) {
|
|
9887
9921
|
const L = h(j);
|
|
9888
9922
|
w(j).t.add(A), y.d.add(j), I !== L.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
|
|
9889
9923
|
}
|
|
9890
9924
|
for (const j of y.d || [])
|
|
9891
|
-
if (!
|
|
9925
|
+
if (!C.d.has(j)) {
|
|
9892
9926
|
y.d.delete(j);
|
|
9893
9927
|
const I = _(j);
|
|
9894
9928
|
I == null || I.t.delete(A);
|
|
@@ -9896,32 +9930,32 @@ const FEATURE_TOGGLES = {
|
|
|
9896
9930
|
}
|
|
9897
9931
|
}), w = m[7] || ((A) => {
|
|
9898
9932
|
var N;
|
|
9899
|
-
const
|
|
9933
|
+
const C = h(A);
|
|
9900
9934
|
let y = n.get(A);
|
|
9901
9935
|
if (!y) {
|
|
9902
9936
|
k(A);
|
|
9903
|
-
for (const j of
|
|
9937
|
+
for (const j of C.d.keys())
|
|
9904
9938
|
w(j).t.add(A);
|
|
9905
9939
|
if (y = {
|
|
9906
9940
|
l: /* @__PURE__ */ new Set(),
|
|
9907
|
-
d: new Set(
|
|
9941
|
+
d: new Set(C.d.keys()),
|
|
9908
9942
|
t: /* @__PURE__ */ new Set()
|
|
9909
9943
|
}, n.set(A, y), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
|
|
9910
9944
|
const j = () => {
|
|
9911
9945
|
let I = !0;
|
|
9912
|
-
const L = (...
|
|
9946
|
+
const L = (...R) => {
|
|
9913
9947
|
try {
|
|
9914
|
-
return v(A, ...
|
|
9948
|
+
return v(A, ...R);
|
|
9915
9949
|
} finally {
|
|
9916
|
-
I || (
|
|
9950
|
+
I || (f(), x());
|
|
9917
9951
|
}
|
|
9918
9952
|
};
|
|
9919
9953
|
try {
|
|
9920
|
-
const
|
|
9921
|
-
|
|
9954
|
+
const R = g(A, L);
|
|
9955
|
+
R && (y.u = () => {
|
|
9922
9956
|
I = !0;
|
|
9923
9957
|
try {
|
|
9924
|
-
|
|
9958
|
+
R();
|
|
9925
9959
|
} finally {
|
|
9926
9960
|
I = !1;
|
|
9927
9961
|
}
|
|
@@ -9936,14 +9970,14 @@ const FEATURE_TOGGLES = {
|
|
|
9936
9970
|
return y;
|
|
9937
9971
|
}), _ = m[8] || ((A) => {
|
|
9938
9972
|
var N;
|
|
9939
|
-
const
|
|
9973
|
+
const C = h(A);
|
|
9940
9974
|
let y = n.get(A);
|
|
9941
9975
|
if (y && !y.l.size && !Array.from(y.t).some((j) => {
|
|
9942
9976
|
var I;
|
|
9943
9977
|
return (I = n.get(j)) == null ? void 0 : I.d.has(A);
|
|
9944
9978
|
})) {
|
|
9945
9979
|
y.u && i.add(y.u), y = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
|
|
9946
|
-
for (const j of
|
|
9980
|
+
for (const j of C.d.keys()) {
|
|
9947
9981
|
const I = _(j);
|
|
9948
9982
|
I == null || I.t.delete(A);
|
|
9949
9983
|
}
|
|
@@ -9966,31 +10000,31 @@ const FEATURE_TOGGLES = {
|
|
|
9966
10000
|
g,
|
|
9967
10001
|
// building-block functions
|
|
9968
10002
|
h,
|
|
9969
|
-
f,
|
|
9970
10003
|
x,
|
|
10004
|
+
f,
|
|
9971
10005
|
k,
|
|
9972
10006
|
b,
|
|
9973
10007
|
v,
|
|
9974
10008
|
B,
|
|
9975
10009
|
w,
|
|
9976
10010
|
_
|
|
9977
|
-
],
|
|
10011
|
+
], S = {
|
|
9978
10012
|
get: (A) => returnAtomValue(k(A)),
|
|
9979
10013
|
set: (A, ...N) => {
|
|
9980
10014
|
try {
|
|
9981
10015
|
return v(A, ...N);
|
|
9982
10016
|
} finally {
|
|
9983
|
-
|
|
10017
|
+
f(), x();
|
|
9984
10018
|
}
|
|
9985
10019
|
},
|
|
9986
10020
|
sub: (A, N) => {
|
|
9987
10021
|
const y = w(A).l;
|
|
9988
|
-
return y.add(N),
|
|
9989
|
-
y.delete(N), _(A),
|
|
10022
|
+
return y.add(N), x(), () => {
|
|
10023
|
+
y.delete(N), _(A), x();
|
|
9990
10024
|
};
|
|
9991
10025
|
}
|
|
9992
10026
|
};
|
|
9993
|
-
return Object.defineProperty(
|
|
10027
|
+
return Object.defineProperty(S, BUILDING_BLOCKS, { value: E }), S;
|
|
9994
10028
|
}, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
|
|
9995
10029
|
let defaultStore;
|
|
9996
10030
|
const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
|
|
@@ -10102,13 +10136,14 @@ const useAutoSave = () => {
|
|
|
10102
10136
|
] });
|
|
10103
10137
|
}, ChaiBuilderEditor = (o) => {
|
|
10104
10138
|
const n = o.onError || noop;
|
|
10105
|
-
return /* @__PURE__ */ jsx("div", { className: "h-screen w-screen", children: /* @__PURE__ */
|
|
10139
|
+
return /* @__PURE__ */ jsx("div", { className: "h-screen w-screen", children: /* @__PURE__ */ jsxs(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: [
|
|
10106
10140
|
/* @__PURE__ */ jsx(ScreenTooSmall, {}),
|
|
10107
10141
|
/* @__PURE__ */ jsx(ChaiBuilderComponent, { ...o }),
|
|
10108
10142
|
/* @__PURE__ */ jsx(ChaiWatchers, { ...o }),
|
|
10109
10143
|
/* @__PURE__ */ jsx(PreviewScreen, {}),
|
|
10110
|
-
/* @__PURE__ */ jsx(Toaster, { richColors: !0 })
|
|
10111
|
-
|
|
10144
|
+
/* @__PURE__ */ jsx(Toaster, { richColors: !0 }),
|
|
10145
|
+
/* @__PURE__ */ jsx("div", { className: "fixed bottom-4 left-4 z-50", children: /* @__PURE__ */ jsx(ChaiFeatureFlagsWidget, {}) })
|
|
10146
|
+
] }) });
|
|
10112
10147
|
};
|
|
10113
10148
|
if (typeof window > "u")
|
|
10114
10149
|
throw new Error("@chaibuilder/sdk is only supported in the browser. Avoid using it in the server side.");
|
|
@@ -10130,6 +10165,7 @@ export {
|
|
|
10130
10165
|
ThemeConfigPanel as ChaiThemeConfigPanel,
|
|
10131
10166
|
UILibrariesPanel as ChaiUILibrariesPanel,
|
|
10132
10167
|
UndoRedo as ChaiUndoRedo,
|
|
10168
|
+
IfChaiFeatureFlag,
|
|
10133
10169
|
PERMISSIONS,
|
|
10134
10170
|
getBlocksFromHTML as convertHTMLToChaiBlocks,
|
|
10135
10171
|
generateUUID as generateBlockId,
|
|
@@ -10140,6 +10176,8 @@ export {
|
|
|
10140
10176
|
registerBlockSettingTemplate,
|
|
10141
10177
|
registerBlockSettingWidget,
|
|
10142
10178
|
registerChaiAddBlockTab,
|
|
10179
|
+
registerChaiFeatureFlag,
|
|
10180
|
+
registerChaiFeatureFlags,
|
|
10143
10181
|
registerChaiLibrary,
|
|
10144
10182
|
registerChaiMediaManager,
|
|
10145
10183
|
registerChaiSaveToLibrary,
|
|
@@ -10156,6 +10194,8 @@ export {
|
|
|
10156
10194
|
useBuilderReset,
|
|
10157
10195
|
useCanvasDisplayWidth,
|
|
10158
10196
|
useCanvasZoom,
|
|
10197
|
+
useChaiFeatureFlag,
|
|
10198
|
+
useChaiFeatureFlags,
|
|
10159
10199
|
useCodeEditor,
|
|
10160
10200
|
useCopyBlocks as useCopyBlockIds,
|
|
10161
10201
|
useCopyToClipboard,
|
|
@@ -10193,7 +10233,8 @@ export {
|
|
|
10193
10233
|
useStylingState,
|
|
10194
10234
|
useTheme,
|
|
10195
10235
|
useThemeOptions,
|
|
10196
|
-
|
|
10236
|
+
useToggleChaiFeatureFlag,
|
|
10237
|
+
Ve as useTranslation,
|
|
10197
10238
|
useUndoManager,
|
|
10198
10239
|
useUpdateBlocksProps,
|
|
10199
10240
|
useUpdateBlocksPropsRealtime,
|