@chaibuilder/sdk 3.0.28 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{IconPicker-CluS-5Mv.js → IconPicker-DB-dcym6.js} +1 -1
- package/dist/{IconPicker-BWE43eMO.cjs → IconPicker-OPOFkNZu.cjs} +1 -1
- package/dist/apply-binding-BEdnEDe4.cjs +1 -0
- package/dist/apply-binding-FoDMumPo.js +704 -0
- package/dist/{code-editor-D9Lla5Lr.cjs → code-editor-BF_Dj7wT.cjs} +1 -1
- package/dist/{code-editor-DmN41-qr.js → code-editor-DHjchara.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +15 -2
- package/dist/core.js +82 -78
- 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-Ct0lOt4c.js → index-0I-fi22L.js} +1010 -1135
- package/dist/index-kJFsIwFo.cjs +128 -0
- package/dist/render.cjs +1 -1
- package/dist/render.js +2 -2
- package/dist/{rte-widget-modal-DzEtNny0.cjs → rte-widget-modal-BZJ8UA08.cjs} +1 -1
- package/dist/{rte-widget-modal-jYxk5Q4W.js → rte-widget-modal-DxyV3u6C.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/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +326 -322
- package/package.json +2 -2
- package/dist/apply-binding-BIYK6lOq.cjs +0 -1
- package/dist/apply-binding-YbVf4970.js +0 -685
- package/dist/index-BtVNiUIw.cjs +0 -128
|
@@ -2,19 +2,19 @@ var U = Object.defineProperty;
|
|
|
2
2
|
var W = (o, n, r) => n in o ? U(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
|
|
3
3
|
var F = (o, n, r) => W(o, typeof n != "symbol" ? n + "" : n, r);
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
|
-
import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas
|
|
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,
|
|
5
|
+
import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, syncBlocksWithDefaults, useRegisteredFonts, getBlockFormSchemas } from "@chaibuilder/runtime";
|
|
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, kebabCase, 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, CircleIcon, MagnifyingGlassIcon, ReloadIcon, 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,
|
|
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, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, b1 as Textarea, 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";
|
|
17
|
-
import { C as COLLECTION_PREFIX, S as STYLES_KEY, i as getSplitChaiClasses, e as adjustSpacingInContentBlocks, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX,
|
|
17
|
+
import { C as COLLECTION_PREFIX, S as STYLES_KEY, i as getSplitChaiClasses, h as getBlocksFromHTML, m as mergeBlocksWithExisting, e as adjustSpacingInContentBlocks, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX, j as ROOT_TEMP_KEY } from "./apply-binding-FoDMumPo.js";
|
|
18
18
|
import { d as defaultThemeOptions, f as defaultThemeValues, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, h as getThemeFontsUrls, i as getThemeCustomFontFace } from "./plugin-BOcGV_IY.js";
|
|
19
19
|
import { isObject } from "@rjsf/utils";
|
|
20
20
|
import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useDebouncedState, useIntervalEffect } from "@react-hookz/web";
|
|
@@ -38,16 +38,17 @@ import validator from "@rjsf/validator-ajv8";
|
|
|
38
38
|
import Autosuggest from "react-autosuggest";
|
|
39
39
|
import { useFeature } from "flagged";
|
|
40
40
|
import { Tree } from "react-arborist";
|
|
41
|
-
import "himalaya";
|
|
41
|
+
import { parse, stringify } from "himalaya";
|
|
42
42
|
import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
|
|
43
43
|
import tailwindForms from "@tailwindcss/forms";
|
|
44
44
|
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 {
|
|
51
|
+
import { compact as compact$1, pick as pick$1 } from "lodash";
|
|
51
52
|
import { limitShift, flip, size } from "@floating-ui/dom";
|
|
52
53
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
53
54
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
@@ -342,16 +343,16 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
342
343
|
_type: "Text",
|
|
343
344
|
content: u.content
|
|
344
345
|
};
|
|
345
|
-
Object.keys(u).forEach((
|
|
346
|
-
|
|
347
|
-
}), l.unshift(h), i = i.map((
|
|
348
|
-
if (
|
|
349
|
-
const
|
|
350
|
-
return Object.keys(
|
|
351
|
-
b.startsWith("content-") && (
|
|
352
|
-
}),
|
|
346
|
+
Object.keys(u).forEach((x) => {
|
|
347
|
+
x.startsWith("content-") && (h[x] = u[x]);
|
|
348
|
+
}), l.unshift(h), i = i.map((x) => {
|
|
349
|
+
if (x._id === r) {
|
|
350
|
+
const f = { ...x, content: "" };
|
|
351
|
+
return Object.keys(f).forEach((b) => {
|
|
352
|
+
b.startsWith("content-") && (f[b] = "");
|
|
353
|
+
}), f;
|
|
353
354
|
}
|
|
354
|
-
return
|
|
355
|
+
return x;
|
|
355
356
|
});
|
|
356
357
|
}
|
|
357
358
|
}
|
|
@@ -479,15 +480,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
479
480
|
if (g.length === 2) {
|
|
480
481
|
const m = g.find((h) => h._id !== d);
|
|
481
482
|
if (m && m._type === "Text") {
|
|
482
|
-
const h = r.find((
|
|
483
|
-
h && "content" in h && (r = r.map((
|
|
484
|
-
if (
|
|
485
|
-
const
|
|
483
|
+
const h = r.find((x) => x._id === u);
|
|
484
|
+
h && "content" in h && (r = r.map((x) => {
|
|
485
|
+
if (x._id === u) {
|
|
486
|
+
const f = { ...x, content: m.content };
|
|
486
487
|
return Object.keys(m).forEach((b) => {
|
|
487
|
-
b.startsWith("content-") && (
|
|
488
|
-
}),
|
|
488
|
+
b.startsWith("content-") && (f[b] = m[b]);
|
|
489
|
+
}), f;
|
|
489
490
|
}
|
|
490
|
-
return
|
|
491
|
+
return x;
|
|
491
492
|
}), a.push(m._id));
|
|
492
493
|
}
|
|
493
494
|
}
|
|
@@ -570,32 +571,32 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
570
571
|
status: "idle",
|
|
571
572
|
props: {},
|
|
572
573
|
error: void 0
|
|
573
|
-
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (
|
|
574
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
|
|
574
575
|
return useEffect(() => {
|
|
575
576
|
if (n === "mock") {
|
|
576
577
|
if (isFunction(a)) {
|
|
577
|
-
i((
|
|
578
|
-
const
|
|
579
|
-
if (!isObject(
|
|
578
|
+
i((f) => ({ ...f, status: "loading", props: {} }));
|
|
579
|
+
const x = a({ block: o });
|
|
580
|
+
if (!isObject(x))
|
|
580
581
|
throw new Error("mockDataProvider should return an object");
|
|
581
|
-
i((
|
|
582
|
+
i((f) => ({ ...f, status: "loaded", props: x }));
|
|
582
583
|
}
|
|
583
584
|
return;
|
|
584
585
|
}
|
|
585
|
-
n === "live" && (!g && !m || (i((
|
|
586
|
-
g ? (p((
|
|
587
|
-
...
|
|
586
|
+
n === "live" && (!g && !m || (i((x) => ({ ...x, status: "loading", props: {} })), d({ block: o }).then((x = {}) => {
|
|
587
|
+
g ? (p((f) => ({
|
|
588
|
+
...f,
|
|
588
589
|
[o._id]: {
|
|
589
590
|
status: "loaded",
|
|
590
|
-
props: get(
|
|
591
|
+
props: get(x, "items", []),
|
|
591
592
|
repeaterItems: o.repeaterItems
|
|
592
593
|
}
|
|
593
|
-
})), i((
|
|
594
|
-
}).catch((
|
|
595
|
-
g ? (p((
|
|
596
|
-
...
|
|
597
|
-
[o._id]: { status: "error", error:
|
|
598
|
-
})), i((
|
|
594
|
+
})), i((f) => ({ ...f, status: "loaded", props: { totalItems: get(x, "totalItems") } })), c([o._id], { totalItems: get(x, "totalItems") })) : i((f) => ({ ...f, status: "loaded", props: isObject(x) ? x : {} }));
|
|
595
|
+
}).catch((x) => {
|
|
596
|
+
g ? (p((f) => ({
|
|
597
|
+
...f,
|
|
598
|
+
[o._id]: { status: "error", error: x, props: [] }
|
|
599
|
+
})), i((f) => ({ ...f, status: "error", error: x, props: {} }))) : i((f) => ({ ...f, status: "error", error: x, props: {} }));
|
|
599
600
|
})));
|
|
600
601
|
}, [o == null ? void 0 : o._id, u, g, m, a, n]), {
|
|
601
602
|
$loading: get(l, "status") === "loading",
|
|
@@ -750,20 +751,20 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
|
750
751
|
return console.warn(`Failed to get block definition for type: ${r._type}`, a), !1;
|
|
751
752
|
}
|
|
752
753
|
}) : !1, useSavePage = () => {
|
|
753
|
-
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (
|
|
754
|
+
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (x) => {
|
|
754
755
|
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
|
|
755
|
-
const
|
|
756
|
-
return !d || d === p ? !1 : checkMissingTranslations(
|
|
756
|
+
const x = l();
|
|
757
|
+
return !d || d === p ? !1 : checkMissingTranslations(x.blocks || [], d);
|
|
757
758
|
};
|
|
758
759
|
return { savePage: useThrottledCallback(
|
|
759
|
-
async (
|
|
760
|
+
async (x = !1) => {
|
|
760
761
|
if (!c("save_page") || !u)
|
|
761
762
|
return;
|
|
762
763
|
n("SAVING"), a("SAVING");
|
|
763
|
-
const
|
|
764
|
+
const f = l();
|
|
764
765
|
return await r({
|
|
765
|
-
autoSave:
|
|
766
|
-
blocks:
|
|
766
|
+
autoSave: x,
|
|
767
|
+
blocks: f.blocks,
|
|
767
768
|
theme: i,
|
|
768
769
|
needTranslations: g()
|
|
769
770
|
}), setTimeout(() => {
|
|
@@ -777,10 +778,10 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
|
777
778
|
if (!c("save_page") || !u)
|
|
778
779
|
return;
|
|
779
780
|
n("SAVING"), a("SAVING");
|
|
780
|
-
const
|
|
781
|
+
const x = l();
|
|
781
782
|
return await r({
|
|
782
783
|
autoSave: !0,
|
|
783
|
-
blocks:
|
|
784
|
+
blocks: x.blocks,
|
|
784
785
|
theme: i,
|
|
785
786
|
needTranslations: g()
|
|
786
787
|
}), setTimeout(() => {
|
|
@@ -838,65 +839,65 @@ const undoRedoStateAtom = atom({
|
|
|
838
839
|
updateBlocksProps: c
|
|
839
840
|
} = useBlocksStoreManager();
|
|
840
841
|
return {
|
|
841
|
-
moveBlocks: (
|
|
842
|
-
const
|
|
843
|
-
const
|
|
844
|
-
return { _id:
|
|
845
|
-
}),
|
|
846
|
-
|
|
847
|
-
undo: () => each(
|
|
848
|
-
i([
|
|
842
|
+
moveBlocks: (f, b, y) => {
|
|
843
|
+
const C = map(f, (j) => {
|
|
844
|
+
const B = n.find((I) => I._id === j)._parent || null, k = n.filter((I) => B ? I._parent === B : !I._parent).map((I) => I._id).indexOf(j);
|
|
845
|
+
return { _id: j, oldParent: B, oldPosition: k };
|
|
846
|
+
}), v = C.find(({ _id: j }) => j === f[0]);
|
|
847
|
+
v && v.oldParent === b && v.oldPosition === y || (i(f, b, y), o({
|
|
848
|
+
undo: () => each(C, ({ _id: j, oldParent: _, oldPosition: B }) => {
|
|
849
|
+
i([j], _, B);
|
|
849
850
|
}),
|
|
850
|
-
redo: () => i(
|
|
851
|
+
redo: () => i(f, b, y)
|
|
851
852
|
}));
|
|
852
853
|
},
|
|
853
|
-
addBlocks: (
|
|
854
|
-
a(
|
|
855
|
-
undo: () => l(map(
|
|
856
|
-
redo: () => a(
|
|
854
|
+
addBlocks: (f, b, y) => {
|
|
855
|
+
a(f, b, y), o({
|
|
856
|
+
undo: () => l(map(f, "_id")),
|
|
857
|
+
redo: () => a(f, b, y)
|
|
857
858
|
});
|
|
858
859
|
},
|
|
859
|
-
removeBlocks: (
|
|
860
|
-
var
|
|
861
|
-
const b = (
|
|
862
|
-
l(map(
|
|
863
|
-
undo: () => a(
|
|
864
|
-
redo: () => l(map(
|
|
860
|
+
removeBlocks: (f) => {
|
|
861
|
+
var v;
|
|
862
|
+
const b = (v = first(f)) == null ? void 0 : v._parent, C = n.filter((j) => b ? j._parent === b : !j._parent).indexOf(first(f));
|
|
863
|
+
l(map(f, "_id")), o({
|
|
864
|
+
undo: () => a(f, b, C),
|
|
865
|
+
redo: () => l(map(f, "_id"))
|
|
865
866
|
});
|
|
866
867
|
},
|
|
867
|
-
updateBlocks: (
|
|
868
|
-
let
|
|
868
|
+
updateBlocks: (f, b, y) => {
|
|
869
|
+
let C = [];
|
|
869
870
|
if (y)
|
|
870
|
-
|
|
871
|
+
C = map(f, (v) => ({ _id: v, ...y }));
|
|
871
872
|
else {
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
const _ = n.find((
|
|
875
|
-
return each(
|
|
873
|
+
const v = keys(b);
|
|
874
|
+
C = map(f, (j) => {
|
|
875
|
+
const _ = n.find((S) => S._id === j), B = { _id: j };
|
|
876
|
+
return each(v, (S) => B[S] = _[S]), B;
|
|
876
877
|
});
|
|
877
878
|
}
|
|
878
|
-
c(map(
|
|
879
|
-
undo: () => c(
|
|
880
|
-
redo: () => c(map(
|
|
879
|
+
c(map(f, (v) => ({ _id: v, ...b }))), o({
|
|
880
|
+
undo: () => c(C),
|
|
881
|
+
redo: () => c(map(f, (v) => ({ _id: v, ...b })))
|
|
881
882
|
});
|
|
882
883
|
},
|
|
883
|
-
updateBlocksRuntime: (
|
|
884
|
-
c(map(
|
|
884
|
+
updateBlocksRuntime: (f, b) => {
|
|
885
|
+
c(map(f, (y) => ({ _id: y, ...b })));
|
|
885
886
|
},
|
|
886
|
-
setNewBlocks: (
|
|
887
|
-
r(
|
|
887
|
+
setNewBlocks: (f) => {
|
|
888
|
+
r(f), o({
|
|
888
889
|
undo: () => r(n),
|
|
889
|
-
redo: () => r(
|
|
890
|
+
redo: () => r(f)
|
|
890
891
|
});
|
|
891
892
|
},
|
|
892
|
-
updateMultipleBlocksProps: (
|
|
893
|
+
updateMultipleBlocksProps: (f) => {
|
|
893
894
|
let b = [];
|
|
894
|
-
b = map(
|
|
895
|
-
const
|
|
896
|
-
return each(
|
|
897
|
-
}), c(
|
|
895
|
+
b = map(f, (y) => {
|
|
896
|
+
const C = keys(y), v = n.find((_) => _._id === y._id), j = {};
|
|
897
|
+
return each(C, (_) => j[_] = v[_]), j;
|
|
898
|
+
}), c(f), o({
|
|
898
899
|
undo: () => c(b),
|
|
899
|
-
redo: () => c(
|
|
900
|
+
redo: () => c(f)
|
|
900
901
|
});
|
|
901
902
|
}
|
|
902
903
|
};
|
|
@@ -904,12 +905,12 @@ const undoRedoStateAtom = atom({
|
|
|
904
905
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
905
906
|
(i, c, d) => {
|
|
906
907
|
var h;
|
|
907
|
-
for (let
|
|
908
|
-
const { _id:
|
|
909
|
-
i[
|
|
910
|
-
const b = filter(i, { _parent:
|
|
908
|
+
for (let x = 0; x < i.length; x++) {
|
|
909
|
+
const { _id: f } = i[x];
|
|
910
|
+
i[x]._id = generateUUID();
|
|
911
|
+
const b = filter(i, { _parent: f });
|
|
911
912
|
for (let y = 0; y < b.length; y++)
|
|
912
|
-
b[y]._parent = i[
|
|
913
|
+
b[y]._parent = i[x]._id;
|
|
913
914
|
}
|
|
914
915
|
const p = first(i);
|
|
915
916
|
let u, g;
|
|
@@ -2362,39 +2363,39 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2362
2363
|
return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
|
|
2363
2364
|
})
|
|
2364
2365
|
), 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(), g = p.length ? p : u, m = (h,
|
|
2366
|
-
const
|
|
2367
|
-
for (const b in
|
|
2368
|
-
const y =
|
|
2366
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, x) => {
|
|
2367
|
+
const f = cloneDeep(x.find((b) => b._id === h));
|
|
2368
|
+
for (const b in f) {
|
|
2369
|
+
const y = f[b];
|
|
2369
2370
|
if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
|
|
2370
|
-
const { baseClasses:
|
|
2371
|
-
|
|
2371
|
+
const { baseClasses: C, classes: v } = getSplitChaiClasses(y);
|
|
2372
|
+
f[b] = compact(flattenDeep([C, v])).join(" ");
|
|
2372
2373
|
} else
|
|
2373
|
-
b !== "_id" && delete
|
|
2374
|
+
b !== "_id" && delete f[b];
|
|
2374
2375
|
}
|
|
2375
|
-
return
|
|
2376
|
+
return f;
|
|
2376
2377
|
};
|
|
2377
2378
|
return {
|
|
2378
2379
|
askAi: useCallback(
|
|
2379
|
-
async (h,
|
|
2380
|
+
async (h, x, f, b) => {
|
|
2380
2381
|
if (l) {
|
|
2381
2382
|
n(!0), a(null);
|
|
2382
2383
|
try {
|
|
2383
|
-
const y = p === u ? "" : p,
|
|
2384
|
-
if (
|
|
2385
|
-
a(
|
|
2384
|
+
const y = p === u ? "" : p, C = f.toLowerCase().includes("translate the content"), v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p, C) : [m(x, d)], j = await l(h, addLangToPrompt(f, g, h), v, y), { blocks: _, error: B } = j;
|
|
2385
|
+
if (B) {
|
|
2386
|
+
a(B);
|
|
2386
2387
|
return;
|
|
2387
2388
|
}
|
|
2388
2389
|
if (h === "styles") {
|
|
2389
|
-
const
|
|
2390
|
+
const S = _.map((k) => {
|
|
2390
2391
|
for (const I in k)
|
|
2391
2392
|
I !== "_id" && (k[I] = `${STYLES_KEY},${k[I]}`);
|
|
2392
2393
|
return k;
|
|
2393
2394
|
});
|
|
2394
|
-
c(
|
|
2395
|
+
c(S);
|
|
2395
2396
|
} else
|
|
2396
2397
|
i(_);
|
|
2397
|
-
b && b(
|
|
2398
|
+
b && b(j);
|
|
2398
2399
|
} catch (y) {
|
|
2399
2400
|
a(y);
|
|
2400
2401
|
} finally {
|
|
@@ -2470,55 +2471,59 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2470
2471
|
);
|
|
2471
2472
|
return [o, a];
|
|
2472
2473
|
}, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
|
|
2473
|
-
const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useCallback(
|
|
2474
|
-
(
|
|
2474
|
+
const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useBuilderProp("flags.useClipboard", !1), c = useCallback(
|
|
2475
|
+
(p) => p.some((u) => getDuplicatedBlocks(o, u, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
|
|
2475
2476
|
[o]
|
|
2476
|
-
),
|
|
2477
|
-
async (
|
|
2477
|
+
), d = useCallback(
|
|
2478
|
+
async (p, u = !1) => {
|
|
2478
2479
|
try {
|
|
2479
|
-
if (isEmpty(
|
|
2480
|
-
r(
|
|
2481
|
-
const
|
|
2482
|
-
_chai_copied_blocks:
|
|
2483
|
-
const
|
|
2484
|
-
if (!
|
|
2485
|
-
return
|
|
2486
|
-
let
|
|
2487
|
-
for (const f of
|
|
2480
|
+
if (isEmpty(p)) return;
|
|
2481
|
+
r(p), a([]);
|
|
2482
|
+
const g = {
|
|
2483
|
+
_chai_copied_blocks: p.flatMap((m) => {
|
|
2484
|
+
const h = getDuplicatedBlocks(o, m, null);
|
|
2485
|
+
if (!u)
|
|
2486
|
+
return h;
|
|
2487
|
+
let x = [];
|
|
2488
|
+
for (const f of h)
|
|
2488
2489
|
if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
|
|
2489
|
-
let
|
|
2490
|
-
f._parent && (
|
|
2490
|
+
let b = l(f.partialBlockId);
|
|
2491
|
+
f._parent && (b == null ? void 0 : b.length) > 0 && (b = b.map((y) => (isEmpty(y._parent) && set(y, "_parent", f._parent), y))), x = [...x, ...b];
|
|
2491
2492
|
} else
|
|
2492
|
-
|
|
2493
|
-
return
|
|
2493
|
+
x.push(f);
|
|
2494
|
+
return x;
|
|
2494
2495
|
})
|
|
2495
2496
|
};
|
|
2497
|
+
if (!i)
|
|
2498
|
+
return;
|
|
2496
2499
|
if (!navigator.clipboard) {
|
|
2497
2500
|
toast.error("Clipboard not available.");
|
|
2498
2501
|
return;
|
|
2499
2502
|
}
|
|
2500
|
-
toast.promise(navigator.clipboard.writeText(JSON.stringify(
|
|
2503
|
+
toast.promise(navigator.clipboard.writeText(JSON.stringify(g)), {
|
|
2501
2504
|
success: "Blocks copied successfully",
|
|
2502
2505
|
error: "Failed to copy blocks to clipboard"
|
|
2503
2506
|
});
|
|
2504
|
-
} catch (
|
|
2505
|
-
toast.error("Failed to copy blocks to clipboard"), console.error("Failed to copy blocks to clipboard:",
|
|
2507
|
+
} catch (g) {
|
|
2508
|
+
toast.error("Failed to copy blocks to clipboard"), console.error("Failed to copy blocks to clipboard:", g);
|
|
2506
2509
|
}
|
|
2507
2510
|
},
|
|
2508
2511
|
[r, a, o]
|
|
2509
2512
|
);
|
|
2510
|
-
return [n,
|
|
2513
|
+
return [n, d, c];
|
|
2511
2514
|
}, useCopyToClipboard = () => {
|
|
2512
|
-
const [o, n] = useState(null), r = useCallback(async (
|
|
2515
|
+
const [o, n] = useState(null), r = useBuilderProp("flags.useClipboard", !1), a = useCallback(async (l) => {
|
|
2516
|
+
if (!r)
|
|
2517
|
+
return console.warn("Clipboard feature is disabled"), !1;
|
|
2513
2518
|
if (!(navigator != null && navigator.clipboard))
|
|
2514
2519
|
return console.warn("Clipboard not supported"), !1;
|
|
2515
2520
|
try {
|
|
2516
|
-
return await navigator.clipboard.writeText(
|
|
2517
|
-
} catch (
|
|
2518
|
-
return console.warn("Copy failed",
|
|
2521
|
+
return await navigator.clipboard.writeText(l), n(l), !0;
|
|
2522
|
+
} catch (i) {
|
|
2523
|
+
return console.warn("Copy failed", i), n(null), !1;
|
|
2519
2524
|
}
|
|
2520
2525
|
}, []);
|
|
2521
|
-
return [o,
|
|
2526
|
+
return [o, a];
|
|
2522
2527
|
}, darkModeAtom = atomWithStorage("darkMode", !1), useDarkMode = () => {
|
|
2523
2528
|
const [o, n] = useAtom$1(darkModeAtom);
|
|
2524
2529
|
return [o, n];
|
|
@@ -2664,13 +2669,13 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2664
2669
|
const d = o(c), p = a;
|
|
2665
2670
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2666
2671
|
return each(p, (m) => {
|
|
2667
|
-
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2668
|
-
u = u.replace(
|
|
2669
|
-
const
|
|
2670
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2672
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2673
|
+
u = u.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2674
|
+
const f = first(m.split(":"));
|
|
2675
|
+
includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(m.split(":").pop().trim());
|
|
2671
2676
|
}), each(p, (m) => {
|
|
2672
|
-
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2673
|
-
g = g.replace(
|
|
2677
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2678
|
+
g = g.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2674
2679
|
}), {
|
|
2675
2680
|
ids: [d._id],
|
|
2676
2681
|
props: {
|
|
@@ -2787,7 +2792,136 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2787
2792
|
return null;
|
|
2788
2793
|
});
|
|
2789
2794
|
wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
|
|
2790
|
-
const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom),
|
|
2795
|
+
const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe = () => useAtom$1(canvasIframeAtom), ATTRIBUTES_TO_REMOVE = ["data-block-index", "data-drop", "data-style-id", "data-block-parent", "data-style-prop"], CORE_BLOCKS$1 = [
|
|
2796
|
+
"Box",
|
|
2797
|
+
"Button",
|
|
2798
|
+
"Checkbox",
|
|
2799
|
+
"Divider",
|
|
2800
|
+
"EmptyBox",
|
|
2801
|
+
"Form",
|
|
2802
|
+
"FormButton",
|
|
2803
|
+
"Heading",
|
|
2804
|
+
"Image",
|
|
2805
|
+
"Input",
|
|
2806
|
+
"Label",
|
|
2807
|
+
"LineBreak",
|
|
2808
|
+
"Link",
|
|
2809
|
+
"List",
|
|
2810
|
+
"ListItem",
|
|
2811
|
+
"Paragraph",
|
|
2812
|
+
"Radio",
|
|
2813
|
+
"RichText",
|
|
2814
|
+
"Select",
|
|
2815
|
+
"Span",
|
|
2816
|
+
"Text",
|
|
2817
|
+
"TextArea",
|
|
2818
|
+
"Video"
|
|
2819
|
+
], cleanNode = (o) => o.type === "element" && ["script", "style", "link"].includes(o.tagName || "") || o.type === "comment" ? null : o.type === "text" ? o : o.type === "element" && o.attributes && o.attributes.find((n) => n.key === "id" && n.value === "add-block-bottom") ? null : (o.type === "element" && o.attributes && (o.attributes = o.attributes.filter((n) => !ATTRIBUTES_TO_REMOVE.includes(n.key))), o.children && (o.children = o.children.map(cleanNode).filter((n) => n !== null)), o), transformNode = (o, n) => {
|
|
2820
|
+
if (o.type !== "element" || !o.attributes)
|
|
2821
|
+
return o;
|
|
2822
|
+
o.tagName === "span" && o.attributes.find((i) => i.key === "role" && i.value === "link") && (o.tagName = "a", o.attributes = o.attributes.filter((i) => i.key !== "role"));
|
|
2823
|
+
const r = o.attributes.find((l) => l.key === "data-block-type"), a = o.attributes.find((l) => l.key === "data-block-id");
|
|
2824
|
+
if (r) {
|
|
2825
|
+
const l = r.value;
|
|
2826
|
+
if (CORE_BLOCKS$1.includes(l))
|
|
2827
|
+
o.attributes = o.attributes.filter((i) => i.key !== "data-block-type"), o.children && (o.children = o.children.map((i) => transformNode(i, n)));
|
|
2828
|
+
else {
|
|
2829
|
+
const i = `chai-${kebabCase(l)}`;
|
|
2830
|
+
o.tagName = i, a ? o.attributes = [{ key: "id", value: a.value }] : o.attributes = [], o.attributes.push({ key: "chai-type", value: l });
|
|
2831
|
+
const c = getRegisteredChaiBlock(l), d = n.find((p) => p._id === (a == null ? void 0 : a.value));
|
|
2832
|
+
if (d && o.attributes.push(
|
|
2833
|
+
...Object.entries(d).filter(([p]) => !["_id", "_type", "_parent", "_index", "_name"].includes(p)).map(([p, u]) => ({
|
|
2834
|
+
key: p,
|
|
2835
|
+
value: typeof u == "string" ? u : JSON.stringify(u)
|
|
2836
|
+
}))
|
|
2837
|
+
), c && (c != null && c.description) && o.attributes.push({
|
|
2838
|
+
key: "about-this-component",
|
|
2839
|
+
value: c.description
|
|
2840
|
+
}), c) {
|
|
2841
|
+
if (c.canMove) {
|
|
2842
|
+
const p = typeof c.canMove == "function" ? c.canMove() : c.canMove;
|
|
2843
|
+
o.attributes.push({
|
|
2844
|
+
key: "can-move",
|
|
2845
|
+
value: String(p)
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
if (c.canDelete) {
|
|
2849
|
+
const p = typeof c.canDelete == "function" ? c.canDelete() : c.canDelete;
|
|
2850
|
+
o.attributes.push({
|
|
2851
|
+
key: "can-delete",
|
|
2852
|
+
value: String(p)
|
|
2853
|
+
});
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
l === "Icon" && (o.attributes = o.attributes.filter((p) => p.key !== "icon")), c && c.canAcceptBlock ? o.children && (o.children = o.children.map((p) => transformNode(p, n))) : o.children = [];
|
|
2857
|
+
}
|
|
2858
|
+
} else
|
|
2859
|
+
o.children && (o.children = o.children.map((l) => transformNode(l, n)));
|
|
2860
|
+
return o.attributes = o.attributes.filter((l) => l.key !== "data-block-type" && l.key !== "data-block-id"), o;
|
|
2861
|
+
}, useBlocksHtmlForAi = () => {
|
|
2862
|
+
const o = useSelectedBlock(), [n] = useBlocksStore(), [r] = useCanvasIframe();
|
|
2863
|
+
return useCallback(() => {
|
|
2864
|
+
var u, g;
|
|
2865
|
+
if (!r) return "";
|
|
2866
|
+
const a = o != null && o._id ? `[data-block-id="${o._id}"]` : "#canvas", l = (g = (u = r.contentDocument) == null ? void 0 : u.querySelector(a)) == null ? void 0 : g[a === "#canvas" ? "innerHTML" : "outerHTML"];
|
|
2867
|
+
if (!l) return "";
|
|
2868
|
+
const d = parse(l).map(cleanNode).filter((m) => m !== null).map((m) => transformNode(m, n));
|
|
2869
|
+
let p = stringify(d);
|
|
2870
|
+
return p = p.replace(/#styles:,/g, "#styles:"), p.replace(/\s+/g, " ").trim();
|
|
2871
|
+
}, [o, r]);
|
|
2872
|
+
}, handlei18N = (o, n) => o.map((r) => {
|
|
2873
|
+
const a = getRegisteredChaiBlock(r._type);
|
|
2874
|
+
if (!a) return r;
|
|
2875
|
+
const l = a.i18nProps;
|
|
2876
|
+
if (!l) return r;
|
|
2877
|
+
const i = filter(n, { _type: r._type }), c = pick(r, l);
|
|
2878
|
+
return each(c, (d, p) => {
|
|
2879
|
+
const u = find(i, (g) => {
|
|
2880
|
+
var x;
|
|
2881
|
+
const m = typeof g[p] == "string" ? (x = g[p]) == null ? void 0 : x.trim().toLowerCase() : JSON.stringify(g[p]), h = typeof d == "string" ? d.trim().toLowerCase() : JSON.stringify(d);
|
|
2882
|
+
return m === h;
|
|
2883
|
+
});
|
|
2884
|
+
if (u) {
|
|
2885
|
+
const g = filter(Object.keys(u), (h) => startsWith(h, `${p}-`)), m = pick(u, g);
|
|
2886
|
+
r = { ...r, ...m };
|
|
2887
|
+
}
|
|
2888
|
+
}), r;
|
|
2889
|
+
}), useHtmlToBlocks = () => {
|
|
2890
|
+
const [o] = useBlocksStore();
|
|
2891
|
+
return useCallback(
|
|
2892
|
+
(n) => {
|
|
2893
|
+
const r = syncBlocksWithDefaults(getBlocksFromHTML(n)), a = mergeBlocksWithExisting(r, o);
|
|
2894
|
+
return handlei18N(a, o);
|
|
2895
|
+
},
|
|
2896
|
+
[o]
|
|
2897
|
+
);
|
|
2898
|
+
}, getAllDescendantBlocks = (o, n) => {
|
|
2899
|
+
const r = o.filter((l) => l._parent === n), a = r.flatMap((l) => getAllDescendantBlocks(o, l._id));
|
|
2900
|
+
return [...r, ...a];
|
|
2901
|
+
}, getBlockWithNestedChildren = (o, n) => {
|
|
2902
|
+
const r = n.find((l) => l._id === o);
|
|
2903
|
+
if (!r) return [];
|
|
2904
|
+
const a = getAllDescendantBlocks(n, o);
|
|
2905
|
+
return [r, ...a];
|
|
2906
|
+
}, useI18nBlocks = () => {
|
|
2907
|
+
const o = useSelectedBlock(), [n] = useBlocksStore();
|
|
2908
|
+
return useCallback(
|
|
2909
|
+
(r = "") => {
|
|
2910
|
+
const a = o != null && o._id ? getBlockWithNestedChildren(o._id, n) : n;
|
|
2911
|
+
return a ? compact$1(
|
|
2912
|
+
a.map((l) => {
|
|
2913
|
+
const i = getRegisteredChaiBlock(l._type);
|
|
2914
|
+
if (!i) return null;
|
|
2915
|
+
const c = (i == null ? void 0 : i.i18nProps) ?? [];
|
|
2916
|
+
if (c.length === 0) return null;
|
|
2917
|
+
const d = r === "ALL" ? Object.keys(l).filter((p) => c.find((u) => p.startsWith(u))) : c.map((p) => r ? `${p}-${r}` : p);
|
|
2918
|
+
return pick$1(l, [...d, "_id"]);
|
|
2919
|
+
})
|
|
2920
|
+
) : [];
|
|
2921
|
+
},
|
|
2922
|
+
[o == null ? void 0 : o._id, n]
|
|
2923
|
+
);
|
|
2924
|
+
}, inlineEditingActiveAtom = atom("");
|
|
2791
2925
|
inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
|
|
2792
2926
|
const inlineEditingItemIndexAtom = atom(0);
|
|
2793
2927
|
inlineEditingItemIndexAtom.debugLabel = "inlineEditingItemIndexAtom";
|
|
@@ -2799,20 +2933,24 @@ const useInlineEditing = () => {
|
|
|
2799
2933
|
setEditingBlockId: n,
|
|
2800
2934
|
setEditingItemIndex: a
|
|
2801
2935
|
};
|
|
2936
|
+
}, getAllDescendantIds = (o, n) => {
|
|
2937
|
+
const r = o.filter((i) => i._parent === n), a = r.map((i) => i._id), l = r.flatMap((i) => getAllDescendantIds(o, i._id));
|
|
2938
|
+
return [...a, ...l];
|
|
2802
2939
|
}, replaceBlock = (o, n, r) => {
|
|
2803
2940
|
const a = find(o, { _id: n });
|
|
2804
2941
|
if (!a) return o;
|
|
2805
|
-
const l =
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2942
|
+
const l = o.findIndex((m) => m._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), d = o.filter((m) => !c.has(m._id)), p = new Set(r.map((m) => m._id)), u = r.map((m) => !m._parent || !p.has(m._parent) ? { ...m, _parent: a._parent } : m);
|
|
2943
|
+
return [
|
|
2944
|
+
...d.slice(0, l),
|
|
2945
|
+
...u,
|
|
2946
|
+
...d.slice(l)
|
|
2947
|
+
];
|
|
2810
2948
|
}, useReplaceBlock = () => {
|
|
2811
2949
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { setNewBlocks: r } = useBlocksStoreUndoableActions(), { hasPermission: a } = usePermissions();
|
|
2812
2950
|
return useCallback(
|
|
2813
2951
|
(l, i) => {
|
|
2814
2952
|
if (!a(PERMISSIONS.EDIT_BLOCK)) return;
|
|
2815
|
-
const c = replaceBlock(o, l, i);
|
|
2953
|
+
const c = l ? replaceBlock(o, l, i) : i;
|
|
2816
2954
|
r(c), i.length > 0 && setTimeout(() => n([i[0]._id]), 200);
|
|
2817
2955
|
},
|
|
2818
2956
|
[o, n, r, a]
|
|
@@ -2837,21 +2975,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2837
2975
|
return "VERTICAL";
|
|
2838
2976
|
}
|
|
2839
2977
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
2840
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (
|
|
2841
|
-
(
|
|
2842
|
-
isDisabledControl(g, m,
|
|
2978
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (f) => c ? get(f, "_parent") === c : !get(f, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), x = useCallback(
|
|
2979
|
+
(f) => {
|
|
2980
|
+
isDisabledControl(g, m, f) || p || (f === "UP" || f === "LEFT" ? l([i], c || null, u - 1) : (f === "DOWN" || f === "RIGHT") && l([i], c || null, u + 2), n());
|
|
2843
2981
|
},
|
|
2844
2982
|
[g, m, p, u, i, c, n]
|
|
2845
2983
|
);
|
|
2846
2984
|
return useHotkeys(
|
|
2847
2985
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2848
|
-
({ key:
|
|
2986
|
+
({ key: f }) => {
|
|
2849
2987
|
var b;
|
|
2850
|
-
|
|
2988
|
+
x((b = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
|
|
2851
2989
|
},
|
|
2852
2990
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2853
|
-
[
|
|
2854
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock:
|
|
2991
|
+
[x]
|
|
2992
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: x, orientation: h };
|
|
2855
2993
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
2856
2994
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2857
2995
|
o,
|
|
@@ -3008,8 +3146,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
|
|
|
3008
3146
|
}),
|
|
3009
3147
|
size({
|
|
3010
3148
|
boundary: u == null ? void 0 : u.body,
|
|
3011
|
-
apply({ availableWidth: b, availableHeight: y, elements:
|
|
3012
|
-
Object.assign(
|
|
3149
|
+
apply({ availableWidth: b, availableHeight: y, elements: C }) {
|
|
3150
|
+
Object.assign(C.floating.style, {
|
|
3013
3151
|
maxWidth: `${Math.max(200, b)}px`,
|
|
3014
3152
|
maxHeight: `${Math.max(100, y)}px`
|
|
3015
3153
|
});
|
|
@@ -3019,7 +3157,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
|
|
|
3019
3157
|
elements: { reference: n }
|
|
3020
3158
|
});
|
|
3021
3159
|
useResizeObserver(n, () => h(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => h(), (u == null ? void 0 : u.body) !== null);
|
|
3022
|
-
const
|
|
3160
|
+
const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
3023
3161
|
return useEffect(() => {
|
|
3024
3162
|
if (n) {
|
|
3025
3163
|
const b = setTimeout(() => h(), 500);
|
|
@@ -3042,16 +3180,16 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
|
|
|
3042
3180
|
onKeyDown: (b) => b.stopPropagation(),
|
|
3043
3181
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3044
3182
|
children: [
|
|
3045
|
-
|
|
3183
|
+
x && /* @__PURE__ */ jsx(
|
|
3046
3184
|
ArrowUpIcon,
|
|
3047
3185
|
{
|
|
3048
3186
|
className: "hover:scale-105",
|
|
3049
3187
|
onClick: () => {
|
|
3050
|
-
c([]), l([
|
|
3188
|
+
c([]), l([x]);
|
|
3051
3189
|
}
|
|
3052
3190
|
}
|
|
3053
3191
|
),
|
|
3054
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3192
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: o }),
|
|
3055
3193
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3056
3194
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3057
3195
|
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
|
|
@@ -3276,8 +3414,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3276
3414
|
i
|
|
3277
3415
|
]), useHotkeys(
|
|
3278
3416
|
"del, backspace",
|
|
3279
|
-
(
|
|
3280
|
-
|
|
3417
|
+
(x) => {
|
|
3418
|
+
x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3281
3419
|
},
|
|
3282
3420
|
h,
|
|
3283
3421
|
[n, l]
|
|
@@ -3287,7 +3425,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3287
3425
|
return useKeyEventWatcher(o), null;
|
|
3288
3426
|
}, AddBlockAtBottom = () => {
|
|
3289
3427
|
const { t: o } = useTranslation(), { hasPermission: n } = usePermissions();
|
|
3290
|
-
return n(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
|
|
3428
|
+
return n(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs("div", { id: "add-block-bottom", className: "group relative w-full cursor-pointer py-2", children: [
|
|
3291
3429
|
/* @__PURE__ */ jsx("br", {}),
|
|
3292
3430
|
/* @__PURE__ */ jsx(
|
|
3293
3431
|
"div",
|
|
@@ -3302,6 +3440,9 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3302
3440
|
] })
|
|
3303
3441
|
}
|
|
3304
3442
|
),
|
|
3443
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
3444
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
3445
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
3305
3446
|
/* @__PURE__ */ jsx("br", {})
|
|
3306
3447
|
] }) : null;
|
|
3307
3448
|
}, CssThemeVariables = ({ theme: o }) => {
|
|
@@ -3480,14 +3621,14 @@ const RteDropdownMenu = ({
|
|
|
3480
3621
|
}) => {
|
|
3481
3622
|
const { document: i } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1), g = useRef(null);
|
|
3482
3623
|
if (useEffect(() => {
|
|
3483
|
-
var
|
|
3624
|
+
var C, v;
|
|
3484
3625
|
if (!p) {
|
|
3485
3626
|
d({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
|
|
3486
3627
|
return;
|
|
3487
3628
|
}
|
|
3488
|
-
const m = (
|
|
3489
|
-
let
|
|
3490
|
-
(h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (
|
|
3629
|
+
const m = (C = g.current) == null ? void 0 : C.getBoundingClientRect(), h = (v = l.current) == null ? void 0 : v.getBoundingClientRect();
|
|
3630
|
+
let x = m == null ? void 0 : m.left, f = (m == null ? void 0 : m.bottom) + 4, b, y;
|
|
3631
|
+
(h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (x = void 0, b = i.body.offsetWidth - (m == null ? void 0 : m.right)), f + 202 >= i.body.clientHeight && (f = null, y = i.body.clientHeight - (m == null ? void 0 : m.bottom) + (h == null ? void 0 : h.height)), d({ left: x, top: f, right: b, bottom: y });
|
|
3491
3632
|
}, [p]), a === "canvas") {
|
|
3492
3633
|
const m = () => {
|
|
3493
3634
|
u(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
|
|
@@ -3521,7 +3662,7 @@ const RteDropdownMenu = ({
|
|
|
3521
3662
|
] });
|
|
3522
3663
|
}
|
|
3523
3664
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { open: p, onOpenChange: u, children: [
|
|
3524
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { className: "relative outline-none", children: n }),
|
|
3665
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { className: "relative outline-none", asChild: !0, children: n }),
|
|
3525
3666
|
/* @__PURE__ */ jsx(DropdownMenuContent, { className: "z-50 rounded-md border bg-white p-1 text-xs shadow-xl", children: p && (typeof r == "function" ? r(() => u(!1)) : r) })
|
|
3526
3667
|
] }) });
|
|
3527
3668
|
};
|
|
@@ -3594,7 +3735,7 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3594
3735
|
onRemoveHighlightColor: i,
|
|
3595
3736
|
onClose: c
|
|
3596
3737
|
}) => {
|
|
3597
|
-
const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, g = Object.values(u).map((
|
|
3738
|
+
const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, g = Object.values(u).map((x) => get(x, d ? "1" : "0")), [m, h] = useState("TEXT");
|
|
3598
3739
|
return /* @__PURE__ */ jsxs("div", { id: "rte-widget-color-picker", className: "px-1", children: [
|
|
3599
3740
|
/* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between rounded-md border bg-muted", children: [
|
|
3600
3741
|
/* @__PURE__ */ jsx(
|
|
@@ -3635,11 +3776,11 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3635
3776
|
)
|
|
3636
3777
|
] });
|
|
3637
3778
|
}, RteColorPicker = ({ editor: o, from: n, menuRef: r }) => {
|
|
3638
|
-
var
|
|
3639
|
-
const a = (
|
|
3640
|
-
|
|
3641
|
-
},
|
|
3642
|
-
|
|
3779
|
+
var v, j;
|
|
3780
|
+
const a = (v = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : v.color, l = (j = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : j.color, [i, c] = useState(a || "#000000F2"), [d, p] = useState(l || "#00000057"), [u, g] = useDebouncedState(i, 150), [m, h] = useDebouncedState(d, 150), x = (_, B) => {
|
|
3781
|
+
B ? (c(_), g(_)) : (o == null || o.chain().setColor(_).run(), c(_));
|
|
3782
|
+
}, f = (_, B) => {
|
|
3783
|
+
B ? (p(_), h(_)) : (o == null || o.chain().setHighlight({ color: _ }).run(), p(_));
|
|
3643
3784
|
}, b = () => {
|
|
3644
3785
|
o == null || o.chain().unsetColor().run(), c("#000000F2");
|
|
3645
3786
|
}, y = () => {
|
|
@@ -3674,8 +3815,8 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3674
3815
|
{
|
|
3675
3816
|
textColor: i,
|
|
3676
3817
|
highlightColor: d,
|
|
3677
|
-
onChangeTextColor:
|
|
3678
|
-
onChangeHighlightColor:
|
|
3818
|
+
onChangeTextColor: x,
|
|
3819
|
+
onChangeHighlightColor: f,
|
|
3679
3820
|
onRemoveTextColor: b,
|
|
3680
3821
|
onRemoveHighlightColor: y,
|
|
3681
3822
|
onClose: _
|
|
@@ -3947,10 +4088,10 @@ const RichTextEditor = memo(
|
|
|
3947
4088
|
placeholder: "Enter text here",
|
|
3948
4089
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3949
4090
|
onBlur: ({ editor: u, event: g }) => {
|
|
3950
|
-
const m = g == null ? void 0 : g.relatedTarget, h = i.querySelector(".ProseMirror"),
|
|
3951
|
-
if (!b && !y && !
|
|
3952
|
-
const
|
|
3953
|
-
r(
|
|
4091
|
+
const m = g == null ? void 0 : g.relatedTarget, h = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = i.querySelector("#chai-rich-text-menu-bar"), b = h == null ? void 0 : h.contains(m), y = x == null ? void 0 : x.contains(m), C = f == null ? void 0 : f.contains(m), v = window.document.getElementById("rte-widget-color-picker");
|
|
4092
|
+
if (!b && !y && !C && !v) {
|
|
4093
|
+
const j = (u == null ? void 0 : u.getHTML()) || "";
|
|
4094
|
+
r(j);
|
|
3954
4095
|
}
|
|
3955
4096
|
},
|
|
3956
4097
|
from: "canvas"
|
|
@@ -4000,14 +4141,14 @@ const RichTextEditor = memo(
|
|
|
4000
4141
|
useEffect(() => {
|
|
4001
4142
|
if (a.current) {
|
|
4002
4143
|
a.current.innerHTML = n, a.current.focus();
|
|
4003
|
-
const h = c.createRange(),
|
|
4004
|
-
h.selectNodeContents(a.current), h.collapse(!1),
|
|
4144
|
+
const h = c.createRange(), x = d.getSelection();
|
|
4145
|
+
h.selectNodeContents(a.current), h.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(h), a.current.focus();
|
|
4005
4146
|
} else
|
|
4006
4147
|
r();
|
|
4007
4148
|
}, [c, d]);
|
|
4008
4149
|
const p = useMemo(() => {
|
|
4009
|
-
var
|
|
4010
|
-
const h = ((
|
|
4150
|
+
var x;
|
|
4151
|
+
const h = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
|
|
4011
4152
|
return h === "button" ? "div" : h;
|
|
4012
4153
|
}, [o]), u = useCallback(
|
|
4013
4154
|
(h) => {
|
|
@@ -4023,12 +4164,12 @@ const RichTextEditor = memo(
|
|
|
4023
4164
|
contentEditable: !0,
|
|
4024
4165
|
className: `${((h = o == null ? void 0 : o.className) == null ? void 0 : h.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
|
|
4025
4166
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
4026
|
-
onInput: (
|
|
4027
|
-
const
|
|
4028
|
-
|
|
4167
|
+
onInput: (x) => {
|
|
4168
|
+
const f = x.target;
|
|
4169
|
+
f && (f.innerText.trim() === "" ? (f.setAttribute("data-placeholder", "Enter text here"), f.children.length > 0 && f.children[0].remove()) : x.target.removeAttribute("data-placeholder"), l(x.target.innerText));
|
|
4029
4170
|
},
|
|
4030
|
-
onClick: (
|
|
4031
|
-
|
|
4171
|
+
onClick: (x) => {
|
|
4172
|
+
x.stopPropagation(), x.preventDefault();
|
|
4032
4173
|
}
|
|
4033
4174
|
};
|
|
4034
4175
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
@@ -4041,62 +4182,62 @@ const RichTextEditor = memo(
|
|
|
4041
4182
|
}
|
|
4042
4183
|
), WithBlockTextEditor = memo(
|
|
4043
4184
|
({ block: o, children: n }) => {
|
|
4044
|
-
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang:
|
|
4185
|
+
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: C, blockType: v } = useMemo(() => {
|
|
4045
4186
|
var E;
|
|
4046
4187
|
const k = o._type;
|
|
4047
4188
|
let I = o[r];
|
|
4048
4189
|
const A = getRegisteredChaiBlock(o._type);
|
|
4049
|
-
return
|
|
4050
|
-
}, [o,
|
|
4190
|
+
return x && ((E = A == null ? void 0 : A.i18nProps) == null ? void 0 : E.includes(r)) && has(o, `${r}-${x}`) && (I = get(o, `${r}-${x}`)), { blockContent: I, blockType: k };
|
|
4191
|
+
}, [o, x]), j = useCallback(
|
|
4051
4192
|
(k) => {
|
|
4052
4193
|
var A;
|
|
4053
4194
|
const I = k || ((A = g.current) == null ? void 0 : A.innerText);
|
|
4054
|
-
h([y], { [r]: I }), u(null), c(null), d(-1),
|
|
4195
|
+
h([y], { [r]: I }), u(null), c(null), d(-1), f([]), y && setTimeout(() => f([y]), 100);
|
|
4055
4196
|
},
|
|
4056
|
-
[y, h, c,
|
|
4197
|
+
[y, h, c, f, x]
|
|
4057
4198
|
), _ = useDebouncedCallback(
|
|
4058
4199
|
(k) => {
|
|
4059
4200
|
h([y], { [r]: k });
|
|
4060
4201
|
},
|
|
4061
|
-
[y, o, h,
|
|
4202
|
+
[y, o, h, x],
|
|
4062
4203
|
1e3
|
|
4063
|
-
),
|
|
4204
|
+
), B = useCallback(
|
|
4064
4205
|
(k) => {
|
|
4065
|
-
k.preventDefault(), y && (b.current = y),
|
|
4206
|
+
k.preventDefault(), y && (b.current = y), j(), setTimeout(() => {
|
|
4066
4207
|
const I = b.current;
|
|
4067
|
-
b.current = null,
|
|
4208
|
+
b.current = null, f([I]);
|
|
4068
4209
|
}, 100);
|
|
4069
4210
|
},
|
|
4070
|
-
[
|
|
4211
|
+
[f, y, x]
|
|
4071
4212
|
);
|
|
4072
4213
|
useEffect(() => {
|
|
4073
|
-
var
|
|
4214
|
+
var w;
|
|
4074
4215
|
if (!y) return;
|
|
4075
4216
|
const k = `[data-block-id="${y}"]`, I = i >= 0 ? `[data-block-index="${i}"]` : "", A = a.querySelector(`${k}${I}`);
|
|
4076
|
-
A && ((
|
|
4077
|
-
}, [y,
|
|
4078
|
-
const
|
|
4217
|
+
A && ((w = A == null ? void 0 : A.classList) == null || w.add("sr-only"), u(A));
|
|
4218
|
+
}, [y, v, a, i]);
|
|
4219
|
+
const S = useMemo(() => p ? (m(), ["RichText", "Paragraph"].includes(v) ? /* @__PURE__ */ jsx(
|
|
4079
4220
|
RichTextEditor,
|
|
4080
4221
|
{
|
|
4081
|
-
blockContent:
|
|
4222
|
+
blockContent: C,
|
|
4082
4223
|
editingElement: p,
|
|
4083
4224
|
onChange: _,
|
|
4084
|
-
onClose:
|
|
4085
|
-
onEscape:
|
|
4225
|
+
onClose: j,
|
|
4226
|
+
onEscape: B
|
|
4086
4227
|
}
|
|
4087
4228
|
) : /* @__PURE__ */ jsx(
|
|
4088
4229
|
MemoizedEditor,
|
|
4089
4230
|
{
|
|
4090
4231
|
editorRef: g,
|
|
4091
|
-
blockContent:
|
|
4232
|
+
blockContent: C,
|
|
4092
4233
|
editingElement: p,
|
|
4093
|
-
onClose:
|
|
4234
|
+
onClose: j,
|
|
4094
4235
|
onChange: _,
|
|
4095
|
-
onEscape:
|
|
4236
|
+
onEscape: B
|
|
4096
4237
|
}
|
|
4097
|
-
)) : null, [p, y,
|
|
4238
|
+
)) : null, [p, y, v, C, j, x]);
|
|
4098
4239
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4099
|
-
|
|
4240
|
+
S,
|
|
4100
4241
|
n
|
|
4101
4242
|
] });
|
|
4102
4243
|
},
|
|
@@ -4129,23 +4270,23 @@ const RichTextEditor = memo(
|
|
|
4129
4270
|
blockAtom: n,
|
|
4130
4271
|
children: r
|
|
4131
4272
|
}) => {
|
|
4132
|
-
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index:
|
|
4273
|
+
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: x, key: f } = useContext(RepeaterContext), b = useMemo(
|
|
4133
4274
|
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
4134
|
-
index:
|
|
4135
|
-
key:
|
|
4275
|
+
index: x,
|
|
4276
|
+
key: f
|
|
4136
4277
|
}) : applyLanguage(i, d, c),
|
|
4137
|
-
[i, d, c, g, m,
|
|
4138
|
-
), y = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]),
|
|
4278
|
+
[i, d, c, g, m, x, f]
|
|
4279
|
+
), y = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), C = useMemo(
|
|
4139
4280
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
4140
4281
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
4141
|
-
),
|
|
4282
|
+
), v = useMemo(
|
|
4142
4283
|
() => ({
|
|
4143
|
-
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index":
|
|
4284
|
+
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": x },
|
|
4144
4285
|
inBuilder: !0,
|
|
4145
4286
|
lang: d || p,
|
|
4146
4287
|
...b,
|
|
4147
4288
|
...y,
|
|
4148
|
-
...
|
|
4289
|
+
...C,
|
|
4149
4290
|
...o
|
|
4150
4291
|
}),
|
|
4151
4292
|
[
|
|
@@ -4155,13 +4296,13 @@ const RichTextEditor = memo(
|
|
|
4155
4296
|
p,
|
|
4156
4297
|
b,
|
|
4157
4298
|
y,
|
|
4158
|
-
|
|
4299
|
+
C,
|
|
4159
4300
|
o
|
|
4160
4301
|
]
|
|
4161
|
-
),
|
|
4302
|
+
), j = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), _ = useMemo(() => get(i, "_show", !0), [i]);
|
|
4162
4303
|
if (isNull(h) || !_) return null;
|
|
4163
|
-
let
|
|
4164
|
-
...
|
|
4304
|
+
let B = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
|
|
4305
|
+
...v,
|
|
4165
4306
|
children: r({
|
|
4166
4307
|
_id: i._id,
|
|
4167
4308
|
_type: i._type,
|
|
@@ -4173,8 +4314,8 @@ const RichTextEditor = memo(
|
|
|
4173
4314
|
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
4174
4315
|
})
|
|
4175
4316
|
}) });
|
|
4176
|
-
const
|
|
4177
|
-
return
|
|
4317
|
+
const S = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: B }) : B;
|
|
4318
|
+
return j ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: S }) : S;
|
|
4178
4319
|
}, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
|
|
4179
4320
|
const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
4180
4321
|
(d) => {
|
|
@@ -4217,7 +4358,7 @@ const RichTextEditor = memo(
|
|
|
4217
4358
|
);
|
|
4218
4359
|
return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (d) => {
|
|
4219
4360
|
const p = l(d._id);
|
|
4220
|
-
return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: m, partialBlockId: h, repeaterItems:
|
|
4361
|
+
return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: m, partialBlockId: h, repeaterItems: x, $repeaterItemsKey: f }) => m === "Repeater" ? isArray(x) && x.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) }, `${g}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) : null }) }, d._id) : null;
|
|
4221
4362
|
});
|
|
4222
4363
|
}, PageBlocksRenderer = () => {
|
|
4223
4364
|
const [o] = useBlocksStore();
|
|
@@ -4283,16 +4424,16 @@ const CanvasEventsWatcher = () => {
|
|
|
4283
4424
|
l(), o([]), r([]);
|
|
4284
4425
|
}), null;
|
|
4285
4426
|
}, StaticCanvas = () => {
|
|
4286
|
-
const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] =
|
|
4427
|
+
const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useCanvasIframe(), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
|
|
4287
4428
|
(h) => {
|
|
4288
|
-
i((
|
|
4429
|
+
i((x) => ({ ...x, width: h }));
|
|
4289
4430
|
},
|
|
4290
4431
|
[i]
|
|
4291
4432
|
);
|
|
4292
4433
|
useEffect(() => {
|
|
4293
4434
|
if (!a.current) return;
|
|
4294
|
-
const { clientWidth: h, clientHeight:
|
|
4295
|
-
i({ width: h, height:
|
|
4435
|
+
const { clientWidth: h, clientHeight: x } = a.current;
|
|
4436
|
+
i({ width: h, height: x });
|
|
4296
4437
|
}, [a, o]);
|
|
4297
4438
|
const m = useMemo(() => {
|
|
4298
4439
|
let h = IframeInitialContent;
|
|
@@ -4320,10 +4461,7 @@ const CanvasEventsWatcher = () => {
|
|
|
4320
4461
|
/* @__PURE__ */ jsxs(Provider$1, { children: [
|
|
4321
4462
|
/* @__PURE__ */ jsxs(Canvas, { children: [
|
|
4322
4463
|
p ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
|
|
4323
|
-
/* @__PURE__ */ jsx(AddBlockAtBottom, {})
|
|
4324
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
4325
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
4326
|
-
/* @__PURE__ */ jsx("br", {})
|
|
4464
|
+
/* @__PURE__ */ jsx(AddBlockAtBottom, {})
|
|
4327
4465
|
] }),
|
|
4328
4466
|
/* @__PURE__ */ jsx(CanvasEventsWatcher, {})
|
|
4329
4467
|
] }),
|
|
@@ -4345,7 +4483,7 @@ const CanvasEventsWatcher = () => {
|
|
|
4345
4483
|
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
|
|
4346
4484
|
/* @__PURE__ */ jsx("p", { children: o("Please try again.") })
|
|
4347
4485
|
] }) });
|
|
4348
|
-
}, CodeEditor$1 = React__default.lazy(() => import("./code-editor-
|
|
4486
|
+
}, CodeEditor$1 = React__default.lazy(() => import("./code-editor-DHjchara.js")), CanvasArea = () => {
|
|
4349
4487
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
4350
4488
|
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: [
|
|
4351
4489
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -4373,7 +4511,7 @@ const CanvasEventsWatcher = () => {
|
|
|
4373
4511
|
}, useBlockSettingComponents = (o) => Object.values(RJSF_EXTENSIONS).filter((n) => n.type === o).reduce(
|
|
4374
4512
|
(n, r) => (n[r.id] = r.component, n),
|
|
4375
4513
|
{}
|
|
4376
|
-
), IconPicker = lazy(() => import("./IconPicker-
|
|
4514
|
+
), IconPicker = lazy(() => import("./IconPicker-DB-dcym6.js").then((o) => ({ default: o.IconPicker }))), sanitizeSvg = (o) => {
|
|
4377
4515
|
try {
|
|
4378
4516
|
let n = o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
|
|
4379
4517
|
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();
|
|
@@ -4414,8 +4552,8 @@ const CanvasEventsWatcher = () => {
|
|
|
4414
4552
|
] })
|
|
4415
4553
|
] });
|
|
4416
4554
|
}, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
|
|
4417
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (
|
|
4418
|
-
if (!
|
|
4555
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (x) => {
|
|
4556
|
+
if (!x.trim()) {
|
|
4419
4557
|
p(!1), g("Please enter a URL");
|
|
4420
4558
|
return;
|
|
4421
4559
|
}
|
|
@@ -4439,7 +4577,7 @@ const CanvasEventsWatcher = () => {
|
|
|
4439
4577
|
{
|
|
4440
4578
|
placeholder: h(`Enter ${r} URL`),
|
|
4441
4579
|
value: a,
|
|
4442
|
-
onChange: (
|
|
4580
|
+
onChange: (x) => l(x.target.value),
|
|
4443
4581
|
onKeyUp: () => m(a)
|
|
4444
4582
|
}
|
|
4445
4583
|
),
|
|
@@ -4484,42 +4622,42 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4484
4622
|
const n = ((l = o.split("/").pop()) == null ? void 0 : l.split("?")[0]) || "";
|
|
4485
4623
|
return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((i) => n.toLowerCase().endsWith(i)) ? n : "";
|
|
4486
4624
|
}, ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
4487
|
-
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", g = i ? `_${u}Id-${i}` : `_${u}Id`, m = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, g, m ? c == null ? void 0 : c.assetId : ""),
|
|
4625
|
+
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", g = i ? `_${u}Id-${i}` : `_${u}Id`, m = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, g, m ? c == null ? void 0 : c.assetId : ""), x = useMemo(() => {
|
|
4488
4626
|
if (!o || !c || !/\{\{.*?\}\}/.test(o)) return o;
|
|
4489
|
-
const
|
|
4627
|
+
const j = { ...c, [u]: o }, _ = applyBindingToBlockProps(j, p, { index: -1, key: "" });
|
|
4490
4628
|
return get(_, u, o);
|
|
4491
|
-
}, [o, c, p, u]),
|
|
4492
|
-
const
|
|
4493
|
-
if (
|
|
4494
|
-
n(
|
|
4495
|
-
const _ =
|
|
4629
|
+
}, [o, c, p, u]), f = !!h || x !== PLACEHOLDER_IMAGE, b = (v) => {
|
|
4630
|
+
const j = isArray(v) ? first(v) : v;
|
|
4631
|
+
if (j) {
|
|
4632
|
+
n(j == null ? void 0 : j.url);
|
|
4633
|
+
const _ = j == null ? void 0 : j.width, B = j == null ? void 0 : j.height, S = g.includes("mobile");
|
|
4496
4634
|
if (c != null && c._id) {
|
|
4497
4635
|
const k = {
|
|
4498
|
-
..._ && { [
|
|
4499
|
-
...
|
|
4500
|
-
...
|
|
4636
|
+
..._ && { [S ? "mobileWidth" : "width"]: _ },
|
|
4637
|
+
...B && { [S ? "mobileHeight" : "height"]: B },
|
|
4638
|
+
...j.description && { alt: j.description }
|
|
4501
4639
|
};
|
|
4502
|
-
if (set(k, g,
|
|
4640
|
+
if (set(k, g, j.id), isEmpty(k)) return;
|
|
4503
4641
|
d([c._id], k);
|
|
4504
4642
|
}
|
|
4505
4643
|
}
|
|
4506
4644
|
}, y = useCallback(() => {
|
|
4507
4645
|
if (n(PLACEHOLDER_IMAGE), c != null && c._id) {
|
|
4508
|
-
const
|
|
4509
|
-
set(
|
|
4646
|
+
const v = {}, j = g.includes("mobile");
|
|
4647
|
+
set(v, g, ""), set(v, j ? "mobileWidth" : "width", ""), set(v, j ? "mobileHeight" : "height", ""), d([c._id], v);
|
|
4510
4648
|
}
|
|
4511
|
-
}, [n, c == null ? void 0 : c._id, d, g]),
|
|
4649
|
+
}, [n, c == null ? void 0 : c._id, d, g]), C = getFileName(x);
|
|
4512
4650
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-start gap-x-3", children: [
|
|
4513
|
-
|
|
4651
|
+
x ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
|
|
4514
4652
|
/* @__PURE__ */ jsx(
|
|
4515
4653
|
"img",
|
|
4516
4654
|
{
|
|
4517
|
-
src:
|
|
4655
|
+
src: x,
|
|
4518
4656
|
className: "h-14 w-14 overflow-hidden rounded-md border border-border object-cover transition duration-200 " + (h && h !== "" ? "cursor-pointer group-hover:blur-sm" : ""),
|
|
4519
4657
|
alt: ""
|
|
4520
4658
|
}
|
|
4521
4659
|
),
|
|
4522
|
-
|
|
4660
|
+
f && /* @__PURE__ */ jsx(
|
|
4523
4661
|
"button",
|
|
4524
4662
|
{
|
|
4525
4663
|
type: "button",
|
|
@@ -4539,8 +4677,8 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4539
4677
|
] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, mode: "image", assetId: h, children: /* @__PURE__ */ jsx("div", { className: "h-14 w-14 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
|
|
4540
4678
|
/* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
|
|
4541
4679
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4542
|
-
/* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children:
|
|
4543
|
-
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 mb-1 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: !isEmpty(
|
|
4680
|
+
/* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children: C }),
|
|
4681
|
+
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 mb-1 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: !isEmpty(x) && x !== PLACEHOLDER_IMAGE ? l("Replace image") : l("Choose image") }) }),
|
|
4544
4682
|
/* @__PURE__ */ jsx("div", { className: "text-center text-xs text-gray-400", children: "OR" })
|
|
4545
4683
|
] }),
|
|
4546
4684
|
/* @__PURE__ */ jsx(
|
|
@@ -4554,8 +4692,8 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4554
4692
|
className: "h-6 text-xs",
|
|
4555
4693
|
placeholder: l("Enter image URL"),
|
|
4556
4694
|
value: o === PLACEHOLDER_IMAGE ? "" : o,
|
|
4557
|
-
onBlur: ({ target: { value:
|
|
4558
|
-
onChange: (
|
|
4695
|
+
onBlur: ({ target: { value: v } }) => a(r, v),
|
|
4696
|
+
onChange: (v) => n(v.target.value)
|
|
4559
4697
|
}
|
|
4560
4698
|
)
|
|
4561
4699
|
] })
|
|
@@ -4563,14 +4701,14 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4563
4701
|
}, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
|
|
4564
4702
|
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
|
|
4565
4703
|
(m) => {
|
|
4566
|
-
const h = (
|
|
4567
|
-
m.type === "object" ? (l((
|
|
4704
|
+
const h = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
|
|
4705
|
+
m.type === "object" ? (l((x) => [...x, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
|
|
4568
4706
|
},
|
|
4569
4707
|
[a, n, r]
|
|
4570
4708
|
), u = React__default.useCallback(() => {
|
|
4571
4709
|
if (a.length > 0) {
|
|
4572
4710
|
const m = a.slice(0, -1);
|
|
4573
|
-
l(m), c(m.reduce((h,
|
|
4711
|
+
l(m), c(m.reduce((h, x) => h[x], o));
|
|
4574
4712
|
}
|
|
4575
4713
|
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: d(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
|
|
4576
4714
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
@@ -4663,7 +4801,7 @@ const DataBindingSelector = ({
|
|
|
4663
4801
|
}) => {
|
|
4664
4802
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4665
4803
|
if (i.length === 1) return "";
|
|
4666
|
-
const g = i.find((
|
|
4804
|
+
const g = i.find((x) => x._type === "Repeater"), h = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4667
4805
|
return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${g._id}` : h}`;
|
|
4668
4806
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4669
4807
|
(g, m) => {
|
|
@@ -4671,43 +4809,43 @@ const DataBindingSelector = ({
|
|
|
4671
4809
|
n(`{{${g}}}`, {}, r);
|
|
4672
4810
|
return;
|
|
4673
4811
|
}
|
|
4674
|
-
const h = (y) => /[.,!?;:]/.test(y),
|
|
4675
|
-
let
|
|
4676
|
-
const
|
|
4677
|
-
return
|
|
4678
|
-
text:
|
|
4679
|
-
prefixLength:
|
|
4812
|
+
const h = (y) => /[.,!?;:]/.test(y), x = (y, C, v) => {
|
|
4813
|
+
let j = "", _ = "";
|
|
4814
|
+
const B = C > 0 ? y[C - 1] : "", S = C < y.length ? y[C] : "";
|
|
4815
|
+
return C > 0 && (B === "." || !h(B) && B !== " ") && (j = " "), C < y.length && !h(S) && S !== " " && (_ = " "), {
|
|
4816
|
+
text: j + v + _,
|
|
4817
|
+
prefixLength: j.length,
|
|
4680
4818
|
suffixLength: _.length
|
|
4681
4819
|
};
|
|
4682
|
-
},
|
|
4683
|
-
if (!
|
|
4820
|
+
}, f = document.getElementById(r);
|
|
4821
|
+
if (!f) return;
|
|
4684
4822
|
const b = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
|
|
4685
4823
|
if (b && (b.querySelector(".ProseMirror") || b.__chaiRTE)) {
|
|
4686
4824
|
const y = b.__chaiRTE;
|
|
4687
4825
|
if (y) {
|
|
4688
|
-
const
|
|
4826
|
+
const C = `{{${g}}}`;
|
|
4689
4827
|
y.commands.focus();
|
|
4690
|
-
const { from:
|
|
4691
|
-
if (
|
|
4692
|
-
y.chain().deleteSelection().insertContent(
|
|
4828
|
+
const { from: v, to: j } = y.state.selection;
|
|
4829
|
+
if (v !== j)
|
|
4830
|
+
y.chain().deleteSelection().insertContent(C).run();
|
|
4693
4831
|
else {
|
|
4694
|
-
const { state:
|
|
4832
|
+
const { state: B } = y, S = B.selection.from, k = B.doc.textBetween(Math.max(0, S - 1), S), I = B.doc.textBetween(S, Math.min(S + 1, B.doc.content.size));
|
|
4695
4833
|
let A = "";
|
|
4696
|
-
|
|
4697
|
-
let
|
|
4698
|
-
I && I !== " " && !h(I) && (
|
|
4834
|
+
S > 0 && k !== " " && !h(k) && (A = " ");
|
|
4835
|
+
let w = "";
|
|
4836
|
+
I && I !== " " && !h(I) && (w = " "), y.chain().insertContent(A + C + w).run();
|
|
4699
4837
|
}
|
|
4700
4838
|
setTimeout(() => n(y.getHTML(), {}, r), 100);
|
|
4701
4839
|
return;
|
|
4702
4840
|
}
|
|
4703
4841
|
} else {
|
|
4704
|
-
const y =
|
|
4705
|
-
if (
|
|
4706
|
-
const I = `{{${g}}}`, { text: A } =
|
|
4707
|
-
n(
|
|
4842
|
+
const y = f, C = y.selectionStart || 0, v = y.value || "", j = y.selectionEnd || C;
|
|
4843
|
+
if (j > C) {
|
|
4844
|
+
const I = `{{${g}}}`, { text: A } = x(v, C, I), w = v.slice(0, C) + A + v.slice(j);
|
|
4845
|
+
n(w, {}, r);
|
|
4708
4846
|
return;
|
|
4709
4847
|
}
|
|
4710
|
-
const
|
|
4848
|
+
const B = `{{${g}}}`, { text: S } = x(v, C, B), k = v.slice(0, C) + S + v.slice(C);
|
|
4711
4849
|
n(k, {}, r);
|
|
4712
4850
|
}
|
|
4713
4851
|
},
|
|
@@ -4730,57 +4868,57 @@ const DataBindingSelector = ({
|
|
|
4730
4868
|
onChange: r
|
|
4731
4869
|
}) => {
|
|
4732
4870
|
var I;
|
|
4733
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (A,
|
|
4871
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (A, w) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [x, f] = useState([]), [b, y] = useState(-1), C = useRef(null), v = (I = n == null ? void 0 : n.find((A) => A.key === u)) == null ? void 0 : I.name;
|
|
4734
4872
|
useEffect(() => {
|
|
4735
|
-
if (h(""),
|
|
4736
|
-
const A = split(o, ":"),
|
|
4737
|
-
g(
|
|
4738
|
-
const E = await l(
|
|
4873
|
+
if (h(""), f([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4874
|
+
const A = split(o, ":"), w = get(A, 1, "page") || "page";
|
|
4875
|
+
g(w), (async () => {
|
|
4876
|
+
const E = await l(w, [get(A, 2, "page")]);
|
|
4739
4877
|
E && Array.isArray(E) && h(get(E, [0, "name"], ""));
|
|
4740
4878
|
})();
|
|
4741
4879
|
}, [o]);
|
|
4742
|
-
const
|
|
4880
|
+
const j = useDebouncedCallback(
|
|
4743
4881
|
async (A) => {
|
|
4744
4882
|
if (isEmpty(A))
|
|
4745
|
-
|
|
4883
|
+
f([]);
|
|
4746
4884
|
else {
|
|
4747
|
-
const
|
|
4748
|
-
|
|
4885
|
+
const w = await l(u, A);
|
|
4886
|
+
f(w);
|
|
4749
4887
|
}
|
|
4750
4888
|
c(!1), y(-1);
|
|
4751
4889
|
},
|
|
4752
4890
|
[u],
|
|
4753
4891
|
300
|
|
4754
4892
|
), _ = (A) => {
|
|
4755
|
-
const
|
|
4756
|
-
|
|
4757
|
-
},
|
|
4893
|
+
const w = ["pageType", u, A.id];
|
|
4894
|
+
w[1] && (r(w.join(":")), h(A.name), p(!1), f([]), y(-1));
|
|
4895
|
+
}, B = (A) => {
|
|
4758
4896
|
switch (A.key) {
|
|
4759
4897
|
case "ArrowDown":
|
|
4760
|
-
A.preventDefault(), y((
|
|
4898
|
+
A.preventDefault(), y((w) => w < x.length - 1 ? w + 1 : w);
|
|
4761
4899
|
break;
|
|
4762
4900
|
case "ArrowUp":
|
|
4763
|
-
A.preventDefault(), y((
|
|
4901
|
+
A.preventDefault(), y((w) => w > 0 ? w - 1 : w);
|
|
4764
4902
|
break;
|
|
4765
4903
|
case "Enter":
|
|
4766
|
-
if (A.preventDefault(),
|
|
4767
|
-
b >= 0 && _(
|
|
4904
|
+
if (A.preventDefault(), x.length === 0) return;
|
|
4905
|
+
b >= 0 && _(x[b]);
|
|
4768
4906
|
break;
|
|
4769
4907
|
case "Escape":
|
|
4770
|
-
A.preventDefault(),
|
|
4908
|
+
A.preventDefault(), S();
|
|
4771
4909
|
break;
|
|
4772
4910
|
}
|
|
4773
4911
|
};
|
|
4774
4912
|
useEffect(() => {
|
|
4775
|
-
if (b >= 0 &&
|
|
4776
|
-
const A =
|
|
4913
|
+
if (b >= 0 && C.current) {
|
|
4914
|
+
const A = C.current.children[b];
|
|
4777
4915
|
A == null || A.scrollIntoView({ block: "nearest" });
|
|
4778
4916
|
}
|
|
4779
4917
|
}, [b]);
|
|
4780
|
-
const
|
|
4781
|
-
h(""),
|
|
4918
|
+
const S = () => {
|
|
4919
|
+
h(""), f([]), y(-1), p(!1), r("");
|
|
4782
4920
|
}, k = (A) => {
|
|
4783
|
-
h(A), p(!isEmpty(A)), c(!0),
|
|
4921
|
+
h(A), p(!isEmpty(A)), c(!0), j(A);
|
|
4784
4922
|
};
|
|
4785
4923
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4786
4924
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (A) => g(A.target.value), children: map(n, (A) => /* @__PURE__ */ jsx("option", { value: A.key, children: A.name }, A.key)) }),
|
|
@@ -4791,26 +4929,26 @@ const DataBindingSelector = ({
|
|
|
4791
4929
|
type: "text",
|
|
4792
4930
|
value: m,
|
|
4793
4931
|
onChange: (A) => k(A.target.value),
|
|
4794
|
-
onKeyDown:
|
|
4795
|
-
placeholder: a(`Search ${
|
|
4932
|
+
onKeyDown: B,
|
|
4933
|
+
placeholder: a(`Search ${v ?? ""}`),
|
|
4796
4934
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4797
4935
|
}
|
|
4798
4936
|
),
|
|
4799
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick:
|
|
4937
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
|
|
4800
4938
|
] }),
|
|
4801
|
-
(i || !isEmpty(
|
|
4939
|
+
(i || !isEmpty(x) || d && isEmpty(x)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4802
4940
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4803
4941
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4804
|
-
] }) : d && isEmpty(
|
|
4942
|
+
] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4805
4943
|
a("No results found for"),
|
|
4806
4944
|
' "',
|
|
4807
4945
|
m,
|
|
4808
4946
|
'"'
|
|
4809
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4947
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: C, children: map(x == null ? void 0 : x.slice(0, 20), (A, w) => /* @__PURE__ */ jsxs(
|
|
4810
4948
|
"li",
|
|
4811
4949
|
{
|
|
4812
4950
|
onClick: () => _(A),
|
|
4813
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(A.id) ? "bg-blue-200" :
|
|
4951
|
+
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"}`,
|
|
4814
4952
|
children: [
|
|
4815
4953
|
A.name,
|
|
4816
4954
|
" ",
|
|
@@ -4828,19 +4966,19 @@ const DataBindingSelector = ({
|
|
|
4828
4966
|
const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: g, languages: m } = useLanguages(), h = useMemo(
|
|
4829
4967
|
() => isEmpty(m) ? "" : isEmpty(u) ? g : u,
|
|
4830
4968
|
[m, u, g]
|
|
4831
|
-
),
|
|
4969
|
+
), x = useMemo(() => get(LANGUAGES, h, h), [h]), f = i === "pageType" && isEmpty(p) ? "url" : i;
|
|
4832
4970
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4833
4971
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-x-2 text-xs font-medium", children: [
|
|
4834
4972
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
4835
4973
|
(o == null ? void 0 : o.title) ?? "Link",
|
|
4836
|
-
/* @__PURE__ */ jsx("span", { className: "pl-1 text-[9px] text-zinc-400", children:
|
|
4974
|
+
/* @__PURE__ */ jsx("span", { className: "pl-1 text-[9px] text-zinc-400", children: x })
|
|
4837
4975
|
] }),
|
|
4838
4976
|
/* @__PURE__ */ jsx(
|
|
4839
4977
|
DataBindingSelector,
|
|
4840
4978
|
{
|
|
4841
4979
|
schema: o,
|
|
4842
4980
|
onChange: (b) => {
|
|
4843
|
-
r({ ...n, href: b, ...
|
|
4981
|
+
r({ ...n, href: b, ...f === "pageType" ? { type: "url" } : {} });
|
|
4844
4982
|
},
|
|
4845
4983
|
id: `root.${a}.href`,
|
|
4846
4984
|
formData: n
|
|
@@ -4858,7 +4996,7 @@ const DataBindingSelector = ({
|
|
|
4858
4996
|
],
|
|
4859
4997
|
(b) => /* @__PURE__ */ jsx("option", { value: b.const, children: b.title }, b.const)
|
|
4860
4998
|
) }),
|
|
4861
|
-
|
|
4999
|
+
f === "pageType" && !isEmpty(p) ? /* @__PURE__ */ jsx(
|
|
4862
5000
|
PageTypeField,
|
|
4863
5001
|
{
|
|
4864
5002
|
href: c,
|
|
@@ -4875,13 +5013,13 @@ const DataBindingSelector = ({
|
|
|
4875
5013
|
spellCheck: "false",
|
|
4876
5014
|
name: "href",
|
|
4877
5015
|
type: "text",
|
|
4878
|
-
className:
|
|
5016
|
+
className: f === "pageType" ? "!hidden" : "",
|
|
4879
5017
|
value: c,
|
|
4880
5018
|
onChange: (b) => r({ ...n, href: b.target.value }),
|
|
4881
5019
|
placeholder: l(i === "url" ? "Enter URL" : i === "scroll" ? "#ElementID" : "Enter details")
|
|
4882
5020
|
}
|
|
4883
5021
|
),
|
|
4884
|
-
|
|
5022
|
+
f === "url" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
4885
5023
|
/* @__PURE__ */ jsx(
|
|
4886
5024
|
"input",
|
|
4887
5025
|
{
|
|
@@ -4915,18 +5053,18 @@ const DataBindingSelector = ({
|
|
|
4915
5053
|
]
|
|
4916
5054
|
}
|
|
4917
5055
|
) });
|
|
4918
|
-
}, RTEModal = React__default.lazy(() => import("./rte-widget-modal-
|
|
5056
|
+
}, RTEModal = React__default.lazy(() => import("./rte-widget-modal-DxyV3u6C.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
|
|
4919
5057
|
const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
|
|
4920
5058
|
blockId: o,
|
|
4921
5059
|
value: a,
|
|
4922
5060
|
placeholder: r,
|
|
4923
5061
|
onBlur: ({ editor: h }) => {
|
|
4924
|
-
const
|
|
4925
|
-
i(n,
|
|
5062
|
+
const x = h == null ? void 0 : h.getHTML();
|
|
5063
|
+
i(n, x);
|
|
4926
5064
|
},
|
|
4927
5065
|
onUpdate: ({ editor: h }) => {
|
|
4928
|
-
const
|
|
4929
|
-
l(
|
|
5066
|
+
const x = h == null ? void 0 : h.getHTML();
|
|
5067
|
+
l(x);
|
|
4930
5068
|
}
|
|
4931
5069
|
});
|
|
4932
5070
|
useEffect(() => {
|
|
@@ -4968,24 +5106,24 @@ const DataBindingSelector = ({
|
|
|
4968
5106
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4969
5107
|
}, [o, u]);
|
|
4970
5108
|
const m = () => {
|
|
4971
|
-
const
|
|
4972
|
-
if (
|
|
4973
|
-
const b = (
|
|
5109
|
+
const f = findIndex(u, { _id: g });
|
|
5110
|
+
if (f > -1) {
|
|
5111
|
+
const b = (f + 1) % u.length, y = get(u, [b, "_id"]);
|
|
4974
5112
|
if (!y) return;
|
|
4975
5113
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4976
5114
|
}
|
|
4977
5115
|
}, h = () => {
|
|
4978
|
-
const
|
|
4979
|
-
if (
|
|
4980
|
-
const b = (
|
|
5116
|
+
const f = findIndex(u, { _id: g });
|
|
5117
|
+
if (f > -1) {
|
|
5118
|
+
const b = (f - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
|
|
4981
5119
|
if (!y) return;
|
|
4982
5120
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4983
5121
|
}
|
|
4984
|
-
},
|
|
4985
|
-
const
|
|
5122
|
+
}, x = () => {
|
|
5123
|
+
const f = i(
|
|
4986
5124
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4987
5125
|
p == null ? void 0 : p._id
|
|
4988
|
-
), b =
|
|
5126
|
+
), b = f == null ? void 0 : f._id;
|
|
4989
5127
|
b && (n({ ...o, currentSlide: b }), c([b]));
|
|
4990
5128
|
};
|
|
4991
5129
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
@@ -5003,7 +5141,7 @@ const DataBindingSelector = ({
|
|
|
5003
5141
|
/* @__PURE__ */ jsxs(
|
|
5004
5142
|
"button",
|
|
5005
5143
|
{
|
|
5006
|
-
onClick:
|
|
5144
|
+
onClick: x,
|
|
5007
5145
|
className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
|
|
5008
5146
|
children: [
|
|
5009
5147
|
/* @__PURE__ */ jsx(PlusCircledIcon, { className: "h-3 w-3" }),
|
|
@@ -5064,8 +5202,8 @@ const DataBindingSelector = ({
|
|
|
5064
5202
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
5065
5203
|
className: "text-xs",
|
|
5066
5204
|
pattern: "[0-9]*",
|
|
5067
|
-
onChange: (
|
|
5068
|
-
let b =
|
|
5205
|
+
onChange: (f) => {
|
|
5206
|
+
let b = f.target.value;
|
|
5069
5207
|
b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
|
|
5070
5208
|
}
|
|
5071
5209
|
}
|
|
@@ -5161,25 +5299,25 @@ const DataBindingSelector = ({
|
|
|
5161
5299
|
u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
|
|
5162
5300
|
] }) });
|
|
5163
5301
|
}, JSONFormFieldTemplate = (o) => {
|
|
5164
|
-
const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: g, onChange: m } = o, { selectedLang: h, fallbackLang:
|
|
5165
|
-
() => isEmpty(
|
|
5166
|
-
[
|
|
5167
|
-
), y = useMemo(() => get(LANGUAGES, b, b), [b]),
|
|
5168
|
-
() => get(
|
|
5169
|
-
[
|
|
5170
|
-
), [
|
|
5302
|
+
const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: g, onChange: m } = o, { selectedLang: h, fallbackLang: x, languages: f } = useLanguages(), b = useMemo(
|
|
5303
|
+
() => isEmpty(f) ? "" : isEmpty(h) ? x : h,
|
|
5304
|
+
[f, h, x]
|
|
5305
|
+
), y = useMemo(() => get(LANGUAGES, b, b), [b]), C = usePageExternalData(), v = useSelectedBlock(), j = useRegisteredChaiBlocks(), _ = useMemo(
|
|
5306
|
+
() => get(j, [v == null ? void 0 : v._type, "i18nProps"], []),
|
|
5307
|
+
[j, v == null ? void 0 : v._type]
|
|
5308
|
+
), [B, S] = useState(null);
|
|
5171
5309
|
if (d)
|
|
5172
5310
|
return null;
|
|
5173
5311
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
|
|
5174
5312
|
const I = _ == null ? void 0 : _.includes(n.replace("root.", ""));
|
|
5175
5313
|
if (u.type === "array") {
|
|
5176
|
-
const E =
|
|
5314
|
+
const E = B === n;
|
|
5177
5315
|
return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
|
|
5178
5316
|
u.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
|
|
5179
5317
|
"label",
|
|
5180
5318
|
{
|
|
5181
5319
|
htmlFor: n,
|
|
5182
|
-
onClick: () =>
|
|
5320
|
+
onClick: () => S(E ? null : n),
|
|
5183
5321
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
5184
5322
|
children: [
|
|
5185
5323
|
E ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }),
|
|
@@ -5208,7 +5346,7 @@ const DataBindingSelector = ({
|
|
|
5208
5346
|
] })
|
|
5209
5347
|
] });
|
|
5210
5348
|
}
|
|
5211
|
-
const A = n.replace("root.", ""),
|
|
5349
|
+
const A = n.replace("root.", ""), w = _.includes(A) && !isEmpty(h) && isEmpty(g);
|
|
5212
5350
|
return /* @__PURE__ */ jsxs("div", { className: r, children: [
|
|
5213
5351
|
u.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
5214
5352
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
@@ -5226,8 +5364,8 @@ const DataBindingSelector = ({
|
|
|
5226
5364
|
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
|
|
5227
5365
|
] }) })
|
|
5228
5366
|
] }),
|
|
5229
|
-
!u.enum && !u.oneOf &&
|
|
5230
|
-
|
|
5367
|
+
!u.enum && !u.oneOf && C && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
|
|
5368
|
+
w ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5231
5369
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
5232
5370
|
"svg",
|
|
5233
5371
|
{
|
|
@@ -5366,43 +5504,43 @@ const DataBindingSelector = ({
|
|
|
5366
5504
|
}), a;
|
|
5367
5505
|
};
|
|
5368
5506
|
function BlockSettings() {
|
|
5369
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m),
|
|
5370
|
-
|
|
5371
|
-
},
|
|
5372
|
-
debounce(({ formData:
|
|
5373
|
-
|
|
5507
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), x = ({ formData: B }, S, k) => {
|
|
5508
|
+
S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(B, S) }, k);
|
|
5509
|
+
}, f = useCallback(
|
|
5510
|
+
debounce(({ formData: B }, S, k) => {
|
|
5511
|
+
x({ formData: B }, S, k), d(B);
|
|
5374
5512
|
}, 1500),
|
|
5375
5513
|
[n == null ? void 0 : n._id, o]
|
|
5376
|
-
), b = ({ formData:
|
|
5377
|
-
|
|
5378
|
-
}, y = ({ formData:
|
|
5379
|
-
|
|
5380
|
-
}, { schema:
|
|
5381
|
-
const
|
|
5382
|
-
if (!
|
|
5514
|
+
), b = ({ formData: B }, S) => {
|
|
5515
|
+
S && (r([n._id], { [S]: get(B, S) }), f({ formData: B }, S, { [S]: get(c, S) }));
|
|
5516
|
+
}, y = ({ formData: B }, S) => {
|
|
5517
|
+
S && (r([g._id], { [S]: get(B, S) }), f({ formData: B }, S, { [S]: get(c, S) }));
|
|
5518
|
+
}, { schema: C, uiSchema: v } = useMemo(() => {
|
|
5519
|
+
const B = n == null ? void 0 : n._type;
|
|
5520
|
+
if (!B)
|
|
5383
5521
|
return { schema: {}, uiSchema: {} };
|
|
5384
5522
|
try {
|
|
5385
|
-
const { schema:
|
|
5386
|
-
if (
|
|
5523
|
+
const { schema: S, uiSchema: k } = getBlockFormSchemas(B);
|
|
5524
|
+
if (B === "Repeater") {
|
|
5387
5525
|
const I = get(n, "repeaterItems", "");
|
|
5388
5526
|
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" }));
|
|
5389
5527
|
}
|
|
5390
|
-
return { schema:
|
|
5528
|
+
return { schema: S, uiSchema: k };
|
|
5391
5529
|
} catch {
|
|
5392
5530
|
return { schema: {}, uiSchema: {} };
|
|
5393
5531
|
}
|
|
5394
|
-
}, [n]), { wrapperSchema:
|
|
5532
|
+
}, [n]), { wrapperSchema: j, wrapperUiSchema: _ } = useMemo(() => {
|
|
5395
5533
|
if (!g || !(g != null && g._type))
|
|
5396
5534
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5397
|
-
const
|
|
5398
|
-
return { wrapperSchema:
|
|
5535
|
+
const B = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: k = {} } = getBlockFormSchemas(B);
|
|
5536
|
+
return { wrapperSchema: S, wrapperUiSchema: k };
|
|
5399
5537
|
}, [g]);
|
|
5400
5538
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5401
5539
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5402
5540
|
/* @__PURE__ */ jsxs(
|
|
5403
5541
|
"div",
|
|
5404
5542
|
{
|
|
5405
|
-
onClick: () => u((
|
|
5543
|
+
onClick: () => u((B) => !B),
|
|
5406
5544
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5407
5545
|
children: [
|
|
5408
5546
|
p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
|
|
@@ -5423,45 +5561,45 @@ function BlockSettings() {
|
|
|
5423
5561
|
blockId: g == null ? void 0 : g._id,
|
|
5424
5562
|
onChange: y,
|
|
5425
5563
|
formData: h,
|
|
5426
|
-
schema:
|
|
5564
|
+
schema: j,
|
|
5427
5565
|
uiSchema: _
|
|
5428
5566
|
}
|
|
5429
5567
|
) })
|
|
5430
5568
|
] }),
|
|
5431
|
-
isEmpty(
|
|
5569
|
+
isEmpty(C) ? null : /* @__PURE__ */ jsx(
|
|
5432
5570
|
JSONForm,
|
|
5433
5571
|
{
|
|
5434
5572
|
blockId: n == null ? void 0 : n._id,
|
|
5435
5573
|
onChange: b,
|
|
5436
5574
|
formData: i,
|
|
5437
|
-
schema:
|
|
5438
|
-
uiSchema:
|
|
5575
|
+
schema: C,
|
|
5576
|
+
uiSchema: v
|
|
5439
5577
|
}
|
|
5440
5578
|
)
|
|
5441
5579
|
] });
|
|
5442
5580
|
}
|
|
5443
5581
|
const BlockStylingProps = () => {
|
|
5444
|
-
var
|
|
5582
|
+
var x;
|
|
5445
5583
|
const o = useSelectedBlock(), [n, r] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
|
|
5446
5584
|
if (!o) return null;
|
|
5447
5585
|
const c = Object.keys(o).filter(
|
|
5448
|
-
(
|
|
5449
|
-
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (
|
|
5586
|
+
(f) => typeof o[f] == "string" && o[f].startsWith("#styles:")
|
|
5587
|
+
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (x = n[0]) == null ? void 0 : x.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((f) => !isEmpty(f)) : [], h = (f) => find(n, (b) => b.prop === f);
|
|
5450
5588
|
return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5451
5589
|
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5452
5590
|
i("Style element"),
|
|
5453
5591
|
":"
|
|
5454
5592
|
] }),
|
|
5455
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (
|
|
5593
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (f) => /* @__PURE__ */ jsxs(
|
|
5456
5594
|
Badge,
|
|
5457
5595
|
{
|
|
5458
5596
|
className: "flex cursor-pointer items-center gap-1 pr-1",
|
|
5459
|
-
variant: h(
|
|
5597
|
+
variant: h(f) ? "default" : "secondary",
|
|
5460
5598
|
onClick: () => {
|
|
5461
|
-
r([{ id: `${
|
|
5599
|
+
r([{ id: `${f}-${o._id}`, blockId: o._id, prop: f }]);
|
|
5462
5600
|
},
|
|
5463
5601
|
children: [
|
|
5464
|
-
startCase(
|
|
5602
|
+
startCase(f),
|
|
5465
5603
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5466
5604
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5467
5605
|
"button",
|
|
@@ -5478,7 +5616,7 @@ const BlockStylingProps = () => {
|
|
|
5478
5616
|
{
|
|
5479
5617
|
className: "text-xs",
|
|
5480
5618
|
onClick: () => {
|
|
5481
|
-
d(
|
|
5619
|
+
d(f);
|
|
5482
5620
|
},
|
|
5483
5621
|
children: i("Reset style")
|
|
5484
5622
|
}
|
|
@@ -5497,7 +5635,7 @@ const BlockStylingProps = () => {
|
|
|
5497
5635
|
] })
|
|
5498
5636
|
]
|
|
5499
5637
|
},
|
|
5500
|
-
|
|
5638
|
+
f
|
|
5501
5639
|
)) }),
|
|
5502
5640
|
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5503
5641
|
] }) });
|
|
@@ -5646,50 +5784,50 @@ const BlockStylingProps = () => {
|
|
|
5646
5784
|
},
|
|
5647
5785
|
a
|
|
5648
5786
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5649
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [
|
|
5787
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [b, y] = useState(""), [C, v] = useState(!1), [j, _] = useState(!1);
|
|
5650
5788
|
useEffect(() => {
|
|
5651
|
-
const { value: A, unit:
|
|
5652
|
-
if (
|
|
5789
|
+
const { value: A, unit: w } = getClassValueAndUnit(i);
|
|
5790
|
+
if (w === "") {
|
|
5653
5791
|
l(A), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5654
5792
|
return;
|
|
5655
5793
|
}
|
|
5656
|
-
h(
|
|
5794
|
+
h(w), l(w === "class" || isEmpty(A) ? "" : A);
|
|
5657
5795
|
}, [i, p, u]);
|
|
5658
|
-
const
|
|
5796
|
+
const B = useThrottledCallback((A) => c(A), [c], THROTTLE_TIME), S = useThrottledCallback((A) => c(A, !1), [c], THROTTLE_TIME), k = useCallback(
|
|
5659
5797
|
(A = !1) => {
|
|
5660
|
-
const
|
|
5661
|
-
if (get(
|
|
5662
|
-
|
|
5798
|
+
const w = getUserInputValues(`${a}`, u);
|
|
5799
|
+
if (get(w, "error", !1)) {
|
|
5800
|
+
f(!0);
|
|
5663
5801
|
return;
|
|
5664
5802
|
}
|
|
5665
|
-
const E = get(
|
|
5803
|
+
const E = get(w, "unit") !== "" ? get(w, "unit") : m;
|
|
5666
5804
|
if (E === "auto" || E === "none") {
|
|
5667
|
-
|
|
5805
|
+
B(`${d}${E}`);
|
|
5668
5806
|
return;
|
|
5669
5807
|
}
|
|
5670
|
-
if (get(
|
|
5808
|
+
if (get(w, "value") === "")
|
|
5671
5809
|
return;
|
|
5672
|
-
const T = `${get(
|
|
5673
|
-
A ?
|
|
5810
|
+
const T = `${get(w, "value", "").startsWith("-") ? "-" : ""}${d}[${get(w, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
|
|
5811
|
+
A ? S(T) : B(T);
|
|
5674
5812
|
},
|
|
5675
|
-
[
|
|
5813
|
+
[B, S, a, m, d, u]
|
|
5676
5814
|
), I = useCallback(
|
|
5677
5815
|
(A) => {
|
|
5678
|
-
const
|
|
5679
|
-
if (get(
|
|
5680
|
-
|
|
5816
|
+
const w = getUserInputValues(`${a}`, u);
|
|
5817
|
+
if (get(w, "error", !1)) {
|
|
5818
|
+
f(!0);
|
|
5681
5819
|
return;
|
|
5682
5820
|
}
|
|
5683
5821
|
if (A === "auto" || A === "none") {
|
|
5684
|
-
|
|
5822
|
+
B(`${d}${A}`);
|
|
5685
5823
|
return;
|
|
5686
5824
|
}
|
|
5687
|
-
if (get(
|
|
5825
|
+
if (get(w, "value") === "")
|
|
5688
5826
|
return;
|
|
5689
|
-
const E = get(
|
|
5690
|
-
|
|
5827
|
+
const E = get(w, "unit") !== "" ? get(w, "unit") : A, T = `${get(w, "value", "").startsWith("-") ? "-" : ""}${d}[${get(w, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
|
|
5828
|
+
B(T);
|
|
5691
5829
|
},
|
|
5692
|
-
[
|
|
5830
|
+
[B, a, d, u]
|
|
5693
5831
|
);
|
|
5694
5832
|
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5695
5833
|
/* @__PURE__ */ jsx(
|
|
@@ -5704,7 +5842,7 @@ const BlockStylingProps = () => {
|
|
|
5704
5842
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
|
|
5705
5843
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
5706
5844
|
] })
|
|
5707
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
5845
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${C ? "z-auto" : ""}`, children: [
|
|
5708
5846
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
5709
5847
|
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
5710
5848
|
"input",
|
|
@@ -5717,27 +5855,27 @@ const BlockStylingProps = () => {
|
|
|
5717
5855
|
if (A.keyCode !== 38 && A.keyCode !== 40)
|
|
5718
5856
|
return;
|
|
5719
5857
|
A.preventDefault(), _(!0);
|
|
5720
|
-
const
|
|
5721
|
-
let E = isNaN$1(
|
|
5858
|
+
const w = parseInt$1(A.target.value);
|
|
5859
|
+
let E = isNaN$1(w) ? 0 : w;
|
|
5722
5860
|
A.keyCode === 38 && (E += 1), A.keyCode === 40 && (E -= 1);
|
|
5723
5861
|
const L = `${E}`, P = `${L.startsWith("-") ? "-" : ""}${d}[${L.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5724
|
-
|
|
5862
|
+
S(P);
|
|
5725
5863
|
},
|
|
5726
5864
|
onKeyUp: (A) => {
|
|
5727
|
-
|
|
5865
|
+
j && (A.preventDefault(), _(!1));
|
|
5728
5866
|
},
|
|
5729
5867
|
onBlur: () => k(),
|
|
5730
5868
|
onChange: (A) => {
|
|
5731
|
-
|
|
5869
|
+
f(!1), l(A.target.value);
|
|
5732
5870
|
},
|
|
5733
5871
|
onClick: (A) => {
|
|
5734
|
-
var
|
|
5735
|
-
(
|
|
5872
|
+
var w;
|
|
5873
|
+
(w = A == null ? void 0 : A.target) == null || w.select(), r(!1);
|
|
5736
5874
|
},
|
|
5737
|
-
value:
|
|
5875
|
+
value: C ? b : a,
|
|
5738
5876
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5739
5877
|
" ",
|
|
5740
|
-
|
|
5878
|
+
x ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
5741
5879
|
)
|
|
5742
5880
|
}
|
|
5743
5881
|
),
|
|
@@ -5766,22 +5904,22 @@ const BlockStylingProps = () => {
|
|
|
5766
5904
|
) })
|
|
5767
5905
|
] })
|
|
5768
5906
|
] }),
|
|
5769
|
-
["none", "auto"].indexOf(m) !== -1 ||
|
|
5907
|
+
["none", "auto"].indexOf(m) !== -1 || C ? null : /* @__PURE__ */ jsx(
|
|
5770
5908
|
DragStyleButton,
|
|
5771
5909
|
{
|
|
5772
|
-
onDragStart: () =>
|
|
5910
|
+
onDragStart: () => v(!0),
|
|
5773
5911
|
onDragEnd: (A) => {
|
|
5774
|
-
if (y(() => ""),
|
|
5912
|
+
if (y(() => ""), v(!1), isEmpty(A))
|
|
5775
5913
|
return;
|
|
5776
|
-
const
|
|
5777
|
-
|
|
5914
|
+
const w = `${A}`, L = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5915
|
+
B(L);
|
|
5778
5916
|
},
|
|
5779
5917
|
onDrag: (A) => {
|
|
5780
5918
|
if (isEmpty(A))
|
|
5781
5919
|
return;
|
|
5782
5920
|
y(A);
|
|
5783
|
-
const
|
|
5784
|
-
|
|
5921
|
+
const w = `${A}`, L = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5922
|
+
S(L);
|
|
5785
5923
|
},
|
|
5786
5924
|
currentValue: a,
|
|
5787
5925
|
unit: m,
|
|
@@ -5856,7 +5994,7 @@ const COLOR_PROP = {
|
|
|
5856
5994
|
return c([]);
|
|
5857
5995
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5858
5996
|
}, [g]);
|
|
5859
|
-
const
|
|
5997
|
+
const x = useCallback(
|
|
5860
5998
|
// eslint-disable-next-line no-shadow
|
|
5861
5999
|
(b) => {
|
|
5862
6000
|
p({ color: g, shade: b });
|
|
@@ -5866,11 +6004,11 @@ const COLOR_PROP = {
|
|
|
5866
6004
|
useEffect(() => {
|
|
5867
6005
|
p({ color: "", shade: "" });
|
|
5868
6006
|
}, [r]);
|
|
5869
|
-
const { match:
|
|
6007
|
+
const { match: f } = useTailwindClassList();
|
|
5870
6008
|
return useEffect(() => {
|
|
5871
6009
|
const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5872
|
-
|
|
5873
|
-
}, [
|
|
6010
|
+
f(o, y) && n(y, o);
|
|
6011
|
+
}, [f, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5874
6012
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5875
6013
|
DropDown,
|
|
5876
6014
|
{
|
|
@@ -5910,7 +6048,7 @@ const COLOR_PROP = {
|
|
|
5910
6048
|
]
|
|
5911
6049
|
}
|
|
5912
6050
|
) }),
|
|
5913
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange:
|
|
6051
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: x, options: i }) })
|
|
5914
6052
|
] });
|
|
5915
6053
|
}, EDITOR_ICONS = {
|
|
5916
6054
|
"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" }) }),
|
|
@@ -6244,35 +6382,35 @@ const COLOR_PROP = {
|
|
|
6244
6382
|
"2xl": "1536px"
|
|
6245
6383
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6246
6384
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6247
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(),
|
|
6248
|
-
(
|
|
6249
|
-
const I = { dark: p, mq: g, mod: u, cls:
|
|
6385
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
|
|
6386
|
+
(S, k = !0) => {
|
|
6387
|
+
const I = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
|
|
6250
6388
|
(p || u !== "") && (I.mq = "xs");
|
|
6251
6389
|
const A = generateFullClsName(I);
|
|
6252
|
-
h(
|
|
6390
|
+
h(f, [A], k);
|
|
6253
6391
|
},
|
|
6254
|
-
[
|
|
6255
|
-
),
|
|
6256
|
-
f
|
|
6257
|
-
}, [
|
|
6392
|
+
[f, p, g, u, l, h]
|
|
6393
|
+
), C = useCallback(() => {
|
|
6394
|
+
x(f, [b], !0);
|
|
6395
|
+
}, [f, b, x]), v = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6258
6396
|
useEffect(() => {
|
|
6259
|
-
i(
|
|
6260
|
-
}, [
|
|
6261
|
-
const [, ,
|
|
6262
|
-
(
|
|
6263
|
-
|
|
6397
|
+
i(v, m);
|
|
6398
|
+
}, [v, i, m]);
|
|
6399
|
+
const [, , j] = useScreenSizeWidth(), _ = useCallback(
|
|
6400
|
+
(S) => {
|
|
6401
|
+
j({
|
|
6264
6402
|
xs: 400,
|
|
6265
6403
|
sm: 640,
|
|
6266
6404
|
md: 800,
|
|
6267
6405
|
lg: 1024,
|
|
6268
6406
|
xl: 1420,
|
|
6269
6407
|
"2xl": 1920
|
|
6270
|
-
}[
|
|
6408
|
+
}[S]);
|
|
6271
6409
|
},
|
|
6272
|
-
[
|
|
6273
|
-
),
|
|
6274
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6275
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !
|
|
6410
|
+
[j]
|
|
6411
|
+
), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6412
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: v, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6413
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !B ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6276
6414
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6277
6415
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6278
6416
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
@@ -6291,7 +6429,7 @@ const COLOR_PROP = {
|
|
|
6291
6429
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
|
|
6292
6430
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6293
6431
|
] }),
|
|
6294
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children:
|
|
6432
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: B ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => C(), 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 && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6295
6433
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6296
6434
|
"button",
|
|
6297
6435
|
{
|
|
@@ -6340,23 +6478,23 @@ const COLOR_PROP = {
|
|
|
6340
6478
|
children: [
|
|
6341
6479
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6342
6480
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6343
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key:
|
|
6481
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: x }, f) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6344
6482
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6345
6483
|
"button",
|
|
6346
6484
|
{
|
|
6347
6485
|
type: "button",
|
|
6348
|
-
onClick: () => u(
|
|
6349
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6486
|
+
onClick: () => u(x),
|
|
6487
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6350
6488
|
children: [
|
|
6351
6489
|
React__default.createElement("div", {
|
|
6352
|
-
className: m(
|
|
6490
|
+
className: m(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6353
6491
|
}),
|
|
6354
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6492
|
+
React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6355
6493
|
]
|
|
6356
6494
|
}
|
|
6357
6495
|
) }),
|
|
6358
6496
|
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
|
|
6359
|
-
] }) }, `option-${
|
|
6497
|
+
] }) }, `option-${f}`)) })
|
|
6360
6498
|
] }),
|
|
6361
6499
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6362
6500
|
BlockStyle,
|
|
@@ -6511,9 +6649,9 @@ const COLOR_PROP = {
|
|
|
6511
6649
|
canvas: n = !1,
|
|
6512
6650
|
tooltip: r = !0
|
|
6513
6651
|
}) => {
|
|
6514
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS),
|
|
6515
|
-
u.includes(y) ? u.length > 2 && g(u.filter((
|
|
6516
|
-
},
|
|
6652
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (y) => {
|
|
6653
|
+
u.includes(y) ? u.length > 2 && g(u.filter((C) => C !== y)) : g((C) => [...C, y]);
|
|
6654
|
+
}, f = (y) => {
|
|
6517
6655
|
n || l(y), c(y);
|
|
6518
6656
|
}, b = getBreakpointValue(n ? i : a).toLowerCase();
|
|
6519
6657
|
return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (y) => /* @__PURE__ */ createElement(
|
|
@@ -6521,7 +6659,7 @@ const COLOR_PROP = {
|
|
|
6521
6659
|
{
|
|
6522
6660
|
canvas: n,
|
|
6523
6661
|
...y,
|
|
6524
|
-
onClick:
|
|
6662
|
+
onClick: f,
|
|
6525
6663
|
key: y.breakpoint,
|
|
6526
6664
|
currentBreakpoint: b
|
|
6527
6665
|
}
|
|
@@ -6535,7 +6673,7 @@ const COLOR_PROP = {
|
|
|
6535
6673
|
openDelay: o,
|
|
6536
6674
|
tooltip: r,
|
|
6537
6675
|
...y,
|
|
6538
|
-
onClick:
|
|
6676
|
+
onClick: f,
|
|
6539
6677
|
key: y.breakpoint,
|
|
6540
6678
|
currentBreakpoint: b
|
|
6541
6679
|
}
|
|
@@ -6550,7 +6688,7 @@ const COLOR_PROP = {
|
|
|
6550
6688
|
DropdownMenuCheckboxItem,
|
|
6551
6689
|
{
|
|
6552
6690
|
disabled: y.breakpoint === "xs",
|
|
6553
|
-
onCheckedChange: () =>
|
|
6691
|
+
onCheckedChange: () => x(toUpper(y.breakpoint)),
|
|
6554
6692
|
checked: includes(u, toUpper(y.breakpoint)),
|
|
6555
6693
|
children: m(y.title)
|
|
6556
6694
|
},
|
|
@@ -6577,125 +6715,12 @@ function BreakpointSelector() {
|
|
|
6577
6715
|
] }) }) })
|
|
6578
6716
|
] });
|
|
6579
6717
|
}
|
|
6580
|
-
const SECONDS = 10;
|
|
6581
|
-
function Countdown() {
|
|
6582
|
-
const [o, n] = useState(SECONDS), [r, a] = useState(!1);
|
|
6583
|
-
useEffect(() => {
|
|
6584
|
-
if (r && o > 0) {
|
|
6585
|
-
const p = setTimeout(() => {
|
|
6586
|
-
n(o - 0.1);
|
|
6587
|
-
}, 100);
|
|
6588
|
-
return () => clearTimeout(p);
|
|
6589
|
-
} else o <= 0 && (a(!1), n(SECONDS));
|
|
6590
|
-
}, [r, o]);
|
|
6591
|
-
const l = () => {
|
|
6592
|
-
a(!0), n(SECONDS);
|
|
6593
|
-
};
|
|
6594
|
-
useEffect(() => {
|
|
6595
|
-
o === SECONDS && l();
|
|
6596
|
-
}, [o]);
|
|
6597
|
-
const i = 18, c = 2 * Math.PI * i, d = c * (1 - (SECONDS - o) / SECONDS);
|
|
6598
|
-
return /* @__PURE__ */ jsxs("div", { className: "relative h-4 w-4", children: [
|
|
6599
|
-
/* @__PURE__ */ jsxs("svg", { className: "h-full w-full", viewBox: "0 0 40 40", children: [
|
|
6600
|
-
/* @__PURE__ */ jsx(
|
|
6601
|
-
"circle",
|
|
6602
|
-
{
|
|
6603
|
-
className: "text-gray-300",
|
|
6604
|
-
strokeWidth: "4",
|
|
6605
|
-
stroke: "currentColor",
|
|
6606
|
-
fill: "transparent",
|
|
6607
|
-
r: i,
|
|
6608
|
-
cx: "20",
|
|
6609
|
-
cy: "20"
|
|
6610
|
-
}
|
|
6611
|
-
),
|
|
6612
|
-
/* @__PURE__ */ jsx(
|
|
6613
|
-
"circle",
|
|
6614
|
-
{
|
|
6615
|
-
className: "text-blue-600",
|
|
6616
|
-
strokeWidth: "4",
|
|
6617
|
-
strokeDasharray: c,
|
|
6618
|
-
strokeDashoffset: d,
|
|
6619
|
-
strokeLinecap: "round",
|
|
6620
|
-
stroke: "currentColor",
|
|
6621
|
-
fill: "transparent",
|
|
6622
|
-
r: i,
|
|
6623
|
-
cx: "20",
|
|
6624
|
-
cy: "20"
|
|
6625
|
-
}
|
|
6626
|
-
)
|
|
6627
|
-
] }),
|
|
6628
|
-
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold", children: " " }) })
|
|
6629
|
-
] });
|
|
6630
|
-
}
|
|
6631
|
-
const AskAIStyles = ({ blockId: o }) => {
|
|
6632
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
6633
|
-
useEffect(() => {
|
|
6634
|
-
var h;
|
|
6635
|
-
(h = d.current) == null || h.focus();
|
|
6636
|
-
}, []);
|
|
6637
|
-
const m = (h) => {
|
|
6638
|
-
const { usage: f } = h || {};
|
|
6639
|
-
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6640
|
-
};
|
|
6641
|
-
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6642
|
-
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
6643
|
-
/* @__PURE__ */ jsx(
|
|
6644
|
-
Textarea,
|
|
6645
|
-
{
|
|
6646
|
-
ref: d,
|
|
6647
|
-
value: i,
|
|
6648
|
-
onChange: (h) => c(h.target.value),
|
|
6649
|
-
placeholder: n("Ask AI to edit styles"),
|
|
6650
|
-
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
6651
|
-
rows: 4,
|
|
6652
|
-
onKeyDown: (h) => {
|
|
6653
|
-
h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
|
|
6654
|
-
}
|
|
6655
|
-
}
|
|
6656
|
-
),
|
|
6657
|
-
/* @__PURE__ */ jsxs("div", { className: "my-2 flex items-center gap-2", children: [
|
|
6658
|
-
a ? null : /* @__PURE__ */ jsx(
|
|
6659
|
-
Button,
|
|
6660
|
-
{
|
|
6661
|
-
disabled: i.trim().length < 5 || a,
|
|
6662
|
-
onClick: () => {
|
|
6663
|
-
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
|
|
6664
|
-
},
|
|
6665
|
-
variant: "default",
|
|
6666
|
-
className: "w-fit",
|
|
6667
|
-
size: "sm",
|
|
6668
|
-
children: a ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6669
|
-
/* @__PURE__ */ jsx(ReloadIcon, { className: "h-5 w-5 animate-spin" }),
|
|
6670
|
-
n("Generating... Please wait...")
|
|
6671
|
-
] }) : n("Edit with AI")
|
|
6672
|
-
}
|
|
6673
|
-
),
|
|
6674
|
-
a ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
6675
|
-
/* @__PURE__ */ jsxs(Skeleton, { className: "flex w-full items-center space-x-1 px-4 py-1 pl-2", children: [
|
|
6676
|
-
/* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4 animate-spin text-gray-500" }),
|
|
6677
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs", children: n("Generating... Please wait...") })
|
|
6678
|
-
] }),
|
|
6679
|
-
/* @__PURE__ */ jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: n("Stop") })
|
|
6680
|
-
] }) : null
|
|
6681
|
-
] }),
|
|
6682
|
-
u ? /* @__PURE__ */ jsx("div", { className: "max-w-full", children: /* @__PURE__ */ jsxs("p", { className: "mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500", children: [
|
|
6683
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
6684
|
-
n("Total tokens used"),
|
|
6685
|
-
": ",
|
|
6686
|
-
u.totalTokens
|
|
6687
|
-
] }),
|
|
6688
|
-
/* @__PURE__ */ jsx(Countdown, {})
|
|
6689
|
-
] }) }) : null,
|
|
6690
|
-
/* @__PURE__ */ jsx("div", { className: "max-w-full", children: l && /* @__PURE__ */ jsx("p", { className: "break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500", children: l.message }) })
|
|
6691
|
-
] });
|
|
6692
|
-
}, 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" }) });
|
|
6693
6718
|
function ManualClasses() {
|
|
6694
6719
|
var L;
|
|
6695
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h
|
|
6696
|
-
const T =
|
|
6720
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), [h, x] = useState(""), f = (L = first(d)) == null ? void 0 : L.prop, { classes: b } = getSplitChaiClasses(get(p, f, "")), y = b.split(" ").filter((T) => !isEmpty(T)), C = useBuilderProp("flags.useClipboard", !1), v = () => {
|
|
6721
|
+
const T = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6697
6722
|
u(m, T, !0), x("");
|
|
6698
|
-
}, [
|
|
6723
|
+
}, [j, _] = useState([]), B = ({ value: T }) => {
|
|
6699
6724
|
const P = T.trim().toLowerCase(), R = P.match(/.+:/g);
|
|
6700
6725
|
let D = [];
|
|
6701
6726
|
if (R && R.length > 0) {
|
|
@@ -6707,7 +6732,7 @@ function ManualClasses() {
|
|
|
6707
6732
|
} else
|
|
6708
6733
|
D = i.search(P);
|
|
6709
6734
|
return _(map(D, "item"));
|
|
6710
|
-
},
|
|
6735
|
+
}, S = () => {
|
|
6711
6736
|
_([]);
|
|
6712
6737
|
}, k = (T) => T.name, I = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), A = useMemo(
|
|
6713
6738
|
() => ({
|
|
@@ -6717,20 +6742,20 @@ function ManualClasses() {
|
|
|
6717
6742
|
autoCapitalize: "off",
|
|
6718
6743
|
spellCheck: !1,
|
|
6719
6744
|
placeholder: c("Enter classes separated by space"),
|
|
6720
|
-
value:
|
|
6745
|
+
value: h,
|
|
6721
6746
|
onFocus: (T) => {
|
|
6722
6747
|
setTimeout(() => {
|
|
6723
6748
|
T.target && T.target.select();
|
|
6724
6749
|
}, 0);
|
|
6725
6750
|
},
|
|
6726
6751
|
onKeyDown: (T) => {
|
|
6727
|
-
T.key === "Enter" &&
|
|
6752
|
+
T.key === "Enter" && h.trim() !== "" && v();
|
|
6728
6753
|
},
|
|
6729
6754
|
onChange: (T, { newValue: P }) => x(P),
|
|
6730
6755
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6731
6756
|
}),
|
|
6732
|
-
[
|
|
6733
|
-
),
|
|
6757
|
+
[h, c, o]
|
|
6758
|
+
), w = (T) => {
|
|
6734
6759
|
debugger;
|
|
6735
6760
|
const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6736
6761
|
g(m, [T]), u(m, P, !0), r(""), l(-1);
|
|
@@ -6739,32 +6764,23 @@ function ManualClasses() {
|
|
|
6739
6764
|
toast.error(c("Clipboard not supported"));
|
|
6740
6765
|
return;
|
|
6741
6766
|
}
|
|
6742
|
-
navigator.clipboard.writeText(
|
|
6767
|
+
navigator.clipboard.writeText(y.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
6743
6768
|
};
|
|
6744
6769
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
6745
|
-
/* @__PURE__ */
|
|
6746
|
-
/* @__PURE__ */
|
|
6747
|
-
|
|
6748
|
-
/* @__PURE__ */
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
] }),
|
|
6753
|
-
h ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
6754
|
-
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
6755
|
-
/* @__PURE__ */ jsx(AiIcon, { className: "h-4 w-4" }),
|
|
6756
|
-
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
6757
|
-
] }) }),
|
|
6758
|
-
/* @__PURE__ */ jsx(PopoverContent, { side: "left", className: "p-2", children: /* @__PURE__ */ jsx(AskAIStyles, { blockId: p == null ? void 0 : p._id }) })
|
|
6759
|
-
] }) : null
|
|
6760
|
-
] }),
|
|
6770
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-x-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
6771
|
+
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
6772
|
+
C && /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6773
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: E, className: "cursor-pointer" }) }),
|
|
6774
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
6775
|
+
] })
|
|
6776
|
+
] }) }),
|
|
6761
6777
|
/* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-x-3", children: [
|
|
6762
6778
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
6763
6779
|
Autosuggest,
|
|
6764
6780
|
{
|
|
6765
|
-
suggestions:
|
|
6766
|
-
onSuggestionsFetchRequested:
|
|
6767
|
-
onSuggestionsClearRequested:
|
|
6781
|
+
suggestions: j,
|
|
6782
|
+
onSuggestionsFetchRequested: B,
|
|
6783
|
+
onSuggestionsClearRequested: S,
|
|
6768
6784
|
getSuggestionValue: k,
|
|
6769
6785
|
renderSuggestion: I,
|
|
6770
6786
|
inputProps: A,
|
|
@@ -6783,14 +6799,14 @@ function ManualClasses() {
|
|
|
6783
6799
|
{
|
|
6784
6800
|
variant: "outline",
|
|
6785
6801
|
className: "h-6 border-border",
|
|
6786
|
-
onClick:
|
|
6787
|
-
disabled:
|
|
6802
|
+
onClick: v,
|
|
6803
|
+
disabled: h.trim() === "",
|
|
6788
6804
|
size: "sm",
|
|
6789
6805
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
6790
6806
|
}
|
|
6791
6807
|
)
|
|
6792
6808
|
] }),
|
|
6793
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
6809
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: y.map(
|
|
6794
6810
|
(T, P) => a === P ? /* @__PURE__ */ jsx(
|
|
6795
6811
|
"input",
|
|
6796
6812
|
{
|
|
@@ -6798,10 +6814,10 @@ function ManualClasses() {
|
|
|
6798
6814
|
value: n,
|
|
6799
6815
|
onChange: (R) => r(R.target.value),
|
|
6800
6816
|
onBlur: () => {
|
|
6801
|
-
|
|
6817
|
+
w(T);
|
|
6802
6818
|
},
|
|
6803
6819
|
onKeyDown: (R) => {
|
|
6804
|
-
R.key === "Enter" &&
|
|
6820
|
+
R.key === "Enter" && w(T);
|
|
6805
6821
|
},
|
|
6806
6822
|
onFocus: (R) => {
|
|
6807
6823
|
setTimeout(() => {
|
|
@@ -6971,9 +6987,9 @@ function BlockStyling() {
|
|
|
6971
6987
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6972
6988
|
let h = parseFloat(i.dragStartValue);
|
|
6973
6989
|
h = isNaN(h) ? 0 : h;
|
|
6974
|
-
let
|
|
6975
|
-
(startsWith(m, "scale") || m === "opacity") && (
|
|
6976
|
-
let b = (i.dragStartY - u.pageY) /
|
|
6990
|
+
let x = MAPPER[i.dragUnit];
|
|
6991
|
+
(startsWith(m, "scale") || m === "opacity") && (x = 10);
|
|
6992
|
+
let b = (i.dragStartY - u.pageY) / x + h;
|
|
6977
6993
|
g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6978
6994
|
},
|
|
6979
6995
|
[i],
|
|
@@ -7022,7 +7038,7 @@ const CoreBlock = ({
|
|
|
7022
7038
|
} else
|
|
7023
7039
|
p(o, r || null, a);
|
|
7024
7040
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7025
|
-
},
|
|
7041
|
+
}, x = useFeature("dnd"), { t: f } = useTranslation();
|
|
7026
7042
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7027
7043
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
7028
7044
|
"button",
|
|
@@ -7035,15 +7051,15 @@ const CoreBlock = ({
|
|
|
7035
7051
|
g([]), m();
|
|
7036
7052
|
}, 200);
|
|
7037
7053
|
},
|
|
7038
|
-
draggable:
|
|
7054
|
+
draggable: x ? "true" : "false",
|
|
7039
7055
|
className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
|
|
7040
7056
|
children: [
|
|
7041
7057
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
7042
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
7058
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(f(d || i)) })
|
|
7043
7059
|
]
|
|
7044
7060
|
}
|
|
7045
7061
|
) }),
|
|
7046
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
7062
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f(d || i) }) })
|
|
7047
7063
|
] }) });
|
|
7048
7064
|
}, DefaultChaiBlocks = ({
|
|
7049
7065
|
parentId: o,
|
|
@@ -7154,18 +7170,18 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7154
7170
|
parentId: r = void 0,
|
|
7155
7171
|
position: a = -1
|
|
7156
7172
|
}) => {
|
|
7157
|
-
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""),
|
|
7158
|
-
const
|
|
7159
|
-
return
|
|
7173
|
+
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), b = (v) => {
|
|
7174
|
+
const j = has(v, "styles_attrs.data-page-section");
|
|
7175
|
+
return v._type === "Box" && j;
|
|
7160
7176
|
}, y = useCallback(
|
|
7161
|
-
async (
|
|
7162
|
-
if (
|
|
7177
|
+
async (v) => {
|
|
7178
|
+
if (v.stopPropagation(), has(o, "component")) {
|
|
7163
7179
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7164
7180
|
return;
|
|
7165
7181
|
}
|
|
7166
7182
|
i(!0);
|
|
7167
|
-
let
|
|
7168
|
-
typeof
|
|
7183
|
+
let j = await c({ library: n, block: o });
|
|
7184
|
+
typeof j == "string" && (j = getBlocksFromHTML(j)), isEmpty(j) || p(syncBlocksWithDefaults(j), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7169
7185
|
},
|
|
7170
7186
|
[d, p, o, c, n, r, a]
|
|
7171
7187
|
);
|
|
@@ -7175,20 +7191,20 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7175
7191
|
{
|
|
7176
7192
|
onClick: l ? () => {
|
|
7177
7193
|
} : y,
|
|
7178
|
-
draggable:
|
|
7179
|
-
onDragStart: async (
|
|
7180
|
-
const
|
|
7194
|
+
draggable: x ? "true" : "false",
|
|
7195
|
+
onDragStart: async (v) => {
|
|
7196
|
+
const j = await c({ library: n, block: o });
|
|
7181
7197
|
let _ = r;
|
|
7182
|
-
if (b(first(
|
|
7183
|
-
const
|
|
7184
|
-
if (
|
|
7185
|
-
const
|
|
7186
|
-
|
|
7187
|
-
|
|
7198
|
+
if (b(first(j)) && (_ = null), !isEmpty(j)) {
|
|
7199
|
+
const B = { blocks: j, uiLibrary: !0, parent: _ };
|
|
7200
|
+
if (v.dataTransfer.setData("text/plain", JSON.stringify(B)), o.preview) {
|
|
7201
|
+
const S = new Image();
|
|
7202
|
+
S.src = o.preview, S.onload = () => {
|
|
7203
|
+
v.dataTransfer.setDragImage(S, 0, 0);
|
|
7188
7204
|
};
|
|
7189
7205
|
} else
|
|
7190
|
-
|
|
7191
|
-
|
|
7206
|
+
v.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7207
|
+
f(B), setTimeout(() => {
|
|
7192
7208
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7193
7209
|
}, 200);
|
|
7194
7210
|
}
|
|
@@ -7211,37 +7227,37 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7211
7227
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: m }) }) })
|
|
7212
7228
|
] });
|
|
7213
7229
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7214
|
-
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((
|
|
7230
|
+
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((w) => w.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), x = useRef(null);
|
|
7215
7231
|
useEffect(() => {
|
|
7216
|
-
c && c.length > 0 && (
|
|
7232
|
+
c && c.length > 0 && (x.current = new Fuse(c, {
|
|
7217
7233
|
keys: ["name", "label", "description", "group"],
|
|
7218
7234
|
threshold: 0.4,
|
|
7219
7235
|
ignoreLocation: !0
|
|
7220
7236
|
}));
|
|
7221
7237
|
}, [c]), useEffect(() => {
|
|
7222
|
-
if (!u.trim() || !
|
|
7238
|
+
if (!u.trim() || !x.current) {
|
|
7223
7239
|
h([]);
|
|
7224
7240
|
return;
|
|
7225
7241
|
}
|
|
7226
|
-
const
|
|
7227
|
-
h(
|
|
7242
|
+
const w = x.current.search(u).map((E) => E.item);
|
|
7243
|
+
h(w);
|
|
7228
7244
|
}, [u]);
|
|
7229
|
-
const
|
|
7245
|
+
const f = u.trim() && !isEmpty(m) ? m : c, b = groupBy(f, "group"), [y, C] = useState(null);
|
|
7230
7246
|
useEffect(() => {
|
|
7231
7247
|
if (isEmpty(keys(b))) {
|
|
7232
|
-
|
|
7248
|
+
C(null);
|
|
7233
7249
|
return;
|
|
7234
7250
|
}
|
|
7235
7251
|
if (!y || !b[y]) {
|
|
7236
|
-
|
|
7252
|
+
C(first(keys(b)));
|
|
7237
7253
|
return;
|
|
7238
7254
|
}
|
|
7239
7255
|
}, [b, y]);
|
|
7240
|
-
const
|
|
7241
|
-
|
|
7242
|
-
|
|
7256
|
+
const v = get(b, y, []), j = useRef(null), { t: _ } = useTranslation(), B = (w) => {
|
|
7257
|
+
j.current && (clearTimeout(j.current), j.current = null), j.current = setTimeout(() => {
|
|
7258
|
+
j.current && C(w);
|
|
7243
7259
|
}, 400);
|
|
7244
|
-
},
|
|
7260
|
+
}, S = () => {
|
|
7245
7261
|
i != null && i.id && p(i.id);
|
|
7246
7262
|
}, k = () => {
|
|
7247
7263
|
g("");
|
|
@@ -7251,7 +7267,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7251
7267
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7252
7268
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7253
7269
|
] });
|
|
7254
|
-
const I = filter(
|
|
7270
|
+
const I = filter(v, (w, E) => E % 2 === 0), A = filter(v, (w, E) => E % 2 === 1);
|
|
7255
7271
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7256
7272
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7257
7273
|
/* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
@@ -7260,7 +7276,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7260
7276
|
{
|
|
7261
7277
|
placeholder: _("Search blocks..."),
|
|
7262
7278
|
value: u,
|
|
7263
|
-
onChange: (
|
|
7279
|
+
onChange: (w) => g(w.target.value),
|
|
7264
7280
|
className: "w-full pl-8 pr-8"
|
|
7265
7281
|
}
|
|
7266
7282
|
),
|
|
@@ -7281,17 +7297,17 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7281
7297
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7282
7298
|
/* @__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: [
|
|
7283
7299
|
/* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
|
|
7284
|
-
/* @__PURE__ */ jsxs(Button, { onClick:
|
|
7300
|
+
/* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7285
7301
|
/* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4" }),
|
|
7286
7302
|
_("Retry")
|
|
7287
7303
|
] })
|
|
7288
|
-
] }) }) : map(b, (
|
|
7304
|
+
] }) }) : map(b, (w, E) => /* @__PURE__ */ jsxs(
|
|
7289
7305
|
"div",
|
|
7290
7306
|
{
|
|
7291
|
-
onMouseEnter: () =>
|
|
7292
|
-
onMouseLeave: () => clearTimeout(
|
|
7307
|
+
onMouseEnter: () => B(E),
|
|
7308
|
+
onMouseLeave: () => clearTimeout(j.current),
|
|
7293
7309
|
role: "button",
|
|
7294
|
-
onClick: () =>
|
|
7310
|
+
onClick: () => C(E),
|
|
7295
7311
|
className: cn$1(
|
|
7296
7312
|
"flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
7297
7313
|
E === y ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
|
|
@@ -7308,26 +7324,26 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7308
7324
|
/* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
|
|
7309
7325
|
ScrollArea,
|
|
7310
7326
|
{
|
|
7311
|
-
onMouseEnter: () =>
|
|
7327
|
+
onMouseEnter: () => j.current ? clearTimeout(j.current) : null,
|
|
7312
7328
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7313
7329
|
children: [
|
|
7314
|
-
isEmpty(
|
|
7315
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: I.map((
|
|
7330
|
+
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: [
|
|
7331
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: I.map((w, E) => /* @__PURE__ */ jsx(
|
|
7316
7332
|
BlockCard,
|
|
7317
7333
|
{
|
|
7318
7334
|
parentId: o,
|
|
7319
7335
|
position: n,
|
|
7320
|
-
block:
|
|
7336
|
+
block: w,
|
|
7321
7337
|
library: i
|
|
7322
7338
|
},
|
|
7323
7339
|
`block-${E}`
|
|
7324
7340
|
)) }),
|
|
7325
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((
|
|
7341
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((w, E) => /* @__PURE__ */ jsx(
|
|
7326
7342
|
BlockCard,
|
|
7327
7343
|
{
|
|
7328
7344
|
parentId: o,
|
|
7329
7345
|
position: n,
|
|
7330
|
-
block:
|
|
7346
|
+
block: w,
|
|
7331
7347
|
library: i
|
|
7332
7348
|
},
|
|
7333
7349
|
`block-second-${E}`
|
|
@@ -7366,25 +7382,25 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7366
7382
|
error: c
|
|
7367
7383
|
}), g(!0);
|
|
7368
7384
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7369
|
-
const h = Object.entries(a).map(([
|
|
7370
|
-
const y = b,
|
|
7385
|
+
const h = Object.entries(a).map(([f, b]) => {
|
|
7386
|
+
const y = b, C = y.type || "partial", v = formatReadableName(C);
|
|
7371
7387
|
return {
|
|
7372
7388
|
type: "PartialBlock",
|
|
7373
7389
|
// Set the type to PartialBlock
|
|
7374
|
-
label: formatReadableName(y.name ||
|
|
7390
|
+
label: formatReadableName(y.name || f),
|
|
7375
7391
|
description: y.description || "",
|
|
7376
7392
|
icon: FrameIcon,
|
|
7377
|
-
group:
|
|
7393
|
+
group: v,
|
|
7378
7394
|
// Use formatted type as group
|
|
7379
7395
|
category: "partial",
|
|
7380
|
-
partialBlockId:
|
|
7396
|
+
partialBlockId: f,
|
|
7381
7397
|
// Store the original ID as partialBlockId
|
|
7382
7398
|
_name: y.name
|
|
7383
7399
|
};
|
|
7384
|
-
}),
|
|
7400
|
+
}), x = uniq(map(h, "group"));
|
|
7385
7401
|
p({
|
|
7386
7402
|
blocks: h,
|
|
7387
|
-
groups:
|
|
7403
|
+
groups: x,
|
|
7388
7404
|
isLoading: !1,
|
|
7389
7405
|
error: null
|
|
7390
7406
|
}), g(!0);
|
|
@@ -7430,43 +7446,43 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7430
7446
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
|
|
7431
7447
|
}, 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" }) => {
|
|
7432
7448
|
var A;
|
|
7433
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (A = find(c, (
|
|
7449
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (A = find(c, (w) => w._id === r)) == null ? void 0 : A._type, [h, x] = useState("all"), [f, b] = useState(null), y = useRef(null);
|
|
7434
7450
|
useEffect(() => {
|
|
7435
|
-
const
|
|
7451
|
+
const w = setTimeout(() => {
|
|
7436
7452
|
var E;
|
|
7437
7453
|
(E = u.current) == null || E.focus();
|
|
7438
7454
|
}, 0);
|
|
7439
|
-
return () => clearTimeout(
|
|
7455
|
+
return () => clearTimeout(w);
|
|
7440
7456
|
}, [g]), useEffect(() => {
|
|
7441
|
-
d && (
|
|
7442
|
-
}, [d]), useEffect(() => (y.current = debounce((
|
|
7443
|
-
|
|
7457
|
+
d && (x("all"), b(null));
|
|
7458
|
+
}, [d]), useEffect(() => (y.current = debounce((w) => {
|
|
7459
|
+
x(w);
|
|
7444
7460
|
}, 500), () => {
|
|
7445
7461
|
y.current && y.current.cancel();
|
|
7446
7462
|
}), []);
|
|
7447
|
-
const
|
|
7448
|
-
b(
|
|
7449
|
-
}, []),
|
|
7463
|
+
const C = useCallback((w) => {
|
|
7464
|
+
b(w), y.current && y.current(w);
|
|
7465
|
+
}, []), v = useCallback(() => {
|
|
7450
7466
|
b(null), y.current && y.current.cancel();
|
|
7451
|
-
}, []),
|
|
7452
|
-
y.current && y.current.cancel(),
|
|
7467
|
+
}, []), j = useCallback((w) => {
|
|
7468
|
+
y.current && y.current.cancel(), x(w), b(null);
|
|
7453
7469
|
}, []), _ = useMemo(
|
|
7454
7470
|
() => d ? values(n).filter(
|
|
7455
|
-
(
|
|
7471
|
+
(w) => {
|
|
7456
7472
|
var E, L;
|
|
7457
|
-
return (((E =
|
|
7473
|
+
return (((E = w.label) == null ? void 0 : E.toLowerCase()) + " " + ((L = w.type) == null ? void 0 : L.toLowerCase())).includes(d.toLowerCase());
|
|
7458
7474
|
}
|
|
7459
7475
|
) : n,
|
|
7460
7476
|
[n, d]
|
|
7461
|
-
),
|
|
7477
|
+
), B = useMemo(
|
|
7462
7478
|
() => d ? o.filter(
|
|
7463
|
-
(
|
|
7464
|
-
) : o.filter((
|
|
7479
|
+
(w) => reject(filter(values(_), { group: w }), { hidden: !0 }).length > 0
|
|
7480
|
+
) : o.filter((w) => reject(filter(values(n), { group: w }), { hidden: !0 }).length > 0),
|
|
7465
7481
|
[n, _, o, d]
|
|
7466
|
-
),
|
|
7467
|
-
() => sortBy(
|
|
7468
|
-
[
|
|
7469
|
-
), k = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), I = useMemo(() => h === "all" ?
|
|
7482
|
+
), S = useMemo(
|
|
7483
|
+
() => sortBy(B, (w) => CORE_GROUPS.indexOf(w) === -1 ? 99 : CORE_GROUPS.indexOf(w)),
|
|
7484
|
+
[B]
|
|
7485
|
+
), k = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), I = useMemo(() => h === "all" ? S : [h], [S, h]);
|
|
7470
7486
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7471
7487
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7472
7488
|
Input$1,
|
|
@@ -7476,43 +7492,43 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7476
7492
|
placeholder: i("Search blocks..."),
|
|
7477
7493
|
value: d,
|
|
7478
7494
|
className: "-ml-2",
|
|
7479
|
-
onChange: (
|
|
7495
|
+
onChange: (w) => p(w.target.value)
|
|
7480
7496
|
}
|
|
7481
7497
|
) }),
|
|
7482
7498
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7483
|
-
|
|
7499
|
+
S.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
7484
7500
|
/* @__PURE__ */ jsx(
|
|
7485
7501
|
"button",
|
|
7486
7502
|
{
|
|
7487
|
-
onClick: () =>
|
|
7488
|
-
onMouseEnter: () =>
|
|
7489
|
-
onMouseLeave:
|
|
7490
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" ||
|
|
7503
|
+
onClick: () => j("all"),
|
|
7504
|
+
onMouseEnter: () => C("all"),
|
|
7505
|
+
onMouseLeave: v,
|
|
7506
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7491
7507
|
children: i("All")
|
|
7492
7508
|
},
|
|
7493
7509
|
"sidebar-all"
|
|
7494
7510
|
),
|
|
7495
|
-
|
|
7511
|
+
S.map((w) => /* @__PURE__ */ jsx(
|
|
7496
7512
|
"button",
|
|
7497
7513
|
{
|
|
7498
|
-
onClick: () =>
|
|
7499
|
-
onMouseEnter: () =>
|
|
7500
|
-
onMouseLeave:
|
|
7501
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h ===
|
|
7502
|
-
children: capitalize(i(
|
|
7514
|
+
onClick: () => j(w),
|
|
7515
|
+
onMouseEnter: () => C(w),
|
|
7516
|
+
onMouseLeave: v,
|
|
7517
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === w || f === w ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7518
|
+
children: capitalize(i(w.toLowerCase()))
|
|
7503
7519
|
},
|
|
7504
|
-
`sidebar-${
|
|
7520
|
+
`sidebar-${w}`
|
|
7505
7521
|
))
|
|
7506
7522
|
] }) }) }),
|
|
7507
|
-
/* @__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:
|
|
7523
|
+
/* @__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: B.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: [
|
|
7508
7524
|
i("No blocks found matching"),
|
|
7509
7525
|
' "',
|
|
7510
7526
|
d,
|
|
7511
7527
|
'"'
|
|
7512
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((
|
|
7513
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7528
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((w) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7529
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(w.toLowerCase())) }),
|
|
7514
7530
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7515
|
-
h === "all" ? filter(values(k), { group:
|
|
7531
|
+
h === "all" ? filter(values(k), { group: w }) : values(k),
|
|
7516
7532
|
{ hidden: !0 }
|
|
7517
7533
|
).map((E) => /* @__PURE__ */ jsx(
|
|
7518
7534
|
CoreBlock,
|
|
@@ -7524,7 +7540,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7524
7540
|
},
|
|
7525
7541
|
E.type
|
|
7526
7542
|
)) })
|
|
7527
|
-
] },
|
|
7543
|
+
] }, w)) }) }) })
|
|
7528
7544
|
] })
|
|
7529
7545
|
] });
|
|
7530
7546
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
@@ -7539,7 +7555,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7539
7555
|
}, [i, g, c]);
|
|
7540
7556
|
const h = useCallback(() => {
|
|
7541
7557
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7542
|
-
}, []),
|
|
7558
|
+
}, []), x = useChaiAddBlockTabs(), f = p && m(PERMISSIONS.IMPORT_HTML), y = useChaiLibraries().length > 0;
|
|
7543
7559
|
return useEffect(() => {
|
|
7544
7560
|
i === "library" && !y && c("core");
|
|
7545
7561
|
}, [i, y, c]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7550,8 +7566,8 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7550
7566
|
/* @__PURE__ */ jsxs(
|
|
7551
7567
|
Tabs,
|
|
7552
7568
|
{
|
|
7553
|
-
onValueChange: (
|
|
7554
|
-
d(""), c(
|
|
7569
|
+
onValueChange: (C) => {
|
|
7570
|
+
d(""), c(C);
|
|
7555
7571
|
},
|
|
7556
7572
|
value: i,
|
|
7557
7573
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -7560,14 +7576,14 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7560
7576
|
y && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7561
7577
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7562
7578
|
g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7563
|
-
|
|
7564
|
-
map(
|
|
7579
|
+
f ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7580
|
+
map(x, (C) => /* @__PURE__ */ jsx(TabsTrigger, { value: C.id, children: React__default.createElement(C.tab) }, `tab-add-block-${C.id}`))
|
|
7565
7581
|
] }),
|
|
7566
7582
|
/* @__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 }) }) }) }),
|
|
7567
7583
|
y && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7568
7584
|
g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7569
|
-
|
|
7570
|
-
map(
|
|
7585
|
+
f ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7586
|
+
map(x, (C) => /* @__PURE__ */ jsx(TabsContent, { value: C.id, children: React__default.createElement(C.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${C.id}`))
|
|
7571
7587
|
]
|
|
7572
7588
|
}
|
|
7573
7589
|
)
|
|
@@ -7686,40 +7702,40 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7686
7702
|
" ",
|
|
7687
7703
|
o("Unlink from library")
|
|
7688
7704
|
] });
|
|
7689
|
-
},
|
|
7690
|
-
const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useCallback(() => {
|
|
7691
|
-
const
|
|
7692
|
-
const
|
|
7705
|
+
}, CopyPasteBlocks = () => {
|
|
7706
|
+
const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useBuilderProp("flags.useClipboard", !1), p = useCallback(() => {
|
|
7707
|
+
const u = n.map((g) => {
|
|
7708
|
+
const m = o.find((h) => h._id === g);
|
|
7693
7709
|
return {
|
|
7694
|
-
id:
|
|
7695
|
-
data:
|
|
7710
|
+
id: g,
|
|
7711
|
+
data: m
|
|
7696
7712
|
};
|
|
7697
7713
|
});
|
|
7698
|
-
l(
|
|
7714
|
+
l(u.map((g) => g.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
|
|
7699
7715
|
cancel: {
|
|
7700
7716
|
label: i("No"),
|
|
7701
7717
|
onClick: () => {
|
|
7702
|
-
a(
|
|
7718
|
+
a(u.map((g) => g.id)), toast.dismiss();
|
|
7703
7719
|
}
|
|
7704
7720
|
},
|
|
7705
7721
|
action: {
|
|
7706
7722
|
label: i("Yes"),
|
|
7707
7723
|
onClick: () => {
|
|
7708
7724
|
a(
|
|
7709
|
-
|
|
7725
|
+
u.map((g) => g.id),
|
|
7710
7726
|
!0
|
|
7711
7727
|
), toast.dismiss();
|
|
7712
7728
|
}
|
|
7713
7729
|
},
|
|
7714
7730
|
position: "top-center"
|
|
7715
|
-
}) : a(
|
|
7731
|
+
}) : a(u.map((g) => g.id));
|
|
7716
7732
|
}, [n, o, a, l]);
|
|
7717
7733
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7718
|
-
|
|
7734
|
+
d && /* @__PURE__ */ jsxs(
|
|
7719
7735
|
DropdownMenuItem,
|
|
7720
7736
|
{
|
|
7721
7737
|
disabled: !canDuplicateBlock(c == null ? void 0 : c._type),
|
|
7722
|
-
onClick:
|
|
7738
|
+
onClick: p,
|
|
7723
7739
|
className: "flex items-center gap-x-4 text-xs",
|
|
7724
7740
|
children: [
|
|
7725
7741
|
/* @__PURE__ */ jsx(CopyIcon, {}),
|
|
@@ -7728,7 +7744,7 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7728
7744
|
]
|
|
7729
7745
|
}
|
|
7730
7746
|
),
|
|
7731
|
-
/* @__PURE__ */ jsxs(
|
|
7747
|
+
d && /* @__PURE__ */ jsxs(
|
|
7732
7748
|
DropdownMenuItem,
|
|
7733
7749
|
{
|
|
7734
7750
|
className: "flex items-center gap-x-4 text-xs",
|
|
@@ -7744,12 +7760,12 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7744
7760
|
)
|
|
7745
7761
|
] });
|
|
7746
7762
|
}, CutBlocks = () => {
|
|
7747
|
-
const [o] = useSelectedBlockIds(), [, n] = useCutBlockIds(), { t: r } = useTranslation();
|
|
7748
|
-
return /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "flex items-center gap-x-4 text-xs", onClick: () => n(o), children: [
|
|
7763
|
+
const [o] = useSelectedBlockIds(), [, n] = useCutBlockIds(), { t: r } = useTranslation(), a = useBuilderProp("flags", { useClipboard: !1 }).useClipboard;
|
|
7764
|
+
return /* @__PURE__ */ jsx(Fragment, { children: a && /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "flex items-center gap-x-4 text-xs", onClick: () => n(o), children: [
|
|
7749
7765
|
/* @__PURE__ */ jsx(ScissorsIcon, {}),
|
|
7750
7766
|
" ",
|
|
7751
7767
|
r("Cut")
|
|
7752
|
-
] });
|
|
7768
|
+
] }) });
|
|
7753
7769
|
}, RemoveBlocks = () => {
|
|
7754
7770
|
const [o] = useSelectedBlockIds(), n = useRemoveBlocks(), r = useSelectedBlock(), { t: a } = useTranslation();
|
|
7755
7771
|
return /* @__PURE__ */ jsxs(
|
|
@@ -7782,7 +7798,7 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7782
7798
|
}
|
|
7783
7799
|
);
|
|
7784
7800
|
}, BlockContextMenuContent = ({ node: o }) => {
|
|
7785
|
-
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), { librarySite: c } = useBuilderProp("
|
|
7801
|
+
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), { librarySite: c } = useBuilderProp("flags", { librarySite: !1 }), d = useCallback(() => {
|
|
7786
7802
|
a(r);
|
|
7787
7803
|
}, [r, a]), p = useMemo(() => has(l, "_libBlockId") && !isEmpty(l._libBlockId), [l == null ? void 0 : l._libBlockId]);
|
|
7788
7804
|
return /* @__PURE__ */ jsxs(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: [
|
|
@@ -7877,26 +7893,26 @@ const Input = ({ node: o }) => {
|
|
|
7877
7893
|
var D;
|
|
7878
7894
|
const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
|
|
7879
7895
|
let d = null;
|
|
7880
|
-
const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected:
|
|
7881
|
-
N.stopPropagation(),
|
|
7896
|
+
const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: f, isDragging: b, isEditing: y, handleClick: C } = o, v = get(h, "_show", !0), j = (N) => {
|
|
7897
|
+
N.stopPropagation(), v && o.toggle();
|
|
7882
7898
|
}, _ = (N) => {
|
|
7883
7899
|
N.isInternal && (d = N.isOpen, N.isOpen && N.close());
|
|
7884
|
-
},
|
|
7900
|
+
}, B = (N) => {
|
|
7885
7901
|
N.isInternal && d !== null && (d ? N.open() : N.close(), d = null);
|
|
7886
|
-
}, [
|
|
7902
|
+
}, [S, k] = useAtom$1(currentAddSelection), I = () => {
|
|
7887
7903
|
var N;
|
|
7888
7904
|
A(), o.parent.isSelected || k((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
|
|
7889
7905
|
}, A = () => {
|
|
7890
7906
|
k(null);
|
|
7891
|
-
},
|
|
7892
|
-
A(), N.stopPropagation(), !o.isOpen &&
|
|
7907
|
+
}, w = (N) => {
|
|
7908
|
+
A(), N.stopPropagation(), !o.isOpen && v && o.toggle(), C(N);
|
|
7893
7909
|
};
|
|
7894
7910
|
useEffect(() => {
|
|
7895
7911
|
const N = setTimeout(() => {
|
|
7896
|
-
|
|
7912
|
+
f && !o.isOpen && !b && v && o.toggle();
|
|
7897
7913
|
}, 500);
|
|
7898
7914
|
return () => clearTimeout(N);
|
|
7899
|
-
}, [
|
|
7915
|
+
}, [f, o, b]);
|
|
7900
7916
|
const E = (N, O) => {
|
|
7901
7917
|
const $ = i.contentDocument || i.contentWindow.document, M = $.querySelector(`[data-block-id=${N}]`);
|
|
7902
7918
|
M && M.setAttribute("data-drop", O);
|
|
@@ -7925,18 +7941,18 @@ const Input = ({ node: o }) => {
|
|
|
7925
7941
|
),
|
|
7926
7942
|
/* @__PURE__ */ jsx("br", {})
|
|
7927
7943
|
] });
|
|
7928
|
-
const { librarySite: T } = useBuilderProp("
|
|
7944
|
+
const { librarySite: T } = useBuilderProp("flags", { librarySite: !1 }), P = useMemo(() => T && has(h, "_libBlockId") && !isEmpty(h._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [h, c, T]), R = useMemo(() => (h == null ? void 0 : h._type) === "PartialBlock" || (h == null ? void 0 : h._type) === "GlobalBlock", [h]);
|
|
7929
7945
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7930
7946
|
"div",
|
|
7931
7947
|
{
|
|
7932
7948
|
onMouseEnter: () => u(m),
|
|
7933
7949
|
onMouseLeave: () => g(),
|
|
7934
|
-
onClick:
|
|
7950
|
+
onClick: w,
|
|
7935
7951
|
style: n,
|
|
7936
7952
|
"data-node-id": m,
|
|
7937
7953
|
ref: r,
|
|
7938
7954
|
onDragStart: () => _(o),
|
|
7939
|
-
onDragEnd: () =>
|
|
7955
|
+
onDragEnd: () => B(o),
|
|
7940
7956
|
onDragOver: (N) => {
|
|
7941
7957
|
N.preventDefault(), E(m, "yes");
|
|
7942
7958
|
},
|
|
@@ -7964,12 +7980,12 @@ const Input = ({ node: o }) => {
|
|
|
7964
7980
|
{
|
|
7965
7981
|
className: cn(
|
|
7966
7982
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
(o == null ? void 0 : o.id) ===
|
|
7983
|
+
x ? "bg-primary/20" : "hover:bg-primary/10",
|
|
7984
|
+
f && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
|
|
7985
|
+
(o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
|
|
7970
7986
|
b && "opacity-20",
|
|
7971
|
-
|
|
7972
|
-
P &&
|
|
7987
|
+
v ? "" : "line-through opacity-50",
|
|
7988
|
+
P && x && "bg-primary/20 text-primary"
|
|
7973
7989
|
),
|
|
7974
7990
|
children: [
|
|
7975
7991
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7977,7 +7993,7 @@ const Input = ({ node: o }) => {
|
|
|
7977
7993
|
"div",
|
|
7978
7994
|
{
|
|
7979
7995
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7980
|
-
children: p && /* @__PURE__ */ jsx("button", { onClick:
|
|
7996
|
+
children: p && /* @__PURE__ */ jsx("button", { onClick: j, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
|
|
7981
7997
|
}
|
|
7982
7998
|
),
|
|
7983
7999
|
/* @__PURE__ */ jsxs(
|
|
@@ -7986,9 +8002,9 @@ const Input = ({ node: o }) => {
|
|
|
7986
8002
|
className: cn(
|
|
7987
8003
|
"leading-1 flex items-center",
|
|
7988
8004
|
P && "text-orange-600/90",
|
|
7989
|
-
P &&
|
|
8005
|
+
P && x && "text-orange-800",
|
|
7990
8006
|
R && "text-purple-600/90",
|
|
7991
|
-
R &&
|
|
8007
|
+
R && x && "text-purple-800"
|
|
7992
8008
|
),
|
|
7993
8009
|
children: [
|
|
7994
8010
|
/* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
|
|
@@ -8007,7 +8023,7 @@ const Input = ({ node: o }) => {
|
|
|
8007
8023
|
)
|
|
8008
8024
|
] }),
|
|
8009
8025
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-px group-hover:visible", children: [
|
|
8010
|
-
canAddChildBlock(h == null ? void 0 : h._type) &&
|
|
8026
|
+
canAddChildBlock(h == null ? void 0 : h._type) && v && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8011
8027
|
/* @__PURE__ */ jsx(
|
|
8012
8028
|
TooltipTrigger,
|
|
8013
8029
|
{
|
|
@@ -8024,14 +8040,14 @@ const Input = ({ node: o }) => {
|
|
|
8024
8040
|
TooltipTrigger,
|
|
8025
8041
|
{
|
|
8026
8042
|
onClick: (N) => {
|
|
8027
|
-
N.stopPropagation(), l([m], { _show: !
|
|
8043
|
+
N.stopPropagation(), l([m], { _show: !v }), o.isOpen && o.toggle();
|
|
8028
8044
|
},
|
|
8029
8045
|
className: "cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",
|
|
8030
8046
|
asChild: !0,
|
|
8031
|
-
children:
|
|
8047
|
+
children: v ? /* @__PURE__ */ jsx(EyeClosedIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-4 w-4" })
|
|
8032
8048
|
}
|
|
8033
8049
|
),
|
|
8034
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(
|
|
8050
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(v ? "Hide the block from page" : "Show the block on page") })
|
|
8035
8051
|
] }),
|
|
8036
8052
|
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, 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" }) }) })
|
|
8037
8053
|
] })
|
|
@@ -8042,10 +8058,10 @@ const Input = ({ node: o }) => {
|
|
|
8042
8058
|
}
|
|
8043
8059
|
) });
|
|
8044
8060
|
}), PasteAtRootContextMenu = ({ parentContext: o, setParentContext: n }) => {
|
|
8045
|
-
const { t: r } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks();
|
|
8061
|
+
const { t: r } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks(), i = useBuilderProp("flags.useClipboard", !1);
|
|
8046
8062
|
return useEffect(() => {
|
|
8047
8063
|
a("root") || n(null);
|
|
8048
|
-
}, [a("root")]), !o || !a("root") ? null : /* @__PURE__ */ jsx("div", { className: "absolute inset-0", children: /* @__PURE__ */ jsxs(DropdownMenu, { open: !0, onOpenChange: () => n(null), children: [
|
|
8064
|
+
}, [a("root")]), !o || !a("root") || !i ? null : /* @__PURE__ */ jsx("div", { className: "absolute inset-0", children: /* @__PURE__ */ jsxs(DropdownMenu, { open: !0, onOpenChange: () => n(null), children: [
|
|
8049
8065
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { className: "hidden" }),
|
|
8050
8066
|
/* @__PURE__ */ jsx(
|
|
8051
8067
|
DropdownMenuContent,
|
|
@@ -8427,7 +8443,7 @@ const Input = ({ node: o }) => {
|
|
|
8427
8443
|
"popover-foreground": ["#3d3436", "#f2e9e4"]
|
|
8428
8444
|
}
|
|
8429
8445
|
}, LazyCssImportModal = lazy(
|
|
8430
|
-
() => import("./css-import-modal-
|
|
8446
|
+
() => import("./css-import-modal-DK2j6oGY.js").then((o) => ({ default: o.CssImportModal }))
|
|
8431
8447
|
), PREV_THEME_KEY = "chai-builder-previous-theme", DEFAULT_THEME_PRESET = [
|
|
8432
8448
|
{ shadcn_default: defaultShadcnPreset },
|
|
8433
8449
|
{ twitter_theme: twitter },
|
|
@@ -8451,23 +8467,23 @@ const Input = ({ node: o }) => {
|
|
|
8451
8467
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8452
8468
|
const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
|
|
8453
8469
|
if (d) {
|
|
8454
|
-
const
|
|
8455
|
-
DEFAULT_THEME_PRESET.forEach((
|
|
8456
|
-
const k = Object.keys(
|
|
8457
|
-
|
|
8470
|
+
const B = d.map((S) => Object.keys(S)[0]);
|
|
8471
|
+
DEFAULT_THEME_PRESET.forEach((S) => {
|
|
8472
|
+
const k = Object.keys(S)[0];
|
|
8473
|
+
B.includes(k) || d.push(S);
|
|
8458
8474
|
});
|
|
8459
8475
|
}
|
|
8460
|
-
const [g, m] = useTheme(), h = useThemeOptions(), { t:
|
|
8461
|
-
(
|
|
8462
|
-
const
|
|
8463
|
-
setPreviousTheme(
|
|
8476
|
+
const [g, m] = useTheme(), h = useThemeOptions(), { t: x } = useTranslation(), f = React.useCallback(
|
|
8477
|
+
(B) => {
|
|
8478
|
+
const S = { ...g };
|
|
8479
|
+
setPreviousTheme(S), m(B), toast.success("Theme updated", {
|
|
8464
8480
|
action: {
|
|
8465
8481
|
label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8466
8482
|
/* @__PURE__ */ jsx(ResetIcon, { className: "h-4 w-4" }),
|
|
8467
8483
|
" Undo"
|
|
8468
8484
|
] }),
|
|
8469
8485
|
onClick: () => {
|
|
8470
|
-
m(
|
|
8486
|
+
m(S), clearPreviousTheme(), toast.dismiss();
|
|
8471
8487
|
}
|
|
8472
8488
|
},
|
|
8473
8489
|
closeButton: !0,
|
|
@@ -8476,81 +8492,81 @@ const Input = ({ node: o }) => {
|
|
|
8476
8492
|
},
|
|
8477
8493
|
[g, m]
|
|
8478
8494
|
), b = () => {
|
|
8479
|
-
const
|
|
8480
|
-
if (
|
|
8481
|
-
const
|
|
8482
|
-
|
|
8495
|
+
const B = d.find((S) => Object.keys(S)[0] === a);
|
|
8496
|
+
if (B) {
|
|
8497
|
+
const S = Object.values(B)[0];
|
|
8498
|
+
S && typeof S == "object" && "fontFamily" in S && "borderRadius" in S && "colors" in S ? (f(S), l("")) : console.error("Invalid preset structure:", S);
|
|
8483
8499
|
} else
|
|
8484
8500
|
console.error("Preset not found:", a);
|
|
8485
|
-
}, y = (
|
|
8486
|
-
|
|
8487
|
-
},
|
|
8488
|
-
(
|
|
8501
|
+
}, y = (B) => {
|
|
8502
|
+
f(B), l("");
|
|
8503
|
+
}, C = useDebouncedCallback(
|
|
8504
|
+
(B, S) => {
|
|
8489
8505
|
m(() => ({
|
|
8490
8506
|
...g,
|
|
8491
8507
|
fontFamily: {
|
|
8492
8508
|
...g.fontFamily,
|
|
8493
|
-
[
|
|
8509
|
+
[B.replace(/font-/g, "")]: S
|
|
8494
8510
|
}
|
|
8495
8511
|
}));
|
|
8496
8512
|
},
|
|
8497
8513
|
[g],
|
|
8498
8514
|
200
|
|
8499
|
-
),
|
|
8500
|
-
(
|
|
8515
|
+
), v = React.useCallback(
|
|
8516
|
+
(B) => {
|
|
8501
8517
|
m(() => ({
|
|
8502
8518
|
...g,
|
|
8503
|
-
borderRadius: `${
|
|
8519
|
+
borderRadius: `${B}px`
|
|
8504
8520
|
}));
|
|
8505
8521
|
},
|
|
8506
8522
|
[g]
|
|
8507
|
-
),
|
|
8508
|
-
(
|
|
8523
|
+
), j = useDebouncedCallback(
|
|
8524
|
+
(B, S) => {
|
|
8509
8525
|
m(() => {
|
|
8510
|
-
const k = get(g, `colors.${
|
|
8511
|
-
return n ? set(k, 1,
|
|
8526
|
+
const k = get(g, `colors.${B}`);
|
|
8527
|
+
return n ? set(k, 1, S) : set(k, 0, S), {
|
|
8512
8528
|
...g,
|
|
8513
8529
|
colors: {
|
|
8514
8530
|
...g.colors,
|
|
8515
|
-
[
|
|
8531
|
+
[B]: k
|
|
8516
8532
|
}
|
|
8517
8533
|
};
|
|
8518
8534
|
});
|
|
8519
8535
|
},
|
|
8520
8536
|
[g],
|
|
8521
8537
|
200
|
|
8522
|
-
), _ = (
|
|
8523
|
-
const k = get(g, `colors.${
|
|
8538
|
+
), _ = (B) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(B.items).map(([S]) => {
|
|
8539
|
+
const k = get(g, `colors.${S}.${n ? 1 : 0}`);
|
|
8524
8540
|
return k ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8525
8541
|
/* @__PURE__ */ jsx(
|
|
8526
8542
|
ColorPickerInput,
|
|
8527
8543
|
{
|
|
8528
8544
|
value: k,
|
|
8529
|
-
onChange: (I) =>
|
|
8545
|
+
onChange: (I) => j(S, I)
|
|
8530
8546
|
}
|
|
8531
8547
|
),
|
|
8532
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children:
|
|
8533
|
-
] },
|
|
8548
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: S.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((I) => I.charAt(0).toUpperCase() + I.slice(1)).join(" ") + (!S.toLowerCase().includes("foreground") && !S.toLowerCase().includes("border") && !S.toLowerCase().includes("input") && !S.toLowerCase().includes("ring") && !S.toLowerCase().includes("background") ? " Background" : "") })
|
|
8549
|
+
] }, S) : null;
|
|
8534
8550
|
}) });
|
|
8535
8551
|
return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8536
8552
|
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8537
8553
|
d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
|
|
8538
8554
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
8539
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8555
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: x("Presets") }),
|
|
8540
8556
|
/* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
|
|
8541
8557
|
/* @__PURE__ */ jsx(UploadIcon, { className: "h-4 w-4" }),
|
|
8542
|
-
|
|
8558
|
+
x("Import theme")
|
|
8543
8559
|
] }) })
|
|
8544
8560
|
] }),
|
|
8545
8561
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
|
|
8546
8562
|
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
|
|
8547
8563
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
|
|
8548
|
-
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((
|
|
8549
|
-
const
|
|
8550
|
-
return /* @__PURE__ */ jsx(SelectItem, { value:
|
|
8564
|
+
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((B) => {
|
|
8565
|
+
const S = Object.keys(B)[0], k = S.replaceAll("_", " ");
|
|
8566
|
+
return /* @__PURE__ */ jsx(SelectItem, { value: S, children: capitalize(k) }, S);
|
|
8551
8567
|
}) })
|
|
8552
8568
|
] }) }),
|
|
8553
|
-
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: b, children:
|
|
8569
|
+
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: b, children: x("Apply") }) })
|
|
8554
8570
|
] })
|
|
8555
8571
|
] }),
|
|
8556
8572
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
@@ -8559,14 +8575,14 @@ const Input = ({ node: o }) => {
|
|
|
8559
8575
|
/* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 text-gray-600" }),
|
|
8560
8576
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
|
|
8561
8577
|
] }),
|
|
8562
|
-
(h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([
|
|
8578
|
+
(h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([B, S]) => /* @__PURE__ */ jsx(
|
|
8563
8579
|
FontSelector,
|
|
8564
8580
|
{
|
|
8565
|
-
label:
|
|
8566
|
-
value: g.fontFamily[
|
|
8567
|
-
onChange: (k) =>
|
|
8581
|
+
label: B,
|
|
8582
|
+
value: g.fontFamily[B.replace(/font-/g, "")] || S[Object.keys(S)[0]],
|
|
8583
|
+
onChange: (k) => C(B, k)
|
|
8568
8584
|
},
|
|
8569
|
-
|
|
8585
|
+
B
|
|
8570
8586
|
)) }),
|
|
8571
8587
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
8572
8588
|
(h == null ? void 0 : h.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
@@ -8577,7 +8593,7 @@ const Input = ({ node: o }) => {
|
|
|
8577
8593
|
] }),
|
|
8578
8594
|
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: g.borderRadius })
|
|
8579
8595
|
] }),
|
|
8580
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange:
|
|
8596
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: v }) })
|
|
8581
8597
|
] }),
|
|
8582
8598
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
8583
8599
|
(h == null ? void 0 : h.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
@@ -8592,7 +8608,7 @@ const Input = ({ node: o }) => {
|
|
|
8592
8608
|
Switch,
|
|
8593
8609
|
{
|
|
8594
8610
|
checked: n,
|
|
8595
|
-
onCheckedChange: (
|
|
8611
|
+
onCheckedChange: (B) => r(B),
|
|
8596
8612
|
"aria-label": "Toggle dark mode",
|
|
8597
8613
|
className: "mx-1"
|
|
8598
8614
|
}
|
|
@@ -8600,7 +8616,7 @@ const Input = ({ node: o }) => {
|
|
|
8600
8616
|
/* @__PURE__ */ jsx(MoonIcon, { className: "h-4 w-4" })
|
|
8601
8617
|
] }) })
|
|
8602
8618
|
] }),
|
|
8603
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((
|
|
8619
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((B) => _(B)) })
|
|
8604
8620
|
] }),
|
|
8605
8621
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && /* @__PURE__ */ jsx(
|
|
8606
8622
|
LazyCssImportModal,
|
|
@@ -9141,7 +9157,7 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9141
9157
|
)
|
|
9142
9158
|
) }) });
|
|
9143
9159
|
}
|
|
9144
|
-
const AIUserPrompt = ({ blockId: o }) => {
|
|
9160
|
+
const 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" }) }), AIUserPrompt = ({ blockId: o }) => {
|
|
9145
9161
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), u = useSelectedBlock();
|
|
9146
9162
|
useEffect(() => {
|
|
9147
9163
|
var m;
|
|
@@ -9241,140 +9257,7 @@ const UndoRedo = () => {
|
|
|
9241
9257
|
/* @__PURE__ */ jsx(Button, { disabled: !o(), size: "sm", onClick: r, className: "rounded-full", variant: "ghost", children: /* @__PURE__ */ jsx(ResetIcon, {}) }),
|
|
9242
9258
|
/* @__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" }) })
|
|
9243
9259
|
] });
|
|
9244
|
-
}
|
|
9245
|
-
function AIChatPanel() {
|
|
9246
|
-
const [o, n] = useState([]), [r, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null), g = useRef(null);
|
|
9247
|
-
useEffect(() => {
|
|
9248
|
-
var y;
|
|
9249
|
-
(y = u.current) == null || y.scrollIntoView({ behavior: "smooth" });
|
|
9250
|
-
}, [o]), useEffect(() => {
|
|
9251
|
-
g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
|
|
9252
|
-
}, [r]);
|
|
9253
|
-
const m = async () => {
|
|
9254
|
-
if (!r.trim() && !c) return;
|
|
9255
|
-
const y = {
|
|
9256
|
-
id: Date.now().toString(),
|
|
9257
|
-
role: "user",
|
|
9258
|
-
content: r,
|
|
9259
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
9260
|
-
};
|
|
9261
|
-
n((S) => [...S, y]), a(""), i(!0), setTimeout(() => {
|
|
9262
|
-
const S = {
|
|
9263
|
-
id: (Date.now() + 1).toString(),
|
|
9264
|
-
role: "assistant",
|
|
9265
|
-
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.",
|
|
9266
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
9267
|
-
};
|
|
9268
|
-
n((C) => [...C, S]), i(!1), d(null);
|
|
9269
|
-
}, 1500);
|
|
9270
|
-
}, h = (y) => {
|
|
9271
|
-
y.key === "Enter" && !y.shiftKey && (y.preventDefault(), m());
|
|
9272
|
-
}, f = (y) => {
|
|
9273
|
-
var C;
|
|
9274
|
-
const S = (C = y.target.files) == null ? void 0 : C[0];
|
|
9275
|
-
if (S) {
|
|
9276
|
-
const B = new FileReader();
|
|
9277
|
-
B.onload = (_) => {
|
|
9278
|
-
var w;
|
|
9279
|
-
d((w = _.target) == null ? void 0 : w.result);
|
|
9280
|
-
}, B.readAsDataURL(S);
|
|
9281
|
-
}
|
|
9282
|
-
}, x = () => {
|
|
9283
|
-
var y;
|
|
9284
|
-
(y = p.current) == null || y.click();
|
|
9285
|
-
}, b = () => {
|
|
9286
|
-
d(null), p.current && (p.current.value = "");
|
|
9287
|
-
};
|
|
9288
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
|
|
9289
|
-
/* @__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: [
|
|
9290
|
-
/* @__PURE__ */ jsx(AiIcon, { className: "mb-2 h-8 w-8 text-primary/50" }),
|
|
9291
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm", children: "Ask me anything to get started" })
|
|
9292
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
9293
|
-
o.map((y) => /* @__PURE__ */ jsxs(
|
|
9294
|
-
"div",
|
|
9295
|
-
{
|
|
9296
|
-
className: cn$2(
|
|
9297
|
-
"flex max-w-full gap-2",
|
|
9298
|
-
y.role === "assistant" ? "items-start" : "items-start justify-end"
|
|
9299
|
-
),
|
|
9300
|
-
children: [
|
|
9301
|
-
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" }) }),
|
|
9302
|
-
/* @__PURE__ */ jsx(
|
|
9303
|
-
"div",
|
|
9304
|
-
{
|
|
9305
|
-
className: cn$2(
|
|
9306
|
-
"rounded-lg px-3 py-2 text-sm",
|
|
9307
|
-
y.role === "assistant" ? "bg-muted text-foreground" : "bg-primary text-primary-foreground"
|
|
9308
|
-
),
|
|
9309
|
-
children: y.content
|
|
9310
|
-
}
|
|
9311
|
-
),
|
|
9312
|
-
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" }) })
|
|
9313
|
-
]
|
|
9314
|
-
},
|
|
9315
|
-
y.id
|
|
9316
|
-
)),
|
|
9317
|
-
l && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
9318
|
-
/* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary/10", children: /* @__PURE__ */ jsx(AiIcon, { className: "h-3 w-3 text-primary" }) }),
|
|
9319
|
-
/* @__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" }) })
|
|
9320
|
-
] }),
|
|
9321
|
-
/* @__PURE__ */ jsx("div", { ref: u })
|
|
9322
|
-
] }) }),
|
|
9323
|
-
c && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "relative h-20 w-20 overflow-hidden rounded-md", children: [
|
|
9324
|
-
/* @__PURE__ */ jsx("img", { src: c || "/placeholder.svg", alt: "Attachment", className: "h-full w-full object-cover" }),
|
|
9325
|
-
/* @__PURE__ */ jsx(
|
|
9326
|
-
Button,
|
|
9327
|
-
{
|
|
9328
|
-
size: "icon",
|
|
9329
|
-
variant: "destructive",
|
|
9330
|
-
className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
|
|
9331
|
-
onClick: b,
|
|
9332
|
-
children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" })
|
|
9333
|
-
}
|
|
9334
|
-
)
|
|
9335
|
-
] }) }),
|
|
9336
|
-
/* @__PURE__ */ jsx("div", { className: "mt-auto p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
|
|
9337
|
-
/* @__PURE__ */ jsxs("div", { className: "relative flex-1", children: [
|
|
9338
|
-
/* @__PURE__ */ jsx(
|
|
9339
|
-
Textarea,
|
|
9340
|
-
{
|
|
9341
|
-
ref: g,
|
|
9342
|
-
value: r,
|
|
9343
|
-
onChange: (y) => a(y.target.value),
|
|
9344
|
-
onKeyDown: h,
|
|
9345
|
-
placeholder: "Ask something...",
|
|
9346
|
-
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9347
|
-
}
|
|
9348
|
-
),
|
|
9349
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
|
|
9350
|
-
/* @__PURE__ */ jsx(
|
|
9351
|
-
Button,
|
|
9352
|
-
{
|
|
9353
|
-
size: "icon",
|
|
9354
|
-
variant: "ghost",
|
|
9355
|
-
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9356
|
-
onClick: x,
|
|
9357
|
-
children: /* @__PURE__ */ jsx(ImageIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
9358
|
-
}
|
|
9359
|
-
)
|
|
9360
|
-
] }),
|
|
9361
|
-
/* @__PURE__ */ jsxs(
|
|
9362
|
-
Button,
|
|
9363
|
-
{
|
|
9364
|
-
size: "sm",
|
|
9365
|
-
className: "h-10 px-3",
|
|
9366
|
-
onClick: m,
|
|
9367
|
-
disabled: l || !r.trim() && !c,
|
|
9368
|
-
children: [
|
|
9369
|
-
/* @__PURE__ */ jsx(PaperPlaneIcon, { className: "mr-1 h-4 w-4" }),
|
|
9370
|
-
"Send"
|
|
9371
|
-
]
|
|
9372
|
-
}
|
|
9373
|
-
)
|
|
9374
|
-
] }) })
|
|
9375
|
-
] });
|
|
9376
|
-
}
|
|
9377
|
-
const ClearCanvas = () => {
|
|
9260
|
+
}, ClearCanvas = () => {
|
|
9378
9261
|
const { t: o } = useTranslation(), { setNewBlocks: n } = useBlocksStoreUndoableActions(), [, r] = useSelectedBlockIds(), [, a] = useSelectedStylingBlocks(), l = useCallback(() => {
|
|
9379
9262
|
n([]), r([]), a([]);
|
|
9380
9263
|
}, [n]);
|
|
@@ -9449,11 +9332,11 @@ const ClearCanvas = () => {
|
|
|
9449
9332
|
preloadedAttributes: n = [],
|
|
9450
9333
|
onAttributesChange: r
|
|
9451
9334
|
}) {
|
|
9452
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""),
|
|
9335
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), x = useRef(null), f = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
|
|
9453
9336
|
useEffect(() => {
|
|
9454
9337
|
l(n);
|
|
9455
9338
|
}, [n]);
|
|
9456
|
-
const
|
|
9339
|
+
const C = () => {
|
|
9457
9340
|
if (i.startsWith("@")) {
|
|
9458
9341
|
h("Attribute keys cannot start with '@'");
|
|
9459
9342
|
return;
|
|
@@ -9462,10 +9345,10 @@ const ClearCanvas = () => {
|
|
|
9462
9345
|
const k = [...a, { key: i, value: d }];
|
|
9463
9346
|
r(k), l(a), c(""), p(""), h("");
|
|
9464
9347
|
}
|
|
9465
|
-
},
|
|
9466
|
-
const I = a.filter((A,
|
|
9348
|
+
}, v = (k) => {
|
|
9349
|
+
const I = a.filter((A, w) => w !== k);
|
|
9467
9350
|
r(I), l(I);
|
|
9468
|
-
},
|
|
9351
|
+
}, j = (k) => {
|
|
9469
9352
|
g(k), c(a[k].key), p(a[k].value);
|
|
9470
9353
|
}, _ = () => {
|
|
9471
9354
|
if (i.startsWith("@")) {
|
|
@@ -9476,9 +9359,9 @@ const ClearCanvas = () => {
|
|
|
9476
9359
|
const k = [...a];
|
|
9477
9360
|
k[u] = { key: i, value: d }, r(k), l(k), g(null), c(""), p(""), h("");
|
|
9478
9361
|
}
|
|
9479
|
-
},
|
|
9480
|
-
k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? _() :
|
|
9481
|
-
},
|
|
9362
|
+
}, B = (k) => {
|
|
9363
|
+
k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? _() : C());
|
|
9364
|
+
}, S = useCallback((k) => {
|
|
9482
9365
|
const I = (E) => /[.,!?;:]/.test(E), A = (E, L, T) => {
|
|
9483
9366
|
let P = "", R = "";
|
|
9484
9367
|
const D = L > 0 ? E[L - 1] : "", N = L < E.length ? E[L] : "";
|
|
@@ -9487,9 +9370,9 @@ const ClearCanvas = () => {
|
|
|
9487
9370
|
prefixLength: P.length,
|
|
9488
9371
|
suffixLength: R.length
|
|
9489
9372
|
};
|
|
9490
|
-
},
|
|
9491
|
-
if (
|
|
9492
|
-
const E =
|
|
9373
|
+
}, w = f.current;
|
|
9374
|
+
if (w) {
|
|
9375
|
+
const E = w.selectionStart || 0, L = w.value || "", T = w.selectionEnd || E;
|
|
9493
9376
|
if (T > E) {
|
|
9494
9377
|
const O = `{{${k}}}`, { text: $ } = A(L, E, O), M = L.slice(0, E) + $ + L.slice(T);
|
|
9495
9378
|
p(M);
|
|
@@ -9504,7 +9387,7 @@ const ClearCanvas = () => {
|
|
|
9504
9387
|
"form",
|
|
9505
9388
|
{
|
|
9506
9389
|
onSubmit: (k) => {
|
|
9507
|
-
k.preventDefault(), u !== null ? _() :
|
|
9390
|
+
k.preventDefault(), u !== null ? _() : C();
|
|
9508
9391
|
},
|
|
9509
9392
|
className: "space-y-3",
|
|
9510
9393
|
children: [
|
|
@@ -9518,7 +9401,7 @@ const ClearCanvas = () => {
|
|
|
9518
9401
|
autoCorrect: "off",
|
|
9519
9402
|
spellCheck: "false",
|
|
9520
9403
|
id: "attrKey",
|
|
9521
|
-
ref:
|
|
9404
|
+
ref: x,
|
|
9522
9405
|
value: i,
|
|
9523
9406
|
onChange: (k) => c(k.target.value),
|
|
9524
9407
|
placeholder: y("Enter Key"),
|
|
@@ -9529,7 +9412,7 @@ const ClearCanvas = () => {
|
|
|
9529
9412
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9530
9413
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9531
9414
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9532
|
-
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect:
|
|
9415
|
+
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: S })
|
|
9533
9416
|
] }),
|
|
9534
9417
|
/* @__PURE__ */ jsx(
|
|
9535
9418
|
Textarea,
|
|
@@ -9539,10 +9422,10 @@ const ClearCanvas = () => {
|
|
|
9539
9422
|
spellCheck: "false",
|
|
9540
9423
|
id: "attrValue",
|
|
9541
9424
|
rows: 2,
|
|
9542
|
-
ref:
|
|
9425
|
+
ref: f,
|
|
9543
9426
|
value: d,
|
|
9544
9427
|
onChange: (k) => p(k.target.value),
|
|
9545
|
-
onKeyDown:
|
|
9428
|
+
onKeyDown: B,
|
|
9546
9429
|
placeholder: "Enter Value",
|
|
9547
9430
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9548
9431
|
}
|
|
@@ -9560,8 +9443,8 @@ const ClearCanvas = () => {
|
|
|
9560
9443
|
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: k.value.toString() })
|
|
9561
9444
|
] }),
|
|
9562
9445
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9563
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9564
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9446
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => j(I), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
|
|
9447
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(I), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
|
|
9565
9448
|
] })
|
|
9566
9449
|
] }, I)) })
|
|
9567
9450
|
] });
|
|
@@ -9703,99 +9586,87 @@ const PartialWrapper = ({ partialBlockId: o }) => {
|
|
|
9703
9586
|
component: DefaultTopBar
|
|
9704
9587
|
}, registerChaiTopBar = (o) => {
|
|
9705
9588
|
TOP_BAR.component = o;
|
|
9706
|
-
}, 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" }) }),
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
button: OutlineButton,
|
|
9724
|
-
panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
|
|
9725
|
-
}), o && n && r.unshift({
|
|
9726
|
-
id: "ai",
|
|
9727
|
-
button: AiButton,
|
|
9728
|
-
label: "AI Assistant",
|
|
9729
|
-
isInternal: !0,
|
|
9730
|
-
width: 450,
|
|
9731
|
-
panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8 h-full max-h-full", children: /* @__PURE__ */ jsx(AIChatPanel, {}) })
|
|
9732
|
-
}), compact(r);
|
|
9733
|
-
}, [o, n]);
|
|
9734
|
-
}
|
|
9589
|
+
}, 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, {}) });
|
|
9590
|
+
registerChaiSidebarPanel("chai-chat-panel", {
|
|
9591
|
+
button: AskAiButton,
|
|
9592
|
+
label: "Ask AI",
|
|
9593
|
+
position: "top",
|
|
9594
|
+
isInternal: !0,
|
|
9595
|
+
width: DEFAULT_PANEL_WIDTH,
|
|
9596
|
+
panel: () => /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsx(AskAI, {}) })
|
|
9597
|
+
});
|
|
9598
|
+
registerChaiSidebarPanel("outline", {
|
|
9599
|
+
button: OutlineButton,
|
|
9600
|
+
label: "Outline",
|
|
9601
|
+
position: "top",
|
|
9602
|
+
isInternal: !0,
|
|
9603
|
+
width: DEFAULT_PANEL_WIDTH,
|
|
9604
|
+
panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
|
|
9605
|
+
});
|
|
9735
9606
|
const RootLayout = () => {
|
|
9736
|
-
const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p =
|
|
9607
|
+
const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = reverse([...u ?? []]), m = useCallback((k) => {
|
|
9737
9608
|
k.preventDefault();
|
|
9738
|
-
}, []),
|
|
9609
|
+
}, []), h = useMemo(() => {
|
|
9610
|
+
const k = [p].flat(), I = k.find((w) => w.id === "chai-chat-panel"), A = k.filter((w) => w.id !== "chai-chat-panel");
|
|
9611
|
+
return I ? [I, ...A] : k;
|
|
9612
|
+
}, [p]), x = useCallback(
|
|
9739
9613
|
(k) => {
|
|
9740
9614
|
console.log("handleMenuItemClick", k, n), r(n === k ? null : k);
|
|
9741
9615
|
},
|
|
9742
9616
|
[n, r]
|
|
9743
|
-
), { t:
|
|
9744
|
-
() => [...p, ...u, ...g],
|
|
9745
|
-
[p, u, g]
|
|
9746
|
-
), y = useBuilderProp("htmlDir", "ltr"), S = find(b, { id: n }) ?? first(b), C = get(S, "width", DEFAULT_PANEL_WIDTH);
|
|
9617
|
+
), { t: f } = useTranslation(), b = useMemo(() => [...p, ...u], [p, u]), y = useBuilderProp("htmlDir", "ltr"), C = find(b, { id: n }) ?? first(b), v = get(C, "width", DEFAULT_PANEL_WIDTH);
|
|
9747
9618
|
useEffect(() => {
|
|
9748
9619
|
if (n !== null) {
|
|
9749
9620
|
const k = find(b, { id: n });
|
|
9750
9621
|
k && get(k, "view", "standard") === "standard" && (a.current = n, i(get(k, "width", DEFAULT_PANEL_WIDTH)));
|
|
9751
9622
|
}
|
|
9752
9623
|
}, [n, b]);
|
|
9753
|
-
const
|
|
9624
|
+
const j = useMemo(() => {
|
|
9754
9625
|
if (n === null) return 0;
|
|
9755
9626
|
const k = find(b, { id: n });
|
|
9756
|
-
return get(k, "view", "standard") === "standard" ?
|
|
9757
|
-
}, [n,
|
|
9627
|
+
return get(k, "view", "standard") === "standard" ? v : l;
|
|
9628
|
+
}, [n, v, l, b]), _ = useCallback(() => {
|
|
9758
9629
|
r(a.current);
|
|
9759
|
-
}, [r, n]),
|
|
9630
|
+
}, [r, n]), B = useCallback(() => {
|
|
9760
9631
|
r("outline");
|
|
9761
9632
|
}, [r]);
|
|
9762
9633
|
useEffect(() => {
|
|
9763
9634
|
n !== null && !find(b, { id: n }) && r("outline");
|
|
9764
9635
|
}, [n, b]);
|
|
9765
|
-
const
|
|
9636
|
+
const S = useCallback(
|
|
9766
9637
|
(k) => {
|
|
9767
|
-
|
|
9638
|
+
x(k);
|
|
9768
9639
|
},
|
|
9769
|
-
[
|
|
9640
|
+
[x]
|
|
9770
9641
|
);
|
|
9771
9642
|
return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9772
9643
|
/* @__PURE__ */ jsxs(
|
|
9773
9644
|
"div",
|
|
9774
9645
|
{
|
|
9775
|
-
onContextMenu:
|
|
9646
|
+
onContextMenu: m,
|
|
9776
9647
|
className: "flex h-full max-h-full flex-col bg-background text-foreground",
|
|
9777
9648
|
children: [
|
|
9778
9649
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9779
9650
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9780
9651
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9781
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children:
|
|
9652
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: h.map((k, I) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9782
9653
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
|
|
9783
9654
|
position: "top",
|
|
9784
9655
|
panelId: k.id,
|
|
9785
9656
|
isActive: n === k.id,
|
|
9786
|
-
show: () =>
|
|
9657
|
+
show: () => S(k.id)
|
|
9787
9658
|
}) }),
|
|
9788
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9659
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
|
|
9789
9660
|
] }, "button-top-" + I)) }),
|
|
9790
9661
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9791
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children:
|
|
9662
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((k, I) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9792
9663
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
|
|
9793
9664
|
position: "bottom",
|
|
9794
9665
|
panelId: k.id,
|
|
9795
9666
|
isActive: n === k.id,
|
|
9796
|
-
show: () =>
|
|
9667
|
+
show: () => S(k.id)
|
|
9797
9668
|
}) }),
|
|
9798
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9669
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
|
|
9799
9670
|
] }, "button-bottom-" + I)) })
|
|
9800
9671
|
] }),
|
|
9801
9672
|
/* @__PURE__ */ jsx(
|
|
@@ -9803,18 +9674,18 @@ const RootLayout = () => {
|
|
|
9803
9674
|
{
|
|
9804
9675
|
id: "left-panel",
|
|
9805
9676
|
className: "h-full max-h-full border-r border-border",
|
|
9806
|
-
initial: { width:
|
|
9807
|
-
animate: { width:
|
|
9677
|
+
initial: { width: j },
|
|
9678
|
+
animate: { width: j },
|
|
9808
9679
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
9809
|
-
children: n !== null && get(
|
|
9680
|
+
children: n !== null && get(C, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
|
|
9810
9681
|
/* @__PURE__ */ jsx(
|
|
9811
9682
|
"div",
|
|
9812
9683
|
{
|
|
9813
|
-
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(
|
|
9814
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9684
|
+
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(C, "isInternal", !1) ? "" : "w-64"}`,
|
|
9685
|
+
children: /* @__PURE__ */ jsx("span", { children: f(get(C, "label", "")) })
|
|
9815
9686
|
}
|
|
9816
9687
|
),
|
|
9817
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(
|
|
9688
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {}) }) })
|
|
9818
9689
|
] })
|
|
9819
9690
|
}
|
|
9820
9691
|
),
|
|
@@ -9834,11 +9705,11 @@ const RootLayout = () => {
|
|
|
9834
9705
|
/* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: c === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9835
9706
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9836
9707
|
" ",
|
|
9837
|
-
|
|
9708
|
+
f("AI Assistant")
|
|
9838
9709
|
] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9839
9710
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9840
9711
|
/* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "h-4 w-4 text-gray-600" }),
|
|
9841
|
-
|
|
9712
|
+
f("Theme Settings")
|
|
9842
9713
|
] }),
|
|
9843
9714
|
/* @__PURE__ */ jsx(
|
|
9844
9715
|
Button,
|
|
@@ -9860,34 +9731,34 @@ const RootLayout = () => {
|
|
|
9860
9731
|
}
|
|
9861
9732
|
),
|
|
9862
9733
|
/* @__PURE__ */ jsx(AddBlocksDialog, {}),
|
|
9863
|
-
n !== null && get(
|
|
9734
|
+
n !== null && get(C, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
|
|
9864
9735
|
SheetContent,
|
|
9865
9736
|
{
|
|
9866
9737
|
side: "left",
|
|
9867
9738
|
className: "flex flex-col gap-0 p-0 sm:max-w-full",
|
|
9868
|
-
style: { width: `${
|
|
9739
|
+
style: { width: `${v}px` },
|
|
9869
9740
|
children: [
|
|
9870
9741
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
9871
|
-
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(
|
|
9872
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9742
|
+
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(C, "icon", null) }),
|
|
9743
|
+
/* @__PURE__ */ jsx("span", { children: f(get(C, "label", "")) })
|
|
9873
9744
|
] }) }),
|
|
9874
|
-
/* @__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(
|
|
9875
|
-
close:
|
|
9745
|
+
/* @__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(C, "panel", NoopComponent), {
|
|
9746
|
+
close: B
|
|
9876
9747
|
}) }) })
|
|
9877
9748
|
]
|
|
9878
9749
|
}
|
|
9879
9750
|
) }),
|
|
9880
9751
|
" ",
|
|
9881
|
-
n !== null && get(
|
|
9752
|
+
n !== null && get(C, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${v}px` }, children: [
|
|
9882
9753
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
9883
|
-
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(
|
|
9884
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9754
|
+
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(C, "icon", null) }),
|
|
9755
|
+
/* @__PURE__ */ jsx("span", { children: f(get(C, "label", "")) })
|
|
9885
9756
|
] }) }),
|
|
9886
|
-
/* @__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(
|
|
9887
|
-
close:
|
|
9757
|
+
/* @__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(C, "panel", NoopComponent), {
|
|
9758
|
+
close: B
|
|
9888
9759
|
}) }) })
|
|
9889
9760
|
] }) }),
|
|
9890
|
-
n !== null && get(
|
|
9761
|
+
n !== null && get(C, "view") === "overlay" && /* @__PURE__ */ jsx(
|
|
9891
9762
|
motion.div,
|
|
9892
9763
|
{
|
|
9893
9764
|
className: "absolute bottom-0 left-12 right-0 top-0 z-50",
|
|
@@ -9906,13 +9777,13 @@ const RootLayout = () => {
|
|
|
9906
9777
|
children: [
|
|
9907
9778
|
/* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
|
|
9908
9779
|
/* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
|
|
9909
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
9910
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9780
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(C, "icon", null) }),
|
|
9781
|
+
/* @__PURE__ */ jsx("span", { children: f(get(C, "label", "")) })
|
|
9911
9782
|
] }),
|
|
9912
9783
|
/* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
|
|
9913
9784
|
] }),
|
|
9914
|
-
/* @__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(
|
|
9915
|
-
close:
|
|
9785
|
+
/* @__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(C, "panel", NoopComponent), {
|
|
9786
|
+
close: B
|
|
9916
9787
|
}) }) })
|
|
9917
9788
|
]
|
|
9918
9789
|
}
|
|
@@ -9969,36 +9840,36 @@ const RootLayout = () => {
|
|
|
9969
9840
|
}) => {
|
|
9970
9841
|
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
|
|
9971
9842
|
if (!l.trim()) return a;
|
|
9972
|
-
const
|
|
9843
|
+
const f = l.toLowerCase();
|
|
9973
9844
|
return Object.fromEntries(
|
|
9974
9845
|
Object.entries(a).filter(([b, y]) => {
|
|
9975
|
-
var
|
|
9976
|
-
return (b == null ? void 0 : b.toLowerCase().includes(
|
|
9846
|
+
var C;
|
|
9847
|
+
return (b == null ? void 0 : b.toLowerCase().includes(f)) || ((C = y == null ? void 0 : y.description) == null ? void 0 : C.toLowerCase().includes(f));
|
|
9977
9848
|
})
|
|
9978
9849
|
);
|
|
9979
|
-
}, [a, l]), m = (
|
|
9850
|
+
}, [a, l]), m = (f) => {
|
|
9980
9851
|
d(!0), u({
|
|
9981
|
-
x:
|
|
9982
|
-
y:
|
|
9852
|
+
x: f.clientX - n.x,
|
|
9853
|
+
y: f.clientY - n.y
|
|
9983
9854
|
});
|
|
9984
|
-
}, h = (
|
|
9855
|
+
}, h = (f) => {
|
|
9985
9856
|
if (!c) return;
|
|
9986
|
-
const b =
|
|
9987
|
-
r(
|
|
9988
|
-
},
|
|
9857
|
+
const b = f.clientX - p.x, y = f.clientY - p.y, C = f.currentTarget, v = C.offsetWidth, j = C.offsetHeight, _ = window.innerWidth - v, B = window.innerHeight - j, S = Math.max(0, Math.min(b, _)), k = Math.max(0, Math.min(y, B));
|
|
9858
|
+
r(S, k);
|
|
9859
|
+
}, x = () => {
|
|
9989
9860
|
d(!1);
|
|
9990
9861
|
};
|
|
9991
9862
|
return useEffect(() => {
|
|
9992
|
-
const
|
|
9863
|
+
const f = () => {
|
|
9993
9864
|
c && d(!1);
|
|
9994
9865
|
};
|
|
9995
|
-
return window.addEventListener("mouseup",
|
|
9866
|
+
return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
|
|
9996
9867
|
}, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
9997
9868
|
"div",
|
|
9998
9869
|
{
|
|
9999
9870
|
onMouseDown: m,
|
|
10000
9871
|
onMouseMove: h,
|
|
10001
|
-
onMouseUp:
|
|
9872
|
+
onMouseUp: x,
|
|
10002
9873
|
className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
|
|
10003
9874
|
style: {
|
|
10004
9875
|
left: n.x,
|
|
@@ -10040,13 +9911,13 @@ const RootLayout = () => {
|
|
|
10040
9911
|
placeholder: "Search features...",
|
|
10041
9912
|
className: "w-full pl-8",
|
|
10042
9913
|
value: l,
|
|
10043
|
-
onChange: (
|
|
9914
|
+
onChange: (f) => i(f.target.value),
|
|
10044
9915
|
autoFocus: !0
|
|
10045
9916
|
}
|
|
10046
9917
|
)
|
|
10047
9918
|
] })
|
|
10048
9919
|
] }),
|
|
10049
|
-
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([
|
|
9920
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, b]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: b }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
|
|
10050
9921
|
'No features found matching "',
|
|
10051
9922
|
l,
|
|
10052
9923
|
'"'
|
|
@@ -10190,8 +10061,8 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10190
10061
|
c.f && u(c.f);
|
|
10191
10062
|
const g = /* @__PURE__ */ new Set(), m = g.add.bind(g);
|
|
10192
10063
|
a.forEach((h) => {
|
|
10193
|
-
var
|
|
10194
|
-
return (
|
|
10064
|
+
var x;
|
|
10065
|
+
return (x = r.get(h)) == null ? void 0 : x.l.forEach(m);
|
|
10195
10066
|
}), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(u), a.size && d(o);
|
|
10196
10067
|
} while (a.size || i.size || l.size);
|
|
10197
10068
|
if (p.length)
|
|
@@ -10199,32 +10070,32 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10199
10070
|
}, recomputeInvalidatedAtoms = (o) => {
|
|
10200
10071
|
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(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
|
|
10201
10072
|
for (; m.length; ) {
|
|
10202
|
-
const h = m[m.length - 1],
|
|
10073
|
+
const h = m[m.length - 1], x = i(o, h);
|
|
10203
10074
|
if (g.has(h)) {
|
|
10204
10075
|
m.pop();
|
|
10205
10076
|
continue;
|
|
10206
10077
|
}
|
|
10207
10078
|
if (u.has(h)) {
|
|
10208
|
-
a.get(h) ===
|
|
10079
|
+
a.get(h) === x.n && p.push([h, x]), g.add(h), m.pop();
|
|
10209
10080
|
continue;
|
|
10210
10081
|
}
|
|
10211
10082
|
u.add(h);
|
|
10212
|
-
for (const
|
|
10213
|
-
u.has(
|
|
10083
|
+
for (const f of getMountedOrPendingDependents(h, x, r))
|
|
10084
|
+
u.has(f) || m.push(f);
|
|
10214
10085
|
}
|
|
10215
10086
|
for (let h = p.length - 1; h >= 0; --h) {
|
|
10216
|
-
const [
|
|
10087
|
+
const [x, f] = p[h];
|
|
10217
10088
|
let b = !1;
|
|
10218
|
-
for (const y of
|
|
10219
|
-
if (y !==
|
|
10089
|
+
for (const y of f.d.keys())
|
|
10090
|
+
if (y !== x && l.has(y)) {
|
|
10220
10091
|
b = !0;
|
|
10221
10092
|
break;
|
|
10222
10093
|
}
|
|
10223
|
-
b && (c(o,
|
|
10094
|
+
b && (c(o, x), d(o, x)), a.delete(x);
|
|
10224
10095
|
}
|
|
10225
10096
|
}, readAtomState = (o, n) => {
|
|
10226
10097
|
var r;
|
|
10227
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14],
|
|
10098
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14], x = a[16], f = a[17], b = u(o, n);
|
|
10228
10099
|
if (isAtomStateInitialized(b) && (l.has(n) && i.get(n) !== b.n || Array.from(b.d).every(
|
|
10229
10100
|
([k, I]) => (
|
|
10230
10101
|
// Recursively, read the atom state of the dependency, and
|
|
@@ -10235,50 +10106,50 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10235
10106
|
return b;
|
|
10236
10107
|
b.d.clear();
|
|
10237
10108
|
let y = !0;
|
|
10238
|
-
function
|
|
10239
|
-
l.has(n) && (
|
|
10109
|
+
function C() {
|
|
10110
|
+
l.has(n) && (f(o, n), m(o), g(o));
|
|
10240
10111
|
}
|
|
10241
|
-
function
|
|
10112
|
+
function v(k) {
|
|
10242
10113
|
var I;
|
|
10243
10114
|
if (isSelfAtom(n, k)) {
|
|
10244
|
-
const
|
|
10245
|
-
if (!isAtomStateInitialized(
|
|
10115
|
+
const w = u(o, k);
|
|
10116
|
+
if (!isAtomStateInitialized(w))
|
|
10246
10117
|
if (hasInitialValue(k))
|
|
10247
10118
|
setAtomStateValueOrPromise(o, k, k.init);
|
|
10248
10119
|
else
|
|
10249
10120
|
throw new Error("no atom init");
|
|
10250
|
-
return returnAtomValue(
|
|
10121
|
+
return returnAtomValue(w);
|
|
10251
10122
|
}
|
|
10252
10123
|
const A = h(o, k);
|
|
10253
10124
|
try {
|
|
10254
10125
|
return returnAtomValue(A);
|
|
10255
10126
|
} finally {
|
|
10256
|
-
b.d.set(k, A.n), isPendingPromise(b.v) && addPendingPromiseToDependency(n, b.v, A), (I = l.get(k)) == null || I.t.add(n), y ||
|
|
10127
|
+
b.d.set(k, A.n), isPendingPromise(b.v) && addPendingPromiseToDependency(n, b.v, A), (I = l.get(k)) == null || I.t.add(n), y || C();
|
|
10257
10128
|
}
|
|
10258
10129
|
}
|
|
10259
|
-
let
|
|
10260
|
-
const
|
|
10130
|
+
let j, _;
|
|
10131
|
+
const B = {
|
|
10261
10132
|
get signal() {
|
|
10262
|
-
return
|
|
10133
|
+
return j || (j = new AbortController()), j.signal;
|
|
10263
10134
|
},
|
|
10264
10135
|
get setSelf() {
|
|
10265
10136
|
return !_ && isActuallyWritableAtom(n) && (_ = (...k) => {
|
|
10266
10137
|
if (!y)
|
|
10267
10138
|
try {
|
|
10268
|
-
return
|
|
10139
|
+
return x(o, n, ...k);
|
|
10269
10140
|
} finally {
|
|
10270
10141
|
m(o), g(o);
|
|
10271
10142
|
}
|
|
10272
10143
|
}), _;
|
|
10273
10144
|
}
|
|
10274
|
-
},
|
|
10145
|
+
}, S = b.n;
|
|
10275
10146
|
try {
|
|
10276
|
-
const k = p(o, n,
|
|
10277
|
-
return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () =>
|
|
10147
|
+
const k = p(o, n, v, B);
|
|
10148
|
+
return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () => j == null ? void 0 : j.abort()), k.then(C, C)), b;
|
|
10278
10149
|
} catch (k) {
|
|
10279
10150
|
return delete b.v, b.e = k, ++b.n, b;
|
|
10280
10151
|
} finally {
|
|
10281
|
-
y = !1,
|
|
10152
|
+
y = !1, S !== b.n && i.get(n) === S && (i.set(n, b.n), c.add(n), (r = d.c) == null || r.call(d, n));
|
|
10282
10153
|
}
|
|
10283
10154
|
}, invalidateDependents = (o, n) => {
|
|
10284
10155
|
const r = getBuildingBlocks(o), a = r[1], l = r[2], i = r[11], c = [n];
|
|
@@ -10291,72 +10162,72 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10291
10162
|
}
|
|
10292
10163
|
}, writeAtomState = (o, n, ...r) => {
|
|
10293
10164
|
const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], m = a[15], h = a[17];
|
|
10294
|
-
let
|
|
10295
|
-
const
|
|
10296
|
-
var
|
|
10297
|
-
const
|
|
10165
|
+
let x = !0;
|
|
10166
|
+
const f = (y) => returnAtomValue(g(o, y)), b = (y, ...C) => {
|
|
10167
|
+
var v;
|
|
10168
|
+
const j = d(o, y);
|
|
10298
10169
|
try {
|
|
10299
10170
|
if (isSelfAtom(n, y)) {
|
|
10300
10171
|
if (!hasInitialValue(y))
|
|
10301
10172
|
throw new Error("atom not writable");
|
|
10302
|
-
const _ =
|
|
10303
|
-
setAtomStateValueOrPromise(o, y,
|
|
10173
|
+
const _ = j.n, B = C[0];
|
|
10174
|
+
setAtomStateValueOrPromise(o, y, B), h(o, y), _ !== j.n && (l.add(y), (v = i.c) == null || v.call(i, y), m(o, y));
|
|
10304
10175
|
return;
|
|
10305
10176
|
} else
|
|
10306
|
-
return writeAtomState(o, y, ...
|
|
10177
|
+
return writeAtomState(o, y, ...C);
|
|
10307
10178
|
} finally {
|
|
10308
|
-
|
|
10179
|
+
x || (u(o), p(o));
|
|
10309
10180
|
}
|
|
10310
10181
|
};
|
|
10311
10182
|
try {
|
|
10312
|
-
return c(o, n,
|
|
10183
|
+
return c(o, n, f, b, ...r);
|
|
10313
10184
|
} finally {
|
|
10314
|
-
|
|
10185
|
+
x = !1;
|
|
10315
10186
|
}
|
|
10316
10187
|
}, mountDependencies = (o, n) => {
|
|
10317
10188
|
var r;
|
|
10318
10189
|
const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], m = d(o, n), h = l.get(n);
|
|
10319
10190
|
if (h && !isPendingPromise(m.v)) {
|
|
10320
|
-
for (const [
|
|
10321
|
-
if (!h.d.has(
|
|
10322
|
-
const b = d(o,
|
|
10323
|
-
u(o,
|
|
10191
|
+
for (const [x, f] of m.d)
|
|
10192
|
+
if (!h.d.has(x)) {
|
|
10193
|
+
const b = d(o, x);
|
|
10194
|
+
u(o, x).t.add(n), h.d.add(x), f !== b.n && (i.add(x), (r = c.c) == null || r.call(c, x), p(o, x));
|
|
10324
10195
|
}
|
|
10325
|
-
for (const
|
|
10326
|
-
if (!m.d.has(
|
|
10327
|
-
h.d.delete(
|
|
10328
|
-
const
|
|
10329
|
-
|
|
10196
|
+
for (const x of h.d || [])
|
|
10197
|
+
if (!m.d.has(x)) {
|
|
10198
|
+
h.d.delete(x);
|
|
10199
|
+
const f = g(o, x);
|
|
10200
|
+
f == null || f.t.delete(n);
|
|
10330
10201
|
}
|
|
10331
10202
|
}
|
|
10332
10203
|
}, mountAtom = (o, n) => {
|
|
10333
10204
|
var r;
|
|
10334
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16],
|
|
10335
|
-
let
|
|
10336
|
-
if (!
|
|
10205
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16], x = p(o, n);
|
|
10206
|
+
let f = l.get(n);
|
|
10207
|
+
if (!f) {
|
|
10337
10208
|
m(o, n);
|
|
10338
|
-
for (const b of
|
|
10209
|
+
for (const b of x.d.keys())
|
|
10339
10210
|
mountAtom(o, b).t.add(n);
|
|
10340
|
-
if (
|
|
10211
|
+
if (f = {
|
|
10341
10212
|
l: /* @__PURE__ */ new Set(),
|
|
10342
|
-
d: new Set(
|
|
10213
|
+
d: new Set(x.d.keys()),
|
|
10343
10214
|
t: /* @__PURE__ */ new Set()
|
|
10344
|
-
}, l.set(n,
|
|
10215
|
+
}, l.set(n, f), (r = c.m) == null || r.call(c, n), isActuallyWritableAtom(n)) {
|
|
10345
10216
|
const b = () => {
|
|
10346
10217
|
let y = !0;
|
|
10347
|
-
const
|
|
10218
|
+
const C = (...v) => {
|
|
10348
10219
|
try {
|
|
10349
|
-
return h(o, n, ...
|
|
10220
|
+
return h(o, n, ...v);
|
|
10350
10221
|
} finally {
|
|
10351
10222
|
y || (g(o), u(o));
|
|
10352
10223
|
}
|
|
10353
10224
|
};
|
|
10354
10225
|
try {
|
|
10355
|
-
const
|
|
10356
|
-
|
|
10226
|
+
const v = d(o, n, C);
|
|
10227
|
+
v && (f.u = () => {
|
|
10357
10228
|
y = !0;
|
|
10358
10229
|
try {
|
|
10359
|
-
|
|
10230
|
+
v();
|
|
10360
10231
|
} finally {
|
|
10361
10232
|
y = !1;
|
|
10362
10233
|
}
|
|
@@ -10368,7 +10239,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10368
10239
|
i.add(b);
|
|
10369
10240
|
}
|
|
10370
10241
|
}
|
|
10371
|
-
return
|
|
10242
|
+
return f;
|
|
10372
10243
|
}, unmountAtom = (o, n) => {
|
|
10373
10244
|
var r;
|
|
10374
10245
|
const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);
|
|
@@ -10617,7 +10488,7 @@ const useAutoSave = () => {
|
|
|
10617
10488
|
if (typeof window > "u")
|
|
10618
10489
|
throw new Error("@chaibuilder/sdk is only supported in the browser. Avoid using it in the server side.");
|
|
10619
10490
|
export {
|
|
10620
|
-
|
|
10491
|
+
useCutBlockIds as $,
|
|
10621
10492
|
AddBlocksPanel as A,
|
|
10622
10493
|
BlockSettings as B,
|
|
10623
10494
|
CanvasArea as C,
|
|
@@ -10634,53 +10505,57 @@ export {
|
|
|
10634
10505
|
NestedPathSelector as N,
|
|
10635
10506
|
useBlockHighlight as O,
|
|
10636
10507
|
PERMISSIONS as P,
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10508
|
+
useBlocksHtmlForAi as Q,
|
|
10509
|
+
useBlocksStore as R,
|
|
10510
|
+
useBrandingOptions as S,
|
|
10640
10511
|
ThemeConfigPanel as T,
|
|
10641
10512
|
UILibrariesPanel as U,
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10513
|
+
useBuilderProp as V,
|
|
10514
|
+
useBuilderReset as W,
|
|
10515
|
+
useCanvasZoom as X,
|
|
10516
|
+
useCopyBlocks as Y,
|
|
10517
|
+
useCopyToClipboard as Z,
|
|
10518
|
+
useCurrentPage as _,
|
|
10648
10519
|
useSelectedBlockIds as a,
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10520
|
+
useDarkMode as a0,
|
|
10521
|
+
useDuplicateBlocks as a1,
|
|
10522
|
+
useHighlightBlockId as a2,
|
|
10523
|
+
useHtmlToBlocks as a3,
|
|
10524
|
+
useI18nBlocks as a4,
|
|
10525
|
+
useInlineEditing as a5,
|
|
10526
|
+
useIsPageLoaded as a6,
|
|
10527
|
+
useLanguages as a7,
|
|
10528
|
+
useLibraryBlocks as a8,
|
|
10529
|
+
usePartialBlocksStore as a9,
|
|
10530
|
+
useScreenSizeWidth as aA,
|
|
10531
|
+
useSelectedLibrary as aB,
|
|
10532
|
+
useSidebarActivePanel as aC,
|
|
10533
|
+
usePartialBlocksList as aa,
|
|
10534
|
+
usePasteBlocks as ab,
|
|
10535
|
+
usePermissions as ac,
|
|
10536
|
+
usePreviewMode as ad,
|
|
10537
|
+
useRemoveAllClassesForBlock as ae,
|
|
10538
|
+
useRemoveBlocks as af,
|
|
10539
|
+
useRemoveClassesFromBlocks as ag,
|
|
10540
|
+
useReplaceBlock as ah,
|
|
10541
|
+
useResetBlockStyles as ai,
|
|
10542
|
+
useRightPanel as aj,
|
|
10543
|
+
useSavePage as ak,
|
|
10544
|
+
useSelectedBlock as al,
|
|
10545
|
+
useSelectedBlockAllClasses as am,
|
|
10546
|
+
useSelectedBlockCurrentClasses as an,
|
|
10547
|
+
useSelectedBlocksDisplayChild as ao,
|
|
10548
|
+
useSelectedBreakpoints as ap,
|
|
10549
|
+
useSelectedStylingBlocks as aq,
|
|
10550
|
+
useStreamMultipleBlocksProps as ar,
|
|
10551
|
+
useStylingBreakpoint as as,
|
|
10552
|
+
useStylingState as at,
|
|
10553
|
+
useTheme as au,
|
|
10554
|
+
useThemeOptions as av,
|
|
10555
|
+
useUndoManager as aw,
|
|
10556
|
+
useWrapperBlock as ax,
|
|
10557
|
+
useBlocksStoreUndoableActions as ay,
|
|
10558
|
+
useCanvasDisplayWidth as az,
|
|
10684
10559
|
useUpdateBlocksProps as b,
|
|
10685
10560
|
useUpdateBlocksPropsRealtime as c,
|
|
10686
10561
|
usePageExternalData as d,
|