@chaibuilder/sdk 3.0.27 → 3.0.29
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/{IconPicker-CluS-5Mv.js → IconPicker-DB-dcym6.js} +1 -1
- package/dist/{IconPicker-BWE43eMO.cjs → IconPicker-OPOFkNZu.cjs} +1 -1
- package/dist/{code-editor-B0zk9FXR.cjs → code-editor-BHRtO5S6.cjs} +1 -1
- package/dist/{code-editor-H0MQ5vzI.js → code-editor-DlWYye4v.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.js +40 -39
- package/dist/{css-import-modal-DaH4zyxk.js → css-import-modal-DK2j6oGY.js} +1 -1
- package/dist/{css-import-modal-BQLoUINw.cjs → css-import-modal-P7f5SEKA.cjs} +1 -1
- package/dist/{index-B9XD9X3W.js → index-CtXUapBz.js} +761 -883
- package/dist/{index-CcmtMRO-.cjs → index-DY3WTMms.cjs} +3 -3
- package/dist/{rte-widget-modal-DaEpcuOz.cjs → rte-widget-modal-B4C7jBcN.cjs} +1 -1
- package/dist/{rte-widget-modal-HU1ZwziZ.js → rte-widget-modal-CqBZ4WKt.js} +2 -2
- package/dist/{tooltip-Bz2MxMHf.js → tooltip-4-b9QGDK.js} +0 -1
- package/dist/{tooltip-CzZ7Fvt7.cjs → tooltip-C2BCZ8Al.cjs} +1 -1
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +1 -1
- package/package.json +1 -1
|
@@ -4,13 +4,13 @@ var F = (o, n, r) => W(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 { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, uniq, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, sortBy, round } from "lodash-es";
|
|
7
|
-
import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, CaretDownIcon, Cross1Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, ListBulletIcon, ValueIcon, TextAlignCenterIcon, TextAlignRightIcon, TextAlignLeftIcon, Link2Icon, LinkBreak2Icon, EnterFullScreenIcon, ExclamationTriangleIcon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, ReloadIcon, CircleIcon, MagnifyingGlassIcon, CaretRightIcon, FrameIcon, CheckIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, StopIcon,
|
|
7
|
+
import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, CaretDownIcon, Cross1Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, ListBulletIcon, ValueIcon, TextAlignCenterIcon, TextAlignRightIcon, TextAlignLeftIcon, Link2Icon, LinkBreak2Icon, EnterFullScreenIcon, ExclamationTriangleIcon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, ReloadIcon, CircleIcon, MagnifyingGlassIcon, CaretRightIcon, FrameIcon, CheckIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, StopIcon, EraserIcon, LightningBoltIcon, ZoomInIcon, StackIcon } from "@radix-ui/react-icons";
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, lazy, useReducer, useDebugValue } from "react";
|
|
10
10
|
import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
11
11
|
import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
|
|
12
12
|
import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./common-functions-BGzDsf1z.js";
|
|
13
|
-
import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, at as Input$1, aW as Skeleton, d as Alert, e as AlertDescription, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, a9 as DialogTitle, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, B as Badge, b6 as TooltipProvider, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b1 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, a6 as DialogHeader, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch,
|
|
13
|
+
import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, at as Input$1, aW as Skeleton, d as Alert, e as AlertDescription, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, a9 as DialogTitle, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, B as Badge, b6 as TooltipProvider, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b1 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, a6 as DialogHeader, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./tooltip-4-b9QGDK.js";
|
|
14
14
|
import clsx$1, { clsx } from "clsx";
|
|
15
15
|
import { twMerge } from "tailwind-merge";
|
|
16
16
|
import TreeModel from "tree-model";
|
|
@@ -45,9 +45,9 @@ import tailwindTypography from "@tailwindcss/typography";
|
|
|
45
45
|
import "tailwindcss-animate";
|
|
46
46
|
import "@mhsdesign/jit-browser-tailwindcss";
|
|
47
47
|
import twContainer from "@tailwindcss/container-queries";
|
|
48
|
+
import { useHotkeys } from "react-hotkeys-hook";
|
|
48
49
|
import { ErrorBoundary } from "react-error-boundary";
|
|
49
50
|
import { motion } from "framer-motion";
|
|
50
|
-
import { useHotkeys } from "react-hotkeys-hook";
|
|
51
51
|
import { limitShift, flip, size } from "@floating-ui/dom";
|
|
52
52
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
53
53
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
@@ -295,20 +295,20 @@ class PubSub {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
298
|
-
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (
|
|
299
|
-
if (
|
|
298
|
+
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (g) => c ? get(g, "_parent") === c : !get(g, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), m = (g) => {
|
|
299
|
+
if (g === "CHILD")
|
|
300
300
|
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
301
301
|
else {
|
|
302
302
|
const h = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
303
|
-
|
|
303
|
+
g === "BEFORE" ? h.position = Math.max(u, 0) : g === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
|
|
304
304
|
}
|
|
305
305
|
};
|
|
306
306
|
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
307
307
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
|
|
308
308
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-primary text-white shadow-2xl", children: [
|
|
309
|
-
p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () =>
|
|
310
|
-
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () =>
|
|
311
|
-
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () =>
|
|
309
|
+
p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("CHILD"), children: r("Add inside") }),
|
|
310
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("BEFORE"), children: r("Add before") }),
|
|
311
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("AFTER"), children: r("Add after") })
|
|
312
312
|
] })
|
|
313
313
|
] }) : null;
|
|
314
314
|
}, draggedBlockAtom = atom(null);
|
|
@@ -334,8 +334,8 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
334
334
|
const l = [...n];
|
|
335
335
|
let i = [...o];
|
|
336
336
|
if (r) {
|
|
337
|
-
const u = o.find((
|
|
338
|
-
if (u && u.content !== void 0 && u.content !== "" && !o.some((
|
|
337
|
+
const u = o.find((m) => m._id === r);
|
|
338
|
+
if (u && u.content !== void 0 && u.content !== "" && !o.some((g) => g._parent === r)) {
|
|
339
339
|
const h = {
|
|
340
340
|
_id: generateUUID(),
|
|
341
341
|
_parent: r,
|
|
@@ -359,13 +359,13 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
359
359
|
r && (c = i.filter((u) => u._parent === r));
|
|
360
360
|
const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
|
|
361
361
|
let p = i.length;
|
|
362
|
-
for (let u = 0,
|
|
362
|
+
for (let u = 0, m = 0; u < i.length; u++)
|
|
363
363
|
if (r !== void 0 ? i[u]._parent === r : !i[u]._parent) {
|
|
364
|
-
if (
|
|
364
|
+
if (m === d) {
|
|
365
365
|
p = u;
|
|
366
366
|
break;
|
|
367
367
|
}
|
|
368
|
-
|
|
368
|
+
m++;
|
|
369
369
|
}
|
|
370
370
|
return !r && a !== void 0 && a >= c.length && (p = i.length), [...i.slice(0, p), ...l, ...i.slice(p)];
|
|
371
371
|
}
|
|
@@ -380,17 +380,17 @@ function findNodeById(o, n) {
|
|
|
380
380
|
return o.first((r) => r.model._id === n) || null;
|
|
381
381
|
}
|
|
382
382
|
function moveNode(o, n, r, a) {
|
|
383
|
-
var u,
|
|
383
|
+
var u, m;
|
|
384
384
|
const l = findNodeById(o, n), i = findNodeById(o, r);
|
|
385
385
|
if (!l || !i) return !1;
|
|
386
386
|
i.children || (i.model.children = []);
|
|
387
|
-
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((
|
|
387
|
+
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((g) => g.model._id === n);
|
|
388
388
|
l.drop(), c = Math.max(c, 0);
|
|
389
|
-
const p = (((
|
|
389
|
+
const p = (((m = l == null ? void 0 : l.model) == null ? void 0 : m._parent) || "root") === r && c <= a ? a - 1 : a;
|
|
390
390
|
try {
|
|
391
391
|
i.addChildAtIndex(l, p);
|
|
392
|
-
} catch (
|
|
393
|
-
return console.error("Error adding child to parent:",
|
|
392
|
+
} catch (g) {
|
|
393
|
+
return console.error("Error adding child to parent:", g), !1;
|
|
394
394
|
}
|
|
395
395
|
return !0;
|
|
396
396
|
}
|
|
@@ -430,10 +430,10 @@ function handleNewParentTextBlock(o, n, r) {
|
|
|
430
430
|
});
|
|
431
431
|
const d = o.map((u) => {
|
|
432
432
|
if (u._id === r) {
|
|
433
|
-
const
|
|
434
|
-
return Object.keys(
|
|
435
|
-
|
|
436
|
-
}),
|
|
433
|
+
const m = { ...u, content: "" };
|
|
434
|
+
return Object.keys(m).forEach((g) => {
|
|
435
|
+
g.startsWith("content-") && (m[g] = "");
|
|
436
|
+
}), m;
|
|
437
437
|
}
|
|
438
438
|
return u;
|
|
439
439
|
}), p = d.findIndex((u) => u._id === n._id);
|
|
@@ -449,8 +449,8 @@ function moveBlocksWithChildren(o, n, r, a) {
|
|
|
449
449
|
const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
|
|
450
450
|
if (moveNode(p, n, c, a)) {
|
|
451
451
|
let u = flattenTree(p);
|
|
452
|
-
const
|
|
453
|
-
return
|
|
452
|
+
const m = u.find((g) => g._id === n);
|
|
453
|
+
return m && (m._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
|
|
454
454
|
}
|
|
455
455
|
return i;
|
|
456
456
|
}
|
|
@@ -473,22 +473,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
473
473
|
}, removeNestedBlocks = (o, n) => {
|
|
474
474
|
let r = [...o], a = [];
|
|
475
475
|
n.forEach((d) => {
|
|
476
|
-
const p = r.find((
|
|
476
|
+
const p = r.find((g) => g._id === d);
|
|
477
477
|
if (!p || !p._parent) return;
|
|
478
|
-
const u = p._parent,
|
|
479
|
-
if (
|
|
480
|
-
const
|
|
481
|
-
if (
|
|
478
|
+
const u = p._parent, m = r.filter((g) => g._parent === u);
|
|
479
|
+
if (m.length === 2) {
|
|
480
|
+
const g = m.find((h) => h._id !== d);
|
|
481
|
+
if (g && g._type === "Text") {
|
|
482
482
|
const h = r.find((f) => f._id === u);
|
|
483
483
|
h && "content" in h && (r = r.map((f) => {
|
|
484
484
|
if (f._id === u) {
|
|
485
|
-
const x = { ...f, content:
|
|
486
|
-
return Object.keys(
|
|
487
|
-
b.startsWith("content-") && (x[b] =
|
|
485
|
+
const x = { ...f, content: g.content };
|
|
486
|
+
return Object.keys(g).forEach((b) => {
|
|
487
|
+
b.startsWith("content-") && (x[b] = g[b]);
|
|
488
488
|
}), x;
|
|
489
489
|
}
|
|
490
490
|
return f;
|
|
491
|
-
}), a.push(
|
|
491
|
+
}), a.push(g._id));
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
});
|
|
@@ -551,7 +551,7 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
551
551
|
for (let p = 0; p < a.length; p++)
|
|
552
552
|
d = moveBlocksWithChildren(d, a[p], l, i);
|
|
553
553
|
return each(a, (p) => {
|
|
554
|
-
const u = find(d, (
|
|
554
|
+
const u = find(d, (m) => m._id === p);
|
|
555
555
|
u && r({ id: p, props: { _parent: u._parent || null } });
|
|
556
556
|
}), n({ type: "blocks-updated", blocks: d }), d;
|
|
557
557
|
});
|
|
@@ -570,7 +570,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
570
570
|
status: "idle",
|
|
571
571
|
props: {},
|
|
572
572
|
error: void 0
|
|
573
|
-
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]),
|
|
573
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), m = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), g = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
|
|
574
574
|
return useEffect(() => {
|
|
575
575
|
if (n === "mock") {
|
|
576
576
|
if (isFunction(a)) {
|
|
@@ -582,8 +582,8 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
582
582
|
}
|
|
583
583
|
return;
|
|
584
584
|
}
|
|
585
|
-
n === "live" && (!
|
|
586
|
-
|
|
585
|
+
n === "live" && (!m && !g || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
|
|
586
|
+
m ? (p((x) => ({
|
|
587
587
|
...x,
|
|
588
588
|
[o._id]: {
|
|
589
589
|
status: "loaded",
|
|
@@ -592,12 +592,12 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
592
592
|
}
|
|
593
593
|
})), i((x) => ({ ...x, status: "loaded", props: { totalItems: get(f, "totalItems") } })), c([o._id], { totalItems: get(f, "totalItems") })) : i((x) => ({ ...x, status: "loaded", props: isObject(f) ? f : {} }));
|
|
594
594
|
}).catch((f) => {
|
|
595
|
-
|
|
595
|
+
m ? (p((x) => ({
|
|
596
596
|
...x,
|
|
597
597
|
[o._id]: { status: "error", error: f, props: [] }
|
|
598
598
|
})), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
|
|
599
599
|
})));
|
|
600
|
-
}, [o == null ? void 0 : o._id, u,
|
|
600
|
+
}, [o == null ? void 0 : o._id, u, m, g, a, n]), {
|
|
601
601
|
$loading: get(l, "status") === "loading",
|
|
602
602
|
...o ? get(l, "props", {}) : {}
|
|
603
603
|
};
|
|
@@ -751,7 +751,7 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
|
751
751
|
}
|
|
752
752
|
}) : !1, useSavePage = () => {
|
|
753
753
|
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (f) => {
|
|
754
|
-
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(),
|
|
754
|
+
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), m = () => {
|
|
755
755
|
const f = l();
|
|
756
756
|
return !d || d === p ? !1 : checkMissingTranslations(f.blocks || [], d);
|
|
757
757
|
};
|
|
@@ -765,7 +765,7 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
|
765
765
|
autoSave: f,
|
|
766
766
|
blocks: x.blocks,
|
|
767
767
|
theme: i,
|
|
768
|
-
needTranslations:
|
|
768
|
+
needTranslations: m()
|
|
769
769
|
}), setTimeout(() => {
|
|
770
770
|
n("SAVED"), a("SAVED");
|
|
771
771
|
}, 100), !0;
|
|
@@ -782,11 +782,11 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
|
782
782
|
autoSave: !0,
|
|
783
783
|
blocks: f.blocks,
|
|
784
784
|
theme: i,
|
|
785
|
-
needTranslations:
|
|
785
|
+
needTranslations: m()
|
|
786
786
|
}), setTimeout(() => {
|
|
787
787
|
n("SAVED"), a("SAVED");
|
|
788
788
|
}, 100), !0;
|
|
789
|
-
}, saveState: o, setSaveState: n, needTranslations:
|
|
789
|
+
}, saveState: o, setSaveState: n, needTranslations: m };
|
|
790
790
|
}, undoManager = new UndoManager();
|
|
791
791
|
undoManager.setLimit(50);
|
|
792
792
|
const undoRedoStateAtom = atom({
|
|
@@ -840,12 +840,12 @@ const undoRedoStateAtom = atom({
|
|
|
840
840
|
return {
|
|
841
841
|
moveBlocks: (x, b, y) => {
|
|
842
842
|
const S = map(x, (B) => {
|
|
843
|
-
const
|
|
844
|
-
return { _id: B, oldParent:
|
|
845
|
-
}),
|
|
846
|
-
|
|
847
|
-
undo: () => each(S, ({ _id: B, oldParent: _, oldPosition:
|
|
848
|
-
i([B], _,
|
|
843
|
+
const j = n.find((I) => I._id === B)._parent || null, k = n.filter((I) => j ? I._parent === j : !I._parent).map((I) => I._id).indexOf(B);
|
|
844
|
+
return { _id: B, oldParent: j, oldPosition: k };
|
|
845
|
+
}), v = S.find(({ _id: B }) => B === x[0]);
|
|
846
|
+
v && v.oldParent === b && v.oldPosition === y || (i(x, b, y), o({
|
|
847
|
+
undo: () => each(S, ({ _id: B, oldParent: _, oldPosition: j }) => {
|
|
848
|
+
i([B], _, j);
|
|
849
849
|
}),
|
|
850
850
|
redo: () => i(x, b, y)
|
|
851
851
|
}));
|
|
@@ -857,8 +857,8 @@ const undoRedoStateAtom = atom({
|
|
|
857
857
|
});
|
|
858
858
|
},
|
|
859
859
|
removeBlocks: (x) => {
|
|
860
|
-
var
|
|
861
|
-
const b = (
|
|
860
|
+
var v;
|
|
861
|
+
const b = (v = first(x)) == null ? void 0 : v._parent, S = n.filter((B) => b ? B._parent === b : !B._parent).indexOf(first(x));
|
|
862
862
|
l(map(x, "_id")), o({
|
|
863
863
|
undo: () => a(x, b, S),
|
|
864
864
|
redo: () => l(map(x, "_id"))
|
|
@@ -867,17 +867,17 @@ const undoRedoStateAtom = atom({
|
|
|
867
867
|
updateBlocks: (x, b, y) => {
|
|
868
868
|
let S = [];
|
|
869
869
|
if (y)
|
|
870
|
-
S = map(x, (
|
|
870
|
+
S = map(x, (v) => ({ _id: v, ...y }));
|
|
871
871
|
else {
|
|
872
|
-
const
|
|
872
|
+
const v = keys(b);
|
|
873
873
|
S = map(x, (B) => {
|
|
874
|
-
const _ = n.find((
|
|
875
|
-
return each(
|
|
874
|
+
const _ = n.find((C) => C._id === B), j = { _id: B };
|
|
875
|
+
return each(v, (C) => j[C] = _[C]), j;
|
|
876
876
|
});
|
|
877
877
|
}
|
|
878
|
-
c(map(x, (
|
|
878
|
+
c(map(x, (v) => ({ _id: v, ...b }))), o({
|
|
879
879
|
undo: () => c(S),
|
|
880
|
-
redo: () => c(map(x, (
|
|
880
|
+
redo: () => c(map(x, (v) => ({ _id: v, ...b })))
|
|
881
881
|
});
|
|
882
882
|
},
|
|
883
883
|
updateBlocksRuntime: (x, b) => {
|
|
@@ -892,8 +892,8 @@ const undoRedoStateAtom = atom({
|
|
|
892
892
|
updateMultipleBlocksProps: (x) => {
|
|
893
893
|
let b = [];
|
|
894
894
|
b = map(x, (y) => {
|
|
895
|
-
const S = keys(y),
|
|
896
|
-
return each(S, (_) => B[_] =
|
|
895
|
+
const S = keys(y), v = n.find((_) => _._id === y._id), B = {};
|
|
896
|
+
return each(S, (_) => B[_] = v[_]), B;
|
|
897
897
|
}), c(x), o({
|
|
898
898
|
undo: () => c(b),
|
|
899
899
|
redo: () => c(x)
|
|
@@ -912,8 +912,8 @@ const undoRedoStateAtom = atom({
|
|
|
912
912
|
b[y]._parent = i[f]._id;
|
|
913
913
|
}
|
|
914
914
|
const p = first(i);
|
|
915
|
-
let u,
|
|
916
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c,
|
|
915
|
+
let u, m;
|
|
916
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, m = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, m = u._parent), r(i, m, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
|
|
917
917
|
},
|
|
918
918
|
[r, o, n]
|
|
919
919
|
);
|
|
@@ -923,15 +923,15 @@ const undoRedoStateAtom = atom({
|
|
|
923
923
|
const b = i.blocks;
|
|
924
924
|
return a(b, c, d);
|
|
925
925
|
}
|
|
926
|
-
const p = generateUUID(), u = getDefaultBlockProps(i.type),
|
|
926
|
+
const p = generateUUID(), u = getDefaultBlockProps(i.type), m = {
|
|
927
927
|
_type: i.type,
|
|
928
928
|
_id: p,
|
|
929
929
|
...u,
|
|
930
930
|
...has(i, "_name") && { _name: i._name },
|
|
931
931
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
932
932
|
};
|
|
933
|
-
let
|
|
934
|
-
return c && (
|
|
933
|
+
let g, h;
|
|
934
|
+
return c && (g = find(o, { _id: c }), m._parent = c, h = c), !canAcceptChildBlock(g == null ? void 0 : g._type, m._type) && g && (m._parent = g._parent, h = g._parent), r([m], h, d), n([m._id]), m;
|
|
935
935
|
},
|
|
936
936
|
[r, a, o, n]
|
|
937
937
|
), addPredefinedBlock: a };
|
|
@@ -2042,7 +2042,7 @@ function removeDuplicateClasses(o) {
|
|
|
2042
2042
|
for (const l of r) {
|
|
2043
2043
|
const i = l.property, c = n.indexOf(l.mq);
|
|
2044
2044
|
for (let d = c + 1; d < n.length; d++) {
|
|
2045
|
-
const p = n[d], u = r.find((
|
|
2045
|
+
const p = n[d], u = r.find((m) => m.property === i && m.mq === p);
|
|
2046
2046
|
if (u && u.cls === l.cls)
|
|
2047
2047
|
a = a.replace(u.fullCls, "");
|
|
2048
2048
|
else if (u && u.cls !== l.cls)
|
|
@@ -2315,7 +2315,7 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
|
|
|
2315
2315
|
let p = "";
|
|
2316
2316
|
o([n], { [i]: "" });
|
|
2317
2317
|
for (let u = 0; u < d.length; u++)
|
|
2318
|
-
p += d[u].join(""), o([n], { [i]: p }), await new Promise((
|
|
2318
|
+
p += d[u].join(""), o([n], { [i]: p }), await new Promise((m) => setTimeout(m, a));
|
|
2319
2319
|
}
|
|
2320
2320
|
}
|
|
2321
2321
|
},
|
|
@@ -2356,19 +2356,19 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2356
2356
|
const l = ["_id", "_type", "_parent"], i = pick(a, l), c = getRegisteredChaiBlock(a._type), d = {}, p = get(c, "aiProps", []);
|
|
2357
2357
|
for (const u in a)
|
|
2358
2358
|
if (!l.includes(u) && p.includes(u)) {
|
|
2359
|
-
const
|
|
2360
|
-
d[u] = isString(
|
|
2359
|
+
const m = get(a, `${u}-${n}`, ""), g = get(a, u, "");
|
|
2360
|
+
d[u] = isString(m) && m.trim() || g, r && (d[u] = g);
|
|
2361
2361
|
}
|
|
2362
2362
|
return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
|
|
2363
2363
|
})
|
|
2364
2364
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2365
|
-
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(),
|
|
2365
|
+
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(), m = p.length ? p : u, g = (h, f) => {
|
|
2366
2366
|
const x = cloneDeep(f.find((b) => b._id === h));
|
|
2367
2367
|
for (const b in x) {
|
|
2368
2368
|
const y = x[b];
|
|
2369
2369
|
if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
|
|
2370
|
-
const { baseClasses: S, classes:
|
|
2371
|
-
x[b] = compact(flattenDeep([S,
|
|
2370
|
+
const { baseClasses: S, classes: v } = getSplitChaiClasses(y);
|
|
2371
|
+
x[b] = compact(flattenDeep([S, v])).join(" ");
|
|
2372
2372
|
} else
|
|
2373
2373
|
b !== "_id" && delete x[b];
|
|
2374
2374
|
}
|
|
@@ -2380,18 +2380,18 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2380
2380
|
if (l) {
|
|
2381
2381
|
n(!0), a(null);
|
|
2382
2382
|
try {
|
|
2383
|
-
const y = p === u ? "" : p, S = x.toLowerCase().includes("translate the content"),
|
|
2384
|
-
if (
|
|
2385
|
-
a(
|
|
2383
|
+
const y = p === u ? "" : p, S = x.toLowerCase().includes("translate the content"), v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p, S) : [g(f, d)], B = await l(h, addLangToPrompt(x, m, h), v, y), { blocks: _, error: j } = B;
|
|
2384
|
+
if (j) {
|
|
2385
|
+
a(j);
|
|
2386
2386
|
return;
|
|
2387
2387
|
}
|
|
2388
2388
|
if (h === "styles") {
|
|
2389
|
-
const
|
|
2389
|
+
const C = _.map((k) => {
|
|
2390
2390
|
for (const I in k)
|
|
2391
2391
|
I !== "_id" && (k[I] = `${STYLES_KEY},${k[I]}`);
|
|
2392
2392
|
return k;
|
|
2393
2393
|
});
|
|
2394
|
-
c(
|
|
2394
|
+
c(C);
|
|
2395
2395
|
} else
|
|
2396
2396
|
i(_);
|
|
2397
2397
|
b && b(B);
|
|
@@ -2408,7 +2408,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2408
2408
|
p,
|
|
2409
2409
|
u,
|
|
2410
2410
|
d,
|
|
2411
|
-
|
|
2411
|
+
m,
|
|
2412
2412
|
c,
|
|
2413
2413
|
i
|
|
2414
2414
|
]
|
|
@@ -2471,7 +2471,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2471
2471
|
return [o, a];
|
|
2472
2472
|
}, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
|
|
2473
2473
|
const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useCallback(
|
|
2474
|
-
(d) => d.some((p) => getDuplicatedBlocks(o, p, null).some((
|
|
2474
|
+
(d) => d.some((p) => getDuplicatedBlocks(o, p, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
|
|
2475
2475
|
[o]
|
|
2476
2476
|
), c = useCallback(
|
|
2477
2477
|
async (d, p = !1) => {
|
|
@@ -2479,12 +2479,12 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2479
2479
|
if (isEmpty(d)) return;
|
|
2480
2480
|
r(d), a([]);
|
|
2481
2481
|
const u = {
|
|
2482
|
-
_chai_copied_blocks: d.flatMap((
|
|
2483
|
-
const
|
|
2482
|
+
_chai_copied_blocks: d.flatMap((m) => {
|
|
2483
|
+
const g = getDuplicatedBlocks(o, m, null);
|
|
2484
2484
|
if (!p)
|
|
2485
|
-
return
|
|
2485
|
+
return g;
|
|
2486
2486
|
let h = [];
|
|
2487
|
-
for (const f of
|
|
2487
|
+
for (const f of g)
|
|
2488
2488
|
if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
|
|
2489
2489
|
let x = l(f.partialBlockId);
|
|
2490
2490
|
f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((b) => (isEmpty(b._parent) && set(b, "_parent", f._parent), b))), h = [...h, ...x];
|
|
@@ -2530,11 +2530,11 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2530
2530
|
each(a, (c) => {
|
|
2531
2531
|
const d = o.find((h) => h._id === c);
|
|
2532
2532
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
2533
|
-
const
|
|
2533
|
+
const m = filter(
|
|
2534
2534
|
o,
|
|
2535
2535
|
(h) => isString(l) ? h._parent === l : !h._parent
|
|
2536
|
-
).indexOf(d) + 1,
|
|
2537
|
-
r(
|
|
2536
|
+
).indexOf(d) + 1, g = getDuplicatedBlocks(o, c, l);
|
|
2537
|
+
r(g, l, m), i.push(get(g, "0._id", ""));
|
|
2538
2538
|
}), n(i);
|
|
2539
2539
|
},
|
|
2540
2540
|
[o, n]
|
|
@@ -2662,19 +2662,19 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2662
2662
|
);
|
|
2663
2663
|
return map(i, (c) => {
|
|
2664
2664
|
const d = o(c), p = a;
|
|
2665
|
-
let { classes: u, baseClasses:
|
|
2666
|
-
return each(p, (
|
|
2667
|
-
const h =
|
|
2665
|
+
let { classes: u, baseClasses: m } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2666
|
+
return each(p, (g) => {
|
|
2667
|
+
const h = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2668
2668
|
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2669
|
-
const x = first(
|
|
2670
|
-
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(
|
|
2671
|
-
}), each(p, (
|
|
2672
|
-
const h =
|
|
2673
|
-
|
|
2669
|
+
const x = first(g.split(":"));
|
|
2670
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(g.split(":").pop().trim());
|
|
2671
|
+
}), each(p, (g) => {
|
|
2672
|
+
const h = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2673
|
+
m = m.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2674
2674
|
}), {
|
|
2675
2675
|
ids: [d._id],
|
|
2676
2676
|
props: {
|
|
2677
|
-
[l.prop]: `${STYLES_KEY}${
|
|
2677
|
+
[l.prop]: `${STYLES_KEY}${m},${u}`
|
|
2678
2678
|
}
|
|
2679
2679
|
};
|
|
2680
2680
|
});
|
|
@@ -2799,6 +2799,28 @@ const useInlineEditing = () => {
|
|
|
2799
2799
|
setEditingBlockId: n,
|
|
2800
2800
|
setEditingItemIndex: a
|
|
2801
2801
|
};
|
|
2802
|
+
}, getAllDescendantIds = (o, n) => {
|
|
2803
|
+
const r = o.filter((i) => i._parent === n), a = r.map((i) => i._id), l = r.flatMap((i) => getAllDescendantIds(o, i._id));
|
|
2804
|
+
return [...a, ...l];
|
|
2805
|
+
}, replaceBlock = (o, n, r) => {
|
|
2806
|
+
const a = find(o, { _id: n });
|
|
2807
|
+
if (!a) return o;
|
|
2808
|
+
const l = o.findIndex((g) => g._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), d = o.filter((g) => !c.has(g._id)), p = new Set(r.map((g) => g._id)), u = r.map((g) => !g._parent || !p.has(g._parent) ? { ...g, _parent: a._parent } : g);
|
|
2809
|
+
return [
|
|
2810
|
+
...d.slice(0, l),
|
|
2811
|
+
...u,
|
|
2812
|
+
...d.slice(l)
|
|
2813
|
+
];
|
|
2814
|
+
}, useReplaceBlock = () => {
|
|
2815
|
+
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { setNewBlocks: r } = useBlocksStoreUndoableActions(), { hasPermission: a } = usePermissions();
|
|
2816
|
+
return useCallback(
|
|
2817
|
+
(l, i) => {
|
|
2818
|
+
if (!a(PERMISSIONS.EDIT_BLOCK)) return;
|
|
2819
|
+
const c = replaceBlock(o, l, i);
|
|
2820
|
+
r(c), i.length > 0 && setTimeout(() => n([i[0]._id]), 200);
|
|
2821
|
+
},
|
|
2822
|
+
[o, n, r, a]
|
|
2823
|
+
);
|
|
2802
2824
|
}, useSelectedLibrary = () => useAtom$1(selectedLibraryAtom), sidebarActivePanelAtom = atom("outline");
|
|
2803
2825
|
sidebarActivePanelAtom.debugLabel = "sidebarActivePanelAtom";
|
|
2804
2826
|
const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS = [
|
|
@@ -2819,11 +2841,11 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2819
2841
|
return "VERTICAL";
|
|
2820
2842
|
}
|
|
2821
2843
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
2822
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }),
|
|
2844
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), m = u <= 0, g = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
2823
2845
|
(x) => {
|
|
2824
|
-
isDisabledControl(
|
|
2846
|
+
isDisabledControl(m, g, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
|
|
2825
2847
|
},
|
|
2826
|
-
[
|
|
2848
|
+
[m, g, p, u, i, c, n]
|
|
2827
2849
|
);
|
|
2828
2850
|
return useHotkeys(
|
|
2829
2851
|
"shift+up, shift+down, shift+left, shift+right",
|
|
@@ -2833,7 +2855,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2833
2855
|
},
|
|
2834
2856
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2835
2857
|
[f]
|
|
2836
|
-
), { isOnlyChild: p, isFirstBlock:
|
|
2858
|
+
), { isOnlyChild: p, isFirstBlock: m, isLastBlock: g, moveBlock: f, orientation: h };
|
|
2837
2859
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
2838
2860
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2839
2861
|
o,
|
|
@@ -2841,12 +2863,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2841
2863
|
);
|
|
2842
2864
|
return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
|
|
2843
2865
|
if (c !== p) return null;
|
|
2844
|
-
const
|
|
2845
|
-
return
|
|
2866
|
+
const m = isDisabledControl(a, l, u);
|
|
2867
|
+
return m ? null : /* @__PURE__ */ jsx(
|
|
2846
2868
|
d,
|
|
2847
2869
|
{
|
|
2848
2870
|
onClick: () => i(u),
|
|
2849
|
-
className: `${
|
|
2871
|
+
className: `${m ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
|
|
2850
2872
|
},
|
|
2851
2873
|
u
|
|
2852
2874
|
);
|
|
@@ -2973,7 +2995,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
|
|
|
2973
2995
|
i([null]);
|
|
2974
2996
|
}, [r, n]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
|
|
2975
2997
|
}, BlockFloatingSelector = ({ block: o, selectedBlockElement: n }) => {
|
|
2976
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles:
|
|
2998
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: m, refs: g, update: h } = useFloating({
|
|
2977
2999
|
placement: "top-start",
|
|
2978
3000
|
middleware: [
|
|
2979
3001
|
shift({
|
|
@@ -3013,8 +3035,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
|
|
|
3013
3035
|
{
|
|
3014
3036
|
role: "button",
|
|
3015
3037
|
tabIndex: 0,
|
|
3016
|
-
ref:
|
|
3017
|
-
style:
|
|
3038
|
+
ref: g.setFloating,
|
|
3039
|
+
style: m,
|
|
3018
3040
|
onClick: (b) => {
|
|
3019
3041
|
b.stopPropagation(), b.preventDefault();
|
|
3020
3042
|
},
|
|
@@ -3240,7 +3262,7 @@ F(Frame, "defaultProps", {
|
|
|
3240
3262
|
initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
|
|
3241
3263
|
});
|
|
3242
3264
|
const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
|
|
3243
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste:
|
|
3265
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: m, pasteBlocks: g } = usePasteBlocks(), h = o ? { document: o } : {};
|
|
3244
3266
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
|
|
3245
3267
|
"ctrl+c,command+c",
|
|
3246
3268
|
() => u(n),
|
|
@@ -3249,10 +3271,10 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3249
3271
|
), useHotkeys(
|
|
3250
3272
|
"ctrl+v,command+v",
|
|
3251
3273
|
() => {
|
|
3252
|
-
|
|
3274
|
+
m(n[0]) && g(n);
|
|
3253
3275
|
},
|
|
3254
3276
|
{ ...h, enabled: !isEmpty(n), preventDefault: !0 },
|
|
3255
|
-
[n,
|
|
3277
|
+
[n, m, g]
|
|
3256
3278
|
), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, enabled: !isEmpty(n), preventDefault: !0 }, [
|
|
3257
3279
|
n,
|
|
3258
3280
|
i
|
|
@@ -3460,28 +3482,28 @@ const RteDropdownMenu = ({
|
|
|
3460
3482
|
from: a,
|
|
3461
3483
|
menuRef: l
|
|
3462
3484
|
}) => {
|
|
3463
|
-
const { document: i } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1),
|
|
3485
|
+
const { document: i } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1), m = useRef(null);
|
|
3464
3486
|
if (useEffect(() => {
|
|
3465
|
-
var S,
|
|
3487
|
+
var S, v;
|
|
3466
3488
|
if (!p) {
|
|
3467
3489
|
d({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
|
|
3468
3490
|
return;
|
|
3469
3491
|
}
|
|
3470
|
-
const
|
|
3471
|
-
let f =
|
|
3472
|
-
(h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (
|
|
3492
|
+
const g = (S = m.current) == null ? void 0 : S.getBoundingClientRect(), h = (v = l.current) == null ? void 0 : v.getBoundingClientRect();
|
|
3493
|
+
let f = g == null ? void 0 : g.left, x = (g == null ? void 0 : g.bottom) + 4, b, y;
|
|
3494
|
+
(h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (g == null ? void 0 : g.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (g == null ? void 0 : g.bottom) + (h == null ? void 0 : h.height)), d({ left: f, top: x, right: b, bottom: y });
|
|
3473
3495
|
}, [p]), a === "canvas") {
|
|
3474
|
-
const
|
|
3496
|
+
const g = () => {
|
|
3475
3497
|
u(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
|
|
3476
3498
|
};
|
|
3477
3499
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3478
|
-
/* @__PURE__ */ jsx("div", { ref:
|
|
3500
|
+
/* @__PURE__ */ jsx("div", { ref: m, onClick: () => u((h) => !h), className: "cursor-pointer", children: n }),
|
|
3479
3501
|
p && (c.left !== void 0 || c.top !== void 0 || c.right !== void 0 || c.bottom !== void 0) && createPortal(
|
|
3480
3502
|
/* @__PURE__ */ jsx(
|
|
3481
3503
|
"div",
|
|
3482
3504
|
{
|
|
3483
3505
|
id: "chaibuilder-rte-dropdown-menu-content",
|
|
3484
|
-
onClick:
|
|
3506
|
+
onClick: g,
|
|
3485
3507
|
className: "fixed inset-0 left-0 top-0 z-[10001] h-full w-screen",
|
|
3486
3508
|
children: /* @__PURE__ */ jsx(
|
|
3487
3509
|
"div",
|
|
@@ -3492,7 +3514,7 @@ const RteDropdownMenu = ({
|
|
|
3492
3514
|
{},
|
|
3493
3515
|
{ left: c.left, top: c.top, right: c.right, bottom: c.bottom }
|
|
3494
3516
|
),
|
|
3495
|
-
children: typeof r == "function" ? r(
|
|
3517
|
+
children: typeof r == "function" ? r(g) : r
|
|
3496
3518
|
}
|
|
3497
3519
|
)
|
|
3498
3520
|
}
|
|
@@ -3576,13 +3598,13 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3576
3598
|
onRemoveHighlightColor: i,
|
|
3577
3599
|
onClose: c
|
|
3578
3600
|
}) => {
|
|
3579
|
-
const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {},
|
|
3601
|
+
const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, m = Object.values(u).map((f) => get(f, d ? "1" : "0")), [g, h] = useState("TEXT");
|
|
3580
3602
|
return /* @__PURE__ */ jsxs("div", { id: "rte-widget-color-picker", className: "px-1", children: [
|
|
3581
3603
|
/* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between rounded-md border bg-muted", children: [
|
|
3582
3604
|
/* @__PURE__ */ jsx(
|
|
3583
3605
|
"div",
|
|
3584
3606
|
{
|
|
3585
|
-
className: `w-full cursor-pointer rounded p-0.5 text-center ${
|
|
3607
|
+
className: `w-full cursor-pointer rounded p-0.5 text-center ${g === "TEXT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
|
|
3586
3608
|
onClick: () => h("TEXT"),
|
|
3587
3609
|
children: "Text Color"
|
|
3588
3610
|
}
|
|
@@ -3590,16 +3612,16 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3590
3612
|
/* @__PURE__ */ jsx(
|
|
3591
3613
|
"div",
|
|
3592
3614
|
{
|
|
3593
|
-
className: `w-full cursor-pointer rounded p-0.5 text-center ${
|
|
3615
|
+
className: `w-full cursor-pointer rounded p-0.5 text-center ${g === "HIGHLIGHT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
|
|
3594
3616
|
onClick: () => h("HIGHLIGHT"),
|
|
3595
3617
|
children: "Highlight Color"
|
|
3596
3618
|
}
|
|
3597
3619
|
)
|
|
3598
3620
|
] }),
|
|
3599
|
-
|
|
3621
|
+
g === "TEXT" ? /* @__PURE__ */ jsx(
|
|
3600
3622
|
Commons,
|
|
3601
3623
|
{
|
|
3602
|
-
themeColors:
|
|
3624
|
+
themeColors: m,
|
|
3603
3625
|
onClose: c,
|
|
3604
3626
|
onChange: r,
|
|
3605
3627
|
color: o,
|
|
@@ -3608,7 +3630,7 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3608
3630
|
) : /* @__PURE__ */ jsx(
|
|
3609
3631
|
Commons,
|
|
3610
3632
|
{
|
|
3611
|
-
themeColors:
|
|
3633
|
+
themeColors: m,
|
|
3612
3634
|
onClose: c,
|
|
3613
3635
|
onChange: a,
|
|
3614
3636
|
color: n,
|
|
@@ -3617,11 +3639,11 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3617
3639
|
)
|
|
3618
3640
|
] });
|
|
3619
3641
|
}, RteColorPicker = ({ editor: o, from: n, menuRef: r }) => {
|
|
3620
|
-
var
|
|
3621
|
-
const a = (
|
|
3622
|
-
|
|
3623
|
-
}, x = (_,
|
|
3624
|
-
|
|
3642
|
+
var v, B;
|
|
3643
|
+
const a = (v = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : v.color, l = (B = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : B.color, [i, c] = useState(a || "#000000F2"), [d, p] = useState(l || "#00000057"), [u, m] = useDebouncedState(i, 150), [g, h] = useDebouncedState(d, 150), f = (_, j) => {
|
|
3644
|
+
j ? (c(_), m(_)) : (o == null || o.chain().setColor(_).run(), c(_));
|
|
3645
|
+
}, x = (_, j) => {
|
|
3646
|
+
j ? (p(_), h(_)) : (o == null || o.chain().setHighlight({ color: _ }).run(), p(_));
|
|
3625
3647
|
}, b = () => {
|
|
3626
3648
|
o == null || o.chain().unsetColor().run(), c("#000000F2");
|
|
3627
3649
|
}, y = () => {
|
|
@@ -3630,8 +3652,8 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3630
3652
|
return useEffect(() => {
|
|
3631
3653
|
l && p(l);
|
|
3632
3654
|
}, [l]), useEffect(() => {
|
|
3633
|
-
|
|
3634
|
-
}, [
|
|
3655
|
+
g != null && g.includes("#") && (g == null ? void 0 : g.length) >= 3 && (o == null || o.chain().setHighlight({ color: g }).run());
|
|
3656
|
+
}, [g]), useEffect(() => {
|
|
3635
3657
|
u != null && u.includes("#") && (u == null ? void 0 : u.length) >= 3 && (o == null || o.chain().setColor(u).run());
|
|
3636
3658
|
}, [u]), /* @__PURE__ */ jsx(
|
|
3637
3659
|
RteDropdownMenu,
|
|
@@ -3928,9 +3950,9 @@ const RichTextEditor = memo(
|
|
|
3928
3950
|
blockId: "active-inline-editing-element",
|
|
3929
3951
|
placeholder: "Enter text here",
|
|
3930
3952
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3931
|
-
onBlur: ({ editor: u, event:
|
|
3932
|
-
const
|
|
3933
|
-
if (!b && !y && !S && !
|
|
3953
|
+
onBlur: ({ editor: u, event: m }) => {
|
|
3954
|
+
const g = m == null ? void 0 : m.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = h == null ? void 0 : h.contains(g), y = f == null ? void 0 : f.contains(g), S = x == null ? void 0 : x.contains(g), v = window.document.getElementById("rte-widget-color-picker");
|
|
3955
|
+
if (!b && !y && !S && !v) {
|
|
3934
3956
|
const B = (u == null ? void 0 : u.getHTML()) || "";
|
|
3935
3957
|
r(B);
|
|
3936
3958
|
}
|
|
@@ -3938,20 +3960,20 @@ const RichTextEditor = memo(
|
|
|
3938
3960
|
from: "canvas"
|
|
3939
3961
|
});
|
|
3940
3962
|
useEffect(() => {
|
|
3941
|
-
var
|
|
3963
|
+
var m, g;
|
|
3942
3964
|
const u = getInitialTextAlign(n);
|
|
3943
|
-
u && ((
|
|
3965
|
+
u && ((m = c == null ? void 0 : c.commands) == null || m.setTextAlign(u)), (g = c == null ? void 0 : c.commands) == null || g.focus(), c == null || c.emit("focus", {
|
|
3944
3966
|
editor: c,
|
|
3945
3967
|
event: new FocusEvent("focus"),
|
|
3946
3968
|
transaction: []
|
|
3947
3969
|
});
|
|
3948
3970
|
}, [c]);
|
|
3949
3971
|
const d = useMemo(() => {
|
|
3950
|
-
var
|
|
3972
|
+
var g;
|
|
3951
3973
|
const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
|
|
3952
3974
|
if (!n) return u;
|
|
3953
|
-
const
|
|
3954
|
-
return `${u} ${
|
|
3975
|
+
const m = ((g = n == null ? void 0 : n.className) == null ? void 0 : g.replace("sr-only", "")) || "";
|
|
3976
|
+
return `${u} ${m}`;
|
|
3955
3977
|
}, [n]), p = (u) => {
|
|
3956
3978
|
u.key === "Escape" && l(u);
|
|
3957
3979
|
};
|
|
@@ -3996,9 +4018,9 @@ const RichTextEditor = memo(
|
|
|
3996
4018
|
(h.key === "Enter" || h.key === "Escape") && i(h);
|
|
3997
4019
|
},
|
|
3998
4020
|
[i]
|
|
3999
|
-
),
|
|
4021
|
+
), m = useCallback(() => {
|
|
4000
4022
|
r();
|
|
4001
|
-
}, [r]),
|
|
4023
|
+
}, [r]), g = useMemo(() => {
|
|
4002
4024
|
var h;
|
|
4003
4025
|
return {
|
|
4004
4026
|
id: "active-inline-editing-element",
|
|
@@ -4016,14 +4038,14 @@ const RichTextEditor = memo(
|
|
|
4016
4038
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
4017
4039
|
return /* @__PURE__ */ jsx(Fragment, { children: createElement(p, {
|
|
4018
4040
|
ref: a,
|
|
4019
|
-
onBlur:
|
|
4041
|
+
onBlur: m,
|
|
4020
4042
|
onKeyDown: u,
|
|
4021
|
-
...
|
|
4043
|
+
...g
|
|
4022
4044
|
}) });
|
|
4023
4045
|
}
|
|
4024
4046
|
), WithBlockTextEditor = memo(
|
|
4025
4047
|
({ block: o, children: n }) => {
|
|
4026
|
-
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null),
|
|
4048
|
+
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), m = useRef(null), { clearHighlight: g } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: S, blockType: v } = useMemo(() => {
|
|
4027
4049
|
var E;
|
|
4028
4050
|
const k = o._type;
|
|
4029
4051
|
let I = o[r];
|
|
@@ -4032,7 +4054,7 @@ const RichTextEditor = memo(
|
|
|
4032
4054
|
}, [o, f]), B = useCallback(
|
|
4033
4055
|
(k) => {
|
|
4034
4056
|
var A;
|
|
4035
|
-
const I = k || ((A =
|
|
4057
|
+
const I = k || ((A = m.current) == null ? void 0 : A.innerText);
|
|
4036
4058
|
h([y], { [r]: I }), u(null), c(null), d(-1), x([]), y && setTimeout(() => x([y]), 100);
|
|
4037
4059
|
},
|
|
4038
4060
|
[y, h, c, x, f]
|
|
@@ -4042,7 +4064,7 @@ const RichTextEditor = memo(
|
|
|
4042
4064
|
},
|
|
4043
4065
|
[y, o, h, f],
|
|
4044
4066
|
1e3
|
|
4045
|
-
),
|
|
4067
|
+
), j = useCallback(
|
|
4046
4068
|
(k) => {
|
|
4047
4069
|
k.preventDefault(), y && (b.current = y), B(), setTimeout(() => {
|
|
4048
4070
|
const I = b.current;
|
|
@@ -4052,33 +4074,33 @@ const RichTextEditor = memo(
|
|
|
4052
4074
|
[x, y, f]
|
|
4053
4075
|
);
|
|
4054
4076
|
useEffect(() => {
|
|
4055
|
-
var
|
|
4077
|
+
var w;
|
|
4056
4078
|
if (!y) return;
|
|
4057
4079
|
const k = `[data-block-id="${y}"]`, I = i >= 0 ? `[data-block-index="${i}"]` : "", A = a.querySelector(`${k}${I}`);
|
|
4058
|
-
A && ((
|
|
4059
|
-
}, [y,
|
|
4060
|
-
const
|
|
4080
|
+
A && ((w = A == null ? void 0 : A.classList) == null || w.add("sr-only"), u(A));
|
|
4081
|
+
}, [y, v, a, i]);
|
|
4082
|
+
const C = useMemo(() => p ? (g(), ["RichText", "Paragraph"].includes(v) ? /* @__PURE__ */ jsx(
|
|
4061
4083
|
RichTextEditor,
|
|
4062
4084
|
{
|
|
4063
4085
|
blockContent: S,
|
|
4064
4086
|
editingElement: p,
|
|
4065
4087
|
onChange: _,
|
|
4066
4088
|
onClose: B,
|
|
4067
|
-
onEscape:
|
|
4089
|
+
onEscape: j
|
|
4068
4090
|
}
|
|
4069
4091
|
) : /* @__PURE__ */ jsx(
|
|
4070
4092
|
MemoizedEditor,
|
|
4071
4093
|
{
|
|
4072
|
-
editorRef:
|
|
4094
|
+
editorRef: m,
|
|
4073
4095
|
blockContent: S,
|
|
4074
4096
|
editingElement: p,
|
|
4075
4097
|
onClose: B,
|
|
4076
4098
|
onChange: _,
|
|
4077
|
-
onEscape:
|
|
4099
|
+
onEscape: j
|
|
4078
4100
|
}
|
|
4079
|
-
)) : null, [p, y,
|
|
4101
|
+
)) : null, [p, y, v, S, B, f]);
|
|
4080
4102
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4081
|
-
|
|
4103
|
+
C,
|
|
4082
4104
|
n
|
|
4083
4105
|
] });
|
|
4084
4106
|
},
|
|
@@ -4111,16 +4133,16 @@ const RichTextEditor = memo(
|
|
|
4111
4133
|
blockAtom: n,
|
|
4112
4134
|
children: r
|
|
4113
4135
|
}) => {
|
|
4114
|
-
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(),
|
|
4115
|
-
() =>
|
|
4136
|
+
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), m = usePageExternalData(), [g] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: f, key: x } = useContext(RepeaterContext), b = useMemo(
|
|
4137
|
+
() => g ? applyBindingToBlockProps(applyLanguage(i, d, c), m, {
|
|
4116
4138
|
index: f,
|
|
4117
4139
|
key: x
|
|
4118
4140
|
}) : applyLanguage(i, d, c),
|
|
4119
|
-
[i, d, c,
|
|
4141
|
+
[i, d, c, m, g, f, x]
|
|
4120
4142
|
), y = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), S = useMemo(
|
|
4121
4143
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
4122
4144
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
4123
|
-
),
|
|
4145
|
+
), v = useMemo(
|
|
4124
4146
|
() => ({
|
|
4125
4147
|
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
|
|
4126
4148
|
inBuilder: !0,
|
|
@@ -4142,8 +4164,8 @@ const RichTextEditor = memo(
|
|
|
4142
4164
|
]
|
|
4143
4165
|
), B = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), _ = useMemo(() => get(i, "_show", !0), [i]);
|
|
4144
4166
|
if (isNull(h) || !_) return null;
|
|
4145
|
-
let
|
|
4146
|
-
...
|
|
4167
|
+
let j = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
|
|
4168
|
+
...v,
|
|
4147
4169
|
children: r({
|
|
4148
4170
|
_id: i._id,
|
|
4149
4171
|
_type: i._type,
|
|
@@ -4155,8 +4177,8 @@ const RichTextEditor = memo(
|
|
|
4155
4177
|
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
4156
4178
|
})
|
|
4157
4179
|
}) });
|
|
4158
|
-
const
|
|
4159
|
-
return B ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children:
|
|
4180
|
+
const C = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: j }) : j;
|
|
4181
|
+
return B ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: C }) : C;
|
|
4160
4182
|
}, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
|
|
4161
4183
|
const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
4162
4184
|
(d) => {
|
|
@@ -4199,7 +4221,7 @@ const RichTextEditor = memo(
|
|
|
4199
4221
|
);
|
|
4200
4222
|
return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (d) => {
|
|
4201
4223
|
const p = l(d._id);
|
|
4202
|
-
return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id:
|
|
4224
|
+
return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: m, _type: g, partialBlockId: h, repeaterItems: f, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(f) && f.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: g }) }, `${m}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(m) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: g }) : null }) }, d._id) : null;
|
|
4203
4225
|
});
|
|
4204
4226
|
}, PageBlocksRenderer = () => {
|
|
4205
4227
|
const [o] = useBlocksStore();
|
|
@@ -4212,18 +4234,18 @@ const RichTextEditor = memo(
|
|
|
4212
4234
|
const { width: d, height: p } = o;
|
|
4213
4235
|
if (d < n) {
|
|
4214
4236
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
4215
|
-
let
|
|
4216
|
-
const
|
|
4217
|
-
p && (
|
|
4237
|
+
let m = {};
|
|
4238
|
+
const g = p * u, h = d * u;
|
|
4239
|
+
p && (m = {
|
|
4218
4240
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
4219
|
-
height: 100 + (p -
|
|
4241
|
+
height: 100 + (p - g) / g * 100 + "%",
|
|
4220
4242
|
width: 100 + (d - h) / h * 100 + "%"
|
|
4221
4243
|
}), i({
|
|
4222
4244
|
position: "relative",
|
|
4223
4245
|
top: 0,
|
|
4224
4246
|
transform: `scale(${u})`,
|
|
4225
4247
|
transformOrigin: a === "rtl" ? "top right" : "top left",
|
|
4226
|
-
...
|
|
4248
|
+
...m,
|
|
4227
4249
|
maxWidth: "none"
|
|
4228
4250
|
// TODO: Add max-width to the wrapper
|
|
4229
4251
|
}), r(u * 100);
|
|
@@ -4250,8 +4272,8 @@ const CanvasEventsWatcher = () => {
|
|
|
4250
4272
|
if (d) {
|
|
4251
4273
|
const p = d.getAttribute("data-style-prop");
|
|
4252
4274
|
if (p) {
|
|
4253
|
-
const u = d.getAttribute("data-style-id"),
|
|
4254
|
-
r([{ id: u, prop: p, blockId:
|
|
4275
|
+
const u = d.getAttribute("data-style-id"), m = d.getAttribute("data-block-parent");
|
|
4276
|
+
r([{ id: u, prop: p, blockId: m }]);
|
|
4255
4277
|
}
|
|
4256
4278
|
}
|
|
4257
4279
|
}, 100);
|
|
@@ -4259,13 +4281,13 @@ const CanvasEventsWatcher = () => {
|
|
|
4259
4281
|
d && (!isEmpty(d) && !includes(i, first(d)) && (c == null || c.closeAll()), o(d));
|
|
4260
4282
|
}), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
|
|
4261
4283
|
if (!d) return;
|
|
4262
|
-
const { blockId: p, styleId: u, styleProp:
|
|
4263
|
-
p && (includes(i, p) || c == null || c.closeAll(), r([{ id: u, prop:
|
|
4284
|
+
const { blockId: p, styleId: u, styleProp: m } = d;
|
|
4285
|
+
p && (includes(i, p) || c == null || c.closeAll(), r([{ id: u, prop: m, blockId: p }]), o([p]));
|
|
4264
4286
|
}), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
|
|
4265
4287
|
l(), o([]), r([]);
|
|
4266
4288
|
}), null;
|
|
4267
4289
|
}, StaticCanvas = () => {
|
|
4268
|
-
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"),
|
|
4290
|
+
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"), m = useCallback(
|
|
4269
4291
|
(h) => {
|
|
4270
4292
|
i((f) => ({ ...f, width: h }));
|
|
4271
4293
|
},
|
|
@@ -4276,11 +4298,11 @@ const CanvasEventsWatcher = () => {
|
|
|
4276
4298
|
const { clientWidth: h, clientHeight: f } = a.current;
|
|
4277
4299
|
i({ width: h, height: f });
|
|
4278
4300
|
}, [a, o]);
|
|
4279
|
-
const
|
|
4301
|
+
const g = useMemo(() => {
|
|
4280
4302
|
let h = IframeInitialContent;
|
|
4281
4303
|
return h = h.replace("__HTML_DIR__", u), h;
|
|
4282
4304
|
}, [u]);
|
|
4283
|
-
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount:
|
|
4305
|
+
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: m, onResize: m, children: /* @__PURE__ */ jsx(
|
|
4284
4306
|
"div",
|
|
4285
4307
|
{
|
|
4286
4308
|
onMouseLeave: () => setTimeout(() => n(""), 300),
|
|
@@ -4294,7 +4316,7 @@ const CanvasEventsWatcher = () => {
|
|
|
4294
4316
|
id: "canvas-iframe",
|
|
4295
4317
|
style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
|
|
4296
4318
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
4297
|
-
initialContent:
|
|
4319
|
+
initialContent: g,
|
|
4298
4320
|
children: [
|
|
4299
4321
|
/* @__PURE__ */ jsx(KeyboardHandler, {}),
|
|
4300
4322
|
/* @__PURE__ */ jsx(BlockSelectionHighlighter, {}),
|
|
@@ -4327,7 +4349,7 @@ const CanvasEventsWatcher = () => {
|
|
|
4327
4349
|
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
|
|
4328
4350
|
/* @__PURE__ */ jsx("p", { children: o("Please try again.") })
|
|
4329
4351
|
] }) });
|
|
4330
|
-
}, CodeEditor$1 = React__default.lazy(() => import("./code-editor-
|
|
4352
|
+
}, CodeEditor$1 = React__default.lazy(() => import("./code-editor-DlWYye4v.js")), CanvasArea = () => {
|
|
4331
4353
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
4332
4354
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
|
|
4333
4355
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -4355,7 +4377,7 @@ const CanvasEventsWatcher = () => {
|
|
|
4355
4377
|
}, useBlockSettingComponents = (o) => Object.values(RJSF_EXTENSIONS).filter((n) => n.type === o).reduce(
|
|
4356
4378
|
(n, r) => (n[r.id] = r.component, n),
|
|
4357
4379
|
{}
|
|
4358
|
-
), IconPicker = lazy(() => import("./IconPicker-
|
|
4380
|
+
), IconPicker = lazy(() => import("./IconPicker-DB-dcym6.js").then((o) => ({ default: o.IconPicker }))), sanitizeSvg = (o) => {
|
|
4359
4381
|
try {
|
|
4360
4382
|
let n = o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
|
|
4361
4383
|
return n = n.replace(/>\s+</g, "><"), n = n.replace(/\n/g, "").replace(/\s{2,}/g, " "), n = n.replace(/\s+=/g, "=").replace(/=\s+/g, "="), n = n.replace(/<!--[\s\S]*?-->/g, ""), n.trim();
|
|
@@ -4396,15 +4418,15 @@ const CanvasEventsWatcher = () => {
|
|
|
4396
4418
|
] })
|
|
4397
4419
|
] });
|
|
4398
4420
|
}, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
|
|
4399
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u,
|
|
4421
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState(null), g = async (f) => {
|
|
4400
4422
|
if (!f.trim()) {
|
|
4401
|
-
p(!1),
|
|
4423
|
+
p(!1), m("Please enter a URL");
|
|
4402
4424
|
return;
|
|
4403
4425
|
}
|
|
4404
4426
|
try {
|
|
4405
|
-
c(!0),
|
|
4427
|
+
c(!0), m(null), p(!0), m(null);
|
|
4406
4428
|
} catch {
|
|
4407
|
-
p(!1),
|
|
4429
|
+
p(!1), m("Error validating URL");
|
|
4408
4430
|
} finally {
|
|
4409
4431
|
c(!1);
|
|
4410
4432
|
}
|
|
@@ -4422,7 +4444,7 @@ const CanvasEventsWatcher = () => {
|
|
|
4422
4444
|
placeholder: h(`Enter ${r} URL`),
|
|
4423
4445
|
value: a,
|
|
4424
4446
|
onChange: (f) => l(f.target.value),
|
|
4425
|
-
onKeyUp: () =>
|
|
4447
|
+
onKeyUp: () => g(a)
|
|
4426
4448
|
}
|
|
4427
4449
|
),
|
|
4428
4450
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
@@ -4466,31 +4488,31 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4466
4488
|
const n = ((l = o.split("/").pop()) == null ? void 0 : l.split("?")[0]) || "";
|
|
4467
4489
|
return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((i) => n.toLowerCase().endsWith(i)) ? n : "";
|
|
4468
4490
|
}, ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
4469
|
-
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "",
|
|
4491
|
+
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", m = i ? `_${u}Id-${i}` : `_${u}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, m, g ? c == null ? void 0 : c.assetId : ""), f = useMemo(() => {
|
|
4470
4492
|
if (!o || !c || !/\{\{.*?\}\}/.test(o)) return o;
|
|
4471
4493
|
const B = { ...c, [u]: o }, _ = applyBindingToBlockProps(B, p, { index: -1, key: "" });
|
|
4472
4494
|
return get(_, u, o);
|
|
4473
|
-
}, [o, c, p, u]), x = !!h || f !== PLACEHOLDER_IMAGE, b = (
|
|
4474
|
-
const B = isArray(
|
|
4495
|
+
}, [o, c, p, u]), x = !!h || f !== PLACEHOLDER_IMAGE, b = (v) => {
|
|
4496
|
+
const B = isArray(v) ? first(v) : v;
|
|
4475
4497
|
if (B) {
|
|
4476
4498
|
n(B == null ? void 0 : B.url);
|
|
4477
|
-
const _ = B == null ? void 0 : B.width,
|
|
4499
|
+
const _ = B == null ? void 0 : B.width, j = B == null ? void 0 : B.height, C = m.includes("mobile");
|
|
4478
4500
|
if (c != null && c._id) {
|
|
4479
4501
|
const k = {
|
|
4480
|
-
..._ && { [
|
|
4481
|
-
...
|
|
4502
|
+
..._ && { [C ? "mobileWidth" : "width"]: _ },
|
|
4503
|
+
...j && { [C ? "mobileHeight" : "height"]: j },
|
|
4482
4504
|
...B.description && { alt: B.description }
|
|
4483
4505
|
};
|
|
4484
|
-
if (set(k,
|
|
4506
|
+
if (set(k, m, B.id), isEmpty(k)) return;
|
|
4485
4507
|
d([c._id], k);
|
|
4486
4508
|
}
|
|
4487
4509
|
}
|
|
4488
4510
|
}, y = useCallback(() => {
|
|
4489
4511
|
if (n(PLACEHOLDER_IMAGE), c != null && c._id) {
|
|
4490
|
-
const
|
|
4491
|
-
set(
|
|
4512
|
+
const v = {}, B = m.includes("mobile");
|
|
4513
|
+
set(v, m, ""), set(v, B ? "mobileWidth" : "width", ""), set(v, B ? "mobileHeight" : "height", ""), d([c._id], v);
|
|
4492
4514
|
}
|
|
4493
|
-
}, [n, c == null ? void 0 : c._id, d,
|
|
4515
|
+
}, [n, c == null ? void 0 : c._id, d, m]), S = getFileName(f);
|
|
4494
4516
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-start gap-x-3", children: [
|
|
4495
4517
|
f ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
|
|
4496
4518
|
/* @__PURE__ */ jsx(
|
|
@@ -4536,25 +4558,25 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4536
4558
|
className: "h-6 text-xs",
|
|
4537
4559
|
placeholder: l("Enter image URL"),
|
|
4538
4560
|
value: o === PLACEHOLDER_IMAGE ? "" : o,
|
|
4539
|
-
onBlur: ({ target: { value:
|
|
4540
|
-
onChange: (
|
|
4561
|
+
onBlur: ({ target: { value: v } }) => a(r, v),
|
|
4562
|
+
onChange: (v) => n(v.target.value)
|
|
4541
4563
|
}
|
|
4542
4564
|
)
|
|
4543
4565
|
] })
|
|
4544
4566
|
] });
|
|
4545
4567
|
}, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
|
|
4546
|
-
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (
|
|
4547
|
-
(
|
|
4568
|
+
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (g) => Array.isArray(g) ? "array" : typeof g == "object" && g !== null ? "object" : "value", p = React__default.useCallback(
|
|
4569
|
+
(g) => {
|
|
4548
4570
|
const h = (f) => r === "value" ? f === "value" || f === "object" : r === "array" ? f === "array" : f === r;
|
|
4549
|
-
|
|
4571
|
+
g.type === "object" ? (l((f) => [...f, g.key]), c(g.value)) : h(g.type) && n([...a, g.key].join("."), r);
|
|
4550
4572
|
},
|
|
4551
4573
|
[a, n, r]
|
|
4552
4574
|
), u = React__default.useCallback(() => {
|
|
4553
4575
|
if (a.length > 0) {
|
|
4554
|
-
const
|
|
4555
|
-
l(
|
|
4576
|
+
const g = a.slice(0, -1);
|
|
4577
|
+
l(g), c(g.reduce((h, f) => h[f], o));
|
|
4556
4578
|
}
|
|
4557
|
-
}, [a, o]),
|
|
4579
|
+
}, [a, o]), m = React__default.useMemo(() => i ? Object.entries(i).map(([g, h]) => ({ key: g, value: h, type: d(h) })).filter((g) => !startsWith(g.key, REPEATER_PREFIX) && g.key.includes("/") ? !1 : r === "value" ? g.type === "value" || g.type === "object" : r === "array" ? g.type === "array" || g.type === "object" : r === "object" ? g.type === "object" : !0) : [], [i, r]);
|
|
4558
4580
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
4559
4581
|
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
4560
4582
|
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
@@ -4564,36 +4586,36 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4564
4586
|
/* @__PURE__ */ jsx(ChevronLeftIcon, { className: "mr-2 h-4 w-4" }),
|
|
4565
4587
|
t("Back")
|
|
4566
4588
|
] }),
|
|
4567
|
-
|
|
4589
|
+
m.map((g) => /* @__PURE__ */ jsxs(
|
|
4568
4590
|
CommandItem,
|
|
4569
4591
|
{
|
|
4570
|
-
value:
|
|
4592
|
+
value: g.key,
|
|
4571
4593
|
disabled: !1,
|
|
4572
|
-
onSelect: () => p(
|
|
4594
|
+
onSelect: () => p(g),
|
|
4573
4595
|
className: "flex items-center justify-between",
|
|
4574
4596
|
children: [
|
|
4575
4597
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
|
|
4576
|
-
startsWith(
|
|
4577
|
-
startsWith(
|
|
4598
|
+
startsWith(g.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(g.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(IdCardIcon, {}) : null,
|
|
4599
|
+
startsWith(g.key, REPEATER_PREFIX) ? t("Repeater Data") : startsWith(g.key, COLLECTION_PREFIX) ? g.key.replace(COLLECTION_PREFIX, "") : g.key
|
|
4578
4600
|
] }),
|
|
4579
4601
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4580
|
-
r === "object" &&
|
|
4602
|
+
r === "object" && g.type === "object" && /* @__PURE__ */ jsx(
|
|
4581
4603
|
Button,
|
|
4582
4604
|
{
|
|
4583
4605
|
size: "sm",
|
|
4584
4606
|
variant: "ghost",
|
|
4585
4607
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4586
4608
|
onClick: (h) => {
|
|
4587
|
-
h.stopPropagation(), n([...a,
|
|
4609
|
+
h.stopPropagation(), n([...a, g.key].join("."), r);
|
|
4588
4610
|
},
|
|
4589
4611
|
children: t("Select")
|
|
4590
4612
|
}
|
|
4591
4613
|
),
|
|
4592
|
-
|
|
4614
|
+
g.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 opacity-50" }) })
|
|
4593
4615
|
] })
|
|
4594
4616
|
]
|
|
4595
4617
|
},
|
|
4596
|
-
|
|
4618
|
+
g.key
|
|
4597
4619
|
))
|
|
4598
4620
|
] })
|
|
4599
4621
|
] })
|
|
@@ -4645,19 +4667,19 @@ const DataBindingSelector = ({
|
|
|
4645
4667
|
}) => {
|
|
4646
4668
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4647
4669
|
if (i.length === 1) return "";
|
|
4648
|
-
const
|
|
4649
|
-
return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${
|
|
4670
|
+
const m = i.find((f) => f._type === "Repeater"), h = get(m, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4671
|
+
return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${m._id}` : h}`;
|
|
4650
4672
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4651
|
-
(
|
|
4652
|
-
if (
|
|
4653
|
-
n(`{{${
|
|
4673
|
+
(m, g) => {
|
|
4674
|
+
if (m = isEmpty(d) ? m : m.replace(`${d}`, "$index"), g === "array" || g === "object") {
|
|
4675
|
+
n(`{{${m}}}`, {}, r);
|
|
4654
4676
|
return;
|
|
4655
4677
|
}
|
|
4656
|
-
const h = (y) => /[.,!?;:]/.test(y), f = (y, S,
|
|
4678
|
+
const h = (y) => /[.,!?;:]/.test(y), f = (y, S, v) => {
|
|
4657
4679
|
let B = "", _ = "";
|
|
4658
|
-
const
|
|
4659
|
-
return S > 0 && (
|
|
4660
|
-
text: B +
|
|
4680
|
+
const j = S > 0 ? y[S - 1] : "", C = S < y.length ? y[S] : "";
|
|
4681
|
+
return S > 0 && (j === "." || !h(j) && j !== " ") && (B = " "), S < y.length && !h(C) && C !== " " && (_ = " "), {
|
|
4682
|
+
text: B + v + _,
|
|
4661
4683
|
prefixLength: B.length,
|
|
4662
4684
|
suffixLength: _.length
|
|
4663
4685
|
};
|
|
@@ -4667,29 +4689,29 @@ const DataBindingSelector = ({
|
|
|
4667
4689
|
if (b && (b.querySelector(".ProseMirror") || b.__chaiRTE)) {
|
|
4668
4690
|
const y = b.__chaiRTE;
|
|
4669
4691
|
if (y) {
|
|
4670
|
-
const S = `{{${
|
|
4692
|
+
const S = `{{${m}}}`;
|
|
4671
4693
|
y.commands.focus();
|
|
4672
|
-
const { from:
|
|
4673
|
-
if (
|
|
4694
|
+
const { from: v, to: B } = y.state.selection;
|
|
4695
|
+
if (v !== B)
|
|
4674
4696
|
y.chain().deleteSelection().insertContent(S).run();
|
|
4675
4697
|
else {
|
|
4676
|
-
const { state:
|
|
4698
|
+
const { state: j } = y, C = j.selection.from, k = j.doc.textBetween(Math.max(0, C - 1), C), I = j.doc.textBetween(C, Math.min(C + 1, j.doc.content.size));
|
|
4677
4699
|
let A = "";
|
|
4678
|
-
|
|
4679
|
-
let
|
|
4680
|
-
I && I !== " " && !h(I) && (
|
|
4700
|
+
C > 0 && k !== " " && !h(k) && (A = " ");
|
|
4701
|
+
let w = "";
|
|
4702
|
+
I && I !== " " && !h(I) && (w = " "), y.chain().insertContent(A + S + w).run();
|
|
4681
4703
|
}
|
|
4682
4704
|
setTimeout(() => n(y.getHTML(), {}, r), 100);
|
|
4683
4705
|
return;
|
|
4684
4706
|
}
|
|
4685
4707
|
} else {
|
|
4686
|
-
const y = x, S = y.selectionStart || 0,
|
|
4708
|
+
const y = x, S = y.selectionStart || 0, v = y.value || "", B = y.selectionEnd || S;
|
|
4687
4709
|
if (B > S) {
|
|
4688
|
-
const I = `{{${
|
|
4689
|
-
n(
|
|
4710
|
+
const I = `{{${m}}}`, { text: A } = f(v, S, I), w = v.slice(0, S) + A + v.slice(B);
|
|
4711
|
+
n(w, {}, r);
|
|
4690
4712
|
return;
|
|
4691
4713
|
}
|
|
4692
|
-
const
|
|
4714
|
+
const j = `{{${m}}}`, { text: C } = f(v, S, j), k = v.slice(0, S) + C + v.slice(S);
|
|
4693
4715
|
n(k, {}, r);
|
|
4694
4716
|
}
|
|
4695
4717
|
},
|
|
@@ -4712,12 +4734,12 @@ const DataBindingSelector = ({
|
|
|
4712
4734
|
onChange: r
|
|
4713
4735
|
}) => {
|
|
4714
4736
|
var I;
|
|
4715
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (A,
|
|
4737
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (A, w) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState("page"), [g, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), S = useRef(null), v = (I = n == null ? void 0 : n.find((A) => A.key === u)) == null ? void 0 : I.name;
|
|
4716
4738
|
useEffect(() => {
|
|
4717
4739
|
if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4718
|
-
const A = split(o, ":"),
|
|
4719
|
-
|
|
4720
|
-
const E = await l(
|
|
4740
|
+
const A = split(o, ":"), w = get(A, 1, "page") || "page";
|
|
4741
|
+
m(w), (async () => {
|
|
4742
|
+
const E = await l(w, [get(A, 2, "page")]);
|
|
4721
4743
|
E && Array.isArray(E) && h(get(E, [0, "name"], ""));
|
|
4722
4744
|
})();
|
|
4723
4745
|
}, [o]);
|
|
@@ -4726,30 +4748,30 @@ const DataBindingSelector = ({
|
|
|
4726
4748
|
if (isEmpty(A))
|
|
4727
4749
|
x([]);
|
|
4728
4750
|
else {
|
|
4729
|
-
const
|
|
4730
|
-
x(
|
|
4751
|
+
const w = await l(u, A);
|
|
4752
|
+
x(w);
|
|
4731
4753
|
}
|
|
4732
4754
|
c(!1), y(-1);
|
|
4733
4755
|
},
|
|
4734
4756
|
[u],
|
|
4735
4757
|
300
|
|
4736
4758
|
), _ = (A) => {
|
|
4737
|
-
const
|
|
4738
|
-
|
|
4739
|
-
},
|
|
4759
|
+
const w = ["pageType", u, A.id];
|
|
4760
|
+
w[1] && (r(w.join(":")), h(A.name), p(!1), x([]), y(-1));
|
|
4761
|
+
}, j = (A) => {
|
|
4740
4762
|
switch (A.key) {
|
|
4741
4763
|
case "ArrowDown":
|
|
4742
|
-
A.preventDefault(), y((
|
|
4764
|
+
A.preventDefault(), y((w) => w < f.length - 1 ? w + 1 : w);
|
|
4743
4765
|
break;
|
|
4744
4766
|
case "ArrowUp":
|
|
4745
|
-
A.preventDefault(), y((
|
|
4767
|
+
A.preventDefault(), y((w) => w > 0 ? w - 1 : w);
|
|
4746
4768
|
break;
|
|
4747
4769
|
case "Enter":
|
|
4748
4770
|
if (A.preventDefault(), f.length === 0) return;
|
|
4749
4771
|
b >= 0 && _(f[b]);
|
|
4750
4772
|
break;
|
|
4751
4773
|
case "Escape":
|
|
4752
|
-
A.preventDefault(),
|
|
4774
|
+
A.preventDefault(), C();
|
|
4753
4775
|
break;
|
|
4754
4776
|
}
|
|
4755
4777
|
};
|
|
@@ -4759,26 +4781,26 @@ const DataBindingSelector = ({
|
|
|
4759
4781
|
A == null || A.scrollIntoView({ block: "nearest" });
|
|
4760
4782
|
}
|
|
4761
4783
|
}, [b]);
|
|
4762
|
-
const
|
|
4784
|
+
const C = () => {
|
|
4763
4785
|
h(""), x([]), y(-1), p(!1), r("");
|
|
4764
4786
|
}, k = (A) => {
|
|
4765
4787
|
h(A), p(!isEmpty(A)), c(!0), B(A);
|
|
4766
4788
|
};
|
|
4767
4789
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4768
|
-
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (A) =>
|
|
4790
|
+
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (A) => m(A.target.value), children: map(n, (A) => /* @__PURE__ */ jsx("option", { value: A.key, children: A.name }, A.key)) }),
|
|
4769
4791
|
u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
|
|
4770
4792
|
/* @__PURE__ */ jsx(
|
|
4771
4793
|
"input",
|
|
4772
4794
|
{
|
|
4773
4795
|
type: "text",
|
|
4774
|
-
value:
|
|
4796
|
+
value: g,
|
|
4775
4797
|
onChange: (A) => k(A.target.value),
|
|
4776
|
-
onKeyDown:
|
|
4777
|
-
placeholder: a(`Search ${
|
|
4798
|
+
onKeyDown: j,
|
|
4799
|
+
placeholder: a(`Search ${v ?? ""}`),
|
|
4778
4800
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4779
4801
|
}
|
|
4780
4802
|
),
|
|
4781
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
4803
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: g && /* @__PURE__ */ jsx("button", { onClick: C, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
|
|
4782
4804
|
] }),
|
|
4783
4805
|
(i || !isEmpty(f) || d && isEmpty(f)) && /* @__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: [
|
|
4784
4806
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -4786,13 +4808,13 @@ const DataBindingSelector = ({
|
|
|
4786
4808
|
] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4787
4809
|
a("No results found for"),
|
|
4788
4810
|
' "',
|
|
4789
|
-
|
|
4811
|
+
g,
|
|
4790
4812
|
'"'
|
|
4791
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(f == null ? void 0 : f.slice(0, 20), (A,
|
|
4813
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(f == null ? void 0 : f.slice(0, 20), (A, w) => /* @__PURE__ */ jsxs(
|
|
4792
4814
|
"li",
|
|
4793
4815
|
{
|
|
4794
4816
|
onClick: () => _(A),
|
|
4795
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(A.id) ? "bg-blue-200" :
|
|
4817
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(A.id) ? "bg-blue-200" : w === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4796
4818
|
children: [
|
|
4797
4819
|
A.name,
|
|
4798
4820
|
" ",
|
|
@@ -4807,9 +4829,9 @@ const DataBindingSelector = ({
|
|
|
4807
4829
|
)) }) })
|
|
4808
4830
|
] });
|
|
4809
4831
|
}, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
|
|
4810
|
-
const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang:
|
|
4811
|
-
() => isEmpty(
|
|
4812
|
-
[
|
|
4832
|
+
const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: m, languages: g } = useLanguages(), h = useMemo(
|
|
4833
|
+
() => isEmpty(g) ? "" : isEmpty(u) ? m : u,
|
|
4834
|
+
[g, u, m]
|
|
4813
4835
|
), f = useMemo(() => get(LANGUAGES, h, h), [h]), x = i === "pageType" && isEmpty(p) ? "url" : i;
|
|
4814
4836
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4815
4837
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-x-2 text-xs font-medium", children: [
|
|
@@ -4897,7 +4919,7 @@ const DataBindingSelector = ({
|
|
|
4897
4919
|
]
|
|
4898
4920
|
}
|
|
4899
4921
|
) });
|
|
4900
|
-
}, RTEModal = React__default.lazy(() => import("./rte-widget-modal-
|
|
4922
|
+
}, RTEModal = React__default.lazy(() => import("./rte-widget-modal-CqBZ4WKt.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
|
|
4901
4923
|
const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
|
|
4902
4924
|
blockId: o,
|
|
4903
4925
|
value: a,
|
|
@@ -4914,9 +4936,9 @@ const DataBindingSelector = ({
|
|
|
4914
4936
|
useEffect(() => {
|
|
4915
4937
|
c.current && u && (c.current.__chaiRTE = u);
|
|
4916
4938
|
}, [o, u]);
|
|
4917
|
-
const
|
|
4939
|
+
const m = () => {
|
|
4918
4940
|
p(!1);
|
|
4919
|
-
},
|
|
4941
|
+
}, g = /* @__PURE__ */ jsxs("div", { id: `chai-rte-${n}`, ref: c, className: "mt-1 rounded-md border border-input", children: [
|
|
4920
4942
|
/* @__PURE__ */ jsx(RteMenubar, { editor: u, onExpand: () => p(!0) }),
|
|
4921
4943
|
/* @__PURE__ */ jsx(
|
|
4922
4944
|
EditorContent,
|
|
@@ -4930,8 +4952,8 @@ const DataBindingSelector = ({
|
|
|
4930
4952
|
)
|
|
4931
4953
|
] });
|
|
4932
4954
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4933
|
-
d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose:
|
|
4934
|
-
d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children:
|
|
4955
|
+
d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: m, editor: u, rteElement: g }) }),
|
|
4956
|
+
d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: g })
|
|
4935
4957
|
] });
|
|
4936
4958
|
}, RichTextEditorField = (o) => {
|
|
4937
4959
|
const { editingBlockId: n } = useInlineEditing(), [r, a] = useState(null), l = useSelectedBlock(), i = l == null ? void 0 : l._id;
|
|
@@ -4943,21 +4965,21 @@ const DataBindingSelector = ({
|
|
|
4943
4965
|
if (!a && !l) return null;
|
|
4944
4966
|
const d = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(r, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
|
|
4945
4967
|
if (!p) return null;
|
|
4946
|
-
const u = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }),
|
|
4968
|
+
const u = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), m = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
|
|
4947
4969
|
useEffect(() => {
|
|
4948
4970
|
(a == null ? void 0 : a._type) === "Slide" && (o == null ? void 0 : o.currentSlide) !== (a == null ? void 0 : a._id) && n({ ...o, currentSlide: a == null ? void 0 : a._id });
|
|
4949
4971
|
}, [a]), useEffect(() => {
|
|
4950
4972
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4951
4973
|
}, [o, u]);
|
|
4952
|
-
const
|
|
4953
|
-
const x = findIndex(u, { _id:
|
|
4974
|
+
const g = () => {
|
|
4975
|
+
const x = findIndex(u, { _id: m });
|
|
4954
4976
|
if (x > -1) {
|
|
4955
4977
|
const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
|
|
4956
4978
|
if (!y) return;
|
|
4957
4979
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4958
4980
|
}
|
|
4959
4981
|
}, h = () => {
|
|
4960
|
-
const x = findIndex(u, { _id:
|
|
4982
|
+
const x = findIndex(u, { _id: m });
|
|
4961
4983
|
if (x > -1) {
|
|
4962
4984
|
const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
|
|
4963
4985
|
if (!y) return;
|
|
@@ -4973,15 +4995,15 @@ const DataBindingSelector = ({
|
|
|
4973
4995
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4974
4996
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4975
4997
|
/* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "h-3 w-3" }) }),
|
|
4976
|
-
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children:
|
|
4998
|
+
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: m ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4977
4999
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4978
5000
|
" ",
|
|
4979
|
-
findIndex(u, { _id:
|
|
5001
|
+
findIndex(u, { _id: m }) + 1
|
|
4980
5002
|
] }),
|
|
4981
5003
|
"/",
|
|
4982
5004
|
u.length
|
|
4983
5005
|
] }) : "-" }),
|
|
4984
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
5006
|
+
/* @__PURE__ */ jsx("button", { onClick: g, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) }),
|
|
4985
5007
|
/* @__PURE__ */ jsxs(
|
|
4986
5008
|
"button",
|
|
4987
5009
|
{
|
|
@@ -5059,7 +5081,7 @@ const DataBindingSelector = ({
|
|
|
5059
5081
|
const r = get(o, "srcsets", []) || [], a = (c, d) => {
|
|
5060
5082
|
const p = c.target.name, u = c.target.value;
|
|
5061
5083
|
n({
|
|
5062
|
-
srcsets: map(r, (
|
|
5084
|
+
srcsets: map(r, (m, g) => g === d ? { ...m, [p]: u } : m)
|
|
5063
5085
|
});
|
|
5064
5086
|
}, l = () => {
|
|
5065
5087
|
n({ srcsets: [...r, {}] });
|
|
@@ -5138,37 +5160,37 @@ const DataBindingSelector = ({
|
|
|
5138
5160
|
] });
|
|
5139
5161
|
}, CollectionFilterSortField = ({ id: o, value: n, onChange: r, onBlur: a }) => {
|
|
5140
5162
|
const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(l, { id: c }), u = get(d, o === "root.filter" ? "filters" : "sorts", []);
|
|
5141
|
-
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: n, onChange: (
|
|
5163
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: n, onChange: (m) => r(m.target.value), onBlur: (m) => a(o, m.target.value), children: [
|
|
5142
5164
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
|
|
5143
|
-
u.map((
|
|
5165
|
+
u.map((m) => /* @__PURE__ */ jsx("option", { value: m.id, children: m.name }, m.id))
|
|
5144
5166
|
] }) });
|
|
5145
5167
|
}, JSONFormFieldTemplate = (o) => {
|
|
5146
|
-
const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData:
|
|
5168
|
+
const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: m, onChange: g } = o, { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = useMemo(
|
|
5147
5169
|
() => isEmpty(x) ? "" : isEmpty(h) ? f : h,
|
|
5148
5170
|
[x, h, f]
|
|
5149
|
-
), y = useMemo(() => get(LANGUAGES, b, b), [b]), S = usePageExternalData(),
|
|
5150
|
-
() => get(B, [
|
|
5151
|
-
[B,
|
|
5152
|
-
), [
|
|
5171
|
+
), y = useMemo(() => get(LANGUAGES, b, b), [b]), S = usePageExternalData(), v = useSelectedBlock(), B = useRegisteredChaiBlocks(), _ = useMemo(
|
|
5172
|
+
() => get(B, [v == null ? void 0 : v._type, "i18nProps"], []),
|
|
5173
|
+
[B, v == null ? void 0 : v._type]
|
|
5174
|
+
), [j, C] = useState(null);
|
|
5153
5175
|
if (d)
|
|
5154
5176
|
return null;
|
|
5155
5177
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
|
|
5156
5178
|
const I = _ == null ? void 0 : _.includes(n.replace("root.", ""));
|
|
5157
5179
|
if (u.type === "array") {
|
|
5158
|
-
const E =
|
|
5180
|
+
const E = j === n;
|
|
5159
5181
|
return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
|
|
5160
5182
|
u.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
|
|
5161
5183
|
"label",
|
|
5162
5184
|
{
|
|
5163
5185
|
htmlFor: n,
|
|
5164
|
-
onClick: () =>
|
|
5186
|
+
onClick: () => C(E ? null : n),
|
|
5165
5187
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
5166
5188
|
children: [
|
|
5167
5189
|
E ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }),
|
|
5168
5190
|
/* @__PURE__ */ jsx(ListBulletIcon, { className: "h-3 w-3" }),
|
|
5169
5191
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: a }),
|
|
5170
5192
|
" ",
|
|
5171
|
-
/* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children:
|
|
5193
|
+
/* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: m == null ? void 0 : m.length }) }),
|
|
5172
5194
|
u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5173
5195
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5174
5196
|
InfoCircledIcon,
|
|
@@ -5183,14 +5205,14 @@ const DataBindingSelector = ({
|
|
|
5183
5205
|
]
|
|
5184
5206
|
}
|
|
5185
5207
|
) }),
|
|
5186
|
-
(
|
|
5208
|
+
(m == null ? void 0 : m.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: l }) : /* @__PURE__ */ jsxs("div", { className: `${E ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
5187
5209
|
l,
|
|
5188
5210
|
i,
|
|
5189
5211
|
c
|
|
5190
5212
|
] })
|
|
5191
5213
|
] });
|
|
5192
5214
|
}
|
|
5193
|
-
const A = n.replace("root.", ""),
|
|
5215
|
+
const A = n.replace("root.", ""), w = _.includes(A) && !isEmpty(h) && isEmpty(m);
|
|
5194
5216
|
return /* @__PURE__ */ jsxs("div", { className: r, children: [
|
|
5195
5217
|
u.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
5196
5218
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
@@ -5209,7 +5231,7 @@ const DataBindingSelector = ({
|
|
|
5209
5231
|
] }) })
|
|
5210
5232
|
] }),
|
|
5211
5233
|
!u.enum && !u.oneOf && S && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
|
|
5212
|
-
|
|
5234
|
+
w ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5213
5235
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
5214
5236
|
"svg",
|
|
5215
5237
|
{
|
|
@@ -5241,10 +5263,10 @@ const DataBindingSelector = ({
|
|
|
5241
5263
|
{
|
|
5242
5264
|
schema: u,
|
|
5243
5265
|
onChange: (E) => {
|
|
5244
|
-
|
|
5266
|
+
g(E, m, n);
|
|
5245
5267
|
},
|
|
5246
5268
|
id: n,
|
|
5247
|
-
formData:
|
|
5269
|
+
formData: m
|
|
5248
5270
|
}
|
|
5249
5271
|
)
|
|
5250
5272
|
] })
|
|
@@ -5291,8 +5313,8 @@ const DataBindingSelector = ({
|
|
|
5291
5313
|
/* @__PURE__ */ jsx("span", { children: "Add" })
|
|
5292
5314
|
] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
|
|
5293
5315
|
const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
|
|
5294
|
-
async ({ formData:
|
|
5295
|
-
get(
|
|
5316
|
+
async ({ formData: m }, g) => {
|
|
5317
|
+
get(m, g) === void 0 && set(m, g, ""), l({ formData: m }, g);
|
|
5296
5318
|
},
|
|
5297
5319
|
[l, i],
|
|
5298
5320
|
400
|
|
@@ -5333,10 +5355,10 @@ const DataBindingSelector = ({
|
|
|
5333
5355
|
uiSchema: r,
|
|
5334
5356
|
schema: n,
|
|
5335
5357
|
formData: a,
|
|
5336
|
-
onChange: ({ formData:
|
|
5337
|
-
if (!
|
|
5338
|
-
const h = take(
|
|
5339
|
-
u({ formData:
|
|
5358
|
+
onChange: ({ formData: m }, g) => {
|
|
5359
|
+
if (!g || o !== (m == null ? void 0 : m._id)) return;
|
|
5360
|
+
const h = take(g.split("."), 2).join(".").replace("root.", "");
|
|
5361
|
+
u({ formData: m }, h);
|
|
5340
5362
|
}
|
|
5341
5363
|
},
|
|
5342
5364
|
i
|
|
@@ -5348,52 +5370,52 @@ const DataBindingSelector = ({
|
|
|
5348
5370
|
}), a;
|
|
5349
5371
|
};
|
|
5350
5372
|
function BlockSettings() {
|
|
5351
|
-
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),
|
|
5352
|
-
|
|
5373
|
+
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), m = useWrapperBlock(), g = getRegisteredChaiBlock(m == null ? void 0 : m._type), h = formDataWithSelectedLang(m, o, g), f = ({ formData: j }, C, k) => {
|
|
5374
|
+
C && (c == null ? void 0 : c._id) === n._id && a([n._id], { [C]: get(j, C) }, k);
|
|
5353
5375
|
}, x = useCallback(
|
|
5354
|
-
debounce(({ formData:
|
|
5355
|
-
f({ formData:
|
|
5376
|
+
debounce(({ formData: j }, C, k) => {
|
|
5377
|
+
f({ formData: j }, C, k), d(j);
|
|
5356
5378
|
}, 1500),
|
|
5357
5379
|
[n == null ? void 0 : n._id, o]
|
|
5358
|
-
), b = ({ formData:
|
|
5359
|
-
|
|
5360
|
-
}, y = ({ formData:
|
|
5361
|
-
|
|
5362
|
-
}, { schema: S, uiSchema:
|
|
5363
|
-
const
|
|
5364
|
-
if (!
|
|
5380
|
+
), b = ({ formData: j }, C) => {
|
|
5381
|
+
C && (r([n._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
|
|
5382
|
+
}, y = ({ formData: j }, C) => {
|
|
5383
|
+
C && (r([m._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
|
|
5384
|
+
}, { schema: S, uiSchema: v } = useMemo(() => {
|
|
5385
|
+
const j = n == null ? void 0 : n._type;
|
|
5386
|
+
if (!j)
|
|
5365
5387
|
return { schema: {}, uiSchema: {} };
|
|
5366
5388
|
try {
|
|
5367
|
-
const { schema:
|
|
5368
|
-
if (
|
|
5389
|
+
const { schema: C, uiSchema: k } = getBlockFormSchemas(j);
|
|
5390
|
+
if (j === "Repeater") {
|
|
5369
5391
|
const I = get(n, "repeaterItems", "");
|
|
5370
5392
|
startsWith(I, `{{${COLLECTION_PREFIX}`) ? (set(k, "filter", { "ui:widget": "collectionSelect" }), set(k, "sort", { "ui:widget": "collectionSelect" })) : (set(k, "filter", { "ui:widget": "hidden" }), set(k, "sort", { "ui:widget": "hidden" }));
|
|
5371
5393
|
}
|
|
5372
|
-
return { schema:
|
|
5394
|
+
return { schema: C, uiSchema: k };
|
|
5373
5395
|
} catch {
|
|
5374
5396
|
return { schema: {}, uiSchema: {} };
|
|
5375
5397
|
}
|
|
5376
5398
|
}, [n]), { wrapperSchema: B, wrapperUiSchema: _ } = useMemo(() => {
|
|
5377
|
-
if (!
|
|
5399
|
+
if (!m || !(m != null && m._type))
|
|
5378
5400
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5379
|
-
const
|
|
5380
|
-
return { wrapperSchema:
|
|
5381
|
-
}, [
|
|
5401
|
+
const j = m == null ? void 0 : m._type, { schema: C = {}, uiSchema: k = {} } = getBlockFormSchemas(j);
|
|
5402
|
+
return { wrapperSchema: C, wrapperUiSchema: k };
|
|
5403
|
+
}, [m]);
|
|
5382
5404
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5383
|
-
!isEmpty(
|
|
5405
|
+
!isEmpty(m) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5384
5406
|
/* @__PURE__ */ jsxs(
|
|
5385
5407
|
"div",
|
|
5386
5408
|
{
|
|
5387
|
-
onClick: () => u((
|
|
5409
|
+
onClick: () => u((j) => !j),
|
|
5388
5410
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5389
5411
|
children: [
|
|
5390
5412
|
p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
|
|
5391
|
-
startCase(
|
|
5413
|
+
startCase(m._type),
|
|
5392
5414
|
" settings",
|
|
5393
5415
|
" ",
|
|
5394
|
-
|
|
5416
|
+
m._name && /* @__PURE__ */ jsxs("span", { className: "text-[11px] font-light text-slate-400", children: [
|
|
5395
5417
|
"(",
|
|
5396
|
-
|
|
5418
|
+
m._name,
|
|
5397
5419
|
")"
|
|
5398
5420
|
] })
|
|
5399
5421
|
]
|
|
@@ -5402,7 +5424,7 @@ function BlockSettings() {
|
|
|
5402
5424
|
/* @__PURE__ */ jsx("div", { className: p ? "h-auto" : "invisible h-0", children: /* @__PURE__ */ jsx(
|
|
5403
5425
|
JSONForm,
|
|
5404
5426
|
{
|
|
5405
|
-
blockId:
|
|
5427
|
+
blockId: m == null ? void 0 : m._id,
|
|
5406
5428
|
onChange: y,
|
|
5407
5429
|
formData: h,
|
|
5408
5430
|
schema: B,
|
|
@@ -5417,7 +5439,7 @@ function BlockSettings() {
|
|
|
5417
5439
|
onChange: b,
|
|
5418
5440
|
formData: i,
|
|
5419
5441
|
schema: S,
|
|
5420
|
-
uiSchema:
|
|
5442
|
+
uiSchema: v
|
|
5421
5443
|
}
|
|
5422
5444
|
)
|
|
5423
5445
|
] });
|
|
@@ -5428,7 +5450,7 @@ const BlockStylingProps = () => {
|
|
|
5428
5450
|
if (!o) return null;
|
|
5429
5451
|
const c = Object.keys(o).filter(
|
|
5430
5452
|
(x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
|
|
5431
|
-
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes:
|
|
5453
|
+
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes: m = "" } = getSplitChaiClasses(u) || {}, g = m ? m.split(" ").filter((x) => !isEmpty(x)) : [], h = (x) => find(n, (b) => b.prop === x);
|
|
5432
5454
|
return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5433
5455
|
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5434
5456
|
i("Style element"),
|
|
@@ -5470,7 +5492,7 @@ const BlockStylingProps = () => {
|
|
|
5470
5492
|
{
|
|
5471
5493
|
className: "text-xs",
|
|
5472
5494
|
onClick: () => {
|
|
5473
|
-
a(l,
|
|
5495
|
+
a(l, g, !0);
|
|
5474
5496
|
},
|
|
5475
5497
|
children: i("Clear styles")
|
|
5476
5498
|
}
|
|
@@ -5628,52 +5650,52 @@ const BlockStylingProps = () => {
|
|
|
5628
5650
|
},
|
|
5629
5651
|
a
|
|
5630
5652
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5631
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative:
|
|
5653
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: m } = o, [g, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [S, v] = useState(!1), [B, _] = useState(!1);
|
|
5632
5654
|
useEffect(() => {
|
|
5633
|
-
const { value: A, unit:
|
|
5634
|
-
if (
|
|
5655
|
+
const { value: A, unit: w } = getClassValueAndUnit(i);
|
|
5656
|
+
if (w === "") {
|
|
5635
5657
|
l(A), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5636
5658
|
return;
|
|
5637
5659
|
}
|
|
5638
|
-
h(
|
|
5660
|
+
h(w), l(w === "class" || isEmpty(A) ? "" : A);
|
|
5639
5661
|
}, [i, p, u]);
|
|
5640
|
-
const
|
|
5662
|
+
const j = useThrottledCallback((A) => c(A), [c], THROTTLE_TIME), C = useThrottledCallback((A) => c(A, !1), [c], THROTTLE_TIME), k = useCallback(
|
|
5641
5663
|
(A = !1) => {
|
|
5642
|
-
const
|
|
5643
|
-
if (get(
|
|
5664
|
+
const w = getUserInputValues(`${a}`, u);
|
|
5665
|
+
if (get(w, "error", !1)) {
|
|
5644
5666
|
x(!0);
|
|
5645
5667
|
return;
|
|
5646
5668
|
}
|
|
5647
|
-
const E = get(
|
|
5669
|
+
const E = get(w, "unit") !== "" ? get(w, "unit") : g;
|
|
5648
5670
|
if (E === "auto" || E === "none") {
|
|
5649
|
-
|
|
5671
|
+
j(`${d}${E}`);
|
|
5650
5672
|
return;
|
|
5651
5673
|
}
|
|
5652
|
-
if (get(
|
|
5674
|
+
if (get(w, "value") === "")
|
|
5653
5675
|
return;
|
|
5654
|
-
const T = `${get(
|
|
5655
|
-
A ?
|
|
5676
|
+
const T = `${get(w, "value", "").startsWith("-") ? "-" : ""}${d}[${get(w, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
|
|
5677
|
+
A ? C(T) : j(T);
|
|
5656
5678
|
},
|
|
5657
|
-
[
|
|
5679
|
+
[j, C, a, g, d, u]
|
|
5658
5680
|
), I = useCallback(
|
|
5659
5681
|
(A) => {
|
|
5660
|
-
const
|
|
5661
|
-
if (get(
|
|
5682
|
+
const w = getUserInputValues(`${a}`, u);
|
|
5683
|
+
if (get(w, "error", !1)) {
|
|
5662
5684
|
x(!0);
|
|
5663
5685
|
return;
|
|
5664
5686
|
}
|
|
5665
5687
|
if (A === "auto" || A === "none") {
|
|
5666
|
-
|
|
5688
|
+
j(`${d}${A}`);
|
|
5667
5689
|
return;
|
|
5668
5690
|
}
|
|
5669
|
-
if (get(
|
|
5691
|
+
if (get(w, "value") === "")
|
|
5670
5692
|
return;
|
|
5671
|
-
const E = get(
|
|
5672
|
-
|
|
5693
|
+
const E = get(w, "unit") !== "" ? get(w, "unit") : A, T = `${get(w, "value", "").startsWith("-") ? "-" : ""}${d}[${get(w, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
|
|
5694
|
+
j(T);
|
|
5673
5695
|
},
|
|
5674
|
-
[
|
|
5696
|
+
[j, a, d, u]
|
|
5675
5697
|
);
|
|
5676
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children:
|
|
5698
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: g === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5677
5699
|
/* @__PURE__ */ jsx(
|
|
5678
5700
|
"input",
|
|
5679
5701
|
{
|
|
@@ -5688,10 +5710,10 @@ const BlockStylingProps = () => {
|
|
|
5688
5710
|
] })
|
|
5689
5711
|
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
|
|
5690
5712
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
5691
|
-
["none", "auto"].indexOf(
|
|
5713
|
+
["none", "auto"].indexOf(g) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
5692
5714
|
"input",
|
|
5693
5715
|
{
|
|
5694
|
-
readOnly:
|
|
5716
|
+
readOnly: g === "class",
|
|
5695
5717
|
onKeyPress: (A) => {
|
|
5696
5718
|
A.key === "Enter" && k();
|
|
5697
5719
|
},
|
|
@@ -5699,11 +5721,11 @@ const BlockStylingProps = () => {
|
|
|
5699
5721
|
if (A.keyCode !== 38 && A.keyCode !== 40)
|
|
5700
5722
|
return;
|
|
5701
5723
|
A.preventDefault(), _(!0);
|
|
5702
|
-
const
|
|
5703
|
-
let E = isNaN$1(
|
|
5724
|
+
const w = parseInt$1(A.target.value);
|
|
5725
|
+
let E = isNaN$1(w) ? 0 : w;
|
|
5704
5726
|
A.keyCode === 38 && (E += 1), A.keyCode === 40 && (E -= 1);
|
|
5705
|
-
const L = `${E}`, P = `${L.startsWith("-") ? "-" : ""}${d}[${L.replace("-", "")}${
|
|
5706
|
-
|
|
5727
|
+
const L = `${E}`, P = `${L.startsWith("-") ? "-" : ""}${d}[${L.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5728
|
+
C(P);
|
|
5707
5729
|
},
|
|
5708
5730
|
onKeyUp: (A) => {
|
|
5709
5731
|
B && (A.preventDefault(), _(!1));
|
|
@@ -5713,8 +5735,8 @@ const BlockStylingProps = () => {
|
|
|
5713
5735
|
x(!1), l(A.target.value);
|
|
5714
5736
|
},
|
|
5715
5737
|
onClick: (A) => {
|
|
5716
|
-
var
|
|
5717
|
-
(
|
|
5738
|
+
var w;
|
|
5739
|
+
(w = A == null ? void 0 : A.target) == null || w.select(), r(!1);
|
|
5718
5740
|
},
|
|
5719
5741
|
value: S ? b : a,
|
|
5720
5742
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
@@ -5731,7 +5753,7 @@ const BlockStylingProps = () => {
|
|
|
5731
5753
|
onClick: () => r(!n),
|
|
5732
5754
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
5733
5755
|
children: [
|
|
5734
|
-
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
5756
|
+
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: g }),
|
|
5735
5757
|
u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
|
|
5736
5758
|
]
|
|
5737
5759
|
}
|
|
@@ -5740,7 +5762,7 @@ const BlockStylingProps = () => {
|
|
|
5740
5762
|
UnitSelection,
|
|
5741
5763
|
{
|
|
5742
5764
|
units: u,
|
|
5743
|
-
current:
|
|
5765
|
+
current: g,
|
|
5744
5766
|
onSelect: (A) => {
|
|
5745
5767
|
r(!1), h(A), I(A);
|
|
5746
5768
|
}
|
|
@@ -5748,26 +5770,26 @@ const BlockStylingProps = () => {
|
|
|
5748
5770
|
) })
|
|
5749
5771
|
] })
|
|
5750
5772
|
] }),
|
|
5751
|
-
["none", "auto"].indexOf(
|
|
5773
|
+
["none", "auto"].indexOf(g) !== -1 || S ? null : /* @__PURE__ */ jsx(
|
|
5752
5774
|
DragStyleButton,
|
|
5753
5775
|
{
|
|
5754
|
-
onDragStart: () =>
|
|
5776
|
+
onDragStart: () => v(!0),
|
|
5755
5777
|
onDragEnd: (A) => {
|
|
5756
|
-
if (y(() => ""),
|
|
5778
|
+
if (y(() => ""), v(!1), isEmpty(A))
|
|
5757
5779
|
return;
|
|
5758
|
-
const
|
|
5759
|
-
|
|
5780
|
+
const w = `${A}`, L = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5781
|
+
j(L);
|
|
5760
5782
|
},
|
|
5761
5783
|
onDrag: (A) => {
|
|
5762
5784
|
if (isEmpty(A))
|
|
5763
5785
|
return;
|
|
5764
5786
|
y(A);
|
|
5765
|
-
const
|
|
5766
|
-
|
|
5787
|
+
const w = `${A}`, L = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5788
|
+
C(L);
|
|
5767
5789
|
},
|
|
5768
5790
|
currentValue: a,
|
|
5769
|
-
unit:
|
|
5770
|
-
negative:
|
|
5791
|
+
unit: g,
|
|
5792
|
+
negative: m,
|
|
5771
5793
|
cssProperty: p
|
|
5772
5794
|
}
|
|
5773
5795
|
)
|
|
@@ -5826,7 +5848,7 @@ const COLOR_PROP = {
|
|
|
5826
5848
|
ringColor: "ring",
|
|
5827
5849
|
ringOffsetColor: "ring-offset"
|
|
5828
5850
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5829
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"),
|
|
5851
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), m = get(u, "1", ""), g = get(u, "2", ""), h = useCallback(
|
|
5830
5852
|
// eslint-disable-next-line no-shadow
|
|
5831
5853
|
(b) => {
|
|
5832
5854
|
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
|
|
@@ -5834,16 +5856,16 @@ const COLOR_PROP = {
|
|
|
5834
5856
|
[c, p]
|
|
5835
5857
|
);
|
|
5836
5858
|
useEffect(() => {
|
|
5837
|
-
if (["current", "inherit", "transparent", "black", "white"].includes(
|
|
5859
|
+
if (["current", "inherit", "transparent", "black", "white"].includes(m))
|
|
5838
5860
|
return c([]);
|
|
5839
5861
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5840
|
-
}, [
|
|
5862
|
+
}, [m]);
|
|
5841
5863
|
const f = useCallback(
|
|
5842
5864
|
// eslint-disable-next-line no-shadow
|
|
5843
5865
|
(b) => {
|
|
5844
|
-
p({ color:
|
|
5866
|
+
p({ color: m, shade: b });
|
|
5845
5867
|
},
|
|
5846
|
-
[
|
|
5868
|
+
[m]
|
|
5847
5869
|
);
|
|
5848
5870
|
useEffect(() => {
|
|
5849
5871
|
p({ color: "", shade: "" });
|
|
@@ -5858,7 +5880,7 @@ const COLOR_PROP = {
|
|
|
5858
5880
|
{
|
|
5859
5881
|
disabled: !l,
|
|
5860
5882
|
rounded: !0,
|
|
5861
|
-
selected:
|
|
5883
|
+
selected: m,
|
|
5862
5884
|
onChange: h,
|
|
5863
5885
|
options: [
|
|
5864
5886
|
"current",
|
|
@@ -5892,7 +5914,7 @@ const COLOR_PROP = {
|
|
|
5892
5914
|
]
|
|
5893
5915
|
}
|
|
5894
5916
|
) }),
|
|
5895
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected:
|
|
5917
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: g, disabled: !m || !l, onChange: f, options: i }) })
|
|
5896
5918
|
] });
|
|
5897
5919
|
}, EDITOR_ICONS = {
|
|
5898
5920
|
"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" }) }),
|
|
@@ -6226,22 +6248,22 @@ const COLOR_PROP = {
|
|
|
6226
6248
|
"2xl": "1536px"
|
|
6227
6249
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6228
6250
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6229
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [,
|
|
6230
|
-
(
|
|
6231
|
-
const I = { dark: p, mq:
|
|
6251
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, m] = useScreenSizeWidth(), g = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(g, "fullCls", ""), [g]), y = useCallback(
|
|
6252
|
+
(C, k = !0) => {
|
|
6253
|
+
const I = { dark: p, mq: m, mod: u, cls: C, property: l, fullCls: "" };
|
|
6232
6254
|
(p || u !== "") && (I.mq = "xs");
|
|
6233
6255
|
const A = generateFullClsName(I);
|
|
6234
6256
|
h(x, [A], k);
|
|
6235
6257
|
},
|
|
6236
|
-
[x, p,
|
|
6258
|
+
[x, p, m, u, l, h]
|
|
6237
6259
|
), S = useCallback(() => {
|
|
6238
6260
|
f(x, [b], !0);
|
|
6239
|
-
}, [x, b, f]),
|
|
6261
|
+
}, [x, b, f]), v = useMemo(() => canChangeClass(g, m), [g, m]);
|
|
6240
6262
|
useEffect(() => {
|
|
6241
|
-
i(
|
|
6242
|
-
}, [
|
|
6263
|
+
i(v, g);
|
|
6264
|
+
}, [v, i, g]);
|
|
6243
6265
|
const [, , B] = useScreenSizeWidth(), _ = useCallback(
|
|
6244
|
-
(
|
|
6266
|
+
(C) => {
|
|
6245
6267
|
B({
|
|
6246
6268
|
xs: 400,
|
|
6247
6269
|
sm: 640,
|
|
@@ -6249,18 +6271,18 @@ const COLOR_PROP = {
|
|
|
6249
6271
|
lg: 1024,
|
|
6250
6272
|
xl: 1420,
|
|
6251
6273
|
"2xl": 1920
|
|
6252
|
-
}[
|
|
6274
|
+
}[C]);
|
|
6253
6275
|
},
|
|
6254
6276
|
[B]
|
|
6255
|
-
),
|
|
6256
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6257
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${
|
|
6277
|
+
), j = get(g, "dark", null) === p && get(g, "mod", null) === u && get(g, "mq", null) === m;
|
|
6278
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: v, canReset: g && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6279
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${g && !j ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6258
6280
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6259
6281
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6260
6282
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
6261
6283
|
AdvanceChoices,
|
|
6262
6284
|
{
|
|
6263
|
-
currentClass: get(
|
|
6285
|
+
currentClass: get(g, "cls", ""),
|
|
6264
6286
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6265
6287
|
units: c || [],
|
|
6266
6288
|
onChange: y,
|
|
@@ -6273,7 +6295,7 @@ const COLOR_PROP = {
|
|
|
6273
6295
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
|
|
6274
6296
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6275
6297
|
] }),
|
|
6276
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children:
|
|
6298
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => S(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : v && g ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6277
6299
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6278
6300
|
"button",
|
|
6279
6301
|
{
|
|
@@ -6285,19 +6307,19 @@ const COLOR_PROP = {
|
|
|
6285
6307
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
6286
6308
|
"Current style is set at ",
|
|
6287
6309
|
/* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
|
|
6288
|
-
getBreakpoint(get(
|
|
6289
|
-
p && !
|
|
6310
|
+
getBreakpoint(get(g, "mq")),
|
|
6311
|
+
p && !g.dark ? "(Light mode)" : ""
|
|
6290
6312
|
] }),
|
|
6291
6313
|
/* @__PURE__ */ jsx("br", {}),
|
|
6292
6314
|
/* @__PURE__ */ jsxs(
|
|
6293
6315
|
"button",
|
|
6294
6316
|
{
|
|
6295
6317
|
type: "button",
|
|
6296
|
-
onClick: () => _(get(
|
|
6318
|
+
onClick: () => _(get(g, "mq")),
|
|
6297
6319
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6298
6320
|
children: [
|
|
6299
6321
|
"Switch to ",
|
|
6300
|
-
get(
|
|
6322
|
+
get(g, "mq").toUpperCase()
|
|
6301
6323
|
]
|
|
6302
6324
|
}
|
|
6303
6325
|
)
|
|
@@ -6314,7 +6336,7 @@ const COLOR_PROP = {
|
|
|
6314
6336
|
units: i = basicUnits,
|
|
6315
6337
|
negative: c = !1
|
|
6316
6338
|
}) => {
|
|
6317
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key),
|
|
6339
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), m = useSelectedBlockCurrentClasses(), g = useCallback((h) => map(m, "property").includes(h), [m]);
|
|
6318
6340
|
return /* @__PURE__ */ jsxs(
|
|
6319
6341
|
"div",
|
|
6320
6342
|
{
|
|
@@ -6331,7 +6353,7 @@ const COLOR_PROP = {
|
|
|
6331
6353
|
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6332
6354
|
children: [
|
|
6333
6355
|
React__default.createElement("div", {
|
|
6334
|
-
className:
|
|
6356
|
+
className: g(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6335
6357
|
}),
|
|
6336
6358
|
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6337
6359
|
]
|
|
@@ -6462,7 +6484,7 @@ const COLOR_PROP = {
|
|
|
6462
6484
|
icon: p,
|
|
6463
6485
|
onClick: u
|
|
6464
6486
|
}) => {
|
|
6465
|
-
const { t:
|
|
6487
|
+
const { t: m } = useTranslation();
|
|
6466
6488
|
return r ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
|
|
6467
6489
|
/* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6468
6490
|
Button,
|
|
@@ -6475,8 +6497,8 @@ const COLOR_PROP = {
|
|
|
6475
6497
|
}
|
|
6476
6498
|
) }),
|
|
6477
6499
|
/* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
6478
|
-
/* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children:
|
|
6479
|
-
o && /* @__PURE__ */ jsx("p", { className: "text-xs", children:
|
|
6500
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: m(a) }),
|
|
6501
|
+
o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: m(l) })
|
|
6480
6502
|
] }) }) })
|
|
6481
6503
|
] }) : /* @__PURE__ */ jsx(
|
|
6482
6504
|
Button,
|
|
@@ -6493,8 +6515,8 @@ const COLOR_PROP = {
|
|
|
6493
6515
|
canvas: n = !1,
|
|
6494
6516
|
tooltip: r = !0
|
|
6495
6517
|
}) => {
|
|
6496
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d,
|
|
6497
|
-
u.includes(y) ? u.length > 2 &&
|
|
6518
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, m = p, { t: g } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
|
|
6519
|
+
u.includes(y) ? u.length > 2 && m(u.filter((S) => S !== y)) : m((S) => [...S, y]);
|
|
6498
6520
|
}, x = (y) => {
|
|
6499
6521
|
n || l(y), c(y);
|
|
6500
6522
|
}, b = getBreakpointValue(n ? i : a).toLowerCase();
|
|
@@ -6526,7 +6548,7 @@ const COLOR_PROP = {
|
|
|
6526
6548
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
6527
6549
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
|
|
6528
6550
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
6529
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { children:
|
|
6551
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
|
|
6530
6552
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
6531
6553
|
map(h, (y) => /* @__PURE__ */ jsx(
|
|
6532
6554
|
DropdownMenuCheckboxItem,
|
|
@@ -6534,7 +6556,7 @@ const COLOR_PROP = {
|
|
|
6534
6556
|
disabled: y.breakpoint === "xs",
|
|
6535
6557
|
onCheckedChange: () => f(toUpper(y.breakpoint)),
|
|
6536
6558
|
checked: includes(u, toUpper(y.breakpoint)),
|
|
6537
|
-
children:
|
|
6559
|
+
children: g(y.title)
|
|
6538
6560
|
},
|
|
6539
6561
|
y.breakpoint
|
|
6540
6562
|
))
|
|
@@ -6611,14 +6633,14 @@ function Countdown() {
|
|
|
6611
6633
|
] });
|
|
6612
6634
|
}
|
|
6613
6635
|
const AskAIStyles = ({ blockId: o }) => {
|
|
6614
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u,
|
|
6636
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, m] = useState();
|
|
6615
6637
|
useEffect(() => {
|
|
6616
6638
|
var h;
|
|
6617
6639
|
(h = d.current) == null || h.focus();
|
|
6618
6640
|
}, []);
|
|
6619
|
-
const
|
|
6641
|
+
const g = (h) => {
|
|
6620
6642
|
const { usage: f } = h || {};
|
|
6621
|
-
!l && f &&
|
|
6643
|
+
!l && f && m(f), p.current = setTimeout(() => m(void 0), 1e4), l || c("");
|
|
6622
6644
|
};
|
|
6623
6645
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6624
6646
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -6632,7 +6654,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6632
6654
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
6633
6655
|
rows: 4,
|
|
6634
6656
|
onKeyDown: (h) => {
|
|
6635
|
-
h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current),
|
|
6657
|
+
h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), m(void 0), r("styles", o, i, g));
|
|
6636
6658
|
}
|
|
6637
6659
|
}
|
|
6638
6660
|
),
|
|
@@ -6642,7 +6664,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6642
6664
|
{
|
|
6643
6665
|
disabled: i.trim().length < 5 || a,
|
|
6644
6666
|
onClick: () => {
|
|
6645
|
-
p.current && clearTimeout(p.current),
|
|
6667
|
+
p.current && clearTimeout(p.current), m(void 0), r("styles", o, i, g);
|
|
6646
6668
|
},
|
|
6647
6669
|
variant: "default",
|
|
6648
6670
|
className: "w-fit",
|
|
@@ -6674,10 +6696,10 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6674
6696
|
}, AiIcon = ({ className: o = "h-full w-full" }) => /* @__PURE__ */ jsx("svg", { className: o, viewBox: "0 0 256 256", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "m198.39 128.986-52.16-19.216-19.216-52.16a16 16 0 0 0-30.028 0L77.77 109.77l-52.16 19.216a16 16 0 0 0 0 30.028l52.16 19.216 19.216 52.16a16 16 0 0 0 30.028 0l19.216-52.16 52.16-19.216a16 16 0 0 0 0-30.028m-57.69 34.23a15.97 15.97 0 0 0-9.483 9.483l-19.22 52.152-19.214-52.15a15.97 15.97 0 0 0-9.482-9.484l-52.152-19.22 52.15-19.214a15.97 15.97 0 0 0 9.484-9.482l19.22-52.152 19.214 52.15a15.97 15.97 0 0 0 9.482 9.484l52.152 19.22ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8" }) });
|
|
6675
6697
|
function ManualClasses() {
|
|
6676
6698
|
var L;
|
|
6677
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(),
|
|
6699
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), m = useRemoveClassesFromBlocks(), [g] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (L = first(d)) == null ? void 0 : L.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), S = y.split(" ").filter((T) => !isEmpty(T)), v = () => {
|
|
6678
6700
|
const T = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6679
|
-
u(
|
|
6680
|
-
}, [B, _] = useState([]),
|
|
6701
|
+
u(g, T, !0), x("");
|
|
6702
|
+
}, [B, _] = useState([]), j = ({ value: T }) => {
|
|
6681
6703
|
const P = T.trim().toLowerCase(), R = P.match(/.+:/g);
|
|
6682
6704
|
let D = [];
|
|
6683
6705
|
if (R && R.length > 0) {
|
|
@@ -6689,7 +6711,7 @@ function ManualClasses() {
|
|
|
6689
6711
|
} else
|
|
6690
6712
|
D = i.search(P);
|
|
6691
6713
|
return _(map(D, "item"));
|
|
6692
|
-
},
|
|
6714
|
+
}, C = () => {
|
|
6693
6715
|
_([]);
|
|
6694
6716
|
}, k = (T) => T.name, I = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), A = useMemo(
|
|
6695
6717
|
() => ({
|
|
@@ -6706,16 +6728,16 @@ function ManualClasses() {
|
|
|
6706
6728
|
}, 0);
|
|
6707
6729
|
},
|
|
6708
6730
|
onKeyDown: (T) => {
|
|
6709
|
-
T.key === "Enter" && f.trim() !== "" &&
|
|
6731
|
+
T.key === "Enter" && f.trim() !== "" && v();
|
|
6710
6732
|
},
|
|
6711
6733
|
onChange: (T, { newValue: P }) => x(P),
|
|
6712
6734
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6713
6735
|
}),
|
|
6714
6736
|
[f, c, o]
|
|
6715
|
-
),
|
|
6737
|
+
), w = (T) => {
|
|
6716
6738
|
debugger;
|
|
6717
6739
|
const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6718
|
-
g
|
|
6740
|
+
m(g, [T]), u(g, P, !0), r(""), l(-1);
|
|
6719
6741
|
}, E = () => {
|
|
6720
6742
|
if (navigator.clipboard === void 0) {
|
|
6721
6743
|
toast.error(c("Clipboard not supported"));
|
|
@@ -6745,8 +6767,8 @@ function ManualClasses() {
|
|
|
6745
6767
|
Autosuggest,
|
|
6746
6768
|
{
|
|
6747
6769
|
suggestions: B,
|
|
6748
|
-
onSuggestionsFetchRequested:
|
|
6749
|
-
onSuggestionsClearRequested:
|
|
6770
|
+
onSuggestionsFetchRequested: j,
|
|
6771
|
+
onSuggestionsClearRequested: C,
|
|
6750
6772
|
getSuggestionValue: k,
|
|
6751
6773
|
renderSuggestion: I,
|
|
6752
6774
|
inputProps: A,
|
|
@@ -6765,7 +6787,7 @@ function ManualClasses() {
|
|
|
6765
6787
|
{
|
|
6766
6788
|
variant: "outline",
|
|
6767
6789
|
className: "h-6 border-border",
|
|
6768
|
-
onClick:
|
|
6790
|
+
onClick: v,
|
|
6769
6791
|
disabled: f.trim() === "",
|
|
6770
6792
|
size: "sm",
|
|
6771
6793
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
@@ -6780,10 +6802,10 @@ function ManualClasses() {
|
|
|
6780
6802
|
value: n,
|
|
6781
6803
|
onChange: (R) => r(R.target.value),
|
|
6782
6804
|
onBlur: () => {
|
|
6783
|
-
|
|
6805
|
+
w(T);
|
|
6784
6806
|
},
|
|
6785
6807
|
onKeyDown: (R) => {
|
|
6786
|
-
R.key === "Enter" &&
|
|
6808
|
+
R.key === "Enter" && w(T);
|
|
6787
6809
|
},
|
|
6788
6810
|
onFocus: (R) => {
|
|
6789
6811
|
setTimeout(() => {
|
|
@@ -6797,7 +6819,7 @@ function ManualClasses() {
|
|
|
6797
6819
|
"button",
|
|
6798
6820
|
{
|
|
6799
6821
|
onDoubleClick: () => {
|
|
6800
|
-
x(T), g
|
|
6822
|
+
x(T), m(g, [T]), setTimeout(() => {
|
|
6801
6823
|
o.current && o.current.focus();
|
|
6802
6824
|
}, 10);
|
|
6803
6825
|
},
|
|
@@ -6807,7 +6829,7 @@ function ManualClasses() {
|
|
|
6807
6829
|
/* @__PURE__ */ jsx(
|
|
6808
6830
|
Cross2Icon,
|
|
6809
6831
|
{
|
|
6810
|
-
onClick: () => g
|
|
6832
|
+
onClick: () => m(g, [T], !0),
|
|
6811
6833
|
className: "hidden h-max w-3.5 cursor-pointer rounded bg-gray-100 p-0.5 text-red-500 hover:bg-gray-50 group-hover:block"
|
|
6812
6834
|
}
|
|
6813
6835
|
),
|
|
@@ -6950,13 +6972,13 @@ function BlockStyling() {
|
|
|
6950
6972
|
cssProperty: ""
|
|
6951
6973
|
}), d = useThrottledCallback(
|
|
6952
6974
|
(u) => {
|
|
6953
|
-
const
|
|
6975
|
+
const m = !get(i, "negative", !1), g = get(i, "cssProperty", "");
|
|
6954
6976
|
let h = parseFloat(i.dragStartValue);
|
|
6955
6977
|
h = isNaN(h) ? 0 : h;
|
|
6956
6978
|
let f = MAPPER[i.dragUnit];
|
|
6957
|
-
(startsWith(
|
|
6979
|
+
(startsWith(g, "scale") || g === "opacity") && (f = 10);
|
|
6958
6980
|
let b = (i.dragStartY - u.pageY) / f + h;
|
|
6959
|
-
|
|
6981
|
+
m && b < 0 && (b = 0), g === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6960
6982
|
},
|
|
6961
6983
|
[i],
|
|
6962
6984
|
50
|
|
@@ -6997,7 +7019,7 @@ const CoreBlock = ({
|
|
|
6997
7019
|
parentId: r,
|
|
6998
7020
|
position: a
|
|
6999
7021
|
}) => {
|
|
7000
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [,
|
|
7022
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, m] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = () => {
|
|
7001
7023
|
if (has(o, "blocks")) {
|
|
7002
7024
|
const b = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
7003
7025
|
u(syncBlocksWithDefaults(b), r || null, a);
|
|
@@ -7014,7 +7036,7 @@ const CoreBlock = ({
|
|
|
7014
7036
|
type: "button",
|
|
7015
7037
|
onDragStart: (b) => {
|
|
7016
7038
|
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
7017
|
-
|
|
7039
|
+
m([]), g();
|
|
7018
7040
|
}, 200);
|
|
7019
7041
|
},
|
|
7020
7042
|
draggable: f ? "true" : "false",
|
|
@@ -7050,8 +7072,8 @@ const registerChaiPreImportHTMLHook = (o) => {
|
|
|
7050
7072
|
}, getPreImportHTML = async (o) => await PRE_IMPORT_HTML_HOOK(o), ImportHTML = ({ parentId: o, position: n }) => {
|
|
7051
7073
|
const { t: r } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), [c, d] = useState(!1), p = async () => {
|
|
7052
7074
|
d(!0);
|
|
7053
|
-
const u = await getPreImportHTML(a),
|
|
7054
|
-
i([...
|
|
7075
|
+
const u = await getPreImportHTML(a), m = getBlocksFromHTML(u);
|
|
7076
|
+
i([...m], o, n), l(""), d(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7055
7077
|
};
|
|
7056
7078
|
return /* @__PURE__ */ jsxs(Card, { className: "border-border/0 p-0 shadow-none", children: [
|
|
7057
7079
|
/* @__PURE__ */ jsx(CardHeader, { className: "p-3", children: /* @__PURE__ */ jsx(CardDescription, { children: r("Use HTML snippets from Tailwind CSS component libraries") }) }),
|
|
@@ -7086,8 +7108,8 @@ const registerChaiPreImportHTMLHook = (o) => {
|
|
|
7086
7108
|
height: i = ""
|
|
7087
7109
|
}) => {
|
|
7088
7110
|
const [c, d] = useState(o), p = (u) => {
|
|
7089
|
-
const
|
|
7090
|
-
d(
|
|
7111
|
+
const m = u.target.value;
|
|
7112
|
+
d(m), n(m);
|
|
7091
7113
|
};
|
|
7092
7114
|
return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
|
|
7093
7115
|
"select",
|
|
@@ -7136,12 +7158,12 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7136
7158
|
parentId: r = void 0,
|
|
7137
7159
|
position: a = -1
|
|
7138
7160
|
}) => {
|
|
7139
|
-
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight:
|
|
7140
|
-
const B = has(
|
|
7141
|
-
return
|
|
7161
|
+
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), g = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), b = (v) => {
|
|
7162
|
+
const B = has(v, "styles_attrs.data-page-section");
|
|
7163
|
+
return v._type === "Box" && B;
|
|
7142
7164
|
}, y = useCallback(
|
|
7143
|
-
async (
|
|
7144
|
-
if (
|
|
7165
|
+
async (v) => {
|
|
7166
|
+
if (v.stopPropagation(), has(o, "component")) {
|
|
7145
7167
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7146
7168
|
return;
|
|
7147
7169
|
}
|
|
@@ -7158,20 +7180,20 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7158
7180
|
onClick: l ? () => {
|
|
7159
7181
|
} : y,
|
|
7160
7182
|
draggable: f ? "true" : "false",
|
|
7161
|
-
onDragStart: async (
|
|
7183
|
+
onDragStart: async (v) => {
|
|
7162
7184
|
const B = await c({ library: n, block: o });
|
|
7163
7185
|
let _ = r;
|
|
7164
7186
|
if (b(first(B)) && (_ = null), !isEmpty(B)) {
|
|
7165
|
-
const
|
|
7166
|
-
if (
|
|
7167
|
-
const
|
|
7168
|
-
|
|
7169
|
-
|
|
7187
|
+
const j = { blocks: B, uiLibrary: !0, parent: _ };
|
|
7188
|
+
if (v.dataTransfer.setData("text/plain", JSON.stringify(j)), o.preview) {
|
|
7189
|
+
const C = new Image();
|
|
7190
|
+
C.src = o.preview, C.onload = () => {
|
|
7191
|
+
v.dataTransfer.setDragImage(C, 0, 0);
|
|
7170
7192
|
};
|
|
7171
7193
|
} else
|
|
7172
|
-
|
|
7173
|
-
x(
|
|
7174
|
-
u([]),
|
|
7194
|
+
v.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7195
|
+
x(j), setTimeout(() => {
|
|
7196
|
+
u([]), m(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7175
7197
|
}, 200);
|
|
7176
7198
|
}
|
|
7177
7199
|
},
|
|
@@ -7183,17 +7205,17 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7183
7205
|
/* @__PURE__ */ jsx(ReloadIcon, { className: "animate-spin h-4 w-4 text-white" }),
|
|
7184
7206
|
/* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
7185
7207
|
] }),
|
|
7186
|
-
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
7187
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children:
|
|
7208
|
+
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: g }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
|
|
7209
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: g }),
|
|
7188
7210
|
h && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: h })
|
|
7189
7211
|
] })
|
|
7190
7212
|
]
|
|
7191
7213
|
}
|
|
7192
7214
|
) }),
|
|
7193
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children:
|
|
7215
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: g }) }) })
|
|
7194
7216
|
] });
|
|
7195
7217
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7196
|
-
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((
|
|
7218
|
+
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((w) => w.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, m] = useState(""), [g, h] = useState([]), f = useRef(null);
|
|
7197
7219
|
useEffect(() => {
|
|
7198
7220
|
c && c.length > 0 && (f.current = new Fuse(c, {
|
|
7199
7221
|
keys: ["name", "label", "description", "group"],
|
|
@@ -7205,10 +7227,10 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7205
7227
|
h([]);
|
|
7206
7228
|
return;
|
|
7207
7229
|
}
|
|
7208
|
-
const
|
|
7209
|
-
h(
|
|
7230
|
+
const w = f.current.search(u).map((E) => E.item);
|
|
7231
|
+
h(w);
|
|
7210
7232
|
}, [u]);
|
|
7211
|
-
const x = u.trim() && !isEmpty(
|
|
7233
|
+
const x = u.trim() && !isEmpty(g) ? g : c, b = groupBy(x, "group"), [y, S] = useState(null);
|
|
7212
7234
|
useEffect(() => {
|
|
7213
7235
|
if (isEmpty(keys(b))) {
|
|
7214
7236
|
S(null);
|
|
@@ -7219,21 +7241,21 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7219
7241
|
return;
|
|
7220
7242
|
}
|
|
7221
7243
|
}, [b, y]);
|
|
7222
|
-
const
|
|
7244
|
+
const v = get(b, y, []), B = useRef(null), { t: _ } = useTranslation(), j = (w) => {
|
|
7223
7245
|
B.current && (clearTimeout(B.current), B.current = null), B.current = setTimeout(() => {
|
|
7224
|
-
B.current && S(
|
|
7246
|
+
B.current && S(w);
|
|
7225
7247
|
}, 400);
|
|
7226
|
-
},
|
|
7248
|
+
}, C = () => {
|
|
7227
7249
|
i != null && i.id && p(i.id);
|
|
7228
7250
|
}, k = () => {
|
|
7229
|
-
|
|
7251
|
+
m("");
|
|
7230
7252
|
};
|
|
7231
7253
|
if (d)
|
|
7232
7254
|
return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
|
|
7233
7255
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7234
7256
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7235
7257
|
] });
|
|
7236
|
-
const I = filter(
|
|
7258
|
+
const I = filter(v, (w, E) => E % 2 === 0), A = filter(v, (w, E) => E % 2 === 1);
|
|
7237
7259
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7238
7260
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7239
7261
|
/* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
@@ -7242,7 +7264,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7242
7264
|
{
|
|
7243
7265
|
placeholder: _("Search blocks..."),
|
|
7244
7266
|
value: u,
|
|
7245
|
-
onChange: (
|
|
7267
|
+
onChange: (w) => m(w.target.value),
|
|
7246
7268
|
className: "w-full pl-8 pr-8"
|
|
7247
7269
|
}
|
|
7248
7270
|
),
|
|
@@ -7263,14 +7285,14 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7263
7285
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7264
7286
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(b) ? /* @__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: [
|
|
7265
7287
|
/* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
|
|
7266
|
-
/* @__PURE__ */ jsxs(Button, { onClick:
|
|
7288
|
+
/* @__PURE__ */ jsxs(Button, { onClick: C, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7267
7289
|
/* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4" }),
|
|
7268
7290
|
_("Retry")
|
|
7269
7291
|
] })
|
|
7270
|
-
] }) }) : map(b, (
|
|
7292
|
+
] }) }) : map(b, (w, E) => /* @__PURE__ */ jsxs(
|
|
7271
7293
|
"div",
|
|
7272
7294
|
{
|
|
7273
|
-
onMouseEnter: () =>
|
|
7295
|
+
onMouseEnter: () => j(E),
|
|
7274
7296
|
onMouseLeave: () => clearTimeout(B.current),
|
|
7275
7297
|
role: "button",
|
|
7276
7298
|
onClick: () => S(E),
|
|
@@ -7293,23 +7315,23 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7293
7315
|
onMouseEnter: () => B.current ? clearTimeout(B.current) : null,
|
|
7294
7316
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7295
7317
|
children: [
|
|
7296
|
-
isEmpty(
|
|
7297
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: I.map((
|
|
7318
|
+
isEmpty(v) && !isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
|
|
7319
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: I.map((w, E) => /* @__PURE__ */ jsx(
|
|
7298
7320
|
BlockCard,
|
|
7299
7321
|
{
|
|
7300
7322
|
parentId: o,
|
|
7301
7323
|
position: n,
|
|
7302
|
-
block:
|
|
7324
|
+
block: w,
|
|
7303
7325
|
library: i
|
|
7304
7326
|
},
|
|
7305
7327
|
`block-${E}`
|
|
7306
7328
|
)) }),
|
|
7307
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((
|
|
7329
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((w, E) => /* @__PURE__ */ jsx(
|
|
7308
7330
|
BlockCard,
|
|
7309
7331
|
{
|
|
7310
7332
|
parentId: o,
|
|
7311
7333
|
position: n,
|
|
7312
|
-
block:
|
|
7334
|
+
block: w,
|
|
7313
7335
|
library: i
|
|
7314
7336
|
},
|
|
7315
7337
|
`block-second-${E}`
|
|
@@ -7337,7 +7359,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7337
7359
|
position: n,
|
|
7338
7360
|
gridCols: r = "grid-cols-2"
|
|
7339
7361
|
}) => {
|
|
7340
|
-
const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u,
|
|
7362
|
+
const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, m] = useAtom$1(hasInitializedPartialBlocksAtom);
|
|
7341
7363
|
useEffect(() => {
|
|
7342
7364
|
if (!u || Object.keys(d.blocks).length === 0)
|
|
7343
7365
|
if (c)
|
|
@@ -7346,17 +7368,17 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7346
7368
|
groups: [],
|
|
7347
7369
|
isLoading: !1,
|
|
7348
7370
|
error: c
|
|
7349
|
-
}),
|
|
7371
|
+
}), m(!0);
|
|
7350
7372
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7351
7373
|
const h = Object.entries(a).map(([x, b]) => {
|
|
7352
|
-
const y = b, S = y.type || "partial",
|
|
7374
|
+
const y = b, S = y.type || "partial", v = formatReadableName(S);
|
|
7353
7375
|
return {
|
|
7354
7376
|
type: "PartialBlock",
|
|
7355
7377
|
// Set the type to PartialBlock
|
|
7356
7378
|
label: formatReadableName(y.name || x),
|
|
7357
7379
|
description: y.description || "",
|
|
7358
7380
|
icon: FrameIcon,
|
|
7359
|
-
group:
|
|
7381
|
+
group: v,
|
|
7360
7382
|
// Use formatted type as group
|
|
7361
7383
|
category: "partial",
|
|
7362
7384
|
partialBlockId: x,
|
|
@@ -7369,31 +7391,31 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7369
7391
|
groups: f,
|
|
7370
7392
|
isLoading: !1,
|
|
7371
7393
|
error: null
|
|
7372
|
-
}),
|
|
7394
|
+
}), m(!0);
|
|
7373
7395
|
} else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7374
7396
|
blocks: [],
|
|
7375
7397
|
groups: [],
|
|
7376
7398
|
isLoading: !1,
|
|
7377
7399
|
error: "No partial blocks available"
|
|
7378
|
-
}),
|
|
7400
|
+
}), m(!0));
|
|
7379
7401
|
}, [
|
|
7380
7402
|
l,
|
|
7381
7403
|
a,
|
|
7382
7404
|
u,
|
|
7383
|
-
|
|
7405
|
+
m,
|
|
7384
7406
|
p,
|
|
7385
7407
|
d.blocks,
|
|
7386
7408
|
c
|
|
7387
7409
|
]);
|
|
7388
|
-
const
|
|
7389
|
-
p((h) => ({ ...h, isLoading: !0, error: null })),
|
|
7410
|
+
const g = () => {
|
|
7411
|
+
p((h) => ({ ...h, isLoading: !0, error: null })), m(!1), i();
|
|
7390
7412
|
};
|
|
7391
7413
|
return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
|
|
7392
7414
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
7393
7415
|
/* @__PURE__ */ jsx(
|
|
7394
7416
|
"button",
|
|
7395
7417
|
{
|
|
7396
|
-
onClick:
|
|
7418
|
+
onClick: g,
|
|
7397
7419
|
className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
|
|
7398
7420
|
children: "Refresh"
|
|
7399
7421
|
}
|
|
@@ -7412,43 +7434,43 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7412
7434
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
|
|
7413
7435
|
}, 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" }) => {
|
|
7414
7436
|
var A;
|
|
7415
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [
|
|
7437
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [m] = useAtom$1(addBlockTabAtom), g = (A = find(c, (w) => w._id === r)) == null ? void 0 : A._type, [h, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
|
|
7416
7438
|
useEffect(() => {
|
|
7417
|
-
const
|
|
7439
|
+
const w = setTimeout(() => {
|
|
7418
7440
|
var E;
|
|
7419
7441
|
(E = u.current) == null || E.focus();
|
|
7420
7442
|
}, 0);
|
|
7421
|
-
return () => clearTimeout(
|
|
7422
|
-
}, [
|
|
7443
|
+
return () => clearTimeout(w);
|
|
7444
|
+
}, [m]), useEffect(() => {
|
|
7423
7445
|
d && (f("all"), b(null));
|
|
7424
|
-
}, [d]), useEffect(() => (y.current = debounce((
|
|
7425
|
-
f(
|
|
7446
|
+
}, [d]), useEffect(() => (y.current = debounce((w) => {
|
|
7447
|
+
f(w);
|
|
7426
7448
|
}, 500), () => {
|
|
7427
7449
|
y.current && y.current.cancel();
|
|
7428
7450
|
}), []);
|
|
7429
|
-
const S = useCallback((
|
|
7430
|
-
b(
|
|
7431
|
-
}, []),
|
|
7451
|
+
const S = useCallback((w) => {
|
|
7452
|
+
b(w), y.current && y.current(w);
|
|
7453
|
+
}, []), v = useCallback(() => {
|
|
7432
7454
|
b(null), y.current && y.current.cancel();
|
|
7433
|
-
}, []), B = useCallback((
|
|
7434
|
-
y.current && y.current.cancel(), f(
|
|
7455
|
+
}, []), B = useCallback((w) => {
|
|
7456
|
+
y.current && y.current.cancel(), f(w), b(null);
|
|
7435
7457
|
}, []), _ = useMemo(
|
|
7436
7458
|
() => d ? values(n).filter(
|
|
7437
|
-
(
|
|
7459
|
+
(w) => {
|
|
7438
7460
|
var E, L;
|
|
7439
|
-
return (((E =
|
|
7461
|
+
return (((E = w.label) == null ? void 0 : E.toLowerCase()) + " " + ((L = w.type) == null ? void 0 : L.toLowerCase())).includes(d.toLowerCase());
|
|
7440
7462
|
}
|
|
7441
7463
|
) : n,
|
|
7442
7464
|
[n, d]
|
|
7443
|
-
),
|
|
7465
|
+
), j = useMemo(
|
|
7444
7466
|
() => d ? o.filter(
|
|
7445
|
-
(
|
|
7446
|
-
) : o.filter((
|
|
7467
|
+
(w) => reject(filter(values(_), { group: w }), { hidden: !0 }).length > 0
|
|
7468
|
+
) : o.filter((w) => reject(filter(values(n), { group: w }), { hidden: !0 }).length > 0),
|
|
7447
7469
|
[n, _, o, d]
|
|
7448
|
-
),
|
|
7449
|
-
() => sortBy(
|
|
7450
|
-
[
|
|
7451
|
-
), k = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), I = useMemo(() => h === "all" ?
|
|
7470
|
+
), C = useMemo(
|
|
7471
|
+
() => sortBy(j, (w) => CORE_GROUPS.indexOf(w) === -1 ? 99 : CORE_GROUPS.indexOf(w)),
|
|
7472
|
+
[j]
|
|
7473
|
+
), k = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), I = useMemo(() => h === "all" ? C : [h], [C, h]);
|
|
7452
7474
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7453
7475
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7454
7476
|
Input$1,
|
|
@@ -7458,43 +7480,43 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7458
7480
|
placeholder: i("Search blocks..."),
|
|
7459
7481
|
value: d,
|
|
7460
7482
|
className: "-ml-2",
|
|
7461
|
-
onChange: (
|
|
7483
|
+
onChange: (w) => p(w.target.value)
|
|
7462
7484
|
}
|
|
7463
7485
|
) }),
|
|
7464
7486
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7465
|
-
|
|
7487
|
+
C.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: [
|
|
7466
7488
|
/* @__PURE__ */ jsx(
|
|
7467
7489
|
"button",
|
|
7468
7490
|
{
|
|
7469
7491
|
onClick: () => B("all"),
|
|
7470
7492
|
onMouseEnter: () => S("all"),
|
|
7471
|
-
onMouseLeave:
|
|
7493
|
+
onMouseLeave: v,
|
|
7472
7494
|
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7473
7495
|
children: i("All")
|
|
7474
7496
|
},
|
|
7475
7497
|
"sidebar-all"
|
|
7476
7498
|
),
|
|
7477
|
-
|
|
7499
|
+
C.map((w) => /* @__PURE__ */ jsx(
|
|
7478
7500
|
"button",
|
|
7479
7501
|
{
|
|
7480
|
-
onClick: () => B(
|
|
7481
|
-
onMouseEnter: () => S(
|
|
7482
|
-
onMouseLeave:
|
|
7483
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h ===
|
|
7484
|
-
children: capitalize(i(
|
|
7502
|
+
onClick: () => B(w),
|
|
7503
|
+
onMouseEnter: () => S(w),
|
|
7504
|
+
onMouseLeave: v,
|
|
7505
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === w || x === w ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7506
|
+
children: capitalize(i(w.toLowerCase()))
|
|
7485
7507
|
},
|
|
7486
|
-
`sidebar-${
|
|
7508
|
+
`sidebar-${w}`
|
|
7487
7509
|
))
|
|
7488
7510
|
] }) }) }),
|
|
7489
|
-
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children:
|
|
7511
|
+
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: j.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
7490
7512
|
i("No blocks found matching"),
|
|
7491
7513
|
' "',
|
|
7492
7514
|
d,
|
|
7493
7515
|
'"'
|
|
7494
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((
|
|
7495
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7516
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((w) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7517
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(w.toLowerCase())) }),
|
|
7496
7518
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7497
|
-
h === "all" ? filter(values(k), { group:
|
|
7519
|
+
h === "all" ? filter(values(k), { group: w }) : values(k),
|
|
7498
7520
|
{ hidden: !0 }
|
|
7499
7521
|
).map((E) => /* @__PURE__ */ jsx(
|
|
7500
7522
|
CoreBlock,
|
|
@@ -7502,11 +7524,11 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7502
7524
|
parentId: r,
|
|
7503
7525
|
position: a,
|
|
7504
7526
|
block: E,
|
|
7505
|
-
disabled: !canAcceptChildBlock(
|
|
7527
|
+
disabled: !canAcceptChildBlock(g, E.type) || !canBeNestedInside(g, E.type)
|
|
7506
7528
|
},
|
|
7507
7529
|
E.type
|
|
7508
7530
|
)) })
|
|
7509
|
-
] },
|
|
7531
|
+
] }, w)) }) }) })
|
|
7510
7532
|
] })
|
|
7511
7533
|
] });
|
|
7512
7534
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
@@ -7515,13 +7537,13 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7515
7537
|
parentId: r = void 0,
|
|
7516
7538
|
position: a = -1
|
|
7517
7539
|
}) => {
|
|
7518
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(),
|
|
7540
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), m = Object.keys(u || {}).length > 0, { hasPermission: g } = usePermissions();
|
|
7519
7541
|
useEffect(() => {
|
|
7520
|
-
i === "partials" && !
|
|
7521
|
-
}, [i,
|
|
7542
|
+
i === "partials" && !m && c("library");
|
|
7543
|
+
}, [i, m, c]);
|
|
7522
7544
|
const h = useCallback(() => {
|
|
7523
7545
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7524
|
-
}, []), f = useChaiAddBlockTabs(), x = p &&
|
|
7546
|
+
}, []), f = useChaiAddBlockTabs(), x = p && g(PERMISSIONS.IMPORT_HTML), y = useChaiLibraries().length > 0;
|
|
7525
7547
|
return useEffect(() => {
|
|
7526
7548
|
i === "library" && !y && c("core");
|
|
7527
7549
|
}, [i, y, c]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7541,13 +7563,13 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7541
7563
|
/* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
|
|
7542
7564
|
y && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7543
7565
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7544
|
-
|
|
7566
|
+
m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7545
7567
|
x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7546
7568
|
map(f, (S) => /* @__PURE__ */ jsx(TabsTrigger, { value: S.id, children: React__default.createElement(S.tab) }, `tab-add-block-${S.id}`))
|
|
7547
7569
|
] }),
|
|
7548
7570
|
/* @__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 }) }) }) }),
|
|
7549
7571
|
y && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7550
|
-
|
|
7572
|
+
m && /* @__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 }) }) }) }),
|
|
7551
7573
|
x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7552
7574
|
map(f, (S) => /* @__PURE__ */ jsx(TabsContent, { value: S.id, children: React__default.createElement(S.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${S.id}`))
|
|
7553
7575
|
]
|
|
@@ -7671,10 +7693,10 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7671
7693
|
}, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
|
|
7672
7694
|
const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useCallback(() => {
|
|
7673
7695
|
const p = n.map((u) => {
|
|
7674
|
-
const
|
|
7696
|
+
const m = o.find((g) => g._id === u);
|
|
7675
7697
|
return {
|
|
7676
7698
|
id: u,
|
|
7677
|
-
data:
|
|
7699
|
+
data: m
|
|
7678
7700
|
};
|
|
7679
7701
|
});
|
|
7680
7702
|
l(p.map((u) => u.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
|
|
@@ -7859,23 +7881,23 @@ const Input = ({ node: o }) => {
|
|
|
7859
7881
|
var D;
|
|
7860
7882
|
const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
|
|
7861
7883
|
let d = null;
|
|
7862
|
-
const p = o.children.length > 0, { highlightBlock: u, clearHighlight:
|
|
7863
|
-
N.stopPropagation(),
|
|
7884
|
+
const p = o.children.length > 0, { highlightBlock: u, clearHighlight: m } = useBlockHighlight(), { id: g, data: h, isSelected: f, willReceiveDrop: x, isDragging: b, isEditing: y, handleClick: S } = o, v = get(h, "_show", !0), B = (N) => {
|
|
7885
|
+
N.stopPropagation(), v && o.toggle();
|
|
7864
7886
|
}, _ = (N) => {
|
|
7865
7887
|
N.isInternal && (d = N.isOpen, N.isOpen && N.close());
|
|
7866
|
-
},
|
|
7888
|
+
}, j = (N) => {
|
|
7867
7889
|
N.isInternal && d !== null && (d ? N.open() : N.close(), d = null);
|
|
7868
|
-
}, [
|
|
7890
|
+
}, [C, k] = useAtom$1(currentAddSelection), I = () => {
|
|
7869
7891
|
var N;
|
|
7870
7892
|
A(), o.parent.isSelected || k((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
|
|
7871
7893
|
}, A = () => {
|
|
7872
7894
|
k(null);
|
|
7873
|
-
},
|
|
7874
|
-
A(), N.stopPropagation(), !o.isOpen &&
|
|
7895
|
+
}, w = (N) => {
|
|
7896
|
+
A(), N.stopPropagation(), !o.isOpen && v && o.toggle(), S(N);
|
|
7875
7897
|
};
|
|
7876
7898
|
useEffect(() => {
|
|
7877
7899
|
const N = setTimeout(() => {
|
|
7878
|
-
x && !o.isOpen && !b &&
|
|
7900
|
+
x && !o.isOpen && !b && v && o.toggle();
|
|
7879
7901
|
}, 500);
|
|
7880
7902
|
return () => clearTimeout(N);
|
|
7881
7903
|
}, [x, o, b]);
|
|
@@ -7889,7 +7911,7 @@ const Input = ({ node: o }) => {
|
|
|
7889
7911
|
const O = get(o, "parent.id");
|
|
7890
7912
|
O !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: O, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
|
|
7891
7913
|
};
|
|
7892
|
-
if (
|
|
7914
|
+
if (g === ROOT_TEMP_KEY)
|
|
7893
7915
|
return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7894
7916
|
/* @__PURE__ */ jsx("br", {}),
|
|
7895
7917
|
c(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
|
|
@@ -7911,22 +7933,22 @@ const Input = ({ node: o }) => {
|
|
|
7911
7933
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7912
7934
|
"div",
|
|
7913
7935
|
{
|
|
7914
|
-
onMouseEnter: () => u(
|
|
7915
|
-
onMouseLeave: () =>
|
|
7916
|
-
onClick:
|
|
7936
|
+
onMouseEnter: () => u(g),
|
|
7937
|
+
onMouseLeave: () => m(),
|
|
7938
|
+
onClick: w,
|
|
7917
7939
|
style: n,
|
|
7918
|
-
"data-node-id":
|
|
7940
|
+
"data-node-id": g,
|
|
7919
7941
|
ref: r,
|
|
7920
7942
|
onDragStart: () => _(o),
|
|
7921
|
-
onDragEnd: () =>
|
|
7943
|
+
onDragEnd: () => j(o),
|
|
7922
7944
|
onDragOver: (N) => {
|
|
7923
|
-
N.preventDefault(), E(
|
|
7945
|
+
N.preventDefault(), E(g, "yes");
|
|
7924
7946
|
},
|
|
7925
7947
|
onDragLeave: (N) => {
|
|
7926
|
-
N.preventDefault(), E(
|
|
7948
|
+
N.preventDefault(), E(g, "no");
|
|
7927
7949
|
},
|
|
7928
7950
|
onDrop: (N) => {
|
|
7929
|
-
N.preventDefault(), E(
|
|
7951
|
+
N.preventDefault(), E(g, "no");
|
|
7930
7952
|
},
|
|
7931
7953
|
children: [
|
|
7932
7954
|
c(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((D = o == null ? void 0 : o.parent) == null ? void 0 : D.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
@@ -7948,9 +7970,9 @@ const Input = ({ node: o }) => {
|
|
|
7948
7970
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",
|
|
7949
7971
|
f ? "bg-primary/20" : "hover:bg-primary/10",
|
|
7950
7972
|
x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
|
|
7951
|
-
(o == null ? void 0 : o.id) ===
|
|
7973
|
+
(o == null ? void 0 : o.id) === C ? "bg-primary/10" : "",
|
|
7952
7974
|
b && "opacity-20",
|
|
7953
|
-
|
|
7975
|
+
v ? "" : "line-through opacity-50",
|
|
7954
7976
|
P && f && "bg-primary/20 text-primary"
|
|
7955
7977
|
),
|
|
7956
7978
|
children: [
|
|
@@ -7989,11 +8011,11 @@ const Input = ({ node: o }) => {
|
|
|
7989
8011
|
)
|
|
7990
8012
|
] }),
|
|
7991
8013
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-px group-hover:visible", children: [
|
|
7992
|
-
canAddChildBlock(h == null ? void 0 : h._type) &&
|
|
8014
|
+
canAddChildBlock(h == null ? void 0 : h._type) && v && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7993
8015
|
/* @__PURE__ */ jsx(
|
|
7994
8016
|
TooltipTrigger,
|
|
7995
8017
|
{
|
|
7996
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
8018
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: g }),
|
|
7997
8019
|
className: "cursor-pointer rounded bg-transparent p-px hover:bg-primary/10",
|
|
7998
8020
|
asChild: !0,
|
|
7999
8021
|
children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4" })
|
|
@@ -8006,16 +8028,16 @@ const Input = ({ node: o }) => {
|
|
|
8006
8028
|
TooltipTrigger,
|
|
8007
8029
|
{
|
|
8008
8030
|
onClick: (N) => {
|
|
8009
|
-
N.stopPropagation(), l([
|
|
8031
|
+
N.stopPropagation(), l([g], { _show: !v }), o.isOpen && o.toggle();
|
|
8010
8032
|
},
|
|
8011
8033
|
className: "cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",
|
|
8012
8034
|
asChild: !0,
|
|
8013
|
-
children:
|
|
8035
|
+
children: v ? /* @__PURE__ */ jsx(EyeClosedIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-4 w-4" })
|
|
8014
8036
|
}
|
|
8015
8037
|
),
|
|
8016
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(
|
|
8038
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(v ? "Hide the block from page" : "Show the block on page") })
|
|
8017
8039
|
] }),
|
|
8018
|
-
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id:
|
|
8040
|
+
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: g, children: /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded bg-transparent p-px hover:bg-primary/10", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "h-3 w-3" }) }) })
|
|
8019
8041
|
] })
|
|
8020
8042
|
]
|
|
8021
8043
|
}
|
|
@@ -8409,7 +8431,7 @@ const Input = ({ node: o }) => {
|
|
|
8409
8431
|
"popover-foreground": ["#3d3436", "#f2e9e4"]
|
|
8410
8432
|
}
|
|
8411
8433
|
}, LazyCssImportModal = lazy(
|
|
8412
|
-
() => import("./css-import-modal-
|
|
8434
|
+
() => import("./css-import-modal-DK2j6oGY.js").then((o) => ({ default: o.CssImportModal }))
|
|
8413
8435
|
), PREV_THEME_KEY = "chai-builder-previous-theme", DEFAULT_THEME_PRESET = [
|
|
8414
8436
|
{ shadcn_default: defaultShadcnPreset },
|
|
8415
8437
|
{ twitter_theme: twitter },
|
|
@@ -8433,86 +8455,86 @@ const Input = ({ node: o }) => {
|
|
|
8433
8455
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8434
8456
|
const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
|
|
8435
8457
|
if (d) {
|
|
8436
|
-
const
|
|
8437
|
-
DEFAULT_THEME_PRESET.forEach((
|
|
8438
|
-
const k = Object.keys(
|
|
8439
|
-
|
|
8458
|
+
const j = d.map((C) => Object.keys(C)[0]);
|
|
8459
|
+
DEFAULT_THEME_PRESET.forEach((C) => {
|
|
8460
|
+
const k = Object.keys(C)[0];
|
|
8461
|
+
j.includes(k) || d.push(C);
|
|
8440
8462
|
});
|
|
8441
8463
|
}
|
|
8442
|
-
const [
|
|
8443
|
-
(
|
|
8444
|
-
const
|
|
8445
|
-
setPreviousTheme(
|
|
8464
|
+
const [m, g] = useTheme(), h = useThemeOptions(), { t: f } = useTranslation(), x = React.useCallback(
|
|
8465
|
+
(j) => {
|
|
8466
|
+
const C = { ...m };
|
|
8467
|
+
setPreviousTheme(C), g(j), toast.success("Theme updated", {
|
|
8446
8468
|
action: {
|
|
8447
8469
|
label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8448
8470
|
/* @__PURE__ */ jsx(ResetIcon, { className: "h-4 w-4" }),
|
|
8449
8471
|
" Undo"
|
|
8450
8472
|
] }),
|
|
8451
8473
|
onClick: () => {
|
|
8452
|
-
|
|
8474
|
+
g(C), clearPreviousTheme(), toast.dismiss();
|
|
8453
8475
|
}
|
|
8454
8476
|
},
|
|
8455
8477
|
closeButton: !0,
|
|
8456
8478
|
duration: 15e3
|
|
8457
8479
|
});
|
|
8458
8480
|
},
|
|
8459
|
-
[
|
|
8481
|
+
[m, g]
|
|
8460
8482
|
), b = () => {
|
|
8461
|
-
const
|
|
8462
|
-
if (
|
|
8463
|
-
const
|
|
8464
|
-
|
|
8483
|
+
const j = d.find((C) => Object.keys(C)[0] === a);
|
|
8484
|
+
if (j) {
|
|
8485
|
+
const C = Object.values(j)[0];
|
|
8486
|
+
C && typeof C == "object" && "fontFamily" in C && "borderRadius" in C && "colors" in C ? (x(C), l("")) : console.error("Invalid preset structure:", C);
|
|
8465
8487
|
} else
|
|
8466
8488
|
console.error("Preset not found:", a);
|
|
8467
|
-
}, y = (
|
|
8468
|
-
x(
|
|
8489
|
+
}, y = (j) => {
|
|
8490
|
+
x(j), l("");
|
|
8469
8491
|
}, S = useDebouncedCallback(
|
|
8470
|
-
(
|
|
8471
|
-
|
|
8472
|
-
...
|
|
8492
|
+
(j, C) => {
|
|
8493
|
+
g(() => ({
|
|
8494
|
+
...m,
|
|
8473
8495
|
fontFamily: {
|
|
8474
|
-
...
|
|
8475
|
-
[
|
|
8496
|
+
...m.fontFamily,
|
|
8497
|
+
[j.replace(/font-/g, "")]: C
|
|
8476
8498
|
}
|
|
8477
8499
|
}));
|
|
8478
8500
|
},
|
|
8479
|
-
[
|
|
8501
|
+
[m],
|
|
8480
8502
|
200
|
|
8481
|
-
),
|
|
8482
|
-
(
|
|
8483
|
-
|
|
8484
|
-
...
|
|
8485
|
-
borderRadius: `${
|
|
8503
|
+
), v = React.useCallback(
|
|
8504
|
+
(j) => {
|
|
8505
|
+
g(() => ({
|
|
8506
|
+
...m,
|
|
8507
|
+
borderRadius: `${j}px`
|
|
8486
8508
|
}));
|
|
8487
8509
|
},
|
|
8488
|
-
[
|
|
8510
|
+
[m]
|
|
8489
8511
|
), B = useDebouncedCallback(
|
|
8490
|
-
(
|
|
8491
|
-
|
|
8492
|
-
const k = get(
|
|
8493
|
-
return n ? set(k, 1,
|
|
8494
|
-
...
|
|
8512
|
+
(j, C) => {
|
|
8513
|
+
g(() => {
|
|
8514
|
+
const k = get(m, `colors.${j}`);
|
|
8515
|
+
return n ? set(k, 1, C) : set(k, 0, C), {
|
|
8516
|
+
...m,
|
|
8495
8517
|
colors: {
|
|
8496
|
-
...
|
|
8497
|
-
[
|
|
8518
|
+
...m.colors,
|
|
8519
|
+
[j]: k
|
|
8498
8520
|
}
|
|
8499
8521
|
};
|
|
8500
8522
|
});
|
|
8501
8523
|
},
|
|
8502
|
-
[
|
|
8524
|
+
[m],
|
|
8503
8525
|
200
|
|
8504
|
-
), _ = (
|
|
8505
|
-
const k = get(
|
|
8526
|
+
), _ = (j) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(j.items).map(([C]) => {
|
|
8527
|
+
const k = get(m, `colors.${C}.${n ? 1 : 0}`);
|
|
8506
8528
|
return k ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8507
8529
|
/* @__PURE__ */ jsx(
|
|
8508
8530
|
ColorPickerInput,
|
|
8509
8531
|
{
|
|
8510
8532
|
value: k,
|
|
8511
|
-
onChange: (I) => B(
|
|
8533
|
+
onChange: (I) => B(C, I)
|
|
8512
8534
|
}
|
|
8513
8535
|
),
|
|
8514
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children:
|
|
8515
|
-
] },
|
|
8536
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: C.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((I) => I.charAt(0).toUpperCase() + I.slice(1)).join(" ") + (!C.toLowerCase().includes("foreground") && !C.toLowerCase().includes("border") && !C.toLowerCase().includes("input") && !C.toLowerCase().includes("ring") && !C.toLowerCase().includes("background") ? " Background" : "") })
|
|
8537
|
+
] }, C) : null;
|
|
8516
8538
|
}) });
|
|
8517
8539
|
return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8518
8540
|
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
@@ -8527,9 +8549,9 @@ const Input = ({ node: o }) => {
|
|
|
8527
8549
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
|
|
8528
8550
|
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
|
|
8529
8551
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
|
|
8530
|
-
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((
|
|
8531
|
-
const
|
|
8532
|
-
return /* @__PURE__ */ jsx(SelectItem, { value:
|
|
8552
|
+
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((j) => {
|
|
8553
|
+
const C = Object.keys(j)[0], k = C.replaceAll("_", " ");
|
|
8554
|
+
return /* @__PURE__ */ jsx(SelectItem, { value: C, children: capitalize(k) }, C);
|
|
8533
8555
|
}) })
|
|
8534
8556
|
] }) }),
|
|
8535
8557
|
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: b, children: f("Apply") }) })
|
|
@@ -8541,14 +8563,14 @@ const Input = ({ node: o }) => {
|
|
|
8541
8563
|
/* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 text-gray-600" }),
|
|
8542
8564
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
|
|
8543
8565
|
] }),
|
|
8544
|
-
(h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([
|
|
8566
|
+
(h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([j, C]) => /* @__PURE__ */ jsx(
|
|
8545
8567
|
FontSelector,
|
|
8546
8568
|
{
|
|
8547
|
-
label:
|
|
8548
|
-
value:
|
|
8549
|
-
onChange: (k) => S(
|
|
8569
|
+
label: j,
|
|
8570
|
+
value: m.fontFamily[j.replace(/font-/g, "")] || C[Object.keys(C)[0]],
|
|
8571
|
+
onChange: (k) => S(j, k)
|
|
8550
8572
|
},
|
|
8551
|
-
|
|
8573
|
+
j
|
|
8552
8574
|
)) }),
|
|
8553
8575
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
8554
8576
|
(h == null ? void 0 : h.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
@@ -8557,9 +8579,9 @@ const Input = ({ node: o }) => {
|
|
|
8557
8579
|
/* @__PURE__ */ jsx(CornerTopRightIcon, { className: "h-3 w-3 text-gray-600" }),
|
|
8558
8580
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Border Radius" })
|
|
8559
8581
|
] }),
|
|
8560
|
-
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children:
|
|
8582
|
+
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: m.borderRadius })
|
|
8561
8583
|
] }),
|
|
8562
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value:
|
|
8584
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: m.borderRadius, onChange: v }) })
|
|
8563
8585
|
] }),
|
|
8564
8586
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
8565
8587
|
(h == null ? void 0 : h.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
@@ -8574,7 +8596,7 @@ const Input = ({ node: o }) => {
|
|
|
8574
8596
|
Switch,
|
|
8575
8597
|
{
|
|
8576
8598
|
checked: n,
|
|
8577
|
-
onCheckedChange: (
|
|
8599
|
+
onCheckedChange: (j) => r(j),
|
|
8578
8600
|
"aria-label": "Toggle dark mode",
|
|
8579
8601
|
className: "mx-1"
|
|
8580
8602
|
}
|
|
@@ -8582,7 +8604,7 @@ const Input = ({ node: o }) => {
|
|
|
8582
8604
|
/* @__PURE__ */ jsx(MoonIcon, { className: "h-4 w-4" })
|
|
8583
8605
|
] }) })
|
|
8584
8606
|
] }),
|
|
8585
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((
|
|
8607
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((j) => _(j)) })
|
|
8586
8608
|
] }),
|
|
8587
8609
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && /* @__PURE__ */ jsx(
|
|
8588
8610
|
LazyCssImportModal,
|
|
@@ -9096,7 +9118,7 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9096
9118
|
lang: get(LANGUAGES, a, a)
|
|
9097
9119
|
})
|
|
9098
9120
|
}), /* @__PURE__ */ jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: c.map(
|
|
9099
|
-
({ name: d, icon: p, subMenus: u, prompt:
|
|
9121
|
+
({ name: d, icon: p, subMenus: u, prompt: m }) => u ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
9100
9122
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
9101
9123
|
"li",
|
|
9102
9124
|
{
|
|
@@ -9112,7 +9134,7 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9112
9134
|
] }) : /* @__PURE__ */ jsxs(
|
|
9113
9135
|
"li",
|
|
9114
9136
|
{
|
|
9115
|
-
onClick: () => o(
|
|
9137
|
+
onClick: () => o(m),
|
|
9116
9138
|
className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-xs hover:bg-primary/10 hover:text-primary dark:hover:bg-gray-800",
|
|
9117
9139
|
children: [
|
|
9118
9140
|
/* @__PURE__ */ jsx(p, { className: "h-3.5 w-3.5" }),
|
|
@@ -9126,10 +9148,10 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9126
9148
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
9127
9149
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), u = useSelectedBlock();
|
|
9128
9150
|
useEffect(() => {
|
|
9129
|
-
var
|
|
9130
|
-
(
|
|
9151
|
+
var g;
|
|
9152
|
+
(g = d.current) == null || g.focus();
|
|
9131
9153
|
}, []);
|
|
9132
|
-
const
|
|
9154
|
+
const m = () => {
|
|
9133
9155
|
l || c("");
|
|
9134
9156
|
};
|
|
9135
9157
|
return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -9144,8 +9166,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9144
9166
|
/* @__PURE__ */ jsx("div", { className: "rounded border p-2 text-sm", children: /* @__PURE__ */ jsx(
|
|
9145
9167
|
QuickPrompts,
|
|
9146
9168
|
{
|
|
9147
|
-
onClick: (
|
|
9148
|
-
p.current && clearTimeout(p.current), r("content", o,
|
|
9169
|
+
onClick: (g) => {
|
|
9170
|
+
p.current && clearTimeout(p.current), r("content", o, g, m);
|
|
9149
9171
|
}
|
|
9150
9172
|
}
|
|
9151
9173
|
) }),
|
|
@@ -9157,12 +9179,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9157
9179
|
{
|
|
9158
9180
|
ref: d,
|
|
9159
9181
|
value: i,
|
|
9160
|
-
onChange: (
|
|
9182
|
+
onChange: (g) => c(g.target.value),
|
|
9161
9183
|
placeholder: n("Ask AI to edit content"),
|
|
9162
9184
|
className: "w-full resize-none border-none p-0 text-xs shadow-none outline-none",
|
|
9163
9185
|
rows: 3,
|
|
9164
|
-
onKeyDown: (
|
|
9165
|
-
|
|
9186
|
+
onKeyDown: (g) => {
|
|
9187
|
+
g.key === "Enter" && (g.preventDefault(), p.current && clearTimeout(p.current), r("content", o, i, m));
|
|
9166
9188
|
}
|
|
9167
9189
|
}
|
|
9168
9190
|
),
|
|
@@ -9172,7 +9194,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9172
9194
|
Button,
|
|
9173
9195
|
{
|
|
9174
9196
|
onClick: () => {
|
|
9175
|
-
p.current && clearTimeout(p.current), r("content", o, i,
|
|
9197
|
+
p.current && clearTimeout(p.current), r("content", o, i, m);
|
|
9176
9198
|
},
|
|
9177
9199
|
variant: "default",
|
|
9178
9200
|
className: "h-7 w-7",
|
|
@@ -9223,140 +9245,7 @@ const UndoRedo = () => {
|
|
|
9223
9245
|
/* @__PURE__ */ jsx(Button, { disabled: !o(), size: "sm", onClick: r, className: "rounded-full", variant: "ghost", children: /* @__PURE__ */ jsx(ResetIcon, {}) }),
|
|
9224
9246
|
/* @__PURE__ */ jsx(Button, { disabled: !n(), onClick: a, size: "sm", className: "rounded-full", variant: "ghost", children: /* @__PURE__ */ jsx(ResetIcon, { className: "rotate-180 scale-y-[-1] transform" }) })
|
|
9225
9247
|
] });
|
|
9226
|
-
}
|
|
9227
|
-
function AIChatPanel() {
|
|
9228
|
-
const [o, n] = useState([]), [r, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null), g = useRef(null);
|
|
9229
|
-
useEffect(() => {
|
|
9230
|
-
var y;
|
|
9231
|
-
(y = u.current) == null || y.scrollIntoView({ behavior: "smooth" });
|
|
9232
|
-
}, [o]), useEffect(() => {
|
|
9233
|
-
g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
|
|
9234
|
-
}, [r]);
|
|
9235
|
-
const m = async () => {
|
|
9236
|
-
if (!r.trim() && !c) return;
|
|
9237
|
-
const y = {
|
|
9238
|
-
id: Date.now().toString(),
|
|
9239
|
-
role: "user",
|
|
9240
|
-
content: r,
|
|
9241
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
9242
|
-
};
|
|
9243
|
-
n((S) => [...S, y]), a(""), i(!0), setTimeout(() => {
|
|
9244
|
-
const S = {
|
|
9245
|
-
id: (Date.now() + 1).toString(),
|
|
9246
|
-
role: "assistant",
|
|
9247
|
-
content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
|
|
9248
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
9249
|
-
};
|
|
9250
|
-
n((C) => [...C, S]), i(!1), d(null);
|
|
9251
|
-
}, 1500);
|
|
9252
|
-
}, h = (y) => {
|
|
9253
|
-
y.key === "Enter" && !y.shiftKey && (y.preventDefault(), m());
|
|
9254
|
-
}, f = (y) => {
|
|
9255
|
-
var C;
|
|
9256
|
-
const S = (C = y.target.files) == null ? void 0 : C[0];
|
|
9257
|
-
if (S) {
|
|
9258
|
-
const B = new FileReader();
|
|
9259
|
-
B.onload = (_) => {
|
|
9260
|
-
var w;
|
|
9261
|
-
d((w = _.target) == null ? void 0 : w.result);
|
|
9262
|
-
}, B.readAsDataURL(S);
|
|
9263
|
-
}
|
|
9264
|
-
}, x = () => {
|
|
9265
|
-
var y;
|
|
9266
|
-
(y = p.current) == null || y.click();
|
|
9267
|
-
}, b = () => {
|
|
9268
|
-
d(null), p.current && (p.current.value = "");
|
|
9269
|
-
};
|
|
9270
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
|
|
9271
|
-
/* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 p-3", children: o.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-10 flex h-full flex-col items-center justify-center p-4 text-center text-muted-foreground", children: [
|
|
9272
|
-
/* @__PURE__ */ jsx(AiIcon, { className: "mb-2 h-8 w-8 text-primary/50" }),
|
|
9273
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm", children: "Ask me anything to get started" })
|
|
9274
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
9275
|
-
o.map((y) => /* @__PURE__ */ jsxs(
|
|
9276
|
-
"div",
|
|
9277
|
-
{
|
|
9278
|
-
className: cn$2(
|
|
9279
|
-
"flex max-w-full gap-2",
|
|
9280
|
-
y.role === "assistant" ? "items-start" : "items-start justify-end"
|
|
9281
|
-
),
|
|
9282
|
-
children: [
|
|
9283
|
-
y.role === "assistant" && /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary/10", children: /* @__PURE__ */ jsx(AiIcon, { className: "h-3 w-3 text-primary" }) }),
|
|
9284
|
-
/* @__PURE__ */ jsx(
|
|
9285
|
-
"div",
|
|
9286
|
-
{
|
|
9287
|
-
className: cn$2(
|
|
9288
|
-
"rounded-lg px-3 py-2 text-sm",
|
|
9289
|
-
y.role === "assistant" ? "bg-muted text-foreground" : "bg-primary text-primary-foreground"
|
|
9290
|
-
),
|
|
9291
|
-
children: y.content
|
|
9292
|
-
}
|
|
9293
|
-
),
|
|
9294
|
-
y.role === "user" && /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-primary-foreground", children: "You" }) })
|
|
9295
|
-
]
|
|
9296
|
-
},
|
|
9297
|
-
y.id
|
|
9298
|
-
)),
|
|
9299
|
-
l && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
9300
|
-
/* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary/10", children: /* @__PURE__ */ jsx(AiIcon, { className: "h-3 w-3 text-primary" }) }),
|
|
9301
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-lg bg-muted px-3 py-2", children: /* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4 animate-spin text-muted-foreground" }) })
|
|
9302
|
-
] }),
|
|
9303
|
-
/* @__PURE__ */ jsx("div", { ref: u })
|
|
9304
|
-
] }) }),
|
|
9305
|
-
c && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "relative h-20 w-20 overflow-hidden rounded-md", children: [
|
|
9306
|
-
/* @__PURE__ */ jsx("img", { src: c || "/placeholder.svg", alt: "Attachment", className: "h-full w-full object-cover" }),
|
|
9307
|
-
/* @__PURE__ */ jsx(
|
|
9308
|
-
Button,
|
|
9309
|
-
{
|
|
9310
|
-
size: "icon",
|
|
9311
|
-
variant: "destructive",
|
|
9312
|
-
className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
|
|
9313
|
-
onClick: b,
|
|
9314
|
-
children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" })
|
|
9315
|
-
}
|
|
9316
|
-
)
|
|
9317
|
-
] }) }),
|
|
9318
|
-
/* @__PURE__ */ jsx("div", { className: "mt-auto p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
|
|
9319
|
-
/* @__PURE__ */ jsxs("div", { className: "relative flex-1", children: [
|
|
9320
|
-
/* @__PURE__ */ jsx(
|
|
9321
|
-
Textarea,
|
|
9322
|
-
{
|
|
9323
|
-
ref: g,
|
|
9324
|
-
value: r,
|
|
9325
|
-
onChange: (y) => a(y.target.value),
|
|
9326
|
-
onKeyDown: h,
|
|
9327
|
-
placeholder: "Ask something...",
|
|
9328
|
-
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9329
|
-
}
|
|
9330
|
-
),
|
|
9331
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
|
|
9332
|
-
/* @__PURE__ */ jsx(
|
|
9333
|
-
Button,
|
|
9334
|
-
{
|
|
9335
|
-
size: "icon",
|
|
9336
|
-
variant: "ghost",
|
|
9337
|
-
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9338
|
-
onClick: x,
|
|
9339
|
-
children: /* @__PURE__ */ jsx(ImageIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
9340
|
-
}
|
|
9341
|
-
)
|
|
9342
|
-
] }),
|
|
9343
|
-
/* @__PURE__ */ jsxs(
|
|
9344
|
-
Button,
|
|
9345
|
-
{
|
|
9346
|
-
size: "sm",
|
|
9347
|
-
className: "h-10 px-3",
|
|
9348
|
-
onClick: m,
|
|
9349
|
-
disabled: l || !r.trim() && !c,
|
|
9350
|
-
children: [
|
|
9351
|
-
/* @__PURE__ */ jsx(PaperPlaneIcon, { className: "mr-1 h-4 w-4" }),
|
|
9352
|
-
"Send"
|
|
9353
|
-
]
|
|
9354
|
-
}
|
|
9355
|
-
)
|
|
9356
|
-
] }) })
|
|
9357
|
-
] });
|
|
9358
|
-
}
|
|
9359
|
-
const ClearCanvas = () => {
|
|
9248
|
+
}, ClearCanvas = () => {
|
|
9360
9249
|
const { t: o } = useTranslation(), { setNewBlocks: n } = useBlocksStoreUndoableActions(), [, r] = useSelectedBlockIds(), [, a] = useSelectedStylingBlocks(), l = useCallback(() => {
|
|
9361
9250
|
n([]), r([]), a([]);
|
|
9362
9251
|
}, [n]);
|
|
@@ -9431,7 +9320,7 @@ const ClearCanvas = () => {
|
|
|
9431
9320
|
preloadedAttributes: n = [],
|
|
9432
9321
|
onAttributesChange: r
|
|
9433
9322
|
}) {
|
|
9434
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u,
|
|
9323
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, m] = useState(null), [g, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
|
|
9435
9324
|
useEffect(() => {
|
|
9436
9325
|
l(n);
|
|
9437
9326
|
}, [n]);
|
|
@@ -9444,11 +9333,11 @@ const ClearCanvas = () => {
|
|
|
9444
9333
|
const k = [...a, { key: i, value: d }];
|
|
9445
9334
|
r(k), l(a), c(""), p(""), h("");
|
|
9446
9335
|
}
|
|
9447
|
-
},
|
|
9448
|
-
const I = a.filter((A,
|
|
9336
|
+
}, v = (k) => {
|
|
9337
|
+
const I = a.filter((A, w) => w !== k);
|
|
9449
9338
|
r(I), l(I);
|
|
9450
9339
|
}, B = (k) => {
|
|
9451
|
-
|
|
9340
|
+
m(k), c(a[k].key), p(a[k].value);
|
|
9452
9341
|
}, _ = () => {
|
|
9453
9342
|
if (i.startsWith("@")) {
|
|
9454
9343
|
h("Attribute keys cannot start with '@'");
|
|
@@ -9456,11 +9345,11 @@ const ClearCanvas = () => {
|
|
|
9456
9345
|
}
|
|
9457
9346
|
if (u !== null && i) {
|
|
9458
9347
|
const k = [...a];
|
|
9459
|
-
k[u] = { key: i, value: d }, r(k), l(k),
|
|
9348
|
+
k[u] = { key: i, value: d }, r(k), l(k), m(null), c(""), p(""), h("");
|
|
9460
9349
|
}
|
|
9461
|
-
},
|
|
9350
|
+
}, j = (k) => {
|
|
9462
9351
|
k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? _() : S());
|
|
9463
|
-
},
|
|
9352
|
+
}, C = useCallback((k) => {
|
|
9464
9353
|
const I = (E) => /[.,!?;:]/.test(E), A = (E, L, T) => {
|
|
9465
9354
|
let P = "", R = "";
|
|
9466
9355
|
const D = L > 0 ? E[L - 1] : "", N = L < E.length ? E[L] : "";
|
|
@@ -9469,9 +9358,9 @@ const ClearCanvas = () => {
|
|
|
9469
9358
|
prefixLength: P.length,
|
|
9470
9359
|
suffixLength: R.length
|
|
9471
9360
|
};
|
|
9472
|
-
},
|
|
9473
|
-
if (
|
|
9474
|
-
const E =
|
|
9361
|
+
}, w = x.current;
|
|
9362
|
+
if (w) {
|
|
9363
|
+
const E = w.selectionStart || 0, L = w.value || "", T = w.selectionEnd || E;
|
|
9475
9364
|
if (T > E) {
|
|
9476
9365
|
const O = `{{${k}}}`, { text: $ } = A(L, E, O), M = L.slice(0, E) + $ + L.slice(T);
|
|
9477
9366
|
p(M);
|
|
@@ -9511,7 +9400,7 @@ const ClearCanvas = () => {
|
|
|
9511
9400
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9512
9401
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9513
9402
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9514
|
-
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect:
|
|
9403
|
+
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: C })
|
|
9515
9404
|
] }),
|
|
9516
9405
|
/* @__PURE__ */ jsx(
|
|
9517
9406
|
Textarea,
|
|
@@ -9524,7 +9413,7 @@ const ClearCanvas = () => {
|
|
|
9524
9413
|
ref: x,
|
|
9525
9414
|
value: d,
|
|
9526
9415
|
onChange: (k) => p(k.target.value),
|
|
9527
|
-
onKeyDown:
|
|
9416
|
+
onKeyDown: j,
|
|
9528
9417
|
placeholder: "Enter Value",
|
|
9529
9418
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9530
9419
|
}
|
|
@@ -9532,7 +9421,7 @@ const ClearCanvas = () => {
|
|
|
9532
9421
|
] })
|
|
9533
9422
|
] }),
|
|
9534
9423
|
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
|
|
9535
|
-
|
|
9424
|
+
g && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: g })
|
|
9536
9425
|
]
|
|
9537
9426
|
}
|
|
9538
9427
|
),
|
|
@@ -9543,7 +9432,7 @@ const ClearCanvas = () => {
|
|
|
9543
9432
|
] }),
|
|
9544
9433
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9545
9434
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(I), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
|
|
9546
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9435
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(I), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
|
|
9547
9436
|
] })
|
|
9548
9437
|
] }, I)) })
|
|
9549
9438
|
] });
|
|
@@ -9685,47 +9574,35 @@ const PartialWrapper = ({ partialBlockId: o }) => {
|
|
|
9685
9574
|
component: DefaultTopBar
|
|
9686
9575
|
}, registerChaiTopBar = (o) => {
|
|
9687
9576
|
TOP_BAR.component = o;
|
|
9688
|
-
}, useTopBarComponent = () => useMemo(() => TOP_BAR.component, []), DEFAULT_PANEL_WIDTH = 280, OutlineButton = ({ isActive: o, show: n }) => /* @__PURE__ */ jsx(Button, { variant: o ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(StackIcon, { className: "h-5 w-5" }) }),
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
button: OutlineButton,
|
|
9706
|
-
panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
|
|
9707
|
-
}), o && n && r.unshift({
|
|
9708
|
-
id: "ai",
|
|
9709
|
-
button: AiButton,
|
|
9710
|
-
label: "AI Assistant",
|
|
9711
|
-
isInternal: !0,
|
|
9712
|
-
width: 450,
|
|
9713
|
-
panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8 h-full max-h-full", children: /* @__PURE__ */ jsx(AIChatPanel, {}) })
|
|
9714
|
-
}), compact(r);
|
|
9715
|
-
}, [o, n]);
|
|
9716
|
-
}
|
|
9577
|
+
}, useTopBarComponent = () => useMemo(() => TOP_BAR.component, []), DEFAULT_PANEL_WIDTH = 280, OutlineButton = ({ isActive: o, show: n }) => /* @__PURE__ */ jsx(Button, { variant: o ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(StackIcon, { className: "h-5 w-5" }) }), AskAiButton = ({ isActive: o, show: n }) => /* @__PURE__ */ jsx(Button, { variant: o ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(AiIcon, {}) });
|
|
9578
|
+
registerChaiSidebarPanel("chai-chat-panel", {
|
|
9579
|
+
button: AskAiButton,
|
|
9580
|
+
label: "Ask AI",
|
|
9581
|
+
position: "top",
|
|
9582
|
+
isInternal: !0,
|
|
9583
|
+
width: DEFAULT_PANEL_WIDTH,
|
|
9584
|
+
panel: () => /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsx(AskAI, {}) })
|
|
9585
|
+
});
|
|
9586
|
+
registerChaiSidebarPanel("outline", {
|
|
9587
|
+
button: OutlineButton,
|
|
9588
|
+
label: "Outline",
|
|
9589
|
+
position: "top",
|
|
9590
|
+
isInternal: !0,
|
|
9591
|
+
width: DEFAULT_PANEL_WIDTH,
|
|
9592
|
+
panel: () => /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsx(ListTree, {}) })
|
|
9593
|
+
});
|
|
9717
9594
|
const RootLayout = () => {
|
|
9718
|
-
const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p =
|
|
9595
|
+
const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), m = reverse([...u ?? []]), g = useCallback((k) => {
|
|
9719
9596
|
k.preventDefault();
|
|
9720
|
-
}, []),
|
|
9597
|
+
}, []), h = useMemo(() => {
|
|
9598
|
+
const k = [p].flat(), I = k.find((w) => w.id === "chai-chat-panel"), A = k.filter((w) => w.id !== "chai-chat-panel");
|
|
9599
|
+
return I ? [I, ...A] : k;
|
|
9600
|
+
}, [p]), f = useCallback(
|
|
9721
9601
|
(k) => {
|
|
9722
9602
|
console.log("handleMenuItemClick", k, n), r(n === k ? null : k);
|
|
9723
9603
|
},
|
|
9724
9604
|
[n, r]
|
|
9725
|
-
), { t: x } = useTranslation(), b = useMemo(
|
|
9726
|
-
() => [...p, ...u, ...g],
|
|
9727
|
-
[p, u, g]
|
|
9728
|
-
), y = useBuilderProp("htmlDir", "ltr"), S = find(b, { id: n }) ?? first(b), C = get(S, "width", DEFAULT_PANEL_WIDTH);
|
|
9605
|
+
), { t: x } = useTranslation(), b = useMemo(() => [...p, ...u], [p, u]), y = useBuilderProp("htmlDir", "ltr"), S = find(b, { id: n }) ?? first(b), v = get(S, "width", DEFAULT_PANEL_WIDTH);
|
|
9729
9606
|
useEffect(() => {
|
|
9730
9607
|
if (n !== null) {
|
|
9731
9608
|
const k = find(b, { id: n });
|
|
@@ -9735,16 +9612,16 @@ const RootLayout = () => {
|
|
|
9735
9612
|
const B = useMemo(() => {
|
|
9736
9613
|
if (n === null) return 0;
|
|
9737
9614
|
const k = find(b, { id: n });
|
|
9738
|
-
return get(k, "view", "standard") === "standard" ?
|
|
9739
|
-
}, [n,
|
|
9615
|
+
return get(k, "view", "standard") === "standard" ? v : l;
|
|
9616
|
+
}, [n, v, l, b]), _ = useCallback(() => {
|
|
9740
9617
|
r(a.current);
|
|
9741
|
-
}, [r, n]),
|
|
9618
|
+
}, [r, n]), j = useCallback(() => {
|
|
9742
9619
|
r("outline");
|
|
9743
9620
|
}, [r]);
|
|
9744
9621
|
useEffect(() => {
|
|
9745
9622
|
n !== null && !find(b, { id: n }) && r("outline");
|
|
9746
9623
|
}, [n, b]);
|
|
9747
|
-
const
|
|
9624
|
+
const C = useCallback(
|
|
9748
9625
|
(k) => {
|
|
9749
9626
|
f(k);
|
|
9750
9627
|
},
|
|
@@ -9754,18 +9631,18 @@ const RootLayout = () => {
|
|
|
9754
9631
|
/* @__PURE__ */ jsxs(
|
|
9755
9632
|
"div",
|
|
9756
9633
|
{
|
|
9757
|
-
onContextMenu:
|
|
9634
|
+
onContextMenu: g,
|
|
9758
9635
|
className: "flex h-full max-h-full flex-col bg-background text-foreground",
|
|
9759
9636
|
children: [
|
|
9760
9637
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9761
9638
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9762
9639
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9763
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children:
|
|
9640
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: h.map((k, I) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9764
9641
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
|
|
9765
9642
|
position: "top",
|
|
9766
9643
|
panelId: k.id,
|
|
9767
9644
|
isActive: n === k.id,
|
|
9768
|
-
show: () =>
|
|
9645
|
+
show: () => C(k.id)
|
|
9769
9646
|
}) }),
|
|
9770
9647
|
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(k.label) }) })
|
|
9771
9648
|
] }, "button-top-" + I)) }),
|
|
@@ -9775,7 +9652,7 @@ const RootLayout = () => {
|
|
|
9775
9652
|
position: "bottom",
|
|
9776
9653
|
panelId: k.id,
|
|
9777
9654
|
isActive: n === k.id,
|
|
9778
|
-
show: () =>
|
|
9655
|
+
show: () => C(k.id)
|
|
9779
9656
|
}) }),
|
|
9780
9657
|
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(k.label) }) })
|
|
9781
9658
|
] }, "button-bottom-" + I)) })
|
|
@@ -9847,26 +9724,26 @@ const RootLayout = () => {
|
|
|
9847
9724
|
{
|
|
9848
9725
|
side: "left",
|
|
9849
9726
|
className: "flex flex-col gap-0 p-0 sm:max-w-full",
|
|
9850
|
-
style: { width: `${
|
|
9727
|
+
style: { width: `${v}px` },
|
|
9851
9728
|
children: [
|
|
9852
9729
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
9853
9730
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
|
|
9854
9731
|
/* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
|
|
9855
9732
|
] }) }),
|
|
9856
9733
|
/* @__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(S, "panel", NoopComponent), {
|
|
9857
|
-
close:
|
|
9734
|
+
close: j
|
|
9858
9735
|
}) }) })
|
|
9859
9736
|
]
|
|
9860
9737
|
}
|
|
9861
9738
|
) }),
|
|
9862
9739
|
" ",
|
|
9863
|
-
n !== null && get(S, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${
|
|
9740
|
+
n !== null && get(S, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${v}px` }, children: [
|
|
9864
9741
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
9865
9742
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
|
|
9866
9743
|
/* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
|
|
9867
9744
|
] }) }),
|
|
9868
9745
|
/* @__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(S, "panel", NoopComponent), {
|
|
9869
|
-
close:
|
|
9746
|
+
close: j
|
|
9870
9747
|
}) }) })
|
|
9871
9748
|
] }) }),
|
|
9872
9749
|
n !== null && get(S, "view") === "overlay" && /* @__PURE__ */ jsx(
|
|
@@ -9894,7 +9771,7 @@ const RootLayout = () => {
|
|
|
9894
9771
|
/* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
|
|
9895
9772
|
] }),
|
|
9896
9773
|
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
|
|
9897
|
-
close:
|
|
9774
|
+
close: j
|
|
9898
9775
|
}) }) })
|
|
9899
9776
|
]
|
|
9900
9777
|
}
|
|
@@ -9949,7 +9826,7 @@ const RootLayout = () => {
|
|
|
9949
9826
|
position: n,
|
|
9950
9827
|
updatePosition: r
|
|
9951
9828
|
}) => {
|
|
9952
|
-
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }),
|
|
9829
|
+
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), m = useMemo(() => {
|
|
9953
9830
|
if (!l.trim()) return a;
|
|
9954
9831
|
const x = l.toLowerCase();
|
|
9955
9832
|
return Object.fromEntries(
|
|
@@ -9958,15 +9835,15 @@ const RootLayout = () => {
|
|
|
9958
9835
|
return (b == null ? void 0 : b.toLowerCase().includes(x)) || ((S = y == null ? void 0 : y.description) == null ? void 0 : S.toLowerCase().includes(x));
|
|
9959
9836
|
})
|
|
9960
9837
|
);
|
|
9961
|
-
}, [a, l]),
|
|
9838
|
+
}, [a, l]), g = (x) => {
|
|
9962
9839
|
d(!0), u({
|
|
9963
9840
|
x: x.clientX - n.x,
|
|
9964
9841
|
y: x.clientY - n.y
|
|
9965
9842
|
});
|
|
9966
9843
|
}, h = (x) => {
|
|
9967
9844
|
if (!c) return;
|
|
9968
|
-
const b = x.clientX - p.x, y = x.clientY - p.y, S = x.currentTarget,
|
|
9969
|
-
r(
|
|
9845
|
+
const b = x.clientX - p.x, y = x.clientY - p.y, S = x.currentTarget, v = S.offsetWidth, B = S.offsetHeight, _ = window.innerWidth - v, j = window.innerHeight - B, C = Math.max(0, Math.min(b, _)), k = Math.max(0, Math.min(y, j));
|
|
9846
|
+
r(C, k);
|
|
9970
9847
|
}, f = () => {
|
|
9971
9848
|
d(!1);
|
|
9972
9849
|
};
|
|
@@ -9978,7 +9855,7 @@ const RootLayout = () => {
|
|
|
9978
9855
|
}, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
9979
9856
|
"div",
|
|
9980
9857
|
{
|
|
9981
|
-
onMouseDown:
|
|
9858
|
+
onMouseDown: g,
|
|
9982
9859
|
onMouseMove: h,
|
|
9983
9860
|
onMouseUp: f,
|
|
9984
9861
|
className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
|
|
@@ -10028,7 +9905,7 @@ const RootLayout = () => {
|
|
|
10028
9905
|
)
|
|
10029
9906
|
] })
|
|
10030
9907
|
] }),
|
|
10031
|
-
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(
|
|
9908
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(m).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(m).map(([x, b]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: x, options: b }, x)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
|
|
10032
9909
|
'No features found matching "',
|
|
10033
9910
|
l,
|
|
10034
9911
|
'"'
|
|
@@ -10161,38 +10038,38 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10161
10038
|
let i = a.get(n);
|
|
10162
10039
|
return i || (i = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, a.set(n, i), l == null || l(o, n)), i;
|
|
10163
10040
|
}, flushCallbacks = (o) => {
|
|
10164
|
-
const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], d = n[13], p = [], u = (
|
|
10041
|
+
const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], d = n[13], p = [], u = (m) => {
|
|
10165
10042
|
try {
|
|
10166
|
-
|
|
10167
|
-
} catch (
|
|
10168
|
-
p.push(
|
|
10043
|
+
m();
|
|
10044
|
+
} catch (g) {
|
|
10045
|
+
p.push(g);
|
|
10169
10046
|
}
|
|
10170
10047
|
};
|
|
10171
10048
|
do {
|
|
10172
10049
|
c.f && u(c.f);
|
|
10173
|
-
const
|
|
10050
|
+
const m = /* @__PURE__ */ new Set(), g = m.add.bind(m);
|
|
10174
10051
|
a.forEach((h) => {
|
|
10175
10052
|
var f;
|
|
10176
|
-
return (f = r.get(h)) == null ? void 0 : f.l.forEach(
|
|
10177
|
-
}), a.clear(), i.forEach(
|
|
10053
|
+
return (f = r.get(h)) == null ? void 0 : f.l.forEach(g);
|
|
10054
|
+
}), a.clear(), i.forEach(g), i.clear(), l.forEach(g), l.clear(), m.forEach(u), a.size && d(o);
|
|
10178
10055
|
} while (a.size || i.size || l.size);
|
|
10179
10056
|
if (p.length)
|
|
10180
10057
|
throw new AggregateError(p);
|
|
10181
10058
|
}, recomputeInvalidatedAtoms = (o) => {
|
|
10182
|
-
const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(),
|
|
10183
|
-
for (;
|
|
10184
|
-
const h =
|
|
10185
|
-
if (
|
|
10186
|
-
|
|
10059
|
+
const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), m = /* @__PURE__ */ new WeakSet(), g = Array.from(l);
|
|
10060
|
+
for (; g.length; ) {
|
|
10061
|
+
const h = g[g.length - 1], f = i(o, h);
|
|
10062
|
+
if (m.has(h)) {
|
|
10063
|
+
g.pop();
|
|
10187
10064
|
continue;
|
|
10188
10065
|
}
|
|
10189
10066
|
if (u.has(h)) {
|
|
10190
|
-
a.get(h) === f.n && p.push([h, f]),
|
|
10067
|
+
a.get(h) === f.n && p.push([h, f]), m.add(h), g.pop();
|
|
10191
10068
|
continue;
|
|
10192
10069
|
}
|
|
10193
10070
|
u.add(h);
|
|
10194
10071
|
for (const x of getMountedOrPendingDependents(h, f, r))
|
|
10195
|
-
u.has(x) ||
|
|
10072
|
+
u.has(x) || g.push(x);
|
|
10196
10073
|
}
|
|
10197
10074
|
for (let h = p.length - 1; h >= 0; --h) {
|
|
10198
10075
|
const [f, x] = p[h];
|
|
@@ -10206,7 +10083,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10206
10083
|
}
|
|
10207
10084
|
}, readAtomState = (o, n) => {
|
|
10208
10085
|
var r;
|
|
10209
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11],
|
|
10086
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], m = a[12], g = a[13], h = a[14], f = a[16], x = a[17], b = u(o, n);
|
|
10210
10087
|
if (isAtomStateInitialized(b) && (l.has(n) && i.get(n) !== b.n || Array.from(b.d).every(
|
|
10211
10088
|
([k, I]) => (
|
|
10212
10089
|
// Recursively, read the atom state of the dependency, and
|
|
@@ -10218,18 +10095,18 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10218
10095
|
b.d.clear();
|
|
10219
10096
|
let y = !0;
|
|
10220
10097
|
function S() {
|
|
10221
|
-
l.has(n) && (x(o, n),
|
|
10098
|
+
l.has(n) && (x(o, n), g(o), m(o));
|
|
10222
10099
|
}
|
|
10223
|
-
function
|
|
10100
|
+
function v(k) {
|
|
10224
10101
|
var I;
|
|
10225
10102
|
if (isSelfAtom(n, k)) {
|
|
10226
|
-
const
|
|
10227
|
-
if (!isAtomStateInitialized(
|
|
10103
|
+
const w = u(o, k);
|
|
10104
|
+
if (!isAtomStateInitialized(w))
|
|
10228
10105
|
if (hasInitialValue(k))
|
|
10229
10106
|
setAtomStateValueOrPromise(o, k, k.init);
|
|
10230
10107
|
else
|
|
10231
10108
|
throw new Error("no atom init");
|
|
10232
|
-
return returnAtomValue(
|
|
10109
|
+
return returnAtomValue(w);
|
|
10233
10110
|
}
|
|
10234
10111
|
const A = h(o, k);
|
|
10235
10112
|
try {
|
|
@@ -10239,7 +10116,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10239
10116
|
}
|
|
10240
10117
|
}
|
|
10241
10118
|
let B, _;
|
|
10242
|
-
const
|
|
10119
|
+
const j = {
|
|
10243
10120
|
get signal() {
|
|
10244
10121
|
return B || (B = new AbortController()), B.signal;
|
|
10245
10122
|
},
|
|
@@ -10249,40 +10126,40 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10249
10126
|
try {
|
|
10250
10127
|
return f(o, n, ...k);
|
|
10251
10128
|
} finally {
|
|
10252
|
-
|
|
10129
|
+
g(o), m(o);
|
|
10253
10130
|
}
|
|
10254
10131
|
}), _;
|
|
10255
10132
|
}
|
|
10256
|
-
},
|
|
10133
|
+
}, C = b.n;
|
|
10257
10134
|
try {
|
|
10258
|
-
const k = p(o, n,
|
|
10135
|
+
const k = p(o, n, v, j);
|
|
10259
10136
|
return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () => B == null ? void 0 : B.abort()), k.then(S, S)), b;
|
|
10260
10137
|
} catch (k) {
|
|
10261
10138
|
return delete b.v, b.e = k, ++b.n, b;
|
|
10262
10139
|
} finally {
|
|
10263
|
-
y = !1,
|
|
10140
|
+
y = !1, C !== b.n && i.get(n) === C && (i.set(n, b.n), c.add(n), (r = d.c) == null || r.call(d, n));
|
|
10264
10141
|
}
|
|
10265
10142
|
}, invalidateDependents = (o, n) => {
|
|
10266
10143
|
const r = getBuildingBlocks(o), a = r[1], l = r[2], i = r[11], c = [n];
|
|
10267
10144
|
for (; c.length; ) {
|
|
10268
10145
|
const d = c.pop(), p = i(o, d);
|
|
10269
10146
|
for (const u of getMountedOrPendingDependents(d, p, a)) {
|
|
10270
|
-
const
|
|
10271
|
-
l.set(u,
|
|
10147
|
+
const m = i(o, u);
|
|
10148
|
+
l.set(u, m.n), c.push(u);
|
|
10272
10149
|
}
|
|
10273
10150
|
}
|
|
10274
10151
|
}, writeAtomState = (o, n, ...r) => {
|
|
10275
|
-
const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13],
|
|
10152
|
+
const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], m = a[14], g = a[15], h = a[17];
|
|
10276
10153
|
let f = !0;
|
|
10277
|
-
const x = (y) => returnAtomValue(
|
|
10278
|
-
var
|
|
10154
|
+
const x = (y) => returnAtomValue(m(o, y)), b = (y, ...S) => {
|
|
10155
|
+
var v;
|
|
10279
10156
|
const B = d(o, y);
|
|
10280
10157
|
try {
|
|
10281
10158
|
if (isSelfAtom(n, y)) {
|
|
10282
10159
|
if (!hasInitialValue(y))
|
|
10283
10160
|
throw new Error("atom not writable");
|
|
10284
|
-
const _ = B.n,
|
|
10285
|
-
setAtomStateValueOrPromise(o, y,
|
|
10161
|
+
const _ = B.n, j = S[0];
|
|
10162
|
+
setAtomStateValueOrPromise(o, y, j), h(o, y), _ !== B.n && (l.add(y), (v = i.c) == null || v.call(i, y), g(o, y));
|
|
10286
10163
|
return;
|
|
10287
10164
|
} else
|
|
10288
10165
|
return writeAtomState(o, y, ...S);
|
|
@@ -10297,26 +10174,26 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10297
10174
|
}
|
|
10298
10175
|
}, mountDependencies = (o, n) => {
|
|
10299
10176
|
var r;
|
|
10300
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18],
|
|
10301
|
-
if (h && !isPendingPromise(
|
|
10302
|
-
for (const [f, x] of
|
|
10177
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], m = a[19], g = d(o, n), h = l.get(n);
|
|
10178
|
+
if (h && !isPendingPromise(g.v)) {
|
|
10179
|
+
for (const [f, x] of g.d)
|
|
10303
10180
|
if (!h.d.has(f)) {
|
|
10304
10181
|
const b = d(o, f);
|
|
10305
10182
|
u(o, f).t.add(n), h.d.add(f), x !== b.n && (i.add(f), (r = c.c) == null || r.call(c, f), p(o, f));
|
|
10306
10183
|
}
|
|
10307
10184
|
for (const f of h.d || [])
|
|
10308
|
-
if (!
|
|
10185
|
+
if (!g.d.has(f)) {
|
|
10309
10186
|
h.d.delete(f);
|
|
10310
|
-
const x =
|
|
10187
|
+
const x = m(o, f);
|
|
10311
10188
|
x == null || x.t.delete(n);
|
|
10312
10189
|
}
|
|
10313
10190
|
}
|
|
10314
10191
|
}, mountAtom = (o, n) => {
|
|
10315
10192
|
var r;
|
|
10316
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12],
|
|
10193
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], m = a[13], g = a[14], h = a[16], f = p(o, n);
|
|
10317
10194
|
let x = l.get(n);
|
|
10318
10195
|
if (!x) {
|
|
10319
|
-
|
|
10196
|
+
g(o, n);
|
|
10320
10197
|
for (const b of f.d.keys())
|
|
10321
10198
|
mountAtom(o, b).t.add(n);
|
|
10322
10199
|
if (x = {
|
|
@@ -10326,19 +10203,19 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10326
10203
|
}, l.set(n, x), (r = c.m) == null || r.call(c, n), isActuallyWritableAtom(n)) {
|
|
10327
10204
|
const b = () => {
|
|
10328
10205
|
let y = !0;
|
|
10329
|
-
const S = (...
|
|
10206
|
+
const S = (...v) => {
|
|
10330
10207
|
try {
|
|
10331
|
-
return h(o, n, ...
|
|
10208
|
+
return h(o, n, ...v);
|
|
10332
10209
|
} finally {
|
|
10333
|
-
y || (
|
|
10210
|
+
y || (m(o), u(o));
|
|
10334
10211
|
}
|
|
10335
10212
|
};
|
|
10336
10213
|
try {
|
|
10337
|
-
const
|
|
10338
|
-
|
|
10214
|
+
const v = d(o, n, S);
|
|
10215
|
+
v && (x.u = () => {
|
|
10339
10216
|
y = !0;
|
|
10340
10217
|
try {
|
|
10341
|
-
|
|
10218
|
+
v();
|
|
10342
10219
|
} finally {
|
|
10343
10220
|
y = !1;
|
|
10344
10221
|
}
|
|
@@ -10354,19 +10231,19 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10354
10231
|
}, unmountAtom = (o, n) => {
|
|
10355
10232
|
var r;
|
|
10356
10233
|
const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);
|
|
10357
|
-
let
|
|
10358
|
-
if (
|
|
10234
|
+
let m = l.get(n);
|
|
10235
|
+
if (m && !m.l.size && !Array.from(m.t).some((g) => {
|
|
10359
10236
|
var h;
|
|
10360
|
-
return (h = l.get(
|
|
10237
|
+
return (h = l.get(g)) == null ? void 0 : h.d.has(n);
|
|
10361
10238
|
})) {
|
|
10362
|
-
|
|
10363
|
-
for (const
|
|
10364
|
-
const h = p(o,
|
|
10239
|
+
m.u && i.add(m.u), m = void 0, l.delete(n), (r = c.u) == null || r.call(c, n);
|
|
10240
|
+
for (const g of u.d.keys()) {
|
|
10241
|
+
const h = p(o, g);
|
|
10365
10242
|
h == null || h.t.delete(n);
|
|
10366
10243
|
}
|
|
10367
10244
|
return;
|
|
10368
10245
|
}
|
|
10369
|
-
return
|
|
10246
|
+
return m;
|
|
10370
10247
|
}, setAtomStateValueOrPromise = (o, n, r) => {
|
|
10371
10248
|
const a = getBuildingBlocks(o)[11], l = a(o, n), i = "v" in l, c = l.v;
|
|
10372
10249
|
if (isPromiseLike$1(r))
|
|
@@ -10481,10 +10358,10 @@ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function",
|
|
|
10481
10358
|
let r = continuablePromiseMap.get(o);
|
|
10482
10359
|
return r || (r = new Promise((a, l) => {
|
|
10483
10360
|
let i = o;
|
|
10484
|
-
const c = (u) => (
|
|
10485
|
-
i === u && a(
|
|
10486
|
-
}, d = (u) => (
|
|
10487
|
-
i === u && l(
|
|
10361
|
+
const c = (u) => (m) => {
|
|
10362
|
+
i === u && a(m);
|
|
10363
|
+
}, d = (u) => (m) => {
|
|
10364
|
+
i === u && l(m);
|
|
10488
10365
|
}, p = () => {
|
|
10489
10366
|
try {
|
|
10490
10367
|
const u = n();
|
|
@@ -10498,21 +10375,21 @@ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function",
|
|
|
10498
10375
|
};
|
|
10499
10376
|
function useAtomValue(o, n) {
|
|
10500
10377
|
const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c, d], p] = useReducer(
|
|
10501
|
-
(
|
|
10502
|
-
const
|
|
10503
|
-
return Object.is(
|
|
10378
|
+
(m) => {
|
|
10379
|
+
const g = l.get(o);
|
|
10380
|
+
return Object.is(m[0], g) && m[1] === l && m[2] === o ? m : [g, l, o];
|
|
10504
10381
|
},
|
|
10505
10382
|
void 0,
|
|
10506
10383
|
() => [l.get(o), l, o]
|
|
10507
10384
|
);
|
|
10508
10385
|
let u = i;
|
|
10509
10386
|
if ((c !== l || d !== o) && (p(), u = l.get(o)), useEffect(() => {
|
|
10510
|
-
const
|
|
10387
|
+
const m = l.sub(o, () => {
|
|
10511
10388
|
if (a)
|
|
10512
10389
|
try {
|
|
10513
|
-
const
|
|
10514
|
-
isPromiseLike(
|
|
10515
|
-
createContinuablePromise(
|
|
10390
|
+
const g = l.get(o);
|
|
10391
|
+
isPromiseLike(g) && attachPromiseStatus(
|
|
10392
|
+
createContinuablePromise(g, () => l.get(o))
|
|
10516
10393
|
);
|
|
10517
10394
|
} catch {
|
|
10518
10395
|
}
|
|
@@ -10522,10 +10399,10 @@ function useAtomValue(o, n) {
|
|
|
10522
10399
|
}
|
|
10523
10400
|
p();
|
|
10524
10401
|
});
|
|
10525
|
-
return p(),
|
|
10402
|
+
return p(), m;
|
|
10526
10403
|
}, [l, o, r, a]), useDebugValue(u), isPromiseLike(u)) {
|
|
10527
|
-
const
|
|
10528
|
-
return a && attachPromiseStatus(
|
|
10404
|
+
const m = createContinuablePromise(u, () => l.get(o));
|
|
10405
|
+
return a && attachPromiseStatus(m), use(m);
|
|
10529
10406
|
}
|
|
10530
10407
|
return u;
|
|
10531
10408
|
}
|
|
@@ -10642,26 +10519,27 @@ export {
|
|
|
10642
10519
|
useRemoveAllClassesForBlock as ab,
|
|
10643
10520
|
useRemoveBlocks as ac,
|
|
10644
10521
|
useRemoveClassesFromBlocks as ad,
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10522
|
+
useReplaceBlock as ae,
|
|
10523
|
+
useResetBlockStyles as af,
|
|
10524
|
+
useRightPanel as ag,
|
|
10525
|
+
useSavePage as ah,
|
|
10526
|
+
useSelectedBlock as ai,
|
|
10527
|
+
useSelectedBlockAllClasses as aj,
|
|
10528
|
+
useSelectedBlockCurrentClasses as ak,
|
|
10529
|
+
useSelectedBlocksDisplayChild as al,
|
|
10530
|
+
useSelectedBreakpoints as am,
|
|
10531
|
+
useSelectedStylingBlocks as an,
|
|
10532
|
+
useStylingBreakpoint as ao,
|
|
10533
|
+
useStylingState as ap,
|
|
10534
|
+
useTheme as aq,
|
|
10535
|
+
useThemeOptions as ar,
|
|
10536
|
+
useUndoManager as as,
|
|
10537
|
+
useWrapperBlock as at,
|
|
10538
|
+
useBlocksStoreUndoableActions as au,
|
|
10539
|
+
useCanvasDisplayWidth as av,
|
|
10540
|
+
useScreenSizeWidth as aw,
|
|
10541
|
+
useSelectedLibrary as ax,
|
|
10542
|
+
useSidebarActivePanel as ay,
|
|
10665
10543
|
useUpdateBlocksProps as b,
|
|
10666
10544
|
useUpdateBlocksPropsRealtime as c,
|
|
10667
10545
|
usePageExternalData as d,
|