@chaibuilder/sdk 2.4.3 → 2.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{code-editor-CJfScsxg.js → code-editor-0HrsuGAE.js} +1 -1
- package/dist/{code-editor-Dy-oKXKY.cjs → code-editor-67qfXwGU.cjs} +1 -1
- package/dist/core.cjs +4 -16
- package/dist/core.js +1229 -1315
- package/dist/css-import-modal-CcUf6F6T.js +296 -0
- package/dist/css-import-modal-CdOK43Be.cjs +13 -0
- package/dist/render.cjs +2 -2
- package/dist/render.js +101 -112
- package/dist/{toggle-D0REpYUl.cjs → toggle-BgZfmuec.cjs} +1 -1
- package/dist/{toggle-BKtuoy5e.js → toggle-CyXEVUOu.js} +241 -244
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +1 -1
- package/package.json +6 -5
package/dist/core.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var F = (o, r, n) =>
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var V = (o, r, n) => r in o ? U(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
|
|
3
|
+
var F = (o, r, n) => V(o, typeof r != "symbol" ? r + "" : r, n);
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
6
6
|
import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
|
|
7
|
-
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, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
|
|
7
|
+
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, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, trim, sortBy, round } from "lodash-es";
|
|
8
8
|
import * as React from "react";
|
|
9
|
-
import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, useReducer, useDebugValue } from "react";
|
|
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$2 } from "./common-functions-BGzDsf1z.js";
|
|
13
|
-
import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b8 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, b6 as TooltipProvider, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b1 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent,
|
|
14
|
-
import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, Info, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, ImportIcon, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon,
|
|
13
|
+
import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b8 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, b6 as TooltipProvider, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b1 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, aX as Slider, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, aL as Separator, aY as Switch, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, r as Avatar, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./toggle-CyXEVUOu.js";
|
|
14
|
+
import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, Info, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Undo as Undo$1, ImportIcon, Type, CornerUpRight, Palette, Sun, Moon, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Layers } from "lucide-react";
|
|
15
15
|
import clsx$1, { clsx } from "clsx";
|
|
16
16
|
import { twMerge } from "tailwind-merge";
|
|
17
17
|
import TreeModel from "tree-model";
|
|
@@ -21,7 +21,7 @@ import { isObject } from "@rjsf/utils";
|
|
|
21
21
|
import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
|
|
22
22
|
import { toast, Toaster } from "sonner";
|
|
23
23
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
24
|
-
import { useTranslation as
|
|
24
|
+
import { useTranslation as Ue } from "react-i18next";
|
|
25
25
|
import Fuse from "fuse.js";
|
|
26
26
|
import UndoManager from "undo-manager";
|
|
27
27
|
import Link from "@tiptap/extension-link";
|
|
@@ -47,7 +47,7 @@ import twContainer from "@tailwindcss/container-queries";
|
|
|
47
47
|
import { ErrorBoundary } from "react-error-boundary";
|
|
48
48
|
import { motion } from "framer-motion";
|
|
49
49
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
50
|
-
import { flip } from "@floating-ui/dom";
|
|
50
|
+
import { limitShift, flip, size } from "@floating-ui/dom";
|
|
51
51
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
52
52
|
import ReactDOM from "react-dom";
|
|
53
53
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
@@ -343,16 +343,16 @@ function insertBlocksAtPosition(o, r, n, a) {
|
|
|
343
343
|
_type: "Text",
|
|
344
344
|
content: u.content
|
|
345
345
|
};
|
|
346
|
-
Object.keys(u).forEach((
|
|
347
|
-
|
|
348
|
-
}), l.unshift(m), i = i.map((
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
return Object.keys(
|
|
352
|
-
|
|
353
|
-
}),
|
|
346
|
+
Object.keys(u).forEach((f) => {
|
|
347
|
+
f.startsWith("content-") && (m[f] = u[f]);
|
|
348
|
+
}), l.unshift(m), i = i.map((f) => {
|
|
349
|
+
if (f._id === n) {
|
|
350
|
+
const x = { ...f, content: "" };
|
|
351
|
+
return Object.keys(x).forEach((k) => {
|
|
352
|
+
k.startsWith("content-") && (x[k] = "");
|
|
353
|
+
}), x;
|
|
354
354
|
}
|
|
355
|
-
return
|
|
355
|
+
return f;
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
358
|
}
|
|
@@ -480,15 +480,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
480
480
|
if (g.length === 2) {
|
|
481
481
|
const h = g.find((m) => m._id !== d);
|
|
482
482
|
if (h && h._type === "Text") {
|
|
483
|
-
const m = n.find((
|
|
484
|
-
m && "content" in m && (n = n.map((
|
|
485
|
-
if (
|
|
486
|
-
const
|
|
487
|
-
return Object.keys(h).forEach((
|
|
488
|
-
|
|
489
|
-
}),
|
|
483
|
+
const m = n.find((f) => f._id === u);
|
|
484
|
+
m && "content" in m && (n = n.map((f) => {
|
|
485
|
+
if (f._id === u) {
|
|
486
|
+
const x = { ...f, content: h.content };
|
|
487
|
+
return Object.keys(h).forEach((k) => {
|
|
488
|
+
k.startsWith("content-") && (x[k] = h[k]);
|
|
489
|
+
}), x;
|
|
490
490
|
}
|
|
491
|
-
return
|
|
491
|
+
return f;
|
|
492
492
|
}), a.push(h._id));
|
|
493
493
|
}
|
|
494
494
|
}
|
|
@@ -571,32 +571,32 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
571
571
|
status: "idle",
|
|
572
572
|
props: {},
|
|
573
573
|
error: void 0
|
|
574
|
-
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (
|
|
574
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, n ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), h = (o == null ? void 0 : o._type) !== "Repeater" && r === "live";
|
|
575
575
|
return useEffect(() => {
|
|
576
576
|
if (r === "mock") {
|
|
577
577
|
if (isFunction(a)) {
|
|
578
|
-
i((
|
|
579
|
-
const
|
|
580
|
-
if (!isObject(
|
|
578
|
+
i((x) => ({ ...x, status: "loading", props: {} }));
|
|
579
|
+
const f = a({ block: o });
|
|
580
|
+
if (!isObject(f))
|
|
581
581
|
throw new Error("mockDataProvider should return an object");
|
|
582
|
-
i((
|
|
582
|
+
i((x) => ({ ...x, status: "loaded", props: f }));
|
|
583
583
|
}
|
|
584
584
|
return;
|
|
585
585
|
}
|
|
586
|
-
r === "live" && (!g && !h || (i((
|
|
587
|
-
g ? (p((
|
|
588
|
-
...
|
|
586
|
+
r === "live" && (!g && !h || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
|
|
587
|
+
g ? (p((x) => ({
|
|
588
|
+
...x,
|
|
589
589
|
[o._id]: {
|
|
590
590
|
status: "loaded",
|
|
591
|
-
props: get(
|
|
591
|
+
props: get(f, "items", []),
|
|
592
592
|
repeaterItems: o.repeaterItems
|
|
593
593
|
}
|
|
594
|
-
})), i((
|
|
595
|
-
}).catch((
|
|
596
|
-
g ? (p((
|
|
597
|
-
...
|
|
598
|
-
[o._id]: { status: "error", error:
|
|
599
|
-
})), i((
|
|
594
|
+
})), i((x) => ({ ...x, status: "loaded", props: { totalItems: get(f, "totalItems") } })), c([o._id], { totalItems: get(f, "totalItems") })) : i((x) => ({ ...x, status: "loaded", props: isObject(f) ? f : {} }));
|
|
595
|
+
}).catch((f) => {
|
|
596
|
+
g ? (p((x) => ({
|
|
597
|
+
...x,
|
|
598
|
+
[o._id]: { status: "error", error: f, props: [] }
|
|
599
|
+
})), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
|
|
600
600
|
})));
|
|
601
601
|
}, [o == null ? void 0 : o._id, u, g, h, a, r]), {
|
|
602
602
|
$loading: get(l, "status") === "loading",
|
|
@@ -761,10 +761,10 @@ const checkMissingTranslations = (o, r) => r ? o.some((n) => {
|
|
|
761
761
|
if (!c("save_page"))
|
|
762
762
|
return;
|
|
763
763
|
r("SAVING"), a("SAVING");
|
|
764
|
-
const
|
|
764
|
+
const f = l();
|
|
765
765
|
return await n({
|
|
766
766
|
autoSave: m,
|
|
767
|
-
blocks:
|
|
767
|
+
blocks: f.blocks,
|
|
768
768
|
theme: i,
|
|
769
769
|
needTranslations: u()
|
|
770
770
|
}), setTimeout(() => {
|
|
@@ -839,65 +839,65 @@ const undoRedoStateAtom = atom({
|
|
|
839
839
|
updateBlocksProps: c
|
|
840
840
|
} = useBlocksStoreManager();
|
|
841
841
|
return {
|
|
842
|
-
moveBlocks: (
|
|
843
|
-
const
|
|
844
|
-
const w = r.find((
|
|
845
|
-
return { _id:
|
|
846
|
-
}),
|
|
847
|
-
|
|
848
|
-
undo: () => each(
|
|
849
|
-
i([
|
|
842
|
+
moveBlocks: (x, k, b) => {
|
|
843
|
+
const A = map(x, (_) => {
|
|
844
|
+
const w = r.find((E) => E._id === _)._parent || null, C = r.filter((E) => w ? E._parent === w : !E._parent).map((E) => E._id).indexOf(_);
|
|
845
|
+
return { _id: _, oldParent: w, oldPosition: C };
|
|
846
|
+
}), B = A.find(({ _id: _ }) => _ === x[0]);
|
|
847
|
+
B && B.oldParent === k && B.oldPosition === b || (i(x, k, b), o({
|
|
848
|
+
undo: () => each(A, ({ _id: _, oldParent: N, oldPosition: w }) => {
|
|
849
|
+
i([_], N, w);
|
|
850
850
|
}),
|
|
851
|
-
redo: () => i(
|
|
851
|
+
redo: () => i(x, k, b)
|
|
852
852
|
}));
|
|
853
853
|
},
|
|
854
|
-
addBlocks: (
|
|
855
|
-
a(
|
|
856
|
-
undo: () => l(map(
|
|
857
|
-
redo: () => a(
|
|
854
|
+
addBlocks: (x, k, b) => {
|
|
855
|
+
a(x, k, b), o({
|
|
856
|
+
undo: () => l(map(x, "_id")),
|
|
857
|
+
redo: () => a(x, k, b)
|
|
858
858
|
});
|
|
859
859
|
},
|
|
860
|
-
removeBlocks: (
|
|
861
|
-
var
|
|
862
|
-
const
|
|
863
|
-
l(map(
|
|
864
|
-
undo: () => a(
|
|
865
|
-
redo: () => l(map(
|
|
860
|
+
removeBlocks: (x) => {
|
|
861
|
+
var B;
|
|
862
|
+
const k = (B = first(x)) == null ? void 0 : B._parent, A = r.filter((_) => k ? _._parent === k : !_._parent).indexOf(first(x));
|
|
863
|
+
l(map(x, "_id")), o({
|
|
864
|
+
undo: () => a(x, k, A),
|
|
865
|
+
redo: () => l(map(x, "_id"))
|
|
866
866
|
});
|
|
867
867
|
},
|
|
868
|
-
updateBlocks: (
|
|
869
|
-
let
|
|
868
|
+
updateBlocks: (x, k, b) => {
|
|
869
|
+
let A = [];
|
|
870
870
|
if (b)
|
|
871
|
-
|
|
871
|
+
A = map(x, (B) => ({ _id: B, ...b }));
|
|
872
872
|
else {
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
const
|
|
876
|
-
return each(
|
|
873
|
+
const B = keys(k);
|
|
874
|
+
A = map(x, (_) => {
|
|
875
|
+
const N = r.find((y) => y._id === _), w = { _id: _ };
|
|
876
|
+
return each(B, (y) => w[y] = N[y]), w;
|
|
877
877
|
});
|
|
878
878
|
}
|
|
879
|
-
c(map(
|
|
880
|
-
undo: () => c(
|
|
881
|
-
redo: () => c(map(
|
|
879
|
+
c(map(x, (B) => ({ _id: B, ...k }))), o({
|
|
880
|
+
undo: () => c(A),
|
|
881
|
+
redo: () => c(map(x, (B) => ({ _id: B, ...k })))
|
|
882
882
|
});
|
|
883
883
|
},
|
|
884
|
-
updateBlocksRuntime: (
|
|
885
|
-
c(map(
|
|
884
|
+
updateBlocksRuntime: (x, k) => {
|
|
885
|
+
c(map(x, (b) => ({ _id: b, ...k })));
|
|
886
886
|
},
|
|
887
|
-
setNewBlocks: (
|
|
888
|
-
n(
|
|
887
|
+
setNewBlocks: (x) => {
|
|
888
|
+
n(x), o({
|
|
889
889
|
undo: () => n(r),
|
|
890
|
-
redo: () => n(
|
|
890
|
+
redo: () => n(x)
|
|
891
891
|
});
|
|
892
892
|
},
|
|
893
|
-
updateMultipleBlocksProps: (
|
|
894
|
-
let
|
|
895
|
-
|
|
896
|
-
const
|
|
897
|
-
return each(
|
|
898
|
-
}), c(
|
|
899
|
-
undo: () => c(
|
|
900
|
-
redo: () => c(
|
|
893
|
+
updateMultipleBlocksProps: (x) => {
|
|
894
|
+
let k = [];
|
|
895
|
+
k = map(x, (b) => {
|
|
896
|
+
const A = keys(b), B = r.find((N) => N._id === b._id), _ = {};
|
|
897
|
+
return each(A, (N) => _[N] = B[N]), _;
|
|
898
|
+
}), c(x), o({
|
|
899
|
+
undo: () => c(k),
|
|
900
|
+
redo: () => c(x)
|
|
901
901
|
});
|
|
902
902
|
}
|
|
903
903
|
};
|
|
@@ -905,12 +905,12 @@ const undoRedoStateAtom = atom({
|
|
|
905
905
|
const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
906
906
|
(i, c, d) => {
|
|
907
907
|
var m;
|
|
908
|
-
for (let
|
|
909
|
-
const { _id:
|
|
910
|
-
i[
|
|
911
|
-
const
|
|
912
|
-
for (let b = 0; b <
|
|
913
|
-
|
|
908
|
+
for (let f = 0; f < i.length; f++) {
|
|
909
|
+
const { _id: x } = i[f];
|
|
910
|
+
i[f]._id = generateUUID();
|
|
911
|
+
const k = filter(i, { _parent: x });
|
|
912
|
+
for (let b = 0; b < k.length; b++)
|
|
913
|
+
k[b]._parent = i[f]._id;
|
|
914
914
|
}
|
|
915
915
|
const p = first(i);
|
|
916
916
|
let u, g;
|
|
@@ -921,8 +921,8 @@ const undoRedoStateAtom = atom({
|
|
|
921
921
|
return { addCoreBlock: useCallback(
|
|
922
922
|
(i, c, d) => {
|
|
923
923
|
if (has(i, "blocks")) {
|
|
924
|
-
const
|
|
925
|
-
return a(
|
|
924
|
+
const k = i.blocks;
|
|
925
|
+
return a(k, c, d);
|
|
926
926
|
}
|
|
927
927
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
928
928
|
_type: i.type,
|
|
@@ -1821,8 +1821,8 @@ const undoRedoStateAtom = atom({
|
|
|
1821
1821
|
regExp: "delay-(\\d+|\\[.*\\])"
|
|
1822
1822
|
},
|
|
1823
1823
|
animation: {
|
|
1824
|
-
classes: ["
|
|
1825
|
-
regExp: "
|
|
1824
|
+
classes: ["animate-none", "animate-spin", "animate-ping"],
|
|
1825
|
+
regExp: "animate-(none|spin|ping)"
|
|
1826
1826
|
},
|
|
1827
1827
|
scaleX: {
|
|
1828
1828
|
classes: map(CLASS_VALUES.scale, (o) => `scale-x-${o}`),
|
|
@@ -2360,43 +2360,43 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2360
2360
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2361
2361
|
})
|
|
2362
2362
|
), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2363
|
-
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m,
|
|
2364
|
-
const
|
|
2365
|
-
for (const
|
|
2366
|
-
const b =
|
|
2363
|
+
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, f) => {
|
|
2364
|
+
const x = cloneDeep(f.find((k) => k._id === m));
|
|
2365
|
+
for (const k in x) {
|
|
2366
|
+
const b = x[k];
|
|
2367
2367
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
2368
|
-
const { baseClasses:
|
|
2369
|
-
|
|
2368
|
+
const { baseClasses: A, classes: B } = getSplitChaiClasses(b);
|
|
2369
|
+
x[k] = compact(flattenDeep([A, B])).join(" ");
|
|
2370
2370
|
} else
|
|
2371
|
-
|
|
2371
|
+
k !== "_id" && delete x[k];
|
|
2372
2372
|
}
|
|
2373
|
-
return
|
|
2373
|
+
return x;
|
|
2374
2374
|
};
|
|
2375
2375
|
return {
|
|
2376
2376
|
askAi: useCallback(
|
|
2377
|
-
async (m,
|
|
2377
|
+
async (m, f, x, k) => {
|
|
2378
2378
|
if (l) {
|
|
2379
2379
|
r(!0), a(null);
|
|
2380
2380
|
try {
|
|
2381
|
-
const b = p === u ? "" : p,
|
|
2382
|
-
if (
|
|
2383
|
-
a(
|
|
2381
|
+
const b = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], B = await l(m, addLangToPrompt(x, g, m), A, b), { blocks: _, error: N } = B;
|
|
2382
|
+
if (N) {
|
|
2383
|
+
a(N);
|
|
2384
2384
|
return;
|
|
2385
2385
|
}
|
|
2386
2386
|
if (m === "styles") {
|
|
2387
|
-
const w =
|
|
2388
|
-
for (const
|
|
2389
|
-
|
|
2390
|
-
return
|
|
2387
|
+
const w = _.map((y) => {
|
|
2388
|
+
for (const C in y)
|
|
2389
|
+
C !== "_id" && (y[C] = `${STYLES_KEY},${y[C]}`);
|
|
2390
|
+
return y;
|
|
2391
2391
|
});
|
|
2392
2392
|
c(w);
|
|
2393
2393
|
} else
|
|
2394
|
-
i(
|
|
2395
|
-
|
|
2394
|
+
i(_);
|
|
2395
|
+
k && k(B);
|
|
2396
2396
|
} catch (b) {
|
|
2397
2397
|
a(b);
|
|
2398
2398
|
} finally {
|
|
2399
|
-
r(!1),
|
|
2399
|
+
r(!1), k && k();
|
|
2400
2400
|
}
|
|
2401
2401
|
}
|
|
2402
2402
|
},
|
|
@@ -2490,12 +2490,12 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2490
2490
|
if (!p)
|
|
2491
2491
|
return h;
|
|
2492
2492
|
let m = [];
|
|
2493
|
-
for (const
|
|
2494
|
-
if (
|
|
2495
|
-
let
|
|
2496
|
-
|
|
2493
|
+
for (const f of h)
|
|
2494
|
+
if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
|
|
2495
|
+
let x = l(f.partialBlockId);
|
|
2496
|
+
f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((k) => (isEmpty(k._parent) && set(k, "_parent", f._parent), k))), m = [...m, ...x];
|
|
2497
2497
|
} else
|
|
2498
|
-
m.push(
|
|
2498
|
+
m.push(f);
|
|
2499
2499
|
return m;
|
|
2500
2500
|
})
|
|
2501
2501
|
};
|
|
@@ -2678,13 +2678,13 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2678
2678
|
const d = o(c), p = a;
|
|
2679
2679
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2680
2680
|
return each(p, (h) => {
|
|
2681
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2682
|
-
u = u.replace(
|
|
2683
|
-
const
|
|
2684
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2681
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2682
|
+
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2683
|
+
const x = first(h.split(":"));
|
|
2684
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
|
|
2685
2685
|
}), each(p, (h) => {
|
|
2686
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2687
|
-
g = g.replace(
|
|
2686
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2687
|
+
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2688
2688
|
}), {
|
|
2689
2689
|
ids: [d._id],
|
|
2690
2690
|
props: {
|
|
@@ -2833,21 +2833,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2833
2833
|
return "VERTICAL";
|
|
2834
2834
|
}
|
|
2835
2835
|
}, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
|
|
2836
|
-
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (
|
|
2837
|
-
(
|
|
2838
|
-
isDisabledControl(g, h,
|
|
2836
|
+
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
2837
|
+
(x) => {
|
|
2838
|
+
isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), r());
|
|
2839
2839
|
},
|
|
2840
2840
|
[g, h, p, u, i, c, r]
|
|
2841
2841
|
);
|
|
2842
2842
|
return useHotkeys(
|
|
2843
2843
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2844
|
-
({ key:
|
|
2845
|
-
var
|
|
2846
|
-
|
|
2844
|
+
({ key: x }) => {
|
|
2845
|
+
var k;
|
|
2846
|
+
f((k = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
|
|
2847
2847
|
},
|
|
2848
2848
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2849
|
-
[
|
|
2850
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock:
|
|
2849
|
+
[f]
|
|
2850
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
|
|
2851
2851
|
}, BlockController = ({ block: o, updateFloatingBar: r }) => {
|
|
2852
2852
|
const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2853
2853
|
o,
|
|
@@ -2989,37 +2989,65 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2989
2989
|
}, BlockFloatingSelector = ({ block: o, selectedBlockElement: r }) => {
|
|
2990
2990
|
const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
|
|
2991
2991
|
placement: "top-start",
|
|
2992
|
-
middleware: [
|
|
2992
|
+
middleware: [
|
|
2993
|
+
shift({
|
|
2994
|
+
boundary: u == null ? void 0 : u.body,
|
|
2995
|
+
limiter: limitShift({
|
|
2996
|
+
offset: 8,
|
|
2997
|
+
mainAxis: !0,
|
|
2998
|
+
crossAxis: !0
|
|
2999
|
+
})
|
|
3000
|
+
}),
|
|
3001
|
+
flip({
|
|
3002
|
+
boundary: u == null ? void 0 : u.body,
|
|
3003
|
+
fallbackPlacements: ["bottom-start", "top-end", "bottom-end", "inside"]
|
|
3004
|
+
}),
|
|
3005
|
+
size({
|
|
3006
|
+
boundary: u == null ? void 0 : u.body,
|
|
3007
|
+
apply({ availableWidth: k, availableHeight: b, elements: A }) {
|
|
3008
|
+
Object.assign(A.floating.style, {
|
|
3009
|
+
maxWidth: `${Math.max(200, k)}px`,
|
|
3010
|
+
maxHeight: `${Math.max(100, b)}px`
|
|
3011
|
+
});
|
|
3012
|
+
}
|
|
3013
|
+
})
|
|
3014
|
+
],
|
|
2993
3015
|
elements: { reference: r }
|
|
2994
3016
|
});
|
|
2995
3017
|
useResizeObserver(r, () => m(), r !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
|
|
2996
|
-
const
|
|
2997
|
-
return
|
|
3018
|
+
const f = get(o, "_parent", null), x = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
3019
|
+
return useEffect(() => {
|
|
3020
|
+
if (r) {
|
|
3021
|
+
const k = setTimeout(() => m(), 500);
|
|
3022
|
+
return () => clearTimeout(k);
|
|
3023
|
+
} else
|
|
3024
|
+
m();
|
|
3025
|
+
}, [r]), !r || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
2998
3026
|
"div",
|
|
2999
3027
|
{
|
|
3000
3028
|
role: "button",
|
|
3001
3029
|
tabIndex: 0,
|
|
3002
3030
|
ref: h.setFloating,
|
|
3003
3031
|
style: g,
|
|
3004
|
-
onClick: (
|
|
3005
|
-
|
|
3032
|
+
onClick: (k) => {
|
|
3033
|
+
k.stopPropagation(), k.preventDefault();
|
|
3006
3034
|
},
|
|
3007
|
-
onMouseEnter: (
|
|
3008
|
-
|
|
3035
|
+
onMouseEnter: (k) => {
|
|
3036
|
+
k.stopPropagation(), i(null);
|
|
3009
3037
|
},
|
|
3010
|
-
onKeyDown: (
|
|
3038
|
+
onKeyDown: (k) => k.stopPropagation(),
|
|
3011
3039
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3012
3040
|
children: [
|
|
3013
|
-
|
|
3041
|
+
f && /* @__PURE__ */ jsx(
|
|
3014
3042
|
ArrowUpIcon,
|
|
3015
3043
|
{
|
|
3016
3044
|
className: "hover:scale-105",
|
|
3017
3045
|
onClick: () => {
|
|
3018
|
-
c([]), l([
|
|
3046
|
+
c([]), l([f]);
|
|
3019
3047
|
}
|
|
3020
3048
|
}
|
|
3021
3049
|
),
|
|
3022
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3050
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: x, block: o }),
|
|
3023
3051
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3024
3052
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3025
3053
|
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
|
|
@@ -3177,8 +3205,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3177
3205
|
i
|
|
3178
3206
|
]), useHotkeys(
|
|
3179
3207
|
"del, backspace",
|
|
3180
|
-
(
|
|
3181
|
-
|
|
3208
|
+
(f) => {
|
|
3209
|
+
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
|
|
3182
3210
|
},
|
|
3183
3211
|
m,
|
|
3184
3212
|
[r, l]
|
|
@@ -3471,8 +3499,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3471
3499
|
],
|
|
3472
3500
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3473
3501
|
onBlur: ({ editor: u, event: g }) => {
|
|
3474
|
-
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"),
|
|
3475
|
-
if (!
|
|
3502
|
+
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = m == null ? void 0 : m.contains(h), k = f == null ? void 0 : f.contains(h);
|
|
3503
|
+
if (!x && !k) {
|
|
3476
3504
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3477
3505
|
n(b);
|
|
3478
3506
|
}
|
|
@@ -3527,14 +3555,14 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3527
3555
|
useEffect(() => {
|
|
3528
3556
|
if (a.current) {
|
|
3529
3557
|
a.current.innerText = r, a.current.focus();
|
|
3530
|
-
const m = c.createRange(),
|
|
3531
|
-
m.selectNodeContents(a.current), m.collapse(!1),
|
|
3558
|
+
const m = c.createRange(), f = d.getSelection();
|
|
3559
|
+
m.selectNodeContents(a.current), m.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(m), a.current.focus();
|
|
3532
3560
|
} else
|
|
3533
3561
|
n();
|
|
3534
3562
|
}, [c, d]);
|
|
3535
3563
|
const p = useMemo(() => {
|
|
3536
|
-
var
|
|
3537
|
-
const m = ((
|
|
3564
|
+
var f;
|
|
3565
|
+
const m = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
|
|
3538
3566
|
return m === "button" ? "div" : m;
|
|
3539
3567
|
}, [o]), u = useCallback(
|
|
3540
3568
|
(m) => {
|
|
@@ -3550,12 +3578,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3550
3578
|
contentEditable: !0,
|
|
3551
3579
|
className: `${((m = o == null ? void 0 : o.className) == null ? void 0 : m.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
|
|
3552
3580
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
3553
|
-
onInput: (
|
|
3554
|
-
const
|
|
3555
|
-
|
|
3581
|
+
onInput: (f) => {
|
|
3582
|
+
const x = f.target;
|
|
3583
|
+
x && (x.innerText.trim() === "" ? (x.setAttribute("data-placeholder", "Enter text here"), x.children.length > 0 && x.children[0].remove()) : f.target.removeAttribute("data-placeholder"), l(f.target.innerText));
|
|
3556
3584
|
},
|
|
3557
|
-
onClick: (
|
|
3558
|
-
|
|
3585
|
+
onClick: (f) => {
|
|
3586
|
+
f.stopPropagation(), f.preventDefault();
|
|
3559
3587
|
}
|
|
3560
3588
|
};
|
|
3561
3589
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
@@ -3568,62 +3596,62 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3568
3596
|
}
|
|
3569
3597
|
), WithBlockTextEditor = memo(
|
|
3570
3598
|
({ block: o, children: r }) => {
|
|
3571
|
-
const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang:
|
|
3572
|
-
var
|
|
3573
|
-
const
|
|
3574
|
-
let
|
|
3575
|
-
const
|
|
3576
|
-
return
|
|
3577
|
-
}, [o,
|
|
3578
|
-
(
|
|
3579
|
-
var
|
|
3580
|
-
const
|
|
3581
|
-
m([b], { [n]:
|
|
3599
|
+
const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), k = useRef(null), b = l, { blockContent: A, blockType: B } = useMemo(() => {
|
|
3600
|
+
var j;
|
|
3601
|
+
const C = o._type;
|
|
3602
|
+
let E = o[n];
|
|
3603
|
+
const v = getRegisteredChaiBlock(o._type);
|
|
3604
|
+
return f && ((j = v == null ? void 0 : v.i18nProps) == null ? void 0 : j.includes(n)) && has(o, `${n}-${f}`) && (E = get(o, `${n}-${f}`)), { blockContent: E, blockType: C };
|
|
3605
|
+
}, [o, f]), _ = useCallback(
|
|
3606
|
+
(C) => {
|
|
3607
|
+
var v;
|
|
3608
|
+
const E = C || ((v = g.current) == null ? void 0 : v.innerText);
|
|
3609
|
+
m([b], { [n]: E }), u(null), c(null), d(-1), x([]);
|
|
3582
3610
|
},
|
|
3583
|
-
[b, m, c,
|
|
3584
|
-
),
|
|
3585
|
-
(
|
|
3586
|
-
m([b], { [n]:
|
|
3611
|
+
[b, m, c, x, f]
|
|
3612
|
+
), N = useDebouncedCallback(
|
|
3613
|
+
(C) => {
|
|
3614
|
+
m([b], { [n]: C });
|
|
3587
3615
|
},
|
|
3588
|
-
[b, o, m,
|
|
3616
|
+
[b, o, m, f],
|
|
3589
3617
|
1e3
|
|
3590
3618
|
), w = useCallback(
|
|
3591
|
-
(
|
|
3592
|
-
|
|
3593
|
-
const
|
|
3594
|
-
|
|
3619
|
+
(C) => {
|
|
3620
|
+
C.preventDefault(), b && (k.current = b), _(), setTimeout(() => {
|
|
3621
|
+
const E = k.current;
|
|
3622
|
+
k.current = null, x([E]);
|
|
3595
3623
|
}, 100);
|
|
3596
3624
|
},
|
|
3597
|
-
[
|
|
3625
|
+
[x, b, f]
|
|
3598
3626
|
);
|
|
3599
3627
|
useEffect(() => {
|
|
3600
|
-
var
|
|
3628
|
+
var S;
|
|
3601
3629
|
if (!b) return;
|
|
3602
|
-
const
|
|
3603
|
-
|
|
3604
|
-
}, [b,
|
|
3605
|
-
const
|
|
3630
|
+
const C = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", v = a.querySelector(`${C}${E}`);
|
|
3631
|
+
v && ((S = v == null ? void 0 : v.classList) == null || S.add("sr-only"), u(v));
|
|
3632
|
+
}, [b, B, a, i]);
|
|
3633
|
+
const y = useMemo(() => p ? (h(), B === "RichText" ? /* @__PURE__ */ jsx(
|
|
3606
3634
|
RichTextEditor,
|
|
3607
3635
|
{
|
|
3608
|
-
blockContent:
|
|
3636
|
+
blockContent: A,
|
|
3609
3637
|
editingElement: p,
|
|
3610
|
-
onChange:
|
|
3611
|
-
onClose:
|
|
3638
|
+
onChange: N,
|
|
3639
|
+
onClose: _,
|
|
3612
3640
|
onEscape: w
|
|
3613
3641
|
}
|
|
3614
3642
|
) : /* @__PURE__ */ jsx(
|
|
3615
3643
|
MemoizedEditor,
|
|
3616
3644
|
{
|
|
3617
3645
|
editorRef: g,
|
|
3618
|
-
blockContent:
|
|
3646
|
+
blockContent: A,
|
|
3619
3647
|
editingElement: p,
|
|
3620
|
-
onClose:
|
|
3621
|
-
onChange:
|
|
3648
|
+
onClose: _,
|
|
3649
|
+
onChange: N,
|
|
3622
3650
|
onEscape: w
|
|
3623
3651
|
}
|
|
3624
|
-
)) : null, [p, b,
|
|
3652
|
+
)) : null, [p, b, B, A, _, f]);
|
|
3625
3653
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3626
|
-
|
|
3654
|
+
y,
|
|
3627
3655
|
r
|
|
3628
3656
|
] });
|
|
3629
3657
|
},
|
|
@@ -3656,23 +3684,23 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3656
3684
|
blockAtom: r,
|
|
3657
3685
|
children: n
|
|
3658
3686
|
}) => {
|
|
3659
|
-
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom),
|
|
3687
|
+
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: x, key: k } = useContext(RepeaterContext), b = useMemo(
|
|
3660
3688
|
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
3661
|
-
index:
|
|
3662
|
-
key:
|
|
3689
|
+
index: x,
|
|
3690
|
+
key: k
|
|
3663
3691
|
}) : applyLanguage(i, d, c),
|
|
3664
|
-
[i, d, c, g, m,
|
|
3665
|
-
),
|
|
3692
|
+
[i, d, c, g, m, x, k]
|
|
3693
|
+
), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
|
|
3666
3694
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
3667
3695
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
3668
|
-
),
|
|
3696
|
+
), _ = useMemo(
|
|
3669
3697
|
() => ({
|
|
3670
|
-
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index":
|
|
3698
|
+
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": x },
|
|
3671
3699
|
inBuilder: !0,
|
|
3672
3700
|
lang: d || p,
|
|
3673
3701
|
...b,
|
|
3702
|
+
...A,
|
|
3674
3703
|
...B,
|
|
3675
|
-
...E,
|
|
3676
3704
|
...o
|
|
3677
3705
|
}),
|
|
3678
3706
|
[
|
|
@@ -3681,14 +3709,14 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3681
3709
|
d,
|
|
3682
3710
|
p,
|
|
3683
3711
|
b,
|
|
3712
|
+
A,
|
|
3684
3713
|
B,
|
|
3685
|
-
E,
|
|
3686
3714
|
o
|
|
3687
3715
|
]
|
|
3688
|
-
),
|
|
3689
|
-
if (isNull(
|
|
3690
|
-
let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(
|
|
3691
|
-
...
|
|
3716
|
+
), N = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
|
|
3717
|
+
if (isNull(f) || h.includes(i._id)) return null;
|
|
3718
|
+
let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(f, {
|
|
3719
|
+
..._,
|
|
3692
3720
|
children: n({
|
|
3693
3721
|
_id: i._id,
|
|
3694
3722
|
_type: i._type,
|
|
@@ -3700,8 +3728,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3700
3728
|
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
3701
3729
|
})
|
|
3702
3730
|
}) });
|
|
3703
|
-
const
|
|
3704
|
-
return
|
|
3731
|
+
const y = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
|
|
3732
|
+
return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: y }) : y;
|
|
3705
3733
|
}, PartialWrapper = ({ children: o, partialBlockId: r }) => {
|
|
3706
3734
|
const n = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
3707
3735
|
(d) => {
|
|
@@ -3741,7 +3769,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3741
3769
|
);
|
|
3742
3770
|
return map(l, (c) => {
|
|
3743
3771
|
const d = a(c._id);
|
|
3744
|
-
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey:
|
|
3772
|
+
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: f }) => g === "Repeater" ? isArray(m) && m.map((x, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${k}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
|
|
3745
3773
|
});
|
|
3746
3774
|
}, PageBlocksRenderer = () => {
|
|
3747
3775
|
const [o] = useBlocksStore();
|
|
@@ -3809,14 +3837,14 @@ const CanvasEventsWatcher = () => {
|
|
|
3809
3837
|
}, StaticCanvas = () => {
|
|
3810
3838
|
const [o] = useCanvasDisplayWidth(), [, r] = useHighlightBlockId(), n = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
|
|
3811
3839
|
(m) => {
|
|
3812
|
-
i((
|
|
3840
|
+
i((f) => ({ ...f, width: m }));
|
|
3813
3841
|
},
|
|
3814
3842
|
[i]
|
|
3815
3843
|
);
|
|
3816
3844
|
useEffect(() => {
|
|
3817
3845
|
if (!a.current) return;
|
|
3818
|
-
const { clientWidth: m, clientHeight:
|
|
3819
|
-
i({ width: m, height:
|
|
3846
|
+
const { clientWidth: m, clientHeight: f } = a.current;
|
|
3847
|
+
i({ width: m, height: f });
|
|
3820
3848
|
}, [a, o]);
|
|
3821
3849
|
const h = useMemo(() => {
|
|
3822
3850
|
let m = IframeInitialContent;
|
|
@@ -3866,7 +3894,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3866
3894
|
}, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
|
|
3867
3895
|
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
|
|
3868
3896
|
/* @__PURE__ */ jsx("p", { children: "Please try again." })
|
|
3869
|
-
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-
|
|
3897
|
+
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-0HrsuGAE.js")), CanvasArea = () => {
|
|
3870
3898
|
const [o] = useCodeEditor(), r = useBuilderProp("onError", noop);
|
|
3871
3899
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
|
|
3872
3900
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -3931,8 +3959,8 @@ const CanvasEventsWatcher = () => {
|
|
|
3931
3959
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3932
3960
|
] });
|
|
3933
3961
|
}, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
|
|
3934
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (
|
|
3935
|
-
if (!
|
|
3962
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (f) => {
|
|
3963
|
+
if (!f.trim()) {
|
|
3936
3964
|
p(!1), g("Please enter a URL");
|
|
3937
3965
|
return;
|
|
3938
3966
|
}
|
|
@@ -3956,7 +3984,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3956
3984
|
{
|
|
3957
3985
|
placeholder: m(`Enter ${n} URL`),
|
|
3958
3986
|
value: a,
|
|
3959
|
-
onChange: (
|
|
3987
|
+
onChange: (f) => l(f.target.value),
|
|
3960
3988
|
onKeyUp: () => h(a)
|
|
3961
3989
|
}
|
|
3962
3990
|
),
|
|
@@ -3997,16 +4025,16 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
3997
4025
|
const h = isArray(g) ? first(g) : g;
|
|
3998
4026
|
if (h) {
|
|
3999
4027
|
r(h == null ? void 0 : h.url);
|
|
4000
|
-
const m = h == null ? void 0 : h.width,
|
|
4028
|
+
const m = h == null ? void 0 : h.width, f = h == null ? void 0 : h.height;
|
|
4001
4029
|
if (i != null && i._id) {
|
|
4002
|
-
const
|
|
4030
|
+
const x = {
|
|
4003
4031
|
...m && { width: m },
|
|
4004
|
-
...
|
|
4032
|
+
...f && { height: f },
|
|
4005
4033
|
...h.description && { alt: h.description },
|
|
4006
4034
|
...h.id && { assetId: h.id }
|
|
4007
4035
|
};
|
|
4008
|
-
if (isEmpty(
|
|
4009
|
-
c([i._id],
|
|
4036
|
+
if (isEmpty(x)) return;
|
|
4037
|
+
c([i._id], x);
|
|
4010
4038
|
}
|
|
4011
4039
|
}
|
|
4012
4040
|
}, p = useCallback(() => {
|
|
@@ -4050,14 +4078,14 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
4050
4078
|
}, PathDropdown = ({ data: o, onSelect: r, dataType: n }) => {
|
|
4051
4079
|
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", p = React__default.useCallback(
|
|
4052
4080
|
(h) => {
|
|
4053
|
-
const m = (
|
|
4054
|
-
h.type === "object" ? (l((
|
|
4081
|
+
const m = (f) => n === "value" ? f === "value" || f === "object" : n === "array" ? f === "array" : f === n;
|
|
4082
|
+
h.type === "object" ? (l((f) => [...f, h.key]), c(h.value)) : m(h.type) && r([...a, h.key].join("."), n);
|
|
4055
4083
|
},
|
|
4056
4084
|
[a, r, n]
|
|
4057
4085
|
), u = React__default.useCallback(() => {
|
|
4058
4086
|
if (a.length > 0) {
|
|
4059
4087
|
const h = a.slice(0, -1);
|
|
4060
|
-
l(h), c(h.reduce((m,
|
|
4088
|
+
l(h), c(h.reduce((m, f) => m[f], o));
|
|
4061
4089
|
}
|
|
4062
4090
|
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([h, m]) => ({ key: h, value: m, type: d(m) })).filter((h) => !startsWith(h.key, REPEATER_PREFIX) && h.key.includes("/") ? !1 : n === "value" ? h.type === "value" || h.type === "object" : n === "array" ? h.type === "array" || h.type === "object" : n === "object" ? h.type === "object" : !0) : [], [i, n]);
|
|
4063
4091
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
@@ -4150,7 +4178,7 @@ const DataBindingSelector = ({
|
|
|
4150
4178
|
}) => {
|
|
4151
4179
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4152
4180
|
if (i.length === 1) return "";
|
|
4153
|
-
const g = i.find((
|
|
4181
|
+
const g = i.find((f) => f._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4154
4182
|
return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
|
|
4155
4183
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4156
4184
|
(g, h) => {
|
|
@@ -4158,44 +4186,44 @@ const DataBindingSelector = ({
|
|
|
4158
4186
|
r(`{{${g}}}`, {}, n);
|
|
4159
4187
|
return;
|
|
4160
4188
|
}
|
|
4161
|
-
const m = (b) => /[.,!?;:]/.test(b),
|
|
4162
|
-
let
|
|
4163
|
-
const w =
|
|
4164
|
-
return
|
|
4165
|
-
text:
|
|
4166
|
-
prefixLength:
|
|
4167
|
-
suffixLength:
|
|
4189
|
+
const m = (b) => /[.,!?;:]/.test(b), f = (b, A, B) => {
|
|
4190
|
+
let _ = "", N = "";
|
|
4191
|
+
const w = A > 0 ? b[A - 1] : "", y = A < b.length ? b[A] : "";
|
|
4192
|
+
return A > 0 && (w === "." || !m(w) && w !== " ") && (_ = " "), A < b.length && !m(y) && y !== " " && (N = " "), {
|
|
4193
|
+
text: _ + B + N,
|
|
4194
|
+
prefixLength: _.length,
|
|
4195
|
+
suffixLength: N.length
|
|
4168
4196
|
};
|
|
4169
|
-
},
|
|
4170
|
-
if (!
|
|
4171
|
-
const
|
|
4172
|
-
if (
|
|
4173
|
-
const b =
|
|
4197
|
+
}, x = document.getElementById(n);
|
|
4198
|
+
if (!x) return;
|
|
4199
|
+
const k = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
|
|
4200
|
+
if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
|
|
4201
|
+
const b = k.__chaiRTE;
|
|
4174
4202
|
if (b) {
|
|
4175
|
-
const
|
|
4203
|
+
const A = `{{${g}}}`;
|
|
4176
4204
|
b.commands.focus();
|
|
4177
|
-
const { from:
|
|
4178
|
-
if (
|
|
4179
|
-
b.chain().deleteSelection().insertContent(
|
|
4205
|
+
const { from: B, to: _ } = b.state.selection;
|
|
4206
|
+
if (B !== _)
|
|
4207
|
+
b.chain().deleteSelection().insertContent(A).run();
|
|
4180
4208
|
else {
|
|
4181
|
-
const { state: w } = b,
|
|
4209
|
+
const { state: w } = b, y = w.selection.from, C = w.doc.textBetween(Math.max(0, y - 1), y), E = w.doc.textBetween(y, Math.min(y + 1, w.doc.content.size));
|
|
4210
|
+
let v = "";
|
|
4211
|
+
y > 0 && C !== " " && !m(C) && (v = " ");
|
|
4182
4212
|
let S = "";
|
|
4183
|
-
|
|
4184
|
-
let k = "";
|
|
4185
|
-
N && N !== " " && !m(N) && (k = " "), b.chain().insertContent(S + B + k).run();
|
|
4213
|
+
E && E !== " " && !m(E) && (S = " "), b.chain().insertContent(v + A + S).run();
|
|
4186
4214
|
}
|
|
4187
4215
|
setTimeout(() => r(b.getHTML(), {}, n), 100);
|
|
4188
4216
|
return;
|
|
4189
4217
|
}
|
|
4190
4218
|
} else {
|
|
4191
|
-
const b =
|
|
4192
|
-
if (
|
|
4193
|
-
const
|
|
4194
|
-
r(
|
|
4219
|
+
const b = x, A = b.selectionStart || 0, B = b.value || "", _ = b.selectionEnd || A;
|
|
4220
|
+
if (_ > A) {
|
|
4221
|
+
const E = `{{${g}}}`, { text: v } = f(B, A, E), S = B.slice(0, A) + v + B.slice(_);
|
|
4222
|
+
r(S, {}, n);
|
|
4195
4223
|
return;
|
|
4196
4224
|
}
|
|
4197
|
-
const w = `{{${g}}}`, { text:
|
|
4198
|
-
r(
|
|
4225
|
+
const w = `{{${g}}}`, { text: y } = f(B, A, w), C = B.slice(0, A) + y + B.slice(A);
|
|
4226
|
+
r(C, {}, n);
|
|
4199
4227
|
}
|
|
4200
4228
|
},
|
|
4201
4229
|
[n, r, a, c == null ? void 0 : c._id, d]
|
|
@@ -4216,99 +4244,99 @@ const DataBindingSelector = ({
|
|
|
4216
4244
|
pageTypes: r,
|
|
4217
4245
|
onChange: n
|
|
4218
4246
|
}) => {
|
|
4219
|
-
var
|
|
4220
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (
|
|
4247
|
+
var E;
|
|
4248
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, S) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [k, b] = useState(-1), A = useRef(null), B = (E = r == null ? void 0 : r.find((v) => v.key === u)) == null ? void 0 : E.name;
|
|
4221
4249
|
useEffect(() => {
|
|
4222
|
-
if (m(""),
|
|
4223
|
-
const
|
|
4224
|
-
g(
|
|
4225
|
-
const
|
|
4226
|
-
|
|
4250
|
+
if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4251
|
+
const v = split(o, ":"), S = get(v, 1, "page") || "page";
|
|
4252
|
+
g(S), (async () => {
|
|
4253
|
+
const j = await l(S, [get(v, 2, "page")]);
|
|
4254
|
+
j && Array.isArray(j) && m(get(j, [0, "name"], ""));
|
|
4227
4255
|
})();
|
|
4228
4256
|
}, [o]);
|
|
4229
|
-
const
|
|
4230
|
-
async (
|
|
4231
|
-
if (isEmpty(
|
|
4232
|
-
|
|
4257
|
+
const _ = useDebouncedCallback(
|
|
4258
|
+
async (v) => {
|
|
4259
|
+
if (isEmpty(v))
|
|
4260
|
+
x([]);
|
|
4233
4261
|
else {
|
|
4234
|
-
const
|
|
4235
|
-
|
|
4262
|
+
const S = await l(u, v);
|
|
4263
|
+
x(S);
|
|
4236
4264
|
}
|
|
4237
4265
|
c(!1), b(-1);
|
|
4238
4266
|
},
|
|
4239
4267
|
[u],
|
|
4240
4268
|
300
|
|
4241
|
-
),
|
|
4242
|
-
const
|
|
4243
|
-
|
|
4244
|
-
}, w = (
|
|
4245
|
-
switch (
|
|
4269
|
+
), N = (v) => {
|
|
4270
|
+
const S = ["pageType", u, v.id];
|
|
4271
|
+
S[1] && (n(S.join(":")), m(v.name), p(!1), x([]), b(-1));
|
|
4272
|
+
}, w = (v) => {
|
|
4273
|
+
switch (v.key) {
|
|
4246
4274
|
case "ArrowDown":
|
|
4247
|
-
|
|
4275
|
+
v.preventDefault(), b((S) => S < f.length - 1 ? S + 1 : S);
|
|
4248
4276
|
break;
|
|
4249
4277
|
case "ArrowUp":
|
|
4250
|
-
|
|
4278
|
+
v.preventDefault(), b((S) => S > 0 ? S - 1 : S);
|
|
4251
4279
|
break;
|
|
4252
4280
|
case "Enter":
|
|
4253
|
-
if (
|
|
4254
|
-
|
|
4281
|
+
if (v.preventDefault(), f.length === 0) return;
|
|
4282
|
+
k >= 0 && N(f[k]);
|
|
4255
4283
|
break;
|
|
4256
4284
|
case "Escape":
|
|
4257
|
-
|
|
4285
|
+
v.preventDefault(), y();
|
|
4258
4286
|
break;
|
|
4259
4287
|
}
|
|
4260
4288
|
};
|
|
4261
4289
|
useEffect(() => {
|
|
4262
|
-
if (
|
|
4263
|
-
const
|
|
4264
|
-
|
|
4290
|
+
if (k >= 0 && A.current) {
|
|
4291
|
+
const v = A.current.children[k];
|
|
4292
|
+
v == null || v.scrollIntoView({ block: "nearest" });
|
|
4265
4293
|
}
|
|
4266
|
-
}, [
|
|
4267
|
-
const
|
|
4268
|
-
m(""),
|
|
4269
|
-
},
|
|
4270
|
-
m(
|
|
4294
|
+
}, [k]);
|
|
4295
|
+
const y = () => {
|
|
4296
|
+
m(""), x([]), b(-1), p(!1), n("");
|
|
4297
|
+
}, C = (v) => {
|
|
4298
|
+
m(v), p(!isEmpty(v)), c(!0), _(v);
|
|
4271
4299
|
};
|
|
4272
4300
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4273
|
-
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (
|
|
4301
|
+
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(r, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
|
|
4274
4302
|
u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
|
|
4275
4303
|
/* @__PURE__ */ jsx(
|
|
4276
4304
|
"input",
|
|
4277
4305
|
{
|
|
4278
4306
|
type: "text",
|
|
4279
4307
|
value: h,
|
|
4280
|
-
onChange: (
|
|
4308
|
+
onChange: (v) => C(v.target.value),
|
|
4281
4309
|
onKeyDown: w,
|
|
4282
|
-
placeholder: a(`Search ${
|
|
4310
|
+
placeholder: a(`Search ${B ?? ""}`),
|
|
4283
4311
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4284
4312
|
}
|
|
4285
4313
|
),
|
|
4286
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick:
|
|
4314
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: y, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4287
4315
|
] }),
|
|
4288
|
-
(i || !isEmpty(
|
|
4316
|
+
(i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4289
4317
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4290
4318
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4291
|
-
] }) : d && isEmpty(
|
|
4319
|
+
] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4292
4320
|
a("No results found for"),
|
|
4293
4321
|
' "',
|
|
4294
4322
|
h,
|
|
4295
4323
|
'"'
|
|
4296
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4324
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, S) => /* @__PURE__ */ jsxs(
|
|
4297
4325
|
"li",
|
|
4298
4326
|
{
|
|
4299
|
-
onClick: () =>
|
|
4300
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(
|
|
4327
|
+
onClick: () => N(v),
|
|
4328
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : S === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4301
4329
|
children: [
|
|
4302
|
-
|
|
4330
|
+
v.name,
|
|
4303
4331
|
" ",
|
|
4304
|
-
|
|
4332
|
+
v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
|
|
4305
4333
|
"( ",
|
|
4306
|
-
|
|
4334
|
+
v.slug,
|
|
4307
4335
|
" )"
|
|
4308
4336
|
] })
|
|
4309
4337
|
]
|
|
4310
4338
|
},
|
|
4311
|
-
|
|
4339
|
+
v.id
|
|
4312
4340
|
)) }) })
|
|
4313
4341
|
] });
|
|
4314
4342
|
}, LinkField = ({ schema: o, formData: r, onChange: n, name: a }) => {
|
|
@@ -4608,15 +4636,15 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4608
4636
|
if (!u) return;
|
|
4609
4637
|
const m = `{{${h}}}`;
|
|
4610
4638
|
u.commands.focus();
|
|
4611
|
-
const { from:
|
|
4612
|
-
if (
|
|
4639
|
+
const { from: f, to: x } = u.state.selection;
|
|
4640
|
+
if (f !== x)
|
|
4613
4641
|
u.chain().deleteSelection().insertContent(m).run();
|
|
4614
4642
|
else {
|
|
4615
|
-
const { state: b } = u,
|
|
4616
|
-
let
|
|
4617
|
-
|
|
4643
|
+
const { state: b } = u, A = b.selection.from, B = b.doc.textBetween(Math.max(0, A - 1), A), _ = b.doc.textBetween(A, Math.min(A + 1, b.doc.content.size));
|
|
4644
|
+
let N = "";
|
|
4645
|
+
A > 0 && B !== " " && !/[.,!?;:]/.test(B) && (N = " ");
|
|
4618
4646
|
let w = "";
|
|
4619
|
-
|
|
4647
|
+
_ && _ !== " " && !/[.,!?;:]/.test(_) && (w = " "), u.chain().insertContent(N + m + w).run();
|
|
4620
4648
|
}
|
|
4621
4649
|
};
|
|
4622
4650
|
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
@@ -4655,13 +4683,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4655
4683
|
})
|
|
4656
4684
|
],
|
|
4657
4685
|
content: n || "",
|
|
4658
|
-
onUpdate: ({ editor:
|
|
4659
|
-
const
|
|
4660
|
-
a(
|
|
4686
|
+
onUpdate: ({ editor: f }) => {
|
|
4687
|
+
const x = f.getHTML();
|
|
4688
|
+
a(x), c || u(x);
|
|
4661
4689
|
},
|
|
4662
|
-
onBlur: ({ editor:
|
|
4663
|
-
const
|
|
4664
|
-
l(o,
|
|
4690
|
+
onBlur: ({ editor: f }) => {
|
|
4691
|
+
const x = f.getHTML();
|
|
4692
|
+
l(o, x);
|
|
4665
4693
|
},
|
|
4666
4694
|
editorProps: {
|
|
4667
4695
|
attributes: {
|
|
@@ -4674,8 +4702,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4674
4702
|
}, [g]), useEffect(() => {
|
|
4675
4703
|
u(n || "");
|
|
4676
4704
|
}, [n]);
|
|
4677
|
-
const h = (
|
|
4678
|
-
a(
|
|
4705
|
+
const h = (f) => {
|
|
4706
|
+
a(f);
|
|
4679
4707
|
}, m = () => {
|
|
4680
4708
|
d(!1), g && g.commands.setContent(p);
|
|
4681
4709
|
};
|
|
@@ -4708,25 +4736,25 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4708
4736
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
|
|
4709
4737
|
}, [o, u]);
|
|
4710
4738
|
const h = () => {
|
|
4711
|
-
const
|
|
4712
|
-
if (
|
|
4713
|
-
const
|
|
4739
|
+
const x = findIndex(u, { _id: g });
|
|
4740
|
+
if (x > -1) {
|
|
4741
|
+
const k = (x + 1) % u.length, b = get(u, [k, "_id"]);
|
|
4714
4742
|
if (!b) return;
|
|
4715
4743
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4716
4744
|
}
|
|
4717
4745
|
}, m = () => {
|
|
4718
|
-
const
|
|
4719
|
-
if (
|
|
4720
|
-
const
|
|
4746
|
+
const x = findIndex(u, { _id: g });
|
|
4747
|
+
if (x > -1) {
|
|
4748
|
+
const k = (x - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
|
|
4721
4749
|
if (!b) return;
|
|
4722
4750
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4723
4751
|
}
|
|
4724
|
-
},
|
|
4725
|
-
const
|
|
4752
|
+
}, f = () => {
|
|
4753
|
+
const x = i(
|
|
4726
4754
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4727
4755
|
p == null ? void 0 : p._id
|
|
4728
|
-
),
|
|
4729
|
-
|
|
4756
|
+
), k = x == null ? void 0 : x._id;
|
|
4757
|
+
k && (r({ ...o, currentSlide: k }), c([k]));
|
|
4730
4758
|
};
|
|
4731
4759
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4732
4760
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
@@ -4743,7 +4771,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4743
4771
|
/* @__PURE__ */ jsxs(
|
|
4744
4772
|
"button",
|
|
4745
4773
|
{
|
|
4746
|
-
onClick:
|
|
4774
|
+
onClick: f,
|
|
4747
4775
|
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",
|
|
4748
4776
|
children: [
|
|
4749
4777
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4804,9 +4832,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4804
4832
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4805
4833
|
className: "text-xs",
|
|
4806
4834
|
pattern: "[0-9]*",
|
|
4807
|
-
onChange: (
|
|
4808
|
-
let
|
|
4809
|
-
|
|
4835
|
+
onChange: (x) => {
|
|
4836
|
+
let k = x.target.value;
|
|
4837
|
+
k.length && (k = k.replace("-", "")), r({ ...o, autoplayInterval: k });
|
|
4810
4838
|
}
|
|
4811
4839
|
}
|
|
4812
4840
|
)
|
|
@@ -4914,28 +4942,28 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4914
4942
|
formData: g,
|
|
4915
4943
|
onChange: h
|
|
4916
4944
|
}) => {
|
|
4917
|
-
const { selectedLang: m, fallbackLang:
|
|
4918
|
-
() => isEmpty(
|
|
4919
|
-
[
|
|
4920
|
-
), b = useMemo(() => get(LANGUAGES,
|
|
4921
|
-
() => get(
|
|
4922
|
-
[
|
|
4923
|
-
), [w,
|
|
4945
|
+
const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), k = useMemo(
|
|
4946
|
+
() => isEmpty(x) ? "" : isEmpty(m) ? f : m,
|
|
4947
|
+
[x, m, f]
|
|
4948
|
+
), b = useMemo(() => get(LANGUAGES, k, k), [k]), A = usePageExternalData(), B = useSelectedBlock(), _ = useRegisteredChaiBlocks(), N = useMemo(
|
|
4949
|
+
() => get(_, [B == null ? void 0 : B._type, "i18nProps"], []),
|
|
4950
|
+
[_, B == null ? void 0 : B._type]
|
|
4951
|
+
), [w, y] = useState(null);
|
|
4924
4952
|
if (d)
|
|
4925
4953
|
return null;
|
|
4926
4954
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
|
|
4927
|
-
const
|
|
4955
|
+
const E = N == null ? void 0 : N.includes(o.replace("root.", ""));
|
|
4928
4956
|
if (u.type === "array") {
|
|
4929
|
-
const
|
|
4957
|
+
const v = w === o;
|
|
4930
4958
|
return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
|
|
4931
4959
|
u.title && /* @__PURE__ */ jsxs(
|
|
4932
4960
|
"label",
|
|
4933
4961
|
{
|
|
4934
4962
|
htmlFor: o,
|
|
4935
|
-
onClick: () =>
|
|
4963
|
+
onClick: () => y(v ? null : o),
|
|
4936
4964
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4937
4965
|
children: [
|
|
4938
|
-
|
|
4966
|
+
v ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
4939
4967
|
/* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
|
|
4940
4968
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
|
|
4941
4969
|
" ",
|
|
@@ -4943,7 +4971,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4943
4971
|
]
|
|
4944
4972
|
}
|
|
4945
4973
|
),
|
|
4946
|
-
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${
|
|
4974
|
+
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${v ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
4947
4975
|
c,
|
|
4948
4976
|
a,
|
|
4949
4977
|
l,
|
|
@@ -4957,7 +4985,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4957
4985
|
/* @__PURE__ */ jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
|
|
4958
4986
|
n,
|
|
4959
4987
|
" ",
|
|
4960
|
-
|
|
4988
|
+
E && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
4961
4989
|
" ",
|
|
4962
4990
|
b
|
|
4963
4991
|
] }),
|
|
@@ -4968,12 +4996,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4968
4996
|
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
|
|
4969
4997
|
] }) })
|
|
4970
4998
|
] }),
|
|
4971
|
-
!u.enum && !u.oneOf &&
|
|
4999
|
+
!u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
4972
5000
|
DataBindingSelector,
|
|
4973
5001
|
{
|
|
4974
5002
|
schema: u,
|
|
4975
|
-
onChange: (
|
|
4976
|
-
h(
|
|
5003
|
+
onChange: (v) => {
|
|
5004
|
+
h(v, g, o);
|
|
4977
5005
|
},
|
|
4978
5006
|
id: o,
|
|
4979
5007
|
formData: g
|
|
@@ -5080,36 +5108,36 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
5080
5108
|
}), a;
|
|
5081
5109
|
};
|
|
5082
5110
|
function BlockSettings() {
|
|
5083
|
-
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h),
|
|
5084
|
-
|
|
5085
|
-
},
|
|
5086
|
-
debounce(({ formData: w },
|
|
5087
|
-
|
|
5111
|
+
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: w }, y, C) => {
|
|
5112
|
+
y && (c == null ? void 0 : c._id) === r._id && a([r._id], { [y]: get(w, y) }, C);
|
|
5113
|
+
}, x = useCallback(
|
|
5114
|
+
debounce(({ formData: w }, y, C) => {
|
|
5115
|
+
f({ formData: w }, y, C), d(w);
|
|
5088
5116
|
}, 1500),
|
|
5089
5117
|
[r == null ? void 0 : r._id, o]
|
|
5090
|
-
),
|
|
5091
|
-
|
|
5092
|
-
}, b = ({ formData: w },
|
|
5093
|
-
|
|
5094
|
-
}, { schema:
|
|
5118
|
+
), k = ({ formData: w }, y) => {
|
|
5119
|
+
y && (n([r._id], { [y]: get(w, y) }), x({ formData: w }, y, { [y]: get(c, y) }));
|
|
5120
|
+
}, b = ({ formData: w }, y) => {
|
|
5121
|
+
y && (n([g._id], { [y]: get(w, y) }), x({ formData: w }, y, { [y]: get(c, y) }));
|
|
5122
|
+
}, { schema: A, uiSchema: B } = useMemo(() => {
|
|
5095
5123
|
const w = r == null ? void 0 : r._type;
|
|
5096
5124
|
if (!w)
|
|
5097
5125
|
return { schema: {}, uiSchema: {} };
|
|
5098
5126
|
try {
|
|
5099
|
-
const { schema:
|
|
5127
|
+
const { schema: y, uiSchema: C } = getBlockFormSchemas(w);
|
|
5100
5128
|
if (w === "Repeater") {
|
|
5101
|
-
const
|
|
5102
|
-
startsWith(
|
|
5129
|
+
const E = get(r, "repeaterItems", "");
|
|
5130
|
+
startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(C, "filter", { "ui:widget": "collectionSelect" }), set(C, "sort", { "ui:widget": "collectionSelect" })) : (set(C, "filter", { "ui:widget": "hidden" }), set(C, "sort", { "ui:widget": "hidden" }));
|
|
5103
5131
|
}
|
|
5104
|
-
return { schema:
|
|
5132
|
+
return { schema: y, uiSchema: C };
|
|
5105
5133
|
} catch {
|
|
5106
5134
|
return { schema: {}, uiSchema: {} };
|
|
5107
5135
|
}
|
|
5108
|
-
}, [r]), { wrapperSchema:
|
|
5136
|
+
}, [r]), { wrapperSchema: _, wrapperUiSchema: N } = useMemo(() => {
|
|
5109
5137
|
if (!g || !(g != null && g._type))
|
|
5110
5138
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5111
|
-
const w = g == null ? void 0 : g._type, { schema:
|
|
5112
|
-
return { wrapperSchema:
|
|
5139
|
+
const w = g == null ? void 0 : g._type, { schema: y = {}, uiSchema: C = {} } = getBlockFormSchemas(w);
|
|
5140
|
+
return { wrapperSchema: y, wrapperUiSchema: C };
|
|
5113
5141
|
}, [g]);
|
|
5114
5142
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5115
5143
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
@@ -5137,52 +5165,52 @@ function BlockSettings() {
|
|
|
5137
5165
|
blockId: g == null ? void 0 : g._id,
|
|
5138
5166
|
onChange: b,
|
|
5139
5167
|
formData: m,
|
|
5140
|
-
schema:
|
|
5141
|
-
uiSchema:
|
|
5168
|
+
schema: _,
|
|
5169
|
+
uiSchema: N
|
|
5142
5170
|
}
|
|
5143
5171
|
) })
|
|
5144
5172
|
] }),
|
|
5145
|
-
isEmpty(
|
|
5173
|
+
isEmpty(A) ? null : /* @__PURE__ */ jsx(
|
|
5146
5174
|
JSONForm,
|
|
5147
5175
|
{
|
|
5148
5176
|
blockId: r == null ? void 0 : r._id,
|
|
5149
|
-
onChange:
|
|
5177
|
+
onChange: k,
|
|
5150
5178
|
formData: i,
|
|
5151
|
-
schema:
|
|
5152
|
-
uiSchema:
|
|
5179
|
+
schema: A,
|
|
5180
|
+
uiSchema: B
|
|
5153
5181
|
}
|
|
5154
5182
|
)
|
|
5155
5183
|
] });
|
|
5156
5184
|
}
|
|
5157
5185
|
const BlockStylingProps = () => {
|
|
5158
|
-
var
|
|
5186
|
+
var f;
|
|
5159
5187
|
const o = useSelectedBlock(), [r, n] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
|
|
5160
5188
|
if (!o) return null;
|
|
5161
5189
|
const c = Object.keys(o).filter(
|
|
5162
|
-
(
|
|
5163
|
-
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (
|
|
5190
|
+
(x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
|
|
5191
|
+
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = r[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], m = (x) => find(r, (k) => k.prop === x);
|
|
5164
5192
|
return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5165
5193
|
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5166
5194
|
i("Style element"),
|
|
5167
5195
|
":"
|
|
5168
5196
|
] }),
|
|
5169
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (
|
|
5197
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (x) => /* @__PURE__ */ jsxs(
|
|
5170
5198
|
Badge,
|
|
5171
5199
|
{
|
|
5172
5200
|
className: "flex cursor-pointer items-center gap-1 pr-1",
|
|
5173
|
-
variant: m(
|
|
5201
|
+
variant: m(x) ? "default" : "secondary",
|
|
5174
5202
|
onClick: () => {
|
|
5175
|
-
n([{ id: `${
|
|
5203
|
+
n([{ id: `${x}-${o._id}`, blockId: o._id, prop: x }]);
|
|
5176
5204
|
},
|
|
5177
5205
|
children: [
|
|
5178
|
-
startCase(
|
|
5206
|
+
startCase(x),
|
|
5179
5207
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5180
5208
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5181
5209
|
"button",
|
|
5182
5210
|
{
|
|
5183
5211
|
type: "button",
|
|
5184
5212
|
className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
|
|
5185
|
-
onClick: (
|
|
5213
|
+
onClick: (k) => k.stopPropagation(),
|
|
5186
5214
|
children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
|
|
5187
5215
|
}
|
|
5188
5216
|
) }),
|
|
@@ -5192,7 +5220,7 @@ const BlockStylingProps = () => {
|
|
|
5192
5220
|
{
|
|
5193
5221
|
className: "text-xs",
|
|
5194
5222
|
onClick: () => {
|
|
5195
|
-
d(
|
|
5223
|
+
d(x);
|
|
5196
5224
|
},
|
|
5197
5225
|
children: i("Reset style")
|
|
5198
5226
|
}
|
|
@@ -5211,7 +5239,7 @@ const BlockStylingProps = () => {
|
|
|
5211
5239
|
] })
|
|
5212
5240
|
]
|
|
5213
5241
|
},
|
|
5214
|
-
|
|
5242
|
+
x
|
|
5215
5243
|
)) }),
|
|
5216
5244
|
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5217
5245
|
] }) });
|
|
@@ -5360,47 +5388,47 @@ const BlockStylingProps = () => {
|
|
|
5360
5388
|
},
|
|
5361
5389
|
a
|
|
5362
5390
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5363
|
-
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [
|
|
5391
|
+
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [k, b] = useState(""), [A, B] = useState(!1), [_, N] = useState(!1);
|
|
5364
5392
|
useEffect(() => {
|
|
5365
|
-
const { value:
|
|
5366
|
-
if (
|
|
5367
|
-
l(
|
|
5393
|
+
const { value: v, unit: S } = getClassValueAndUnit(i);
|
|
5394
|
+
if (S === "") {
|
|
5395
|
+
l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5368
5396
|
return;
|
|
5369
5397
|
}
|
|
5370
|
-
m(
|
|
5398
|
+
m(S), l(S === "class" || isEmpty(v) ? "" : v);
|
|
5371
5399
|
}, [i, p, u]);
|
|
5372
|
-
const w = useThrottledCallback((
|
|
5373
|
-
(
|
|
5374
|
-
const
|
|
5375
|
-
if (get(
|
|
5376
|
-
|
|
5400
|
+
const w = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), y = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), C = useCallback(
|
|
5401
|
+
(v = !1) => {
|
|
5402
|
+
const S = getUserInputValues(`${a}`, u);
|
|
5403
|
+
if (get(S, "error", !1)) {
|
|
5404
|
+
x(!0);
|
|
5377
5405
|
return;
|
|
5378
5406
|
}
|
|
5379
|
-
const
|
|
5380
|
-
if (
|
|
5381
|
-
w(`${d}${
|
|
5407
|
+
const j = get(S, "unit") !== "" ? get(S, "unit") : h;
|
|
5408
|
+
if (j === "auto" || j === "none") {
|
|
5409
|
+
w(`${d}${j}`);
|
|
5382
5410
|
return;
|
|
5383
5411
|
}
|
|
5384
|
-
if (get(
|
|
5412
|
+
if (get(S, "value") === "")
|
|
5385
5413
|
return;
|
|
5386
|
-
const L = `${get(
|
|
5387
|
-
|
|
5414
|
+
const L = `${get(S, "value", "").startsWith("-") ? "-" : ""}${d}[${get(S, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5415
|
+
v ? y(L) : w(L);
|
|
5388
5416
|
},
|
|
5389
|
-
[w,
|
|
5390
|
-
),
|
|
5391
|
-
(
|
|
5392
|
-
const
|
|
5393
|
-
if (get(
|
|
5394
|
-
|
|
5417
|
+
[w, y, a, h, d, u]
|
|
5418
|
+
), E = useCallback(
|
|
5419
|
+
(v) => {
|
|
5420
|
+
const S = getUserInputValues(`${a}`, u);
|
|
5421
|
+
if (get(S, "error", !1)) {
|
|
5422
|
+
x(!0);
|
|
5395
5423
|
return;
|
|
5396
5424
|
}
|
|
5397
|
-
if (
|
|
5398
|
-
w(`${d}${
|
|
5425
|
+
if (v === "auto" || v === "none") {
|
|
5426
|
+
w(`${d}${v}`);
|
|
5399
5427
|
return;
|
|
5400
5428
|
}
|
|
5401
|
-
if (get(
|
|
5429
|
+
if (get(S, "value") === "")
|
|
5402
5430
|
return;
|
|
5403
|
-
const
|
|
5431
|
+
const j = get(S, "unit") !== "" ? get(S, "unit") : v, L = `${get(S, "value", "").startsWith("-") ? "-" : ""}${d}[${get(S, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5404
5432
|
w(L);
|
|
5405
5433
|
},
|
|
5406
5434
|
[w, a, d, u]
|
|
@@ -5418,40 +5446,40 @@ const BlockStylingProps = () => {
|
|
|
5418
5446
|
/* @__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, {}) }) }),
|
|
5419
5447
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
5420
5448
|
] })
|
|
5421
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
5449
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
|
|
5422
5450
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
5423
5451
|
["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
5424
5452
|
"input",
|
|
5425
5453
|
{
|
|
5426
5454
|
readOnly: h === "class",
|
|
5427
|
-
onKeyPress: (
|
|
5428
|
-
|
|
5455
|
+
onKeyPress: (v) => {
|
|
5456
|
+
v.key === "Enter" && C();
|
|
5429
5457
|
},
|
|
5430
|
-
onKeyDown: (
|
|
5431
|
-
if (
|
|
5458
|
+
onKeyDown: (v) => {
|
|
5459
|
+
if (v.keyCode !== 38 && v.keyCode !== 40)
|
|
5432
5460
|
return;
|
|
5433
|
-
|
|
5434
|
-
const
|
|
5435
|
-
let
|
|
5436
|
-
|
|
5437
|
-
const
|
|
5438
|
-
|
|
5461
|
+
v.preventDefault(), N(!0);
|
|
5462
|
+
const S = parseInt$1(v.target.value);
|
|
5463
|
+
let j = isNaN$1(S) ? 0 : S;
|
|
5464
|
+
v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
|
|
5465
|
+
const T = `${j}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5466
|
+
y(R);
|
|
5439
5467
|
},
|
|
5440
|
-
onKeyUp: (
|
|
5441
|
-
|
|
5468
|
+
onKeyUp: (v) => {
|
|
5469
|
+
_ && (v.preventDefault(), N(!1));
|
|
5442
5470
|
},
|
|
5443
|
-
onBlur: () =>
|
|
5444
|
-
onChange: (
|
|
5445
|
-
|
|
5471
|
+
onBlur: () => C(),
|
|
5472
|
+
onChange: (v) => {
|
|
5473
|
+
x(!1), l(v.target.value);
|
|
5446
5474
|
},
|
|
5447
|
-
onClick: (
|
|
5448
|
-
var
|
|
5449
|
-
(
|
|
5475
|
+
onClick: (v) => {
|
|
5476
|
+
var S;
|
|
5477
|
+
(S = v == null ? void 0 : v.target) == null || S.select(), n(!1);
|
|
5450
5478
|
},
|
|
5451
|
-
value:
|
|
5479
|
+
value: A ? k : a,
|
|
5452
5480
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5453
5481
|
" ",
|
|
5454
|
-
|
|
5482
|
+
f ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
5455
5483
|
)
|
|
5456
5484
|
}
|
|
5457
5485
|
),
|
|
@@ -5473,29 +5501,29 @@ const BlockStylingProps = () => {
|
|
|
5473
5501
|
{
|
|
5474
5502
|
units: u,
|
|
5475
5503
|
current: h,
|
|
5476
|
-
onSelect: (
|
|
5477
|
-
n(!1), m(
|
|
5504
|
+
onSelect: (v) => {
|
|
5505
|
+
n(!1), m(v), E(v);
|
|
5478
5506
|
}
|
|
5479
5507
|
}
|
|
5480
5508
|
) })
|
|
5481
5509
|
] })
|
|
5482
5510
|
] }),
|
|
5483
|
-
["none", "auto"].indexOf(h) !== -1 ||
|
|
5511
|
+
["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
|
|
5484
5512
|
DragStyleButton,
|
|
5485
5513
|
{
|
|
5486
|
-
onDragStart: () =>
|
|
5487
|
-
onDragEnd: (
|
|
5488
|
-
if (b(() => ""),
|
|
5514
|
+
onDragStart: () => B(!0),
|
|
5515
|
+
onDragEnd: (v) => {
|
|
5516
|
+
if (b(() => ""), B(!1), isEmpty(v))
|
|
5489
5517
|
return;
|
|
5490
|
-
const
|
|
5491
|
-
w(
|
|
5518
|
+
const S = `${v}`, T = `${S.startsWith("-") ? "-" : ""}${d}[${S.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5519
|
+
w(T);
|
|
5492
5520
|
},
|
|
5493
|
-
onDrag: (
|
|
5494
|
-
if (isEmpty(
|
|
5521
|
+
onDrag: (v) => {
|
|
5522
|
+
if (isEmpty(v))
|
|
5495
5523
|
return;
|
|
5496
|
-
b(
|
|
5497
|
-
const
|
|
5498
|
-
|
|
5524
|
+
b(v);
|
|
5525
|
+
const S = `${v}`, T = `${S.startsWith("-") ? "-" : ""}${d}[${S.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5526
|
+
y(T);
|
|
5499
5527
|
},
|
|
5500
5528
|
currentValue: a,
|
|
5501
5529
|
unit: h,
|
|
@@ -5560,8 +5588,8 @@ const COLOR_PROP = {
|
|
|
5560
5588
|
}, ColorChoice = ({ property: o, onChange: r }) => {
|
|
5561
5589
|
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
|
|
5562
5590
|
// eslint-disable-next-line no-shadow
|
|
5563
|
-
(
|
|
5564
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
5591
|
+
(k) => {
|
|
5592
|
+
["current", "inherit", "transparent", "black", "white"].includes(k) ? (c([]), p({ color: k })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
|
|
5565
5593
|
},
|
|
5566
5594
|
[c, p]
|
|
5567
5595
|
);
|
|
@@ -5570,21 +5598,21 @@ const COLOR_PROP = {
|
|
|
5570
5598
|
return c([]);
|
|
5571
5599
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5572
5600
|
}, [g]);
|
|
5573
|
-
const
|
|
5601
|
+
const f = useCallback(
|
|
5574
5602
|
// eslint-disable-next-line no-shadow
|
|
5575
|
-
(
|
|
5576
|
-
p({ color: g, shade:
|
|
5603
|
+
(k) => {
|
|
5604
|
+
p({ color: g, shade: k });
|
|
5577
5605
|
},
|
|
5578
5606
|
[g]
|
|
5579
5607
|
);
|
|
5580
5608
|
useEffect(() => {
|
|
5581
5609
|
p({ color: "", shade: "" });
|
|
5582
5610
|
}, [n]);
|
|
5583
|
-
const { match:
|
|
5611
|
+
const { match: x } = useTailwindClassList();
|
|
5584
5612
|
return useEffect(() => {
|
|
5585
5613
|
const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5586
|
-
|
|
5587
|
-
}, [
|
|
5614
|
+
x(o, b) && r(b, o);
|
|
5615
|
+
}, [x, d, r, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5588
5616
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5589
5617
|
DropDown,
|
|
5590
5618
|
{
|
|
@@ -5624,7 +5652,7 @@ const COLOR_PROP = {
|
|
|
5624
5652
|
]
|
|
5625
5653
|
}
|
|
5626
5654
|
) }),
|
|
5627
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange:
|
|
5655
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
|
|
5628
5656
|
] });
|
|
5629
5657
|
}, EDITOR_ICONS = {
|
|
5630
5658
|
"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" }) }),
|
|
@@ -5958,34 +5986,34 @@ const COLOR_PROP = {
|
|
|
5958
5986
|
"2xl": "1536px"
|
|
5959
5987
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
5960
5988
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
5961
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(),
|
|
5962
|
-
(
|
|
5963
|
-
const
|
|
5964
|
-
(p || u !== "") && (
|
|
5965
|
-
const
|
|
5966
|
-
m(
|
|
5989
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), k = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
|
|
5990
|
+
(y, C = !0) => {
|
|
5991
|
+
const E = { dark: p, mq: g, mod: u, cls: y, property: l, fullCls: "" };
|
|
5992
|
+
(p || u !== "") && (E.mq = "xs");
|
|
5993
|
+
const v = generateFullClsName(E);
|
|
5994
|
+
m(x, [v], C);
|
|
5967
5995
|
},
|
|
5968
|
-
[
|
|
5969
|
-
),
|
|
5970
|
-
x
|
|
5971
|
-
}, [
|
|
5996
|
+
[x, p, g, u, l, m]
|
|
5997
|
+
), A = useCallback(() => {
|
|
5998
|
+
f(x, [k], !0);
|
|
5999
|
+
}, [x, k, f]), B = useMemo(() => canChangeClass(h, g), [h, g]);
|
|
5972
6000
|
useEffect(() => {
|
|
5973
|
-
i(
|
|
5974
|
-
}, [
|
|
5975
|
-
const [, ,
|
|
5976
|
-
(
|
|
5977
|
-
|
|
6001
|
+
i(B, h);
|
|
6002
|
+
}, [B, i, h]);
|
|
6003
|
+
const [, , _] = useScreenSizeWidth(), N = useCallback(
|
|
6004
|
+
(y) => {
|
|
6005
|
+
_({
|
|
5978
6006
|
xs: 400,
|
|
5979
6007
|
sm: 640,
|
|
5980
6008
|
md: 800,
|
|
5981
6009
|
lg: 1024,
|
|
5982
6010
|
xl: 1420,
|
|
5983
6011
|
"2xl": 1920
|
|
5984
|
-
}[
|
|
6012
|
+
}[y]);
|
|
5985
6013
|
},
|
|
5986
|
-
[
|
|
6014
|
+
[_]
|
|
5987
6015
|
), w = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
|
|
5988
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6016
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: h && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
5989
6017
|
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !w ? "text-foreground" : ""}`, children: r(a) }) }),
|
|
5990
6018
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
5991
6019
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
@@ -6005,7 +6033,7 @@ const COLOR_PROP = {
|
|
|
6005
6033
|
n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
6006
6034
|
n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
6007
6035
|
] }),
|
|
6008
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
6036
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${k ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6009
6037
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6010
6038
|
"button",
|
|
6011
6039
|
{
|
|
@@ -6025,7 +6053,7 @@ const COLOR_PROP = {
|
|
|
6025
6053
|
"button",
|
|
6026
6054
|
{
|
|
6027
6055
|
type: "button",
|
|
6028
|
-
onClick: () =>
|
|
6056
|
+
onClick: () => N(get(h, "mq")),
|
|
6029
6057
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6030
6058
|
children: [
|
|
6031
6059
|
"Switch to ",
|
|
@@ -6054,23 +6082,23 @@ const COLOR_PROP = {
|
|
|
6054
6082
|
children: [
|
|
6055
6083
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6056
6084
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6057
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key:
|
|
6085
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6058
6086
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6059
6087
|
"button",
|
|
6060
6088
|
{
|
|
6061
6089
|
type: "button",
|
|
6062
|
-
onClick: () => u(
|
|
6063
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6090
|
+
onClick: () => u(f),
|
|
6091
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6064
6092
|
children: [
|
|
6065
6093
|
React__default.createElement("div", {
|
|
6066
|
-
className: h(
|
|
6094
|
+
className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6067
6095
|
}),
|
|
6068
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6096
|
+
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6069
6097
|
]
|
|
6070
6098
|
}
|
|
6071
6099
|
) }),
|
|
6072
6100
|
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
|
|
6073
|
-
] }) }, `option-${
|
|
6101
|
+
] }) }, `option-${x}`)) })
|
|
6074
6102
|
] }),
|
|
6075
6103
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6076
6104
|
BlockStyle,
|
|
@@ -6225,19 +6253,19 @@ const COLOR_PROP = {
|
|
|
6225
6253
|
canvas: r = !1,
|
|
6226
6254
|
tooltip: n = !0
|
|
6227
6255
|
}) => {
|
|
6228
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS),
|
|
6229
|
-
u.includes(b) ? u.length > 2 && g(u.filter((
|
|
6230
|
-
},
|
|
6256
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
|
|
6257
|
+
u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
|
|
6258
|
+
}, x = (b) => {
|
|
6231
6259
|
r || l(b), c(b);
|
|
6232
|
-
},
|
|
6260
|
+
}, k = getBreakpointValue(r ? i : a).toLowerCase();
|
|
6233
6261
|
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
|
|
6234
6262
|
BreakpointCard,
|
|
6235
6263
|
{
|
|
6236
6264
|
canvas: r,
|
|
6237
6265
|
...b,
|
|
6238
|
-
onClick:
|
|
6266
|
+
onClick: x,
|
|
6239
6267
|
key: b.breakpoint,
|
|
6240
|
-
currentBreakpoint:
|
|
6268
|
+
currentBreakpoint: k
|
|
6241
6269
|
}
|
|
6242
6270
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
6243
6271
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
@@ -6249,9 +6277,9 @@ const COLOR_PROP = {
|
|
|
6249
6277
|
openDelay: o,
|
|
6250
6278
|
tooltip: n,
|
|
6251
6279
|
...b,
|
|
6252
|
-
onClick:
|
|
6280
|
+
onClick: x,
|
|
6253
6281
|
key: b.breakpoint,
|
|
6254
|
-
currentBreakpoint:
|
|
6282
|
+
currentBreakpoint: k
|
|
6255
6283
|
}
|
|
6256
6284
|
)
|
|
6257
6285
|
) }),
|
|
@@ -6264,7 +6292,7 @@ const COLOR_PROP = {
|
|
|
6264
6292
|
DropdownMenuCheckboxItem,
|
|
6265
6293
|
{
|
|
6266
6294
|
disabled: b.breakpoint === "xs",
|
|
6267
|
-
onCheckedChange: () =>
|
|
6295
|
+
onCheckedChange: () => f(toUpper(b.breakpoint)),
|
|
6268
6296
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6269
6297
|
children: h(b.title)
|
|
6270
6298
|
},
|
|
@@ -6349,8 +6377,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6349
6377
|
(m = d.current) == null || m.focus();
|
|
6350
6378
|
}, []);
|
|
6351
6379
|
const h = (m) => {
|
|
6352
|
-
const { usage:
|
|
6353
|
-
!l &&
|
|
6380
|
+
const { usage: f } = m || {};
|
|
6381
|
+
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6354
6382
|
};
|
|
6355
6383
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6356
6384
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
|
|
@@ -6405,25 +6433,25 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6405
6433
|
] });
|
|
6406
6434
|
};
|
|
6407
6435
|
function ManualClasses() {
|
|
6408
|
-
var
|
|
6409
|
-
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [
|
|
6410
|
-
const L =
|
|
6411
|
-
u(h, L, !0),
|
|
6412
|
-
}, [
|
|
6413
|
-
const R = L.trim().toLowerCase(),
|
|
6436
|
+
var T;
|
|
6437
|
+
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), k = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), A = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
|
|
6438
|
+
const L = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6439
|
+
u(h, L, !0), x("");
|
|
6440
|
+
}, [_, N] = useState([]), w = ({ value: L }) => {
|
|
6441
|
+
const R = L.trim().toLowerCase(), I = R.match(/.+:/g);
|
|
6414
6442
|
let D = [];
|
|
6415
|
-
if (
|
|
6416
|
-
const [O] =
|
|
6443
|
+
if (I && I.length > 0) {
|
|
6444
|
+
const [O] = I, P = R.replace(O, "");
|
|
6417
6445
|
D = i.search(P).map((M) => ({
|
|
6418
6446
|
...M,
|
|
6419
6447
|
item: { ...M.item, name: O + M.item.name }
|
|
6420
6448
|
}));
|
|
6421
6449
|
} else
|
|
6422
6450
|
D = i.search(R);
|
|
6423
|
-
return
|
|
6424
|
-
},
|
|
6425
|
-
|
|
6426
|
-
},
|
|
6451
|
+
return N(map(D, "item"));
|
|
6452
|
+
}, y = () => {
|
|
6453
|
+
N([]);
|
|
6454
|
+
}, C = (L) => L.name, E = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), v = useMemo(
|
|
6427
6455
|
() => ({
|
|
6428
6456
|
ref: o,
|
|
6429
6457
|
autoComplete: "off",
|
|
@@ -6431,36 +6459,36 @@ function ManualClasses() {
|
|
|
6431
6459
|
autoCapitalize: "off",
|
|
6432
6460
|
spellCheck: !1,
|
|
6433
6461
|
placeholder: c("Enter classes separated by space"),
|
|
6434
|
-
value:
|
|
6462
|
+
value: f,
|
|
6435
6463
|
onFocus: (L) => {
|
|
6436
6464
|
setTimeout(() => {
|
|
6437
6465
|
L.target && L.target.select();
|
|
6438
6466
|
}, 0);
|
|
6439
6467
|
},
|
|
6440
6468
|
onKeyDown: (L) => {
|
|
6441
|
-
L.key === "Enter" &&
|
|
6469
|
+
L.key === "Enter" && f.trim() !== "" && B();
|
|
6442
6470
|
},
|
|
6443
|
-
onChange: (L, { newValue: R }) =>
|
|
6471
|
+
onChange: (L, { newValue: R }) => x(R),
|
|
6444
6472
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6445
6473
|
}),
|
|
6446
|
-
[
|
|
6447
|
-
),
|
|
6474
|
+
[f, c, o]
|
|
6475
|
+
), S = (L) => {
|
|
6448
6476
|
debugger;
|
|
6449
6477
|
const R = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6450
6478
|
g(h, [L]), u(h, R, !0), n(""), l(-1);
|
|
6451
|
-
},
|
|
6479
|
+
}, j = () => {
|
|
6452
6480
|
if (navigator.clipboard === void 0) {
|
|
6453
6481
|
toast.error(c("Clipboard not supported"));
|
|
6454
6482
|
return;
|
|
6455
6483
|
}
|
|
6456
|
-
navigator.clipboard.writeText(
|
|
6484
|
+
navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
6457
6485
|
};
|
|
6458
6486
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
6459
6487
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
6460
6488
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
6461
6489
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
6462
6490
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6463
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
6491
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: j, className: "cursor-pointer" }) }),
|
|
6464
6492
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
6465
6493
|
] })
|
|
6466
6494
|
] }),
|
|
@@ -6476,12 +6504,12 @@ function ManualClasses() {
|
|
|
6476
6504
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
6477
6505
|
Autosuggest,
|
|
6478
6506
|
{
|
|
6479
|
-
suggestions:
|
|
6507
|
+
suggestions: _,
|
|
6480
6508
|
onSuggestionsFetchRequested: w,
|
|
6481
|
-
onSuggestionsClearRequested:
|
|
6482
|
-
getSuggestionValue:
|
|
6483
|
-
renderSuggestion:
|
|
6484
|
-
inputProps:
|
|
6509
|
+
onSuggestionsClearRequested: y,
|
|
6510
|
+
getSuggestionValue: C,
|
|
6511
|
+
renderSuggestion: E,
|
|
6512
|
+
inputProps: v,
|
|
6485
6513
|
containerProps: {
|
|
6486
6514
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
6487
6515
|
},
|
|
@@ -6497,29 +6525,29 @@ function ManualClasses() {
|
|
|
6497
6525
|
{
|
|
6498
6526
|
variant: "outline",
|
|
6499
6527
|
className: "h-6 border-border",
|
|
6500
|
-
onClick:
|
|
6501
|
-
disabled:
|
|
6528
|
+
onClick: B,
|
|
6529
|
+
disabled: f.trim() === "",
|
|
6502
6530
|
size: "sm",
|
|
6503
6531
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
6504
6532
|
}
|
|
6505
6533
|
)
|
|
6506
6534
|
] }),
|
|
6507
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
6535
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
|
|
6508
6536
|
(L, R) => a === R ? /* @__PURE__ */ jsx(
|
|
6509
6537
|
"input",
|
|
6510
6538
|
{
|
|
6511
6539
|
ref: o,
|
|
6512
6540
|
value: r,
|
|
6513
|
-
onChange: (
|
|
6541
|
+
onChange: (I) => n(I.target.value),
|
|
6514
6542
|
onBlur: () => {
|
|
6515
|
-
|
|
6543
|
+
S(L);
|
|
6516
6544
|
},
|
|
6517
|
-
onKeyDown: (
|
|
6518
|
-
|
|
6545
|
+
onKeyDown: (I) => {
|
|
6546
|
+
I.key === "Enter" && S(L);
|
|
6519
6547
|
},
|
|
6520
|
-
onFocus: (
|
|
6548
|
+
onFocus: (I) => {
|
|
6521
6549
|
setTimeout(() => {
|
|
6522
|
-
|
|
6550
|
+
I.target.select();
|
|
6523
6551
|
}, 0);
|
|
6524
6552
|
},
|
|
6525
6553
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
|
|
@@ -6529,7 +6557,7 @@ function ManualClasses() {
|
|
|
6529
6557
|
"button",
|
|
6530
6558
|
{
|
|
6531
6559
|
onDoubleClick: () => {
|
|
6532
|
-
|
|
6560
|
+
x(L), g(h, [L]), setTimeout(() => {
|
|
6533
6561
|
o.current && o.current.focus();
|
|
6534
6562
|
}, 10);
|
|
6535
6563
|
},
|
|
@@ -6683,10 +6711,10 @@ function BlockStyling() {
|
|
|
6683
6711
|
const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
|
|
6684
6712
|
let m = parseFloat(i.dragStartValue);
|
|
6685
6713
|
m = isNaN(m) ? 0 : m;
|
|
6686
|
-
let
|
|
6687
|
-
(startsWith(h, "scale") || h === "opacity") && (
|
|
6688
|
-
let
|
|
6689
|
-
g &&
|
|
6714
|
+
let f = MAPPER[i.dragUnit];
|
|
6715
|
+
(startsWith(h, "scale") || h === "opacity") && (f = 10);
|
|
6716
|
+
let k = (i.dragStartY - u.pageY) / f + m;
|
|
6717
|
+
g && k < 0 && (k = 0), h === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
|
|
6690
6718
|
},
|
|
6691
6719
|
[i],
|
|
6692
6720
|
50
|
|
@@ -6729,12 +6757,12 @@ const CoreBlock = ({
|
|
|
6729
6757
|
}) => {
|
|
6730
6758
|
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
|
|
6731
6759
|
if (has(o, "blocks")) {
|
|
6732
|
-
const
|
|
6733
|
-
u(syncBlocksWithDefaults(
|
|
6760
|
+
const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
6761
|
+
u(syncBlocksWithDefaults(k), n || null, a);
|
|
6734
6762
|
} else
|
|
6735
6763
|
p(o, n || null, a);
|
|
6736
6764
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6737
|
-
},
|
|
6765
|
+
}, f = useFeature("dnd"), { t: x } = useTranslation();
|
|
6738
6766
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6739
6767
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6740
6768
|
"button",
|
|
@@ -6742,20 +6770,20 @@ const CoreBlock = ({
|
|
|
6742
6770
|
disabled: r,
|
|
6743
6771
|
onClick: m,
|
|
6744
6772
|
type: "button",
|
|
6745
|
-
onDragStart: (
|
|
6746
|
-
|
|
6773
|
+
onDragStart: (k) => {
|
|
6774
|
+
k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6747
6775
|
g([]), h();
|
|
6748
6776
|
}, 200);
|
|
6749
6777
|
},
|
|
6750
|
-
draggable:
|
|
6778
|
+
draggable: f ? "true" : "false",
|
|
6751
6779
|
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",
|
|
6752
6780
|
children: [
|
|
6753
6781
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6754
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6782
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
|
|
6755
6783
|
]
|
|
6756
6784
|
}
|
|
6757
6785
|
) }),
|
|
6758
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6786
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
|
|
6759
6787
|
] }) });
|
|
6760
6788
|
}, DefaultChaiBlocks = ({
|
|
6761
6789
|
parentId: o,
|
|
@@ -6819,7 +6847,22 @@ const CoreBlock = ({
|
|
|
6819
6847
|
}, shouldAddText = (o, r) => o.children.length === 1 && includes(
|
|
6820
6848
|
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
6821
6849
|
r._type
|
|
6822
|
-
), getTextContent = (o) => o.map((r) => r.type === "text" ? get(r, "content", "") : isEmpty(r.children) ? "" : getTextContent(r.children)).join(""), getSanitizedValue = (o) => o === null ? "" : o,
|
|
6850
|
+
), getTextContent = (o) => o.map((r) => r.type === "text" ? get(r, "content", "") : isEmpty(r.children) ? "" : getTextContent(r.children)).join(""), getSanitizedValue = (o) => o === null ? "" : o, getHeightAndWidthFromClass = (o) => {
|
|
6851
|
+
const r = compact(map(o.split(/\s+/), trim)), n = find(r, (d) => /^w-/.test(d)), a = find(r, (d) => /^h-/.test(d));
|
|
6852
|
+
if (!a || !n) return { height: "", width: "" };
|
|
6853
|
+
const l = (d) => {
|
|
6854
|
+
if (!d) return;
|
|
6855
|
+
const p = d.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
|
|
6856
|
+
if (!p) return;
|
|
6857
|
+
if (p[1]) return p[1];
|
|
6858
|
+
const u = p[2];
|
|
6859
|
+
return /^\d+(\.\d+)?$/.test(u) ? `${Number(u) * 4}px` : u === "auto" || includes(u, "%") ? u : "16px";
|
|
6860
|
+
}, i = l(n), c = l(a);
|
|
6861
|
+
return {
|
|
6862
|
+
width: includes(i, "px") ? i : "16px",
|
|
6863
|
+
height: includes(c, "px") ? c : "16px"
|
|
6864
|
+
};
|
|
6865
|
+
}, getAttrs = (o) => {
|
|
6823
6866
|
if (o.tagName === "svg") return {};
|
|
6824
6867
|
const r = {}, n = ATTRIBUTE_MAP[o.tagName] || {}, a = o.attributes;
|
|
6825
6868
|
return forEach(a, ({ key: l, value: i }) => {
|
|
@@ -6943,21 +6986,21 @@ const CoreBlock = ({
|
|
|
6943
6986
|
}
|
|
6944
6987
|
}
|
|
6945
6988
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
6946
|
-
var h, m,
|
|
6989
|
+
var h, m, f, x, k, b, A, B, _, N;
|
|
6947
6990
|
if (n.type === "comment") return [];
|
|
6948
6991
|
let a = { _id: generateUUID() };
|
|
6949
6992
|
if (r && (a._parent = r.block._id), n.type === "text")
|
|
6950
6993
|
return isEmpty(get(n, "content", "")) ? [] : r && shouldAddText(r.node, r.block) ? (set(r, "block.content", get(n, "content", "")), []) : { ...a, _type: "Text", content: get(n, "content", "") };
|
|
6951
6994
|
const l = get(n, "attributes", []), i = l.find(
|
|
6952
|
-
(
|
|
6995
|
+
(w) => w.key === "data-chai-richtext" || w.key === "chai-richtext"
|
|
6953
6996
|
), c = l.find(
|
|
6954
|
-
(
|
|
6997
|
+
(w) => w.key === "data-chai-lightbox" || w.key === "chai-lightbox"
|
|
6955
6998
|
), d = l.find(
|
|
6956
|
-
(
|
|
6999
|
+
(w) => w.key === "data-chai-dropdown" || w.key === "chai-dropdown"
|
|
6957
7000
|
), p = l.find(
|
|
6958
|
-
(
|
|
7001
|
+
(w) => w.key === "data-chai-dropdown-button" || w.key === "chai-dropdown-button"
|
|
6959
7002
|
), u = l.find(
|
|
6960
|
-
(
|
|
7003
|
+
(w) => w.key === "data-chai-dropdown-content" || w.key === "chai-dropdown-content"
|
|
6961
7004
|
);
|
|
6962
7005
|
if (a = {
|
|
6963
7006
|
...a,
|
|
@@ -6965,13 +7008,13 @@ const CoreBlock = ({
|
|
|
6965
7008
|
...getAttrs(n),
|
|
6966
7009
|
...getStyles(n)
|
|
6967
7010
|
}, n.attributes) {
|
|
6968
|
-
const
|
|
6969
|
-
|
|
7011
|
+
const w = n.attributes.find((y) => includes(NAME_ATTRIBUTES, y.key));
|
|
7012
|
+
w && (a._name = w.value);
|
|
6970
7013
|
}
|
|
6971
7014
|
if (i)
|
|
6972
7015
|
return a.content = stringify(n.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
|
|
6973
7016
|
if (c) {
|
|
6974
|
-
const
|
|
7017
|
+
const w = [
|
|
6975
7018
|
"data-chai-lightbox",
|
|
6976
7019
|
"chai-lightbox",
|
|
6977
7020
|
"data-vbtype",
|
|
@@ -6983,44 +7026,50 @@ const CoreBlock = ({
|
|
|
6983
7026
|
];
|
|
6984
7027
|
a = {
|
|
6985
7028
|
...a,
|
|
6986
|
-
href: ((h = l.find((
|
|
6987
|
-
hrefType: ((m = l.find((
|
|
6988
|
-
autoplay: ((
|
|
6989
|
-
maxWidth: ((
|
|
6990
|
-
backdropColor: ((b = l.find((
|
|
6991
|
-
galleryName: ((
|
|
6992
|
-
}, forEach(
|
|
6993
|
-
has(a, `styles_attrs.${
|
|
7029
|
+
href: ((h = l.find((y) => y.key === "href")) == null ? void 0 : h.value) || "",
|
|
7030
|
+
hrefType: ((m = l.find((y) => y.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
|
|
7031
|
+
autoplay: ((f = l.find((y) => y.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
7032
|
+
maxWidth: ((k = (x = l.find((y) => y.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : k.replace("px", "")) || "",
|
|
7033
|
+
backdropColor: ((b = l.find((y) => y.key === "data-overlay")) == null ? void 0 : b.value) || "",
|
|
7034
|
+
galleryName: ((A = l.find((y) => y.key === "data-gall")) == null ? void 0 : A.value) || ""
|
|
7035
|
+
}, forEach(w, (y) => {
|
|
7036
|
+
has(a, `styles_attrs.${y}`) && delete a.styles_attrs[y];
|
|
6994
7037
|
});
|
|
6995
7038
|
}
|
|
6996
7039
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
6997
7040
|
delete a.styles_attrs;
|
|
6998
|
-
const
|
|
6999
|
-
a.content = getTextContent(
|
|
7000
|
-
const
|
|
7041
|
+
const w = filter(n.children || [], (C) => (C == null ? void 0 : C.tagName) !== "span");
|
|
7042
|
+
a.content = getTextContent(w);
|
|
7043
|
+
const y = find(
|
|
7001
7044
|
n.children || [],
|
|
7002
|
-
(
|
|
7045
|
+
(C) => (C == null ? void 0 : C.tagName) === "span" && some(C.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg")
|
|
7003
7046
|
);
|
|
7004
|
-
if (
|
|
7005
|
-
const
|
|
7006
|
-
if (
|
|
7007
|
-
a.icon = stringify([
|
|
7008
|
-
const { height:
|
|
7009
|
-
a.iconHeight =
|
|
7047
|
+
if (y) {
|
|
7048
|
+
const C = find(y.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg");
|
|
7049
|
+
if (C) {
|
|
7050
|
+
a.icon = stringify([C]);
|
|
7051
|
+
const { height: E, width: v } = getSvgDimensions(C, "16px", "16px");
|
|
7052
|
+
a.iconHeight = E, a.iconWidth = v;
|
|
7010
7053
|
}
|
|
7011
7054
|
}
|
|
7012
7055
|
return [a];
|
|
7013
7056
|
}
|
|
7014
7057
|
if (a._type === "Input") {
|
|
7015
|
-
const
|
|
7016
|
-
|
|
7058
|
+
const w = a.inputType || "text";
|
|
7059
|
+
w === "checkbox" ? set(a, "_type", "Checkbox") : w === "radio" && set(a, "_type", "Radio");
|
|
7017
7060
|
} else if (n.tagName === "video" || n.tagName === "iframe") {
|
|
7018
|
-
const
|
|
7019
|
-
return hasVideoEmbed(
|
|
7061
|
+
const w = stringify([n]);
|
|
7062
|
+
return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
|
|
7020
7063
|
} else if (n.tagName === "svg") {
|
|
7021
|
-
const
|
|
7022
|
-
|
|
7023
|
-
|
|
7064
|
+
const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: y, width: C } = getHeightAndWidthFromClass(w);
|
|
7065
|
+
if (y && C)
|
|
7066
|
+
a.styles = `${STYLES_KEY}, ${cn$2(`w-${C} h-${y}`, w)}`.trim(), a.height = y == null ? void 0 : y.replace("px", ""), a.width = C == null ? void 0 : C.replace("px", "");
|
|
7067
|
+
else {
|
|
7068
|
+
const E = (B = find(n.attributes, { key: "height" })) == null ? void 0 : B.value, v = (_ = find(n.attributes, { key: "width" })) == null ? void 0 : _.value;
|
|
7069
|
+
E && v ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${v}px] h-[${E}px]`, w)}`.trim(), a.height = E, a.width = v) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
|
|
7070
|
+
}
|
|
7071
|
+
return n.attributes = filter(n.attributes, (E) => !includes(["style", "width", "height", "class"], E.key)), a.icon = stringify([n]), [a];
|
|
7072
|
+
} else if (n.tagName == "option" && r && ((N = r.block) == null ? void 0 : N._type) === "Select")
|
|
7024
7073
|
return r.block.options.push({
|
|
7025
7074
|
label: getTextContent(n.children),
|
|
7026
7075
|
...getAttrs(n)
|
|
@@ -7028,10 +7077,19 @@ const CoreBlock = ({
|
|
|
7028
7077
|
const g = traverseNodes(n.children, { block: a, node: n });
|
|
7029
7078
|
return [a, ...g];
|
|
7030
7079
|
}), getSvgDimensions = (o, r, n) => {
|
|
7031
|
-
|
|
7080
|
+
var p, u;
|
|
7081
|
+
const a = get(o, "attributes", []), { height: l, width: i } = getHeightAndWidthFromClass(
|
|
7082
|
+
get(find(a, { key: "class" }), "value", "")
|
|
7083
|
+
);
|
|
7084
|
+
if (l && i)
|
|
7085
|
+
return {
|
|
7086
|
+
height: `[${l}px]`,
|
|
7087
|
+
width: `[${i}px]`
|
|
7088
|
+
};
|
|
7089
|
+
const c = (p = find(a, { key: "height" })) == null ? void 0 : p.value, d = (u = find(a, { key: "width" })) == null ? void 0 : u.value;
|
|
7032
7090
|
return {
|
|
7033
|
-
height:
|
|
7034
|
-
width:
|
|
7091
|
+
height: c ? `[${c}px]` : n,
|
|
7092
|
+
width: d ? `[${d}px]` : r
|
|
7035
7093
|
};
|
|
7036
7094
|
}, getSanitizedHTML = (o) => {
|
|
7037
7095
|
o = o.replace(/(\w+)=\\?"(.*?)\\?"/g, (a, l, i) => {
|
|
@@ -7127,18 +7185,18 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7127
7185
|
parentId: n = void 0,
|
|
7128
7186
|
position: a = -1
|
|
7129
7187
|
}) => {
|
|
7130
|
-
const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""),
|
|
7131
|
-
const
|
|
7132
|
-
return
|
|
7188
|
+
const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), k = (B) => {
|
|
7189
|
+
const _ = has(B, "styles_attrs.data-page-section");
|
|
7190
|
+
return B._type === "Box" && _;
|
|
7133
7191
|
}, b = useCallback(
|
|
7134
|
-
async (
|
|
7135
|
-
if (
|
|
7192
|
+
async (B) => {
|
|
7193
|
+
if (B.stopPropagation(), has(o, "component")) {
|
|
7136
7194
|
d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7137
7195
|
return;
|
|
7138
7196
|
}
|
|
7139
7197
|
i(!0);
|
|
7140
|
-
let
|
|
7141
|
-
typeof
|
|
7198
|
+
let _ = await c({ library: r, block: o });
|
|
7199
|
+
typeof _ == "string" && (_ = getBlocksFromHTML(_)), isEmpty(_) || p(syncBlocksWithDefaults(_), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7142
7200
|
},
|
|
7143
7201
|
[d, p, o, c, r, n, a]
|
|
7144
7202
|
);
|
|
@@ -7148,20 +7206,20 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7148
7206
|
{
|
|
7149
7207
|
onClick: l ? () => {
|
|
7150
7208
|
} : b,
|
|
7151
|
-
draggable:
|
|
7152
|
-
onDragStart: async (
|
|
7153
|
-
const
|
|
7154
|
-
let
|
|
7155
|
-
if (
|
|
7156
|
-
const w = { blocks:
|
|
7157
|
-
if (
|
|
7158
|
-
const
|
|
7159
|
-
|
|
7160
|
-
|
|
7209
|
+
draggable: f ? "true" : "false",
|
|
7210
|
+
onDragStart: async (B) => {
|
|
7211
|
+
const _ = await c({ library: r, block: o });
|
|
7212
|
+
let N = n;
|
|
7213
|
+
if (k(first(_)) && (N = null), !isEmpty(_)) {
|
|
7214
|
+
const w = { blocks: _, uiLibrary: !0, parent: N };
|
|
7215
|
+
if (B.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
|
|
7216
|
+
const y = new Image();
|
|
7217
|
+
y.src = o.preview, y.onload = () => {
|
|
7218
|
+
B.dataTransfer.setDragImage(y, 0, 0);
|
|
7161
7219
|
};
|
|
7162
7220
|
} else
|
|
7163
|
-
|
|
7164
|
-
|
|
7221
|
+
B.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7222
|
+
x(w), setTimeout(() => {
|
|
7165
7223
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7166
7224
|
}, 200);
|
|
7167
7225
|
}
|
|
@@ -7187,39 +7245,39 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7187
7245
|
] }) })
|
|
7188
7246
|
] });
|
|
7189
7247
|
}, UILibrarySection = ({ parentId: o, position: r }) => {
|
|
7190
|
-
const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((
|
|
7248
|
+
const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((S) => S.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
|
|
7191
7249
|
useEffect(() => {
|
|
7192
|
-
c && c.length > 0 && (
|
|
7250
|
+
c && c.length > 0 && (f.current = new Fuse(c, {
|
|
7193
7251
|
keys: ["name", "label", "description", "group"],
|
|
7194
7252
|
threshold: 0.4,
|
|
7195
7253
|
ignoreLocation: !0
|
|
7196
7254
|
}));
|
|
7197
7255
|
}, [c]), useEffect(() => {
|
|
7198
|
-
if (!u.trim() || !
|
|
7256
|
+
if (!u.trim() || !f.current) {
|
|
7199
7257
|
m([]);
|
|
7200
7258
|
return;
|
|
7201
7259
|
}
|
|
7202
|
-
const
|
|
7203
|
-
m(
|
|
7260
|
+
const S = f.current.search(u).map((j) => j.item);
|
|
7261
|
+
m(S);
|
|
7204
7262
|
}, [u]);
|
|
7205
|
-
const
|
|
7263
|
+
const x = u.trim() && !isEmpty(h) ? h : c, k = groupBy(x, "group"), [b, A] = useState(null);
|
|
7206
7264
|
useEffect(() => {
|
|
7207
|
-
if (isEmpty(keys(
|
|
7208
|
-
|
|
7265
|
+
if (isEmpty(keys(k))) {
|
|
7266
|
+
A(null);
|
|
7209
7267
|
return;
|
|
7210
7268
|
}
|
|
7211
|
-
if (!b || !
|
|
7212
|
-
|
|
7269
|
+
if (!b || !k[b]) {
|
|
7270
|
+
A(first(keys(k)));
|
|
7213
7271
|
return;
|
|
7214
7272
|
}
|
|
7215
|
-
}, [
|
|
7216
|
-
const
|
|
7217
|
-
|
|
7218
|
-
|
|
7273
|
+
}, [k, b]);
|
|
7274
|
+
const B = get(k, b, []), _ = useRef(null), { t: N } = useTranslation(), w = (S) => {
|
|
7275
|
+
_.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
|
|
7276
|
+
_.current && A(S);
|
|
7219
7277
|
}, 400);
|
|
7220
|
-
},
|
|
7278
|
+
}, y = () => {
|
|
7221
7279
|
i != null && i.id && p(i.id);
|
|
7222
|
-
},
|
|
7280
|
+
}, C = () => {
|
|
7223
7281
|
g("");
|
|
7224
7282
|
};
|
|
7225
7283
|
if (d)
|
|
@@ -7227,23 +7285,23 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7227
7285
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7228
7286
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7229
7287
|
] });
|
|
7230
|
-
const
|
|
7288
|
+
const E = filter(B, (S, j) => j % 2 === 0), v = filter(B, (S, j) => j % 2 === 1);
|
|
7231
7289
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7232
7290
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7233
7291
|
/* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
7234
7292
|
/* @__PURE__ */ jsx(
|
|
7235
7293
|
Input$1,
|
|
7236
7294
|
{
|
|
7237
|
-
placeholder:
|
|
7295
|
+
placeholder: N("Search blocks..."),
|
|
7238
7296
|
value: u,
|
|
7239
|
-
onChange: (
|
|
7297
|
+
onChange: (S) => g(S.target.value),
|
|
7240
7298
|
className: "w-full pl-8 pr-8"
|
|
7241
7299
|
}
|
|
7242
7300
|
),
|
|
7243
7301
|
u && /* @__PURE__ */ jsx(
|
|
7244
7302
|
"button",
|
|
7245
7303
|
{
|
|
7246
|
-
onClick:
|
|
7304
|
+
onClick: C,
|
|
7247
7305
|
className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
|
|
7248
7306
|
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
7249
7307
|
}
|
|
@@ -7253,60 +7311,60 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7253
7311
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 min-w-60 max-w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7254
7312
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
|
|
7255
7313
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7256
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7314
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: N("Groups") }),
|
|
7257
7315
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7258
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(
|
|
7259
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm", children:
|
|
7260
|
-
/* @__PURE__ */ jsxs(Button, { onClick:
|
|
7316
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7317
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm", children: N("Failed to load the UI library. Try again") }),
|
|
7318
|
+
/* @__PURE__ */ jsxs(Button, { onClick: y, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7261
7319
|
/* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
|
|
7262
|
-
|
|
7320
|
+
N("Retry")
|
|
7263
7321
|
] })
|
|
7264
|
-
] }) }) : map(
|
|
7322
|
+
] }) }) : map(k, (S, j) => /* @__PURE__ */ jsxs(
|
|
7265
7323
|
"div",
|
|
7266
7324
|
{
|
|
7267
|
-
onMouseEnter: () => w(
|
|
7268
|
-
onMouseLeave: () => clearTimeout(
|
|
7325
|
+
onMouseEnter: () => w(j),
|
|
7326
|
+
onMouseLeave: () => clearTimeout(_.current),
|
|
7269
7327
|
role: "button",
|
|
7270
|
-
onClick: () =>
|
|
7328
|
+
onClick: () => A(j),
|
|
7271
7329
|
className: cn$2(
|
|
7272
7330
|
"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",
|
|
7273
|
-
|
|
7331
|
+
j === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
|
|
7274
7332
|
),
|
|
7275
7333
|
children: [
|
|
7276
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(j
|
|
7334
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(N(j.toLowerCase())) }),
|
|
7277
7335
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7278
7336
|
]
|
|
7279
7337
|
},
|
|
7280
|
-
|
|
7338
|
+
j
|
|
7281
7339
|
)) })
|
|
7282
7340
|
] })
|
|
7283
7341
|
] }),
|
|
7284
7342
|
/* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
|
|
7285
7343
|
ScrollArea,
|
|
7286
7344
|
{
|
|
7287
|
-
onMouseEnter: () =>
|
|
7345
|
+
onMouseEnter: () => _.current ? clearTimeout(_.current) : null,
|
|
7288
7346
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7289
7347
|
children: [
|
|
7290
|
-
isEmpty(
|
|
7291
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7348
|
+
isEmpty(B) && !isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
|
|
7349
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: E.map((S, j) => /* @__PURE__ */ jsx(
|
|
7292
7350
|
BlockCard,
|
|
7293
7351
|
{
|
|
7294
7352
|
parentId: o,
|
|
7295
7353
|
position: r,
|
|
7296
|
-
block:
|
|
7354
|
+
block: S,
|
|
7297
7355
|
library: i
|
|
7298
7356
|
},
|
|
7299
|
-
`block-${
|
|
7357
|
+
`block-${j}`
|
|
7300
7358
|
)) }),
|
|
7301
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7359
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((S, j) => /* @__PURE__ */ jsx(
|
|
7302
7360
|
BlockCard,
|
|
7303
7361
|
{
|
|
7304
7362
|
parentId: o,
|
|
7305
7363
|
position: r,
|
|
7306
|
-
block:
|
|
7364
|
+
block: S,
|
|
7307
7365
|
library: i
|
|
7308
7366
|
},
|
|
7309
|
-
`block-second-${
|
|
7367
|
+
`block-second-${j}`
|
|
7310
7368
|
)) })
|
|
7311
7369
|
] }),
|
|
7312
7370
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7342,25 +7400,25 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7342
7400
|
error: c
|
|
7343
7401
|
}), g(!0);
|
|
7344
7402
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7345
|
-
const m = Object.entries(a).map(([
|
|
7346
|
-
const b =
|
|
7403
|
+
const m = Object.entries(a).map(([x, k]) => {
|
|
7404
|
+
const b = k, A = b.type || "partial", B = formatReadableName(A);
|
|
7347
7405
|
return {
|
|
7348
7406
|
type: "PartialBlock",
|
|
7349
7407
|
// Set the type to PartialBlock
|
|
7350
|
-
label: formatReadableName(b.name ||
|
|
7408
|
+
label: formatReadableName(b.name || x),
|
|
7351
7409
|
description: b.description || "",
|
|
7352
7410
|
icon: Globe,
|
|
7353
|
-
group:
|
|
7411
|
+
group: B,
|
|
7354
7412
|
// Use formatted type as group
|
|
7355
7413
|
category: "partial",
|
|
7356
|
-
partialBlockId:
|
|
7414
|
+
partialBlockId: x,
|
|
7357
7415
|
// Store the original ID as partialBlockId
|
|
7358
7416
|
_name: b.name
|
|
7359
7417
|
};
|
|
7360
|
-
}),
|
|
7418
|
+
}), f = uniq(map(m, "group"));
|
|
7361
7419
|
p({
|
|
7362
7420
|
blocks: m,
|
|
7363
|
-
groups:
|
|
7421
|
+
groups: f,
|
|
7364
7422
|
isLoading: !1,
|
|
7365
7423
|
error: null
|
|
7366
7424
|
}), g(!0);
|
|
@@ -7405,44 +7463,44 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7405
7463
|
}, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
|
|
7406
7464
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
|
|
7407
7465
|
}, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7408
|
-
var
|
|
7409
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (
|
|
7466
|
+
var v;
|
|
7467
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (S) => S._id === n)) == null ? void 0 : v._type, [m, f] = useState("all"), [x, k] = useState(null), b = useRef(null);
|
|
7410
7468
|
useEffect(() => {
|
|
7411
|
-
const
|
|
7412
|
-
var
|
|
7413
|
-
(
|
|
7469
|
+
const S = setTimeout(() => {
|
|
7470
|
+
var j;
|
|
7471
|
+
(j = u.current) == null || j.focus();
|
|
7414
7472
|
}, 0);
|
|
7415
|
-
return () => clearTimeout(
|
|
7473
|
+
return () => clearTimeout(S);
|
|
7416
7474
|
}, [g]), useEffect(() => {
|
|
7417
|
-
d && (
|
|
7418
|
-
}, [d]), useEffect(() => (b.current = debounce((
|
|
7419
|
-
|
|
7475
|
+
d && (f("all"), k(null));
|
|
7476
|
+
}, [d]), useEffect(() => (b.current = debounce((S) => {
|
|
7477
|
+
f(S);
|
|
7420
7478
|
}, 500), () => {
|
|
7421
7479
|
b.current && b.current.cancel();
|
|
7422
7480
|
}), []);
|
|
7423
|
-
const
|
|
7424
|
-
|
|
7425
|
-
}, []),
|
|
7426
|
-
|
|
7427
|
-
}, []),
|
|
7428
|
-
b.current && b.current.cancel(),
|
|
7429
|
-
}, []),
|
|
7481
|
+
const A = useCallback((S) => {
|
|
7482
|
+
k(S), b.current && b.current(S);
|
|
7483
|
+
}, []), B = useCallback(() => {
|
|
7484
|
+
k(null), b.current && b.current.cancel();
|
|
7485
|
+
}, []), _ = useCallback((S) => {
|
|
7486
|
+
b.current && b.current.cancel(), f(S), k(null);
|
|
7487
|
+
}, []), N = useMemo(
|
|
7430
7488
|
() => d ? values(r).filter(
|
|
7431
|
-
(
|
|
7432
|
-
var
|
|
7433
|
-
return (((
|
|
7489
|
+
(S) => {
|
|
7490
|
+
var j, T;
|
|
7491
|
+
return (((j = S.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = S.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
|
|
7434
7492
|
}
|
|
7435
7493
|
) : r,
|
|
7436
7494
|
[r, d]
|
|
7437
7495
|
), w = useMemo(
|
|
7438
7496
|
() => d ? o.filter(
|
|
7439
|
-
(
|
|
7440
|
-
) : o.filter((
|
|
7441
|
-
[r,
|
|
7442
|
-
),
|
|
7443
|
-
() => sortBy(w, (
|
|
7497
|
+
(S) => reject(filter(values(N), { group: S }), { hidden: !0 }).length > 0
|
|
7498
|
+
) : o.filter((S) => reject(filter(values(r), { group: S }), { hidden: !0 }).length > 0),
|
|
7499
|
+
[r, N, o, d]
|
|
7500
|
+
), y = useMemo(
|
|
7501
|
+
() => sortBy(w, (S) => CORE_GROUPS.indexOf(S) === -1 ? 99 : CORE_GROUPS.indexOf(S)),
|
|
7444
7502
|
[w]
|
|
7445
|
-
),
|
|
7503
|
+
), C = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), E = useMemo(() => m === "all" ? y : [m], [y, m]);
|
|
7446
7504
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7447
7505
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7448
7506
|
Input$1,
|
|
@@ -7452,32 +7510,32 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7452
7510
|
placeholder: i("Search blocks..."),
|
|
7453
7511
|
value: d,
|
|
7454
7512
|
className: "-ml-2",
|
|
7455
|
-
onChange: (
|
|
7513
|
+
onChange: (S) => p(S.target.value)
|
|
7456
7514
|
}
|
|
7457
7515
|
) }),
|
|
7458
7516
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7459
|
-
|
|
7517
|
+
y.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
7460
7518
|
/* @__PURE__ */ jsx(
|
|
7461
7519
|
"button",
|
|
7462
7520
|
{
|
|
7463
|
-
onClick: () =>
|
|
7464
|
-
onMouseEnter: () =>
|
|
7465
|
-
onMouseLeave:
|
|
7466
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" ||
|
|
7521
|
+
onClick: () => _("all"),
|
|
7522
|
+
onMouseEnter: () => A("all"),
|
|
7523
|
+
onMouseLeave: B,
|
|
7524
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7467
7525
|
children: i("All")
|
|
7468
7526
|
},
|
|
7469
7527
|
"sidebar-all"
|
|
7470
7528
|
),
|
|
7471
|
-
|
|
7529
|
+
y.map((S) => /* @__PURE__ */ jsx(
|
|
7472
7530
|
"button",
|
|
7473
7531
|
{
|
|
7474
|
-
onClick: () =>
|
|
7475
|
-
onMouseEnter: () =>
|
|
7476
|
-
onMouseLeave:
|
|
7477
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m ===
|
|
7478
|
-
children: capitalize(i(
|
|
7532
|
+
onClick: () => _(S),
|
|
7533
|
+
onMouseEnter: () => A(S),
|
|
7534
|
+
onMouseLeave: B,
|
|
7535
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === S || x === S ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7536
|
+
children: capitalize(i(S.toLowerCase()))
|
|
7479
7537
|
},
|
|
7480
|
-
`sidebar-${
|
|
7538
|
+
`sidebar-${S}`
|
|
7481
7539
|
))
|
|
7482
7540
|
] }) }) }),
|
|
7483
7541
|
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: w.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
@@ -7485,22 +7543,22 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7485
7543
|
' "',
|
|
7486
7544
|
d,
|
|
7487
7545
|
'"'
|
|
7488
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children:
|
|
7489
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7546
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: E.map((S) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7547
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(S.toLowerCase())) }),
|
|
7490
7548
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7491
|
-
m === "all" ? filter(values(
|
|
7549
|
+
m === "all" ? filter(values(C), { group: S }) : values(C),
|
|
7492
7550
|
{ hidden: !0 }
|
|
7493
|
-
).map((
|
|
7551
|
+
).map((j) => /* @__PURE__ */ jsx(
|
|
7494
7552
|
CoreBlock,
|
|
7495
7553
|
{
|
|
7496
7554
|
parentId: n,
|
|
7497
7555
|
position: a,
|
|
7498
|
-
block:
|
|
7499
|
-
disabled: !canAcceptChildBlock(h,
|
|
7556
|
+
block: j,
|
|
7557
|
+
disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
|
|
7500
7558
|
},
|
|
7501
|
-
|
|
7559
|
+
j.type
|
|
7502
7560
|
)) })
|
|
7503
|
-
] },
|
|
7561
|
+
] }, S)) }) }) })
|
|
7504
7562
|
] })
|
|
7505
7563
|
] });
|
|
7506
7564
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
@@ -7515,7 +7573,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7515
7573
|
}, [i, g, c]);
|
|
7516
7574
|
const m = useCallback(() => {
|
|
7517
7575
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7518
|
-
}, []),
|
|
7576
|
+
}, []), f = useChaiAddBlockTabs(), x = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
|
|
7519
7577
|
return useEffect(() => {
|
|
7520
7578
|
i === "library" && !b && c("core");
|
|
7521
7579
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7526,8 +7584,8 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7526
7584
|
/* @__PURE__ */ jsxs(
|
|
7527
7585
|
Tabs,
|
|
7528
7586
|
{
|
|
7529
|
-
onValueChange: (
|
|
7530
|
-
d(""), c(
|
|
7587
|
+
onValueChange: (A) => {
|
|
7588
|
+
d(""), c(A);
|
|
7531
7589
|
},
|
|
7532
7590
|
value: i,
|
|
7533
7591
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -7536,14 +7594,14 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7536
7594
|
b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7537
7595
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7538
7596
|
g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7539
|
-
|
|
7540
|
-
map(
|
|
7597
|
+
x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7598
|
+
map(f, (A) => /* @__PURE__ */ jsx(TabsTrigger, { value: A.id, children: React__default.createElement(A.tab) }, `tab-add-block-${A.id}`))
|
|
7541
7599
|
] }),
|
|
7542
7600
|
/* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
|
|
7543
7601
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
|
|
7544
7602
|
g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
|
|
7545
|
-
|
|
7546
|
-
map(
|
|
7603
|
+
x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
|
|
7604
|
+
map(f, (A) => /* @__PURE__ */ jsx(TabsContent, { value: A.id, children: React__default.createElement(A.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${A.id}`))
|
|
7547
7605
|
]
|
|
7548
7606
|
}
|
|
7549
7607
|
)
|
|
@@ -7853,35 +7911,35 @@ const Input = ({ node: o }) => {
|
|
|
7853
7911
|
var R;
|
|
7854
7912
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7855
7913
|
let p = null;
|
|
7856
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data:
|
|
7857
|
-
|
|
7858
|
-
},
|
|
7859
|
-
|
|
7860
|
-
}, w = (
|
|
7861
|
-
|
|
7862
|
-
}, [
|
|
7863
|
-
var
|
|
7864
|
-
|
|
7865
|
-
},
|
|
7866
|
-
|
|
7867
|
-
},
|
|
7868
|
-
|
|
7914
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: k, isDragging: b, isEditing: A, handleClick: B } = o, _ = (I) => {
|
|
7915
|
+
I.stopPropagation(), !l.includes(m) && o.toggle();
|
|
7916
|
+
}, N = (I) => {
|
|
7917
|
+
I.isInternal && (p = I.isOpen, I.isOpen && I.close());
|
|
7918
|
+
}, w = (I) => {
|
|
7919
|
+
I.isInternal && p !== null && (p ? I.open() : I.close(), p = null);
|
|
7920
|
+
}, [y, C] = useAtom$1(currentAddSelection), E = () => {
|
|
7921
|
+
var I;
|
|
7922
|
+
v(), o.parent.isSelected || C((I = o == null ? void 0 : o.parent) == null ? void 0 : I.id);
|
|
7923
|
+
}, v = () => {
|
|
7924
|
+
C(null);
|
|
7925
|
+
}, S = (I) => {
|
|
7926
|
+
v(), I.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(I);
|
|
7869
7927
|
};
|
|
7870
7928
|
useEffect(() => {
|
|
7871
|
-
const
|
|
7872
|
-
|
|
7929
|
+
const I = setTimeout(() => {
|
|
7930
|
+
k && !o.isOpen && !b && !l.includes(m) && o.toggle();
|
|
7873
7931
|
}, 500);
|
|
7874
|
-
return () => clearTimeout(
|
|
7875
|
-
}, [
|
|
7876
|
-
const
|
|
7877
|
-
const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${
|
|
7932
|
+
return () => clearTimeout(I);
|
|
7933
|
+
}, [k, o, b]);
|
|
7934
|
+
const j = (I, D) => {
|
|
7935
|
+
const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${I}]`);
|
|
7878
7936
|
P && P.setAttribute("data-drop", D);
|
|
7879
7937
|
const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
|
|
7880
7938
|
$.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
|
|
7881
|
-
},
|
|
7882
|
-
|
|
7939
|
+
}, T = (I) => {
|
|
7940
|
+
v();
|
|
7883
7941
|
const D = get(o, "parent.id");
|
|
7884
|
-
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position:
|
|
7942
|
+
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: I }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: I });
|
|
7885
7943
|
};
|
|
7886
7944
|
if (m === ROOT_TEMP_KEY)
|
|
7887
7945
|
return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
@@ -7890,7 +7948,7 @@ const Input = ({ node: o }) => {
|
|
|
7890
7948
|
"div",
|
|
7891
7949
|
{
|
|
7892
7950
|
role: "button",
|
|
7893
|
-
onClick: () =>
|
|
7951
|
+
onClick: () => T(-1),
|
|
7894
7952
|
className: "h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",
|
|
7895
7953
|
children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-[9px] leading-tight text-white hover:bg-primary", children: [
|
|
7896
7954
|
/* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7901,36 +7959,36 @@ const Input = ({ node: o }) => {
|
|
|
7901
7959
|
),
|
|
7902
7960
|
/* @__PURE__ */ jsx("br", {})
|
|
7903
7961
|
] });
|
|
7904
|
-
const L = useMemo(() => has(
|
|
7962
|
+
const L = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, d]);
|
|
7905
7963
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7906
7964
|
"div",
|
|
7907
7965
|
{
|
|
7908
7966
|
onMouseEnter: () => g(m),
|
|
7909
7967
|
onMouseLeave: () => h(),
|
|
7910
|
-
onClick:
|
|
7968
|
+
onClick: S,
|
|
7911
7969
|
style: r,
|
|
7912
7970
|
"data-node-id": m,
|
|
7913
7971
|
ref: l.includes(m) ? null : n,
|
|
7914
|
-
onDragStart: () =>
|
|
7972
|
+
onDragStart: () => N(o),
|
|
7915
7973
|
onDragEnd: () => w(o),
|
|
7916
|
-
onDragOver: (
|
|
7917
|
-
|
|
7974
|
+
onDragOver: (I) => {
|
|
7975
|
+
I.preventDefault(), j(m, "yes");
|
|
7918
7976
|
},
|
|
7919
|
-
onDragLeave: (
|
|
7920
|
-
|
|
7977
|
+
onDragLeave: (I) => {
|
|
7978
|
+
I.preventDefault(), j(m, "no");
|
|
7921
7979
|
},
|
|
7922
|
-
onDrop: (
|
|
7923
|
-
|
|
7980
|
+
onDrop: (I) => {
|
|
7981
|
+
I.preventDefault(), j(m, "no");
|
|
7924
7982
|
},
|
|
7925
7983
|
children: [
|
|
7926
7984
|
d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
7927
7985
|
"div",
|
|
7928
7986
|
{
|
|
7929
|
-
onClick: (
|
|
7930
|
-
|
|
7987
|
+
onClick: (I) => {
|
|
7988
|
+
I.stopPropagation(), T(o.childIndex);
|
|
7931
7989
|
},
|
|
7932
|
-
onMouseEnter:
|
|
7933
|
-
onMouseLeave:
|
|
7990
|
+
onMouseEnter: E,
|
|
7991
|
+
onMouseLeave: v,
|
|
7934
7992
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7935
7993
|
children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
|
|
7936
7994
|
}
|
|
@@ -7940,12 +7998,12 @@ const Input = ({ node: o }) => {
|
|
|
7940
7998
|
{
|
|
7941
7999
|
className: cn(
|
|
7942
8000
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
(o == null ? void 0 : o.id) ===
|
|
8001
|
+
x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
|
|
8002
|
+
k && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
|
|
8003
|
+
(o == null ? void 0 : o.id) === y ? "bg-primary/10" : "",
|
|
7946
8004
|
b && "opacity-20",
|
|
7947
8005
|
l.includes(m) ? "opacity-50" : "",
|
|
7948
|
-
L &&
|
|
8006
|
+
L && x && "bg-primary/20 text-primary"
|
|
7949
8007
|
),
|
|
7950
8008
|
children: [
|
|
7951
8009
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7953,7 +8011,7 @@ const Input = ({ node: o }) => {
|
|
|
7953
8011
|
"div",
|
|
7954
8012
|
{
|
|
7955
8013
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7956
|
-
children: u && /* @__PURE__ */ jsx("button", { onClick:
|
|
8014
|
+
children: u && /* @__PURE__ */ jsx("button", { onClick: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-white" : "text-slate-400"}` }) })
|
|
7957
8015
|
}
|
|
7958
8016
|
),
|
|
7959
8017
|
/* @__PURE__ */ jsxs(
|
|
@@ -7962,18 +8020,18 @@ const Input = ({ node: o }) => {
|
|
|
7962
8020
|
className: cn(
|
|
7963
8021
|
"leading-1 flex items-center",
|
|
7964
8022
|
L && "text-primary/60",
|
|
7965
|
-
L &&
|
|
8023
|
+
L && x && "text-primary/80"
|
|
7966
8024
|
),
|
|
7967
8025
|
children: [
|
|
7968
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7969
|
-
|
|
8026
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
|
|
8027
|
+
A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
|
|
7970
8028
|
"div",
|
|
7971
8029
|
{
|
|
7972
8030
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
7973
|
-
onDoubleClick: (
|
|
7974
|
-
|
|
8031
|
+
onDoubleClick: (I) => {
|
|
8032
|
+
I.stopPropagation(), o.edit(), o.deselect();
|
|
7975
8033
|
},
|
|
7976
|
-
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(
|
|
8034
|
+
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(f) })
|
|
7977
8035
|
}
|
|
7978
8036
|
)
|
|
7979
8037
|
]
|
|
@@ -7981,7 +8039,7 @@ const Input = ({ node: o }) => {
|
|
|
7981
8039
|
)
|
|
7982
8040
|
] }),
|
|
7983
8041
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7984
|
-
canAddChildBlock(
|
|
8042
|
+
canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7985
8043
|
/* @__PURE__ */ jsx(
|
|
7986
8044
|
TooltipTrigger,
|
|
7987
8045
|
{
|
|
@@ -7997,8 +8055,8 @@ const Input = ({ node: o }) => {
|
|
|
7997
8055
|
/* @__PURE__ */ jsx(
|
|
7998
8056
|
TooltipTrigger,
|
|
7999
8057
|
{
|
|
8000
|
-
onClick: (
|
|
8001
|
-
|
|
8058
|
+
onClick: (I) => {
|
|
8059
|
+
I.stopPropagation(), i(m), o.isOpen && o.toggle();
|
|
8002
8060
|
},
|
|
8003
8061
|
className: "cursor-pointer rounded bg-transparent",
|
|
8004
8062
|
asChild: !0,
|
|
@@ -8218,17 +8276,18 @@ const Input = ({ node: o }) => {
|
|
|
8218
8276
|
/* @__PURE__ */ jsx(PasteAtRootContextMenu, { parentContext, setParentContext })
|
|
8219
8277
|
] });
|
|
8220
8278
|
}, BorderRadiusInput = ({ value: o, onChange: r, disabled: n }) => {
|
|
8221
|
-
const a =
|
|
8279
|
+
const [a, l] = useState(o), i = useThrottledCallback(r, [o], 200, !0);
|
|
8222
8280
|
return /* @__PURE__ */ jsx(
|
|
8223
|
-
|
|
8281
|
+
Slider,
|
|
8224
8282
|
{
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
max: "30",
|
|
8283
|
+
min: 0,
|
|
8284
|
+
step: 1,
|
|
8285
|
+
max: 50,
|
|
8229
8286
|
disabled: n,
|
|
8230
|
-
|
|
8231
|
-
|
|
8287
|
+
value: [Number(a.replace("px", ""))],
|
|
8288
|
+
onValueChange: (c) => {
|
|
8289
|
+
l(c[0].toString() + "px"), i(c[0].toString());
|
|
8290
|
+
},
|
|
8232
8291
|
className: "flex-1 cursor-pointer"
|
|
8233
8292
|
}
|
|
8234
8293
|
);
|
|
@@ -8259,337 +8318,192 @@ const Input = ({ node: o }) => {
|
|
|
8259
8318
|
onChange: n
|
|
8260
8319
|
}) => {
|
|
8261
8320
|
const a = useRegisteredFonts();
|
|
8262
|
-
return
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
children: a.map((l) => /* @__PURE__ */ jsx("option", { value: l.family, children: l.family }, l.family))
|
|
8271
|
-
}
|
|
8272
|
-
)
|
|
8321
|
+
return useEffect(() => {
|
|
8322
|
+
a.some((l) => l.family === r) || n(a[0].family);
|
|
8323
|
+
}, [r, n]), /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
8324
|
+
/* @__PURE__ */ jsx(Label, { className: "mb-1 block text-xs text-gray-600", children: startCase(o) }),
|
|
8325
|
+
/* @__PURE__ */ jsxs(Select$1, { value: r, onValueChange: n, children: [
|
|
8326
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-full text-xs text-black", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select font" }) }),
|
|
8327
|
+
/* @__PURE__ */ jsx(SelectContent, { children: a.map((l) => /* @__PURE__ */ jsx(SelectItem, { value: l.family, children: l.family }, l.family)) })
|
|
8328
|
+
] })
|
|
8273
8329
|
] });
|
|
8274
|
-
},
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
body: ""
|
|
8279
|
-
},
|
|
8280
|
-
borderRadius: "",
|
|
8281
|
-
colors: {}
|
|
8282
|
-
};
|
|
8283
|
-
try {
|
|
8284
|
-
const n = extractCssBlockContent(o, ":root"), a = extractCssBlockContent(o, ".dark"), l = extractVariableValue(n, "--font-sans") || extractVariableValue(n, "--font-family") || extractVariableValue(n, "--font-heading") || extractVariableValue(n, "--font-body");
|
|
8285
|
-
r.fontFamily = {
|
|
8286
|
-
heading: l || "ui-sans-serif, system-ui, sans-serif",
|
|
8287
|
-
body: l || "ui-sans-serif, system-ui, sans-serif"
|
|
8288
|
-
}, r.borderRadius = extractVariableValue(n, "--radius") || extractVariableValue(n, "--border-radius") || "0.5rem", [
|
|
8289
|
-
"background",
|
|
8290
|
-
"foreground",
|
|
8291
|
-
"primary",
|
|
8292
|
-
"primary-foreground",
|
|
8293
|
-
"secondary",
|
|
8294
|
-
"secondary-foreground",
|
|
8295
|
-
"muted",
|
|
8296
|
-
"muted-foreground",
|
|
8297
|
-
"accent",
|
|
8298
|
-
"accent-foreground",
|
|
8299
|
-
"destructive",
|
|
8300
|
-
"destructive-foreground",
|
|
8301
|
-
"border",
|
|
8302
|
-
"input",
|
|
8303
|
-
"ring",
|
|
8304
|
-
"card",
|
|
8305
|
-
"card-foreground",
|
|
8306
|
-
"popover",
|
|
8307
|
-
"popover-foreground"
|
|
8308
|
-
].forEach((c) => {
|
|
8309
|
-
const d = extractVariableValue(n, `--${c}`), p = extractVariableValue(a, `--${c}`);
|
|
8310
|
-
if (d || p) {
|
|
8311
|
-
const u = d ? processAndFormatColor(d) : "#000000", g = p ? processAndFormatColor(p) : u;
|
|
8312
|
-
r.colors[c] = [u, g];
|
|
8313
|
-
}
|
|
8314
|
-
});
|
|
8315
|
-
} catch (n) {
|
|
8316
|
-
console.error("Error parsing CSS to ChaiThemeValues:", n);
|
|
8317
|
-
}
|
|
8318
|
-
return r;
|
|
8319
|
-
}, extractCssBlockContent = (o, r) => {
|
|
8320
|
-
var a, l;
|
|
8321
|
-
const n = new RegExp(`${escapeRegExp(r)}\\s*{([^}]+)}`);
|
|
8322
|
-
return ((l = (a = o.match(n)) == null ? void 0 : a[1]) == null ? void 0 : l.trim()) || null;
|
|
8323
|
-
}, extractVariableValue = (o, r) => {
|
|
8324
|
-
var l;
|
|
8325
|
-
if (!o) return null;
|
|
8326
|
-
const n = new RegExp(`${escapeRegExp(r)}\\s*:\\s*([^;]+)`), a = o.match(n);
|
|
8327
|
-
return ((l = a == null ? void 0 : a[1]) == null ? void 0 : l.trim()) || null;
|
|
8328
|
-
}, processAndFormatColor = (o) => {
|
|
8329
|
-
try {
|
|
8330
|
-
let r = o.replace(/var\([^)]+\)/g, "").trim();
|
|
8331
|
-
return /^\d/.test(r) && !r.startsWith("#") && !r.startsWith("rgb") && !r.startsWith("hsl") && (r = `hsl(${r})`), r.startsWith("#") && /^#[0-9A-F]{6}$/i.test(r) ? r : r.startsWith("hsl(") ? hslToHex(r) : r.startsWith("rgb(") ? rgbToHex(r) : /^[0-9A-F]{6}$/i.test(r) ? `#${r}` : "#000000";
|
|
8332
|
-
} catch (r) {
|
|
8333
|
-
return console.error("Error processing color value:", o, r), o.startsWith("#") ? o : "#000000";
|
|
8334
|
-
}
|
|
8335
|
-
}, hslToHex = (o) => {
|
|
8336
|
-
const r = o.match(/hsla?\((\d+)(?:deg)?,?\s*(\d+)%?,?\s*(\d+)%?(?:,?\s*[\d.]+)?\)/);
|
|
8337
|
-
if (!r) return "#000000";
|
|
8338
|
-
const n = parseInt(r[1]) / 360, a = parseInt(r[2]) / 100, l = parseInt(r[3]) / 100, i = (g, h, m) => (m < 0 && (m += 1), m > 1 && (m -= 1), m < 1 / 6 ? g + (h - g) * 6 * m : m < 1 / 2 ? h : m < 2 / 3 ? g + (h - g) * (2 / 3 - m) * 6 : g);
|
|
8339
|
-
let c, d, p;
|
|
8340
|
-
if (a === 0)
|
|
8341
|
-
c = d = p = l;
|
|
8342
|
-
else {
|
|
8343
|
-
const g = l < 0.5 ? l * (1 + a) : l + a - l * a, h = 2 * l - g;
|
|
8344
|
-
c = i(h, g, n + 1 / 3), d = i(h, g, n), p = i(h, g, n - 1 / 3);
|
|
8345
|
-
}
|
|
8346
|
-
const u = (g) => {
|
|
8347
|
-
const h = Math.round(g * 255).toString(16);
|
|
8348
|
-
return h.length === 1 ? "0" + h : h;
|
|
8349
|
-
};
|
|
8350
|
-
return `#${u(c)}${u(d)}${u(p)}`;
|
|
8351
|
-
}, rgbToHex = (o) => {
|
|
8352
|
-
const r = o.match(/rgba?\((\d+)(?:\.\d+)?,?\s*(\d+)(?:\.\d+)?,?\s*(\d+)(?:\.\d+)?(?:,?\s*[\d.]+)?\)/);
|
|
8353
|
-
if (!r) return "#000000";
|
|
8354
|
-
const n = parseInt(r[1]), a = parseInt(r[2]), l = parseInt(r[3]), i = (c) => {
|
|
8355
|
-
const d = c.toString(16);
|
|
8356
|
-
return d.length === 1 ? "0" + d : d;
|
|
8357
|
-
};
|
|
8358
|
-
return `#${i(n)}${i(a)}${i(l)}`;
|
|
8359
|
-
}, escapeRegExp = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), validateChaiThemeValues = (o) => [
|
|
8360
|
-
"background",
|
|
8361
|
-
"foreground",
|
|
8362
|
-
"primary",
|
|
8363
|
-
"primary-foreground"
|
|
8364
|
-
].every(
|
|
8365
|
-
(a) => o.colors[a] && Array.isArray(o.colors[a]) && o.colors[a].length >= 2
|
|
8366
|
-
) && !!o.fontFamily.heading && !!o.fontFamily.body && !!o.borderRadius, validateCssInput = (o) => {
|
|
8367
|
-
if (!o.trim())
|
|
8368
|
-
return { isValid: !1, error: "Please enter CSS content" };
|
|
8369
|
-
try {
|
|
8370
|
-
return !o.includes("--") || !o.includes(":") ? {
|
|
8371
|
-
isValid: !1,
|
|
8372
|
-
error: "Invalid CSS format. CSS should contain variable definitions like --primary: #color"
|
|
8373
|
-
} : !o.includes("{") || !o.includes("}") ? {
|
|
8374
|
-
isValid: !1,
|
|
8375
|
-
error: "Invalid CSS format. CSS should contain proper block structure with { }"
|
|
8376
|
-
} : { isValid: !0 };
|
|
8377
|
-
} catch {
|
|
8378
|
-
return { isValid: !1, error: "Failed to parse CSS. Please check your syntax." };
|
|
8379
|
-
}
|
|
8380
|
-
}, CSS_PLACEHOLDER = `:root {
|
|
8381
|
-
--background: 0 0% 100%;
|
|
8382
|
-
--foreground: oklch(0.52 0.13 144.17);
|
|
8383
|
-
--primary: #3e2723;
|
|
8384
|
-
--primary-foreground: #ffffff;
|
|
8385
|
-
}
|
|
8386
|
-
|
|
8387
|
-
.dark {
|
|
8388
|
-
--background: 222.2 84% 4.9%;
|
|
8389
|
-
--foreground: hsl(37.50 36.36% 95.69%);
|
|
8390
|
-
--primary: rgb(46, 125, 50);
|
|
8391
|
-
--primary-foreground: #ffffff;
|
|
8392
|
-
}`, CssImportModal = ({
|
|
8393
|
-
open: o,
|
|
8394
|
-
onOpenChange: r,
|
|
8395
|
-
onImport: n
|
|
8396
|
-
}) => {
|
|
8397
|
-
const [a, l] = React.useState(""), [i, c] = React.useState(null), [d, p] = React.useState(!1), { t: u } = useTranslation(), g = async () => {
|
|
8398
|
-
p(!0), c(null);
|
|
8330
|
+
}, LazyCssImportModal = lazy(
|
|
8331
|
+
() => import("./css-import-modal-CcUf6F6T.js").then((o) => ({ default: o.CssImportModal }))
|
|
8332
|
+
), PREV_THEME_KEY = "chai-builder-previous-theme", setPreviousTheme = (o) => {
|
|
8333
|
+
if (!(typeof window > "u"))
|
|
8399
8334
|
try {
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
c(null);
|
|
8411
|
-
}, 5e3), p(!1);
|
|
8412
|
-
return;
|
|
8413
|
-
}
|
|
8414
|
-
n(x), l(""), c(null), r(!1);
|
|
8415
|
-
} catch (m) {
|
|
8416
|
-
console.error("Error importing CSS:", m), c("Failed to parse CSS. Please check your syntax and try again."), setTimeout(() => {
|
|
8417
|
-
c(null);
|
|
8418
|
-
}, 5e3);
|
|
8419
|
-
} finally {
|
|
8420
|
-
p(!1);
|
|
8335
|
+
localStorage.setItem(PREV_THEME_KEY, JSON.stringify(o));
|
|
8336
|
+
} catch (r) {
|
|
8337
|
+
console.warn("Failed to save previous theme to localStorage:", r);
|
|
8338
|
+
}
|
|
8339
|
+
}, clearPreviousTheme = () => {
|
|
8340
|
+
if (!(typeof window > "u"))
|
|
8341
|
+
try {
|
|
8342
|
+
localStorage.removeItem(PREV_THEME_KEY);
|
|
8343
|
+
} catch (o) {
|
|
8344
|
+
console.warn("Failed to clear previous theme from localStorage:", o);
|
|
8421
8345
|
}
|
|
8422
|
-
}, h = () => {
|
|
8423
|
-
l(""), c(null), r(!1);
|
|
8424
|
-
};
|
|
8425
|
-
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: r, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-2xl max-h-[80vh] flex flex-col", children: [
|
|
8426
|
-
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
8427
|
-
/* @__PURE__ */ jsx(DialogTitle, { children: u("Import CSS Theme") }),
|
|
8428
|
-
/* @__PURE__ */ jsx(DialogDescription, { children: u("Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties.") })
|
|
8429
|
-
] }),
|
|
8430
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-4 overflow-hidden", children: [
|
|
8431
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
8432
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: "css-input", children: u("CSS Variables") }),
|
|
8433
|
-
/* @__PURE__ */ jsx(
|
|
8434
|
-
Textarea,
|
|
8435
|
-
{
|
|
8436
|
-
id: "css-input",
|
|
8437
|
-
placeholder: CSS_PLACEHOLDER,
|
|
8438
|
-
value: a,
|
|
8439
|
-
onChange: (m) => l(m.target.value),
|
|
8440
|
-
className: "min-h-[300px] font-mono text-sm resize-none",
|
|
8441
|
-
disabled: d
|
|
8442
|
-
}
|
|
8443
|
-
)
|
|
8444
|
-
] }),
|
|
8445
|
-
i && /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600", children: i }) })
|
|
8446
|
-
] }),
|
|
8447
|
-
/* @__PURE__ */ jsxs(DialogFooter, { className: "gap-2", children: [
|
|
8448
|
-
/* @__PURE__ */ jsx(
|
|
8449
|
-
Button,
|
|
8450
|
-
{
|
|
8451
|
-
variant: "outline",
|
|
8452
|
-
onClick: h,
|
|
8453
|
-
disabled: d,
|
|
8454
|
-
children: u("Cancel")
|
|
8455
|
-
}
|
|
8456
|
-
),
|
|
8457
|
-
/* @__PURE__ */ jsx(
|
|
8458
|
-
Button,
|
|
8459
|
-
{
|
|
8460
|
-
onClick: g,
|
|
8461
|
-
disabled: !a.trim() || d,
|
|
8462
|
-
children: u(d ? "Importing..." : "Import Theme")
|
|
8463
|
-
}
|
|
8464
|
-
)
|
|
8465
|
-
] })
|
|
8466
|
-
] }) });
|
|
8467
8346
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8468
|
-
const [r] = useDarkMode(), [
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8347
|
+
const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), [g, h] = useTheme(), m = useThemeOptions(), { t: f } = useTranslation(), x = React.useCallback(
|
|
8348
|
+
(w) => {
|
|
8349
|
+
const y = { ...g };
|
|
8350
|
+
setPreviousTheme(y), h(w), toast.success("Theme updated", {
|
|
8351
|
+
action: {
|
|
8352
|
+
label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8353
|
+
/* @__PURE__ */ jsx(Undo$1, { className: "h-4 w-4" }),
|
|
8354
|
+
" Undo"
|
|
8355
|
+
] }),
|
|
8356
|
+
onClick: () => {
|
|
8357
|
+
h(y), clearPreviousTheme(), toast.dismiss();
|
|
8358
|
+
}
|
|
8359
|
+
},
|
|
8360
|
+
closeButton: !0,
|
|
8361
|
+
duration: 15e3
|
|
8362
|
+
});
|
|
8363
|
+
},
|
|
8364
|
+
[g, h]
|
|
8365
|
+
), k = () => {
|
|
8366
|
+
const w = d.find((y) => Object.keys(y)[0] === a);
|
|
8367
|
+
if (w) {
|
|
8368
|
+
const y = Object.values(w)[0];
|
|
8369
|
+
y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? (x(y), l("")) : console.error("Invalid preset structure:", y);
|
|
8475
8370
|
} else
|
|
8476
|
-
console.error("Preset not found:",
|
|
8477
|
-
},
|
|
8478
|
-
|
|
8479
|
-
},
|
|
8480
|
-
(
|
|
8481
|
-
|
|
8482
|
-
...
|
|
8371
|
+
console.error("Preset not found:", a);
|
|
8372
|
+
}, b = (w) => {
|
|
8373
|
+
x(w), l("");
|
|
8374
|
+
}, A = useDebouncedCallback(
|
|
8375
|
+
(w, y) => {
|
|
8376
|
+
h(() => ({
|
|
8377
|
+
...g,
|
|
8483
8378
|
fontFamily: {
|
|
8484
|
-
...
|
|
8485
|
-
[
|
|
8379
|
+
...g.fontFamily,
|
|
8380
|
+
[w.replace(/font-/g, "")]: y
|
|
8486
8381
|
}
|
|
8487
8382
|
}));
|
|
8488
8383
|
},
|
|
8489
|
-
[
|
|
8384
|
+
[g],
|
|
8490
8385
|
200
|
|
8491
|
-
), B =
|
|
8492
|
-
(
|
|
8493
|
-
|
|
8494
|
-
...
|
|
8495
|
-
borderRadius: `${
|
|
8386
|
+
), B = React.useCallback(
|
|
8387
|
+
(w) => {
|
|
8388
|
+
h(() => ({
|
|
8389
|
+
...g,
|
|
8390
|
+
borderRadius: `${w}px`
|
|
8496
8391
|
}));
|
|
8497
8392
|
},
|
|
8498
|
-
[
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
...u,
|
|
8393
|
+
[g]
|
|
8394
|
+
), _ = useDebouncedCallback(
|
|
8395
|
+
(w, y) => {
|
|
8396
|
+
h(() => {
|
|
8397
|
+
const C = get(g, `colors.${w}`);
|
|
8398
|
+
return r ? set(C, 1, y) : set(C, 0, y), {
|
|
8399
|
+
...g,
|
|
8506
8400
|
colors: {
|
|
8507
|
-
...
|
|
8508
|
-
[
|
|
8401
|
+
...g.colors,
|
|
8402
|
+
[w]: C
|
|
8509
8403
|
}
|
|
8510
8404
|
};
|
|
8511
8405
|
});
|
|
8512
8406
|
},
|
|
8513
|
-
[
|
|
8407
|
+
[g],
|
|
8514
8408
|
200
|
|
8515
|
-
),
|
|
8516
|
-
const C = get(
|
|
8517
|
-
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8409
|
+
), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([y]) => {
|
|
8410
|
+
const C = get(g, `colors.${y}.${r ? 1 : 0}`);
|
|
8411
|
+
return C ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8518
8412
|
/* @__PURE__ */ jsx(
|
|
8519
8413
|
ColorPickerInput,
|
|
8520
8414
|
{
|
|
8521
8415
|
value: C,
|
|
8522
|
-
onChange: (
|
|
8416
|
+
onChange: (E) => _(y, E)
|
|
8523
8417
|
}
|
|
8524
8418
|
),
|
|
8525
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children:
|
|
8526
|
-
] },
|
|
8419
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: y.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!y.toLowerCase().includes("foreground") && !y.toLowerCase().includes("border") && !y.toLowerCase().includes("input") && !y.toLowerCase().includes("ring") && !y.toLowerCase().includes("background") ? " Background" : "") })
|
|
8420
|
+
] }, y) : null;
|
|
8527
8421
|
}) });
|
|
8528
|
-
return
|
|
8422
|
+
return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8529
8423
|
/* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8530
|
-
|
|
8424
|
+
d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
|
|
8531
8425
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
8532
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8533
|
-
/* @__PURE__ */ jsxs(Button, { variant: "link", size: "sm", onClick: () =>
|
|
8534
|
-
/* @__PURE__ */ jsx(ImportIcon, { className: "h-
|
|
8535
|
-
" "
|
|
8536
|
-
|
|
8537
|
-
] })
|
|
8426
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: f("Presets") }),
|
|
8427
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
|
|
8428
|
+
/* @__PURE__ */ jsx(ImportIcon, { className: "h-4 w-4" }),
|
|
8429
|
+
f("Import theme")
|
|
8430
|
+
] }) })
|
|
8538
8431
|
] }),
|
|
8539
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8540
|
-
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(
|
|
8541
|
-
"
|
|
8542
|
-
{
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
Array.isArray(c) && c.map((j) => /* @__PURE__ */ jsx("option", { value: Object.keys(j)[0], children: capitalize(Object.keys(j)[0].replaceAll("_", " ")) }, Object.keys(j)[0]))
|
|
8549
|
-
]
|
|
8550
|
-
}
|
|
8551
|
-
) }),
|
|
8552
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-[30%] items-end", children: /* @__PURE__ */ jsx(
|
|
8553
|
-
Button,
|
|
8554
|
-
{
|
|
8555
|
-
className: "w-full text-sm",
|
|
8556
|
-
disabled: n === "",
|
|
8557
|
-
variant: "default",
|
|
8558
|
-
onClick: f,
|
|
8559
|
-
children: m("Apply")
|
|
8560
|
-
}
|
|
8561
|
-
) })
|
|
8432
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
|
|
8433
|
+
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
|
|
8434
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
|
|
8435
|
+
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
|
|
8436
|
+
const y = Object.keys(w)[0], C = y.replaceAll("_", " ");
|
|
8437
|
+
return /* @__PURE__ */ jsx(SelectItem, { value: y, children: capitalize(C) }, y);
|
|
8438
|
+
}) })
|
|
8439
|
+
] }) }),
|
|
8440
|
+
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children: f("Apply") }) })
|
|
8562
8441
|
] })
|
|
8563
8442
|
] }),
|
|
8564
|
-
/* @__PURE__ */
|
|
8565
|
-
|
|
8443
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
8444
|
+
/* @__PURE__ */ jsxs("div", { className: cn$2("my-2 space-y-3", o), children: [
|
|
8445
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8446
|
+
/* @__PURE__ */ jsx(Type, { className: "h-3 w-3 text-gray-600" }),
|
|
8447
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
|
|
8448
|
+
] }),
|
|
8449
|
+
(m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w, y]) => /* @__PURE__ */ jsx(
|
|
8566
8450
|
FontSelector,
|
|
8567
8451
|
{
|
|
8568
|
-
label:
|
|
8569
|
-
value:
|
|
8570
|
-
onChange: (C) =>
|
|
8452
|
+
label: w,
|
|
8453
|
+
value: g.fontFamily[w.replace(/font-/g, "")] || y[Object.keys(y)[0]],
|
|
8454
|
+
onChange: (C) => A(w, C)
|
|
8571
8455
|
},
|
|
8572
|
-
|
|
8456
|
+
w
|
|
8573
8457
|
)) }),
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center
|
|
8577
|
-
/* @__PURE__ */
|
|
8578
|
-
|
|
8579
|
-
|
|
8458
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
8459
|
+
(m == null ? void 0 : m.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
8460
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
8461
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8462
|
+
/* @__PURE__ */ jsx(CornerUpRight, { className: "h-3 w-3 text-gray-600" }),
|
|
8463
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Border Radius" })
|
|
8464
|
+
] }),
|
|
8465
|
+
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: g.borderRadius })
|
|
8466
|
+
] }),
|
|
8467
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: B }) })
|
|
8580
8468
|
] }),
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
/* @__PURE__ */
|
|
8584
|
-
|
|
8469
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
8470
|
+
(m == null ? void 0 : m.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
8471
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
8472
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8473
|
+
/* @__PURE__ */ jsx(Palette, { className: "h-3 w-3 text-gray-600" }),
|
|
8474
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Colors" })
|
|
8475
|
+
] }),
|
|
8476
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8477
|
+
/* @__PURE__ */ jsx(Sun, { className: "h-4 w-4" }),
|
|
8478
|
+
/* @__PURE__ */ jsx(
|
|
8479
|
+
Switch,
|
|
8480
|
+
{
|
|
8481
|
+
checked: r,
|
|
8482
|
+
onCheckedChange: (w) => n(w),
|
|
8483
|
+
"aria-label": "Toggle dark mode",
|
|
8484
|
+
className: "mx-1"
|
|
8485
|
+
}
|
|
8486
|
+
),
|
|
8487
|
+
/* @__PURE__ */ jsx(Moon, { className: "h-4 w-4" })
|
|
8488
|
+
] }) })
|
|
8489
|
+
] }),
|
|
8490
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: m.colors.map((w) => N(w)) })
|
|
8491
|
+
] }),
|
|
8492
|
+
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && /* @__PURE__ */ jsx(
|
|
8493
|
+
LazyCssImportModal,
|
|
8494
|
+
{
|
|
8495
|
+
open: i,
|
|
8496
|
+
onOpenChange: c,
|
|
8497
|
+
onImport: b
|
|
8498
|
+
}
|
|
8499
|
+
) })
|
|
8585
8500
|
] }),
|
|
8586
8501
|
/* @__PURE__ */ jsx("br", {}),
|
|
8587
8502
|
/* @__PURE__ */ jsx("br", {}),
|
|
8588
8503
|
/* @__PURE__ */ jsx("br", {}),
|
|
8589
8504
|
/* @__PURE__ */ jsx("br", {})
|
|
8590
8505
|
] }),
|
|
8591
|
-
|
|
8592
|
-
/* @__PURE__ */ jsx(CssImportModal, { open: l, onOpenChange: i, onImport: y })
|
|
8506
|
+
p && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(p) })
|
|
8593
8507
|
] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
|
|
8594
8508
|
}), Core = "Core", Import = "Import", Breakpoints = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Styling", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", theme_config = { heading_font: "Heading Font", body_font: "Body Font", rounded_corner: "Rounded Corners", primary: "Primary", secondary: "Secondary", background: "Background", text_color: "Text Color", background_dark_mode: "Background (Dark Mode)", text_color_dark_mode: "Text Color (Dark Mode)" }, web_blocks = { box: "box", tag: "Tag", div: "div", level: "Level", header: "header", footer: "footer", section: "section", article: "article", aside: "aside", main: "main", nav: "navigation", figure: "figure", details: "details", summary: "summary", dialog: "dialog", strike: "strike", caption: "caption", legend: "legend", figcaption: "figure caption", mark: "mark", background_image: "Background Image", label: "Label", default: "default", icon_size: "Icon Size", icon_position: "Icon Position", start: "Start", end: "End", button: "Button", custom_html: "Custom HTML", html_code: "HTML Code", default_snippet: "The HTML snippet goes here...", placeholder: "Enter custom HTML code here", custom_script: "Custom Script", dark_mode: "Dark Mode", divider: "Divider", empty_box: "Empty Box", heading: "Heading", image: "Image", alt: "Alt", width: "Width", height: "Height", video: "Video", span: "Span", content: "Content", icon: "Icon", richtext: "Rich Text", list: "List", list_type: "List Type", listitem: "List Item", link: "Link", list_item: "List Item", none: "None", disc: "Disc", number: "Number", paragraph: "Paragraph", lightbox_link: "Lightbox Link", href: "Link", type: "Type", iframe: "iframe", inline: "inline", ajax: "ajax", autoplay: "Video autoplay", max_width: "Max Width", backdrop_color: "Background Color", gallery_name: "Gallery Name", slot: "Slot", empty_slot: "Empty Slot", text: "Text", video_url: "Video URL", controls: "Show Controls", loop: "Loop", muted: "Muted", checkbox: "Checkbox", required: "Required", checked: "Checked", submit_button: "Submit Button", form: "Form", submit_url: "Submit URL", error_message: "Error Message", success_message: "Success Message", input: "Input", value: "Value", show_label: "Show Label", field_name: "Field Name", radio: "Radio", multiple: "Multiple", options: "Options", select: "Select", multiple_choice: "Multiple Choice", textarea: "Textarea", rows: "Rows" }, Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", lngEn = {
|
|
8595
8509
|
"Add block": "Add Block",
|
|
@@ -9075,12 +8989,12 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9075
8989
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
9076
8990
|
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
|
|
9077
8991
|
useEffect(() => {
|
|
9078
|
-
var
|
|
9079
|
-
(
|
|
8992
|
+
var x;
|
|
8993
|
+
(x = h.current) == null || x.focus();
|
|
9080
8994
|
}, []);
|
|
9081
|
-
const
|
|
9082
|
-
const { usage:
|
|
9083
|
-
!l &&
|
|
8995
|
+
const f = (x) => {
|
|
8996
|
+
const { usage: k } = x || {};
|
|
8997
|
+
!l && k && g(k), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
9084
8998
|
};
|
|
9085
8999
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
9086
9000
|
/* @__PURE__ */ jsxs(
|
|
@@ -9100,12 +9014,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9100
9014
|
{
|
|
9101
9015
|
ref: h,
|
|
9102
9016
|
value: i,
|
|
9103
|
-
onChange: (
|
|
9017
|
+
onChange: (x) => c(x.target.value),
|
|
9104
9018
|
placeholder: r("Ask AI to edit content"),
|
|
9105
9019
|
className: "w-full",
|
|
9106
9020
|
rows: 3,
|
|
9107
|
-
onKeyDown: (
|
|
9108
|
-
|
|
9021
|
+
onKeyDown: (x) => {
|
|
9022
|
+
x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f));
|
|
9109
9023
|
}
|
|
9110
9024
|
}
|
|
9111
9025
|
),
|
|
@@ -9115,7 +9029,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9115
9029
|
{
|
|
9116
9030
|
disabled: i.trim().length < 5 || a,
|
|
9117
9031
|
onClick: () => {
|
|
9118
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o, i,
|
|
9032
|
+
m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f);
|
|
9119
9033
|
},
|
|
9120
9034
|
variant: "default",
|
|
9121
9035
|
className: "w-fit",
|
|
@@ -9147,8 +9061,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9147
9061
|
/* @__PURE__ */ jsx(
|
|
9148
9062
|
QuickPrompts,
|
|
9149
9063
|
{
|
|
9150
|
-
onClick: (
|
|
9151
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o,
|
|
9064
|
+
onClick: (x) => {
|
|
9065
|
+
m.current && clearTimeout(m.current), g(void 0), n("content", o, x, f);
|
|
9152
9066
|
}
|
|
9153
9067
|
}
|
|
9154
9068
|
)
|
|
@@ -9165,8 +9079,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9165
9079
|
const m = async () => {
|
|
9166
9080
|
try {
|
|
9167
9081
|
d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
|
|
9168
|
-
} catch (
|
|
9169
|
-
u(
|
|
9082
|
+
} catch (f) {
|
|
9083
|
+
u(f);
|
|
9170
9084
|
} finally {
|
|
9171
9085
|
d(!1);
|
|
9172
9086
|
}
|
|
@@ -9174,8 +9088,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9174
9088
|
return /* @__PURE__ */ jsx(
|
|
9175
9089
|
Accordion,
|
|
9176
9090
|
{
|
|
9177
|
-
onValueChange: (
|
|
9178
|
-
g(
|
|
9091
|
+
onValueChange: (f) => {
|
|
9092
|
+
g(f !== "");
|
|
9179
9093
|
},
|
|
9180
9094
|
type: "single",
|
|
9181
9095
|
collapsible: !0,
|
|
@@ -9187,12 +9101,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9187
9101
|
{
|
|
9188
9102
|
ref: l,
|
|
9189
9103
|
value: n,
|
|
9190
|
-
onChange: (
|
|
9104
|
+
onChange: (f) => a(f.target.value),
|
|
9191
9105
|
placeholder: o("Tell about this page eg this page is about"),
|
|
9192
9106
|
className: "mt-1 w-full",
|
|
9193
9107
|
rows: 10,
|
|
9194
|
-
onKeyDown: (
|
|
9195
|
-
|
|
9108
|
+
onKeyDown: (f) => {
|
|
9109
|
+
f.key === "Enter" && (f.preventDefault(), m());
|
|
9196
9110
|
}
|
|
9197
9111
|
}
|
|
9198
9112
|
),
|
|
@@ -9302,31 +9216,31 @@ function AIChatPanel() {
|
|
|
9302
9216
|
content: n,
|
|
9303
9217
|
timestamp: /* @__PURE__ */ new Date()
|
|
9304
9218
|
};
|
|
9305
|
-
r((
|
|
9306
|
-
const
|
|
9219
|
+
r((A) => [...A, b]), a(""), i(!0), setTimeout(() => {
|
|
9220
|
+
const A = {
|
|
9307
9221
|
id: (Date.now() + 1).toString(),
|
|
9308
9222
|
role: "assistant",
|
|
9309
9223
|
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.",
|
|
9310
9224
|
timestamp: /* @__PURE__ */ new Date()
|
|
9311
9225
|
};
|
|
9312
|
-
r((
|
|
9226
|
+
r((B) => [...B, A]), i(!1), d(null);
|
|
9313
9227
|
}, 1500);
|
|
9314
9228
|
}, m = (b) => {
|
|
9315
9229
|
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
|
|
9316
|
-
},
|
|
9317
|
-
var
|
|
9318
|
-
const
|
|
9319
|
-
if (
|
|
9320
|
-
const
|
|
9321
|
-
|
|
9230
|
+
}, f = (b) => {
|
|
9231
|
+
var B;
|
|
9232
|
+
const A = (B = b.target.files) == null ? void 0 : B[0];
|
|
9233
|
+
if (A) {
|
|
9234
|
+
const _ = new FileReader();
|
|
9235
|
+
_.onload = (N) => {
|
|
9322
9236
|
var w;
|
|
9323
|
-
d((w =
|
|
9324
|
-
},
|
|
9237
|
+
d((w = N.target) == null ? void 0 : w.result);
|
|
9238
|
+
}, _.readAsDataURL(A);
|
|
9325
9239
|
}
|
|
9326
|
-
},
|
|
9240
|
+
}, x = () => {
|
|
9327
9241
|
var b;
|
|
9328
9242
|
(b = p.current) == null || b.click();
|
|
9329
|
-
},
|
|
9243
|
+
}, k = () => {
|
|
9330
9244
|
d(null), p.current && (p.current.value = "");
|
|
9331
9245
|
};
|
|
9332
9246
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
|
|
@@ -9372,7 +9286,7 @@ function AIChatPanel() {
|
|
|
9372
9286
|
size: "icon",
|
|
9373
9287
|
variant: "destructive",
|
|
9374
9288
|
className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
|
|
9375
|
-
onClick:
|
|
9289
|
+
onClick: k,
|
|
9376
9290
|
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
9377
9291
|
}
|
|
9378
9292
|
)
|
|
@@ -9390,14 +9304,14 @@ function AIChatPanel() {
|
|
|
9390
9304
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9391
9305
|
}
|
|
9392
9306
|
),
|
|
9393
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange:
|
|
9307
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
|
|
9394
9308
|
/* @__PURE__ */ jsx(
|
|
9395
9309
|
Button,
|
|
9396
9310
|
{
|
|
9397
9311
|
size: "icon",
|
|
9398
9312
|
variant: "ghost",
|
|
9399
9313
|
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9400
|
-
onClick:
|
|
9314
|
+
onClick: x,
|
|
9401
9315
|
children: /* @__PURE__ */ jsx(Image$1, { className: "h-4 w-4 text-muted-foreground" })
|
|
9402
9316
|
}
|
|
9403
9317
|
)
|
|
@@ -9515,7 +9429,7 @@ const AiAssistant = () => {
|
|
|
9515
9429
|
preloadedAttributes: r = [],
|
|
9516
9430
|
onAttributesChange: n
|
|
9517
9431
|
}) {
|
|
9518
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""),
|
|
9432
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), k = usePageExternalData();
|
|
9519
9433
|
useEffect(() => {
|
|
9520
9434
|
l(r);
|
|
9521
9435
|
}, [r]);
|
|
@@ -9525,43 +9439,43 @@ const AiAssistant = () => {
|
|
|
9525
9439
|
return;
|
|
9526
9440
|
}
|
|
9527
9441
|
if (i) {
|
|
9528
|
-
const
|
|
9529
|
-
n(
|
|
9442
|
+
const y = [...a, { key: i, value: d }];
|
|
9443
|
+
n(y), l(a), c(""), p(""), m("");
|
|
9530
9444
|
}
|
|
9531
|
-
},
|
|
9532
|
-
const
|
|
9533
|
-
n(
|
|
9534
|
-
},
|
|
9535
|
-
g(
|
|
9536
|
-
},
|
|
9445
|
+
}, A = (y) => {
|
|
9446
|
+
const C = a.filter((E, v) => v !== y);
|
|
9447
|
+
n(C), l(C);
|
|
9448
|
+
}, B = (y) => {
|
|
9449
|
+
g(y), c(a[y].key), p(a[y].value);
|
|
9450
|
+
}, _ = () => {
|
|
9537
9451
|
if (i.startsWith("@")) {
|
|
9538
9452
|
m("Attribute keys cannot start with '@'");
|
|
9539
9453
|
return;
|
|
9540
9454
|
}
|
|
9541
9455
|
if (u !== null && i) {
|
|
9542
|
-
const
|
|
9543
|
-
|
|
9456
|
+
const y = [...a];
|
|
9457
|
+
y[u] = { key: i, value: d }, n(y), l(y), g(null), c(""), p(""), m("");
|
|
9544
9458
|
}
|
|
9545
|
-
},
|
|
9546
|
-
|
|
9547
|
-
}, w = useCallback((
|
|
9548
|
-
const
|
|
9459
|
+
}, N = (y) => {
|
|
9460
|
+
y.key === "Enter" && !y.shiftKey && (y.preventDefault(), u !== null ? _() : b());
|
|
9461
|
+
}, w = useCallback((y) => {
|
|
9462
|
+
const C = (S) => /[.,!?;:]/.test(S), E = (S, j, T) => {
|
|
9549
9463
|
let L = "", R = "";
|
|
9550
|
-
const
|
|
9551
|
-
return
|
|
9552
|
-
text: L +
|
|
9464
|
+
const I = j > 0 ? S[j - 1] : "", D = j < S.length ? S[j] : "";
|
|
9465
|
+
return j > 0 && (I === "." || !C(I) && I !== " ") && (L = " "), j < S.length && !C(D) && D !== " " && (R = " "), {
|
|
9466
|
+
text: L + T + R,
|
|
9553
9467
|
prefixLength: L.length,
|
|
9554
9468
|
suffixLength: R.length
|
|
9555
9469
|
};
|
|
9556
|
-
},
|
|
9557
|
-
if (
|
|
9558
|
-
const
|
|
9559
|
-
if (
|
|
9560
|
-
const O = `{{${
|
|
9470
|
+
}, v = x.current;
|
|
9471
|
+
if (v) {
|
|
9472
|
+
const S = v.selectionStart || 0, j = v.value || "", T = v.selectionEnd || S;
|
|
9473
|
+
if (T > S) {
|
|
9474
|
+
const O = `{{${y}}}`, { text: P } = E(j, S, O), $ = j.slice(0, S) + P + j.slice(T);
|
|
9561
9475
|
p($);
|
|
9562
9476
|
return;
|
|
9563
9477
|
}
|
|
9564
|
-
const R = `{{${
|
|
9478
|
+
const R = `{{${y}}}`, { text: I } = E(j, S, R), D = j.slice(0, S) + I + j.slice(S);
|
|
9565
9479
|
p(D);
|
|
9566
9480
|
}
|
|
9567
9481
|
}, []);
|
|
@@ -9569,8 +9483,8 @@ const AiAssistant = () => {
|
|
|
9569
9483
|
/* @__PURE__ */ jsxs(
|
|
9570
9484
|
"form",
|
|
9571
9485
|
{
|
|
9572
|
-
onSubmit: (
|
|
9573
|
-
|
|
9486
|
+
onSubmit: (y) => {
|
|
9487
|
+
y.preventDefault(), u !== null ? _() : b();
|
|
9574
9488
|
},
|
|
9575
9489
|
className: "space-y-3",
|
|
9576
9490
|
children: [
|
|
@@ -9584,9 +9498,9 @@ const AiAssistant = () => {
|
|
|
9584
9498
|
autoCorrect: "off",
|
|
9585
9499
|
spellCheck: "false",
|
|
9586
9500
|
id: "attrKey",
|
|
9587
|
-
ref:
|
|
9501
|
+
ref: f,
|
|
9588
9502
|
value: i,
|
|
9589
|
-
onChange: (
|
|
9503
|
+
onChange: (y) => c(y.target.value),
|
|
9590
9504
|
placeholder: "Enter Key",
|
|
9591
9505
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9592
9506
|
}
|
|
@@ -9595,7 +9509,7 @@ const AiAssistant = () => {
|
|
|
9595
9509
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9596
9510
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9597
9511
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9598
|
-
!isEmpty(
|
|
9512
|
+
!isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: w })
|
|
9599
9513
|
] }),
|
|
9600
9514
|
/* @__PURE__ */ jsx(
|
|
9601
9515
|
Textarea,
|
|
@@ -9605,10 +9519,10 @@ const AiAssistant = () => {
|
|
|
9605
9519
|
spellCheck: "false",
|
|
9606
9520
|
id: "attrValue",
|
|
9607
9521
|
rows: 2,
|
|
9608
|
-
ref:
|
|
9522
|
+
ref: x,
|
|
9609
9523
|
value: d,
|
|
9610
|
-
onChange: (
|
|
9611
|
-
onKeyDown:
|
|
9524
|
+
onChange: (y) => p(y.target.value),
|
|
9525
|
+
onKeyDown: N,
|
|
9612
9526
|
placeholder: "Enter Value",
|
|
9613
9527
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9614
9528
|
}
|
|
@@ -9620,16 +9534,16 @@ const AiAssistant = () => {
|
|
|
9620
9534
|
]
|
|
9621
9535
|
}
|
|
9622
9536
|
),
|
|
9623
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
9537
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((y, C) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9624
9538
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9625
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9626
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children:
|
|
9539
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: y.key }),
|
|
9540
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: y.value.toString() })
|
|
9627
9541
|
] }),
|
|
9628
9542
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9629
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9630
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9543
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(C), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9544
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(C), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9631
9545
|
] })
|
|
9632
|
-
] },
|
|
9546
|
+
] }, C)) })
|
|
9633
9547
|
] });
|
|
9634
9548
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9635
9549
|
const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -9791,42 +9705,42 @@ const RootLayout = () => {
|
|
|
9791
9705
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9792
9706
|
n("outline");
|
|
9793
9707
|
});
|
|
9794
|
-
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((
|
|
9795
|
-
|
|
9708
|
+
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((y) => {
|
|
9709
|
+
y.preventDefault();
|
|
9796
9710
|
}, []), m = useCallback(
|
|
9797
|
-
(
|
|
9798
|
-
n(r ===
|
|
9711
|
+
(y) => {
|
|
9712
|
+
n(r === y ? null : y);
|
|
9799
9713
|
},
|
|
9800
9714
|
[r]
|
|
9801
|
-
), { t:
|
|
9715
|
+
), { t: f } = useTranslation(), x = useMemo(
|
|
9802
9716
|
() => [...p, ...u, ...g],
|
|
9803
9717
|
[p, u, g]
|
|
9804
|
-
),
|
|
9718
|
+
), k = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), A = get(b, "width", DEFAULT_PANEL_WIDTH);
|
|
9805
9719
|
useEffect(() => {
|
|
9806
9720
|
if (r !== null) {
|
|
9807
|
-
const
|
|
9808
|
-
|
|
9721
|
+
const y = find(x, { id: r });
|
|
9722
|
+
y && get(y, "view", "standard") === "standard" && (a.current = r, i(get(y, "width", DEFAULT_PANEL_WIDTH)));
|
|
9809
9723
|
}
|
|
9810
|
-
}, [r,
|
|
9811
|
-
const
|
|
9724
|
+
}, [r, x]);
|
|
9725
|
+
const B = useMemo(() => {
|
|
9812
9726
|
if (r === null) return 0;
|
|
9813
|
-
const
|
|
9814
|
-
return get(
|
|
9815
|
-
}, [r,
|
|
9727
|
+
const y = find(x, { id: r });
|
|
9728
|
+
return get(y, "view", "standard") === "standard" ? A : l;
|
|
9729
|
+
}, [r, A, l, x]), _ = useCallback(() => {
|
|
9816
9730
|
n(a.current);
|
|
9817
|
-
}, [n]),
|
|
9731
|
+
}, [n]), N = useCallback(() => {
|
|
9818
9732
|
n("outline");
|
|
9819
9733
|
}, [n]);
|
|
9820
9734
|
useEffect(() => {
|
|
9821
|
-
find(
|
|
9822
|
-
}, [r,
|
|
9735
|
+
find(x, { id: r }) || n("outline");
|
|
9736
|
+
}, [r, x]);
|
|
9823
9737
|
const w = useCallback(
|
|
9824
|
-
(
|
|
9825
|
-
m(
|
|
9738
|
+
(y) => {
|
|
9739
|
+
m(y);
|
|
9826
9740
|
},
|
|
9827
9741
|
[m]
|
|
9828
9742
|
);
|
|
9829
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
9743
|
+
return /* @__PURE__ */ jsx("div", { dir: k, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9830
9744
|
/* @__PURE__ */ jsxs(
|
|
9831
9745
|
"div",
|
|
9832
9746
|
{
|
|
@@ -9836,40 +9750,40 @@ const RootLayout = () => {
|
|
|
9836
9750
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9837
9751
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9838
9752
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9839
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((
|
|
9840
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9753
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((y, C) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9754
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
|
|
9841
9755
|
position: "top",
|
|
9842
|
-
panelId:
|
|
9843
|
-
isActive: r ===
|
|
9844
|
-
show: () => w(
|
|
9756
|
+
panelId: y.id,
|
|
9757
|
+
isActive: r === y.id,
|
|
9758
|
+
show: () => w(y.id)
|
|
9845
9759
|
}) }),
|
|
9846
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9847
|
-
] }, "button-top-" +
|
|
9760
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(y.label) }) })
|
|
9761
|
+
] }, "button-top-" + C)) }),
|
|
9848
9762
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9849
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((
|
|
9850
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9763
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y, C) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9764
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
|
|
9851
9765
|
position: "bottom",
|
|
9852
|
-
panelId:
|
|
9853
|
-
isActive: r ===
|
|
9854
|
-
show: () => w(
|
|
9766
|
+
panelId: y.id,
|
|
9767
|
+
isActive: r === y.id,
|
|
9768
|
+
show: () => w(y.id)
|
|
9855
9769
|
}) }),
|
|
9856
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9857
|
-
] }, "button-bottom-" +
|
|
9770
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(y.label) }) })
|
|
9771
|
+
] }, "button-bottom-" + C)) })
|
|
9858
9772
|
] }),
|
|
9859
9773
|
/* @__PURE__ */ jsx(
|
|
9860
9774
|
motion.div,
|
|
9861
9775
|
{
|
|
9862
9776
|
id: "left-panel",
|
|
9863
9777
|
className: "h-full max-h-full border-r border-border",
|
|
9864
|
-
initial: { width:
|
|
9865
|
-
animate: { width:
|
|
9778
|
+
initial: { width: B },
|
|
9779
|
+
animate: { width: B },
|
|
9866
9780
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
9867
9781
|
children: r !== null && get(b, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
|
|
9868
9782
|
/* @__PURE__ */ jsx(
|
|
9869
9783
|
"div",
|
|
9870
9784
|
{
|
|
9871
9785
|
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
|
|
9872
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9786
|
+
children: /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9873
9787
|
}
|
|
9874
9788
|
),
|
|
9875
9789
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {}) }) })
|
|
@@ -9892,11 +9806,11 @@ const RootLayout = () => {
|
|
|
9892
9806
|
/* @__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: [
|
|
9893
9807
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9894
9808
|
" ",
|
|
9895
|
-
|
|
9809
|
+
f("AI Assistant")
|
|
9896
9810
|
] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9897
9811
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9898
|
-
/* @__PURE__ */ jsx(
|
|
9899
|
-
|
|
9812
|
+
/* @__PURE__ */ jsx(Palette, { className: "w-4 h-4 text-gray-600" }),
|
|
9813
|
+
f("Theme Settings")
|
|
9900
9814
|
] }),
|
|
9901
9815
|
/* @__PURE__ */ jsx(
|
|
9902
9816
|
Button,
|
|
@@ -9918,31 +9832,31 @@ const RootLayout = () => {
|
|
|
9918
9832
|
}
|
|
9919
9833
|
),
|
|
9920
9834
|
/* @__PURE__ */ jsx(AddBlocksDialog, {}),
|
|
9921
|
-
r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () =>
|
|
9835
|
+
r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
|
|
9922
9836
|
SheetContent,
|
|
9923
9837
|
{
|
|
9924
9838
|
side: "left",
|
|
9925
9839
|
className: "flex flex-col gap-0 p-0 sm:max-w-full",
|
|
9926
|
-
style: { width: `${
|
|
9840
|
+
style: { width: `${A}px` },
|
|
9927
9841
|
children: [
|
|
9928
9842
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
9929
9843
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9930
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9844
|
+
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9931
9845
|
] }) }),
|
|
9932
9846
|
/* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
9933
|
-
close:
|
|
9847
|
+
close: N
|
|
9934
9848
|
}) }) })
|
|
9935
9849
|
]
|
|
9936
9850
|
}
|
|
9937
9851
|
) }),
|
|
9938
9852
|
" ",
|
|
9939
|
-
r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () =>
|
|
9853
|
+
r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${A}px` }, children: [
|
|
9940
9854
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
9941
9855
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9942
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9856
|
+
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9943
9857
|
] }) }),
|
|
9944
9858
|
/* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
9945
|
-
close:
|
|
9859
|
+
close: N
|
|
9946
9860
|
}) }) })
|
|
9947
9861
|
] }) }),
|
|
9948
9862
|
r !== null && get(b, "view") === "overlay" && /* @__PURE__ */ jsx(
|
|
@@ -9965,12 +9879,12 @@ const RootLayout = () => {
|
|
|
9965
9879
|
/* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
|
|
9966
9880
|
/* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
|
|
9967
9881
|
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
|
|
9968
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9882
|
+
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9969
9883
|
] }),
|
|
9970
|
-
/* @__PURE__ */ jsx(Button, { onClick: () =>
|
|
9884
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
|
|
9971
9885
|
] }),
|
|
9972
9886
|
/* @__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(b, "panel", NoopComponent), {
|
|
9973
|
-
close:
|
|
9887
|
+
close: N
|
|
9974
9888
|
}) }) })
|
|
9975
9889
|
]
|
|
9976
9890
|
}
|
|
@@ -10009,36 +9923,36 @@ const RootLayout = () => {
|
|
|
10009
9923
|
}) => {
|
|
10010
9924
|
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
|
|
10011
9925
|
if (!l.trim()) return a;
|
|
10012
|
-
const
|
|
9926
|
+
const x = l.toLowerCase();
|
|
10013
9927
|
return Object.fromEntries(
|
|
10014
|
-
Object.entries(a).filter(([
|
|
10015
|
-
var
|
|
10016
|
-
return (
|
|
9928
|
+
Object.entries(a).filter(([k, b]) => {
|
|
9929
|
+
var A;
|
|
9930
|
+
return (k == null ? void 0 : k.toLowerCase().includes(x)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(x));
|
|
10017
9931
|
})
|
|
10018
9932
|
);
|
|
10019
|
-
}, [a, l]), h = (
|
|
9933
|
+
}, [a, l]), h = (x) => {
|
|
10020
9934
|
d(!0), u({
|
|
10021
|
-
x:
|
|
10022
|
-
y:
|
|
9935
|
+
x: x.clientX - r.x,
|
|
9936
|
+
y: x.clientY - r.y
|
|
10023
9937
|
});
|
|
10024
|
-
}, m = (
|
|
9938
|
+
}, m = (x) => {
|
|
10025
9939
|
if (!c) return;
|
|
10026
|
-
const
|
|
10027
|
-
n(
|
|
10028
|
-
},
|
|
9940
|
+
const k = x.clientX - p.x, b = x.clientY - p.y, A = x.currentTarget, B = A.offsetWidth, _ = A.offsetHeight, N = window.innerWidth - B, w = window.innerHeight - _, y = Math.max(0, Math.min(k, N)), C = Math.max(0, Math.min(b, w));
|
|
9941
|
+
n(y, C);
|
|
9942
|
+
}, f = () => {
|
|
10029
9943
|
d(!1);
|
|
10030
9944
|
};
|
|
10031
9945
|
return useEffect(() => {
|
|
10032
|
-
const
|
|
9946
|
+
const x = () => {
|
|
10033
9947
|
c && d(!1);
|
|
10034
9948
|
};
|
|
10035
|
-
return window.addEventListener("mouseup",
|
|
9949
|
+
return window.addEventListener("mouseup", x), () => window.removeEventListener("mouseup", x);
|
|
10036
9950
|
}, [c]), !r || r.x < 0 || r.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
10037
9951
|
"div",
|
|
10038
9952
|
{
|
|
10039
9953
|
onMouseDown: h,
|
|
10040
9954
|
onMouseMove: m,
|
|
10041
|
-
onMouseUp:
|
|
9955
|
+
onMouseUp: f,
|
|
10042
9956
|
className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
|
|
10043
9957
|
style: {
|
|
10044
9958
|
left: r.x,
|
|
@@ -10080,13 +9994,13 @@ const RootLayout = () => {
|
|
|
10080
9994
|
placeholder: "Search features...",
|
|
10081
9995
|
className: "w-full pl-8",
|
|
10082
9996
|
value: l,
|
|
10083
|
-
onChange: (
|
|
9997
|
+
onChange: (x) => i(x.target.value),
|
|
10084
9998
|
autoFocus: !0
|
|
10085
9999
|
}
|
|
10086
10000
|
)
|
|
10087
10001
|
] })
|
|
10088
10002
|
] }),
|
|
10089
|
-
/* @__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(([
|
|
10003
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([x, k]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: x, options: k }, x)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
|
|
10090
10004
|
'No features found matching "',
|
|
10091
10005
|
l,
|
|
10092
10006
|
'"'
|
|
@@ -10197,225 +10111,225 @@ const RootLayout = () => {
|
|
|
10197
10111
|
for (const i of r.p)
|
|
10198
10112
|
l.add(i);
|
|
10199
10113
|
return l;
|
|
10200
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...
|
|
10201
|
-
var
|
|
10202
|
-
return (
|
|
10203
|
-
}, g = (m,
|
|
10204
|
-
var
|
|
10205
|
-
return (
|
|
10114
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
|
|
10115
|
+
var x;
|
|
10116
|
+
return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
|
|
10117
|
+
}, g = (m, f) => {
|
|
10118
|
+
var x;
|
|
10119
|
+
return (x = m.onMount) == null ? void 0 : x.call(m, f);
|
|
10206
10120
|
}, ...h) => {
|
|
10207
|
-
const m = h[0] || ((
|
|
10208
|
-
let
|
|
10209
|
-
return
|
|
10210
|
-
}),
|
|
10211
|
-
let
|
|
10212
|
-
const
|
|
10121
|
+
const m = h[0] || ((C) => {
|
|
10122
|
+
let E = o.get(C);
|
|
10123
|
+
return E || (E = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, E), u == null || u(C, y)), E;
|
|
10124
|
+
}), f = h[1] || (() => {
|
|
10125
|
+
let C, E;
|
|
10126
|
+
const v = (S) => {
|
|
10213
10127
|
try {
|
|
10214
|
-
|
|
10215
|
-
} catch (
|
|
10216
|
-
|
|
10128
|
+
S();
|
|
10129
|
+
} catch (j) {
|
|
10130
|
+
C || (C = !0, E = j);
|
|
10217
10131
|
}
|
|
10218
10132
|
};
|
|
10219
10133
|
do {
|
|
10220
|
-
c.f &&
|
|
10221
|
-
const
|
|
10222
|
-
a.forEach((
|
|
10134
|
+
c.f && v(c.f);
|
|
10135
|
+
const S = /* @__PURE__ */ new Set(), j = S.add.bind(S);
|
|
10136
|
+
a.forEach((T) => {
|
|
10223
10137
|
var L;
|
|
10224
|
-
return (L = r.get(
|
|
10225
|
-
}), a.clear(), i.forEach(
|
|
10138
|
+
return (L = r.get(T)) == null ? void 0 : L.l.forEach(j);
|
|
10139
|
+
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), S.forEach(v), a.size && x();
|
|
10226
10140
|
} while (a.size || i.size || l.size);
|
|
10227
|
-
if (
|
|
10228
|
-
throw
|
|
10229
|
-
}),
|
|
10230
|
-
const
|
|
10231
|
-
for (;
|
|
10232
|
-
const
|
|
10233
|
-
if (
|
|
10234
|
-
|
|
10141
|
+
if (C)
|
|
10142
|
+
throw E;
|
|
10143
|
+
}), x = h[2] || (() => {
|
|
10144
|
+
const C = [], E = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), S = Array.from(a);
|
|
10145
|
+
for (; S.length; ) {
|
|
10146
|
+
const j = S[S.length - 1], T = m(j);
|
|
10147
|
+
if (v.has(j)) {
|
|
10148
|
+
S.pop();
|
|
10235
10149
|
continue;
|
|
10236
10150
|
}
|
|
10237
|
-
if (
|
|
10238
|
-
n.get(
|
|
10151
|
+
if (E.has(j)) {
|
|
10152
|
+
n.get(j) === T.n && C.push([j, T]), v.add(j), S.pop();
|
|
10239
10153
|
continue;
|
|
10240
10154
|
}
|
|
10241
|
-
|
|
10242
|
-
for (const L of getMountedOrPendingDependents(
|
|
10243
|
-
|
|
10155
|
+
E.add(j);
|
|
10156
|
+
for (const L of getMountedOrPendingDependents(j, T, r))
|
|
10157
|
+
E.has(L) || S.push(L);
|
|
10244
10158
|
}
|
|
10245
|
-
for (let
|
|
10246
|
-
const [
|
|
10159
|
+
for (let j = C.length - 1; j >= 0; --j) {
|
|
10160
|
+
const [T, L] = C[j];
|
|
10247
10161
|
let R = !1;
|
|
10248
|
-
for (const
|
|
10249
|
-
if (
|
|
10162
|
+
for (const I of L.d.keys())
|
|
10163
|
+
if (I !== T && a.has(I)) {
|
|
10250
10164
|
R = !0;
|
|
10251
10165
|
break;
|
|
10252
10166
|
}
|
|
10253
|
-
R && (
|
|
10167
|
+
R && (k(T), B(T)), n.delete(T);
|
|
10254
10168
|
}
|
|
10255
|
-
}),
|
|
10256
|
-
var
|
|
10257
|
-
const
|
|
10258
|
-
if (isAtomStateInitialized(
|
|
10169
|
+
}), k = h[3] || ((C) => {
|
|
10170
|
+
var E, v;
|
|
10171
|
+
const S = m(C);
|
|
10172
|
+
if (isAtomStateInitialized(S) && (r.has(C) && n.get(C) !== S.n || Array.from(S.d).every(
|
|
10259
10173
|
([P, $]) => (
|
|
10260
10174
|
// Recursively, read the atom state of the dependency, and
|
|
10261
10175
|
// check if the atom epoch number is unchanged
|
|
10262
|
-
|
|
10176
|
+
k(P).n === $
|
|
10263
10177
|
)
|
|
10264
10178
|
)))
|
|
10265
|
-
return
|
|
10266
|
-
|
|
10267
|
-
let
|
|
10268
|
-
const
|
|
10269
|
-
r.has(
|
|
10179
|
+
return S;
|
|
10180
|
+
S.d.clear();
|
|
10181
|
+
let j = !0;
|
|
10182
|
+
const T = () => {
|
|
10183
|
+
r.has(C) && (B(C), x(), f());
|
|
10270
10184
|
}, L = (P) => {
|
|
10271
10185
|
var $;
|
|
10272
|
-
if (isSelfAtom(
|
|
10273
|
-
const
|
|
10274
|
-
if (!isAtomStateInitialized(
|
|
10186
|
+
if (isSelfAtom(C, P)) {
|
|
10187
|
+
const H = m(P);
|
|
10188
|
+
if (!isAtomStateInitialized(H))
|
|
10275
10189
|
if (hasInitialValue(P))
|
|
10276
10190
|
setAtomStateValueOrPromise(P, P.init, m);
|
|
10277
10191
|
else
|
|
10278
10192
|
throw new Error("no atom init");
|
|
10279
|
-
return returnAtomValue(
|
|
10193
|
+
return returnAtomValue(H);
|
|
10280
10194
|
}
|
|
10281
|
-
const M =
|
|
10195
|
+
const M = k(P);
|
|
10282
10196
|
try {
|
|
10283
10197
|
return returnAtomValue(M);
|
|
10284
10198
|
} finally {
|
|
10285
|
-
|
|
10199
|
+
S.d.set(P, M.n), isPendingPromise(S.v) && addPendingPromiseToDependency(C, S.v, M), ($ = r.get(P)) == null || $.t.add(C), j || T();
|
|
10286
10200
|
}
|
|
10287
10201
|
};
|
|
10288
|
-
let R,
|
|
10202
|
+
let R, I;
|
|
10289
10203
|
const D = {
|
|
10290
10204
|
get signal() {
|
|
10291
10205
|
return R || (R = new AbortController()), R.signal;
|
|
10292
10206
|
},
|
|
10293
10207
|
get setSelf() {
|
|
10294
|
-
return !
|
|
10295
|
-
if (!
|
|
10208
|
+
return !I && isActuallyWritableAtom(C) && (I = (...P) => {
|
|
10209
|
+
if (!j)
|
|
10296
10210
|
try {
|
|
10297
|
-
return
|
|
10211
|
+
return A(C, ...P);
|
|
10298
10212
|
} finally {
|
|
10299
|
-
|
|
10213
|
+
x(), f();
|
|
10300
10214
|
}
|
|
10301
|
-
}),
|
|
10215
|
+
}), I;
|
|
10302
10216
|
}
|
|
10303
|
-
}, O =
|
|
10217
|
+
}, O = S.n;
|
|
10304
10218
|
try {
|
|
10305
|
-
const P = d(
|
|
10306
|
-
return setAtomStateValueOrPromise(
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
)),
|
|
10219
|
+
const P = d(C, L, D);
|
|
10220
|
+
return setAtomStateValueOrPromise(C, P, m), isPromiseLike$1(P) && ((E = P.onCancel) == null || E.call(P, () => R == null ? void 0 : R.abort()), P.then(
|
|
10221
|
+
T,
|
|
10222
|
+
T
|
|
10223
|
+
)), S;
|
|
10310
10224
|
} catch (P) {
|
|
10311
|
-
return delete
|
|
10225
|
+
return delete S.v, S.e = P, ++S.n, S;
|
|
10312
10226
|
} finally {
|
|
10313
|
-
|
|
10227
|
+
j = !1, O !== S.n && n.get(C) === O && (n.set(C, S.n), a.add(C), (v = c.c) == null || v.call(c, C));
|
|
10314
10228
|
}
|
|
10315
|
-
}), b = h[4] || ((
|
|
10316
|
-
const
|
|
10317
|
-
for (;
|
|
10318
|
-
const
|
|
10319
|
-
for (const
|
|
10320
|
-
const
|
|
10321
|
-
n.set(
|
|
10229
|
+
}), b = h[4] || ((C) => {
|
|
10230
|
+
const E = [C];
|
|
10231
|
+
for (; E.length; ) {
|
|
10232
|
+
const v = E.pop(), S = m(v);
|
|
10233
|
+
for (const j of getMountedOrPendingDependents(v, S, r)) {
|
|
10234
|
+
const T = m(j);
|
|
10235
|
+
n.set(j, T.n), E.push(j);
|
|
10322
10236
|
}
|
|
10323
10237
|
}
|
|
10324
|
-
}),
|
|
10325
|
-
let
|
|
10326
|
-
const
|
|
10238
|
+
}), A = h[5] || ((C, ...E) => {
|
|
10239
|
+
let v = !0;
|
|
10240
|
+
const S = (T) => returnAtomValue(k(T)), j = (T, ...L) => {
|
|
10327
10241
|
var R;
|
|
10328
|
-
const
|
|
10242
|
+
const I = m(T);
|
|
10329
10243
|
try {
|
|
10330
|
-
if (isSelfAtom(
|
|
10331
|
-
if (!hasInitialValue(
|
|
10244
|
+
if (isSelfAtom(C, T)) {
|
|
10245
|
+
if (!hasInitialValue(T))
|
|
10332
10246
|
throw new Error("atom not writable");
|
|
10333
|
-
const D =
|
|
10334
|
-
setAtomStateValueOrPromise(
|
|
10247
|
+
const D = I.n, O = L[0];
|
|
10248
|
+
setAtomStateValueOrPromise(T, O, m), B(T), D !== I.n && (a.add(T), (R = c.c) == null || R.call(c, T), b(T));
|
|
10335
10249
|
return;
|
|
10336
10250
|
} else
|
|
10337
|
-
return
|
|
10251
|
+
return A(T, ...L);
|
|
10338
10252
|
} finally {
|
|
10339
|
-
|
|
10253
|
+
v || (x(), f());
|
|
10340
10254
|
}
|
|
10341
10255
|
};
|
|
10342
10256
|
try {
|
|
10343
|
-
return p(
|
|
10257
|
+
return p(C, S, j, ...E);
|
|
10344
10258
|
} finally {
|
|
10345
|
-
|
|
10259
|
+
v = !1;
|
|
10346
10260
|
}
|
|
10347
|
-
}),
|
|
10348
|
-
var
|
|
10349
|
-
const
|
|
10350
|
-
if (
|
|
10351
|
-
for (const [
|
|
10352
|
-
if (!
|
|
10353
|
-
const L = m(
|
|
10354
|
-
|
|
10261
|
+
}), B = h[6] || ((C) => {
|
|
10262
|
+
var E;
|
|
10263
|
+
const v = m(C), S = r.get(C);
|
|
10264
|
+
if (S && !isPendingPromise(v.v)) {
|
|
10265
|
+
for (const [j, T] of v.d)
|
|
10266
|
+
if (!S.d.has(j)) {
|
|
10267
|
+
const L = m(j);
|
|
10268
|
+
_(j).t.add(C), S.d.add(j), T !== L.n && (a.add(j), (E = c.c) == null || E.call(c, j), b(j));
|
|
10355
10269
|
}
|
|
10356
|
-
for (const
|
|
10357
|
-
if (!
|
|
10358
|
-
|
|
10359
|
-
const
|
|
10360
|
-
|
|
10270
|
+
for (const j of S.d || [])
|
|
10271
|
+
if (!v.d.has(j)) {
|
|
10272
|
+
S.d.delete(j);
|
|
10273
|
+
const T = N(j);
|
|
10274
|
+
T == null || T.t.delete(C);
|
|
10361
10275
|
}
|
|
10362
10276
|
}
|
|
10363
|
-
}),
|
|
10364
|
-
var
|
|
10365
|
-
const
|
|
10366
|
-
let
|
|
10367
|
-
if (!
|
|
10368
|
-
|
|
10369
|
-
for (const
|
|
10370
|
-
|
|
10371
|
-
if (
|
|
10277
|
+
}), _ = h[7] || ((C) => {
|
|
10278
|
+
var E;
|
|
10279
|
+
const v = m(C);
|
|
10280
|
+
let S = r.get(C);
|
|
10281
|
+
if (!S) {
|
|
10282
|
+
k(C);
|
|
10283
|
+
for (const j of v.d.keys())
|
|
10284
|
+
_(j).t.add(C);
|
|
10285
|
+
if (S = {
|
|
10372
10286
|
l: /* @__PURE__ */ new Set(),
|
|
10373
|
-
d: new Set(
|
|
10287
|
+
d: new Set(v.d.keys()),
|
|
10374
10288
|
t: /* @__PURE__ */ new Set()
|
|
10375
|
-
}, r.set(
|
|
10376
|
-
const
|
|
10377
|
-
let
|
|
10289
|
+
}, r.set(C, S), (E = c.m) == null || E.call(c, C), isActuallyWritableAtom(C)) {
|
|
10290
|
+
const j = () => {
|
|
10291
|
+
let T = !0;
|
|
10378
10292
|
const L = (...R) => {
|
|
10379
10293
|
try {
|
|
10380
|
-
return
|
|
10294
|
+
return A(C, ...R);
|
|
10381
10295
|
} finally {
|
|
10382
|
-
|
|
10296
|
+
T || (x(), f());
|
|
10383
10297
|
}
|
|
10384
10298
|
};
|
|
10385
10299
|
try {
|
|
10386
|
-
const R = g(
|
|
10387
|
-
R && (
|
|
10388
|
-
|
|
10300
|
+
const R = g(C, L);
|
|
10301
|
+
R && (S.u = () => {
|
|
10302
|
+
T = !0;
|
|
10389
10303
|
try {
|
|
10390
10304
|
R();
|
|
10391
10305
|
} finally {
|
|
10392
|
-
|
|
10306
|
+
T = !1;
|
|
10393
10307
|
}
|
|
10394
10308
|
});
|
|
10395
10309
|
} finally {
|
|
10396
|
-
|
|
10310
|
+
T = !1;
|
|
10397
10311
|
}
|
|
10398
10312
|
};
|
|
10399
|
-
l.add(
|
|
10313
|
+
l.add(j);
|
|
10400
10314
|
}
|
|
10401
10315
|
}
|
|
10402
|
-
return
|
|
10403
|
-
}),
|
|
10404
|
-
var
|
|
10405
|
-
const
|
|
10406
|
-
let
|
|
10407
|
-
if (
|
|
10408
|
-
var
|
|
10409
|
-
return (
|
|
10316
|
+
return S;
|
|
10317
|
+
}), N = h[8] || ((C) => {
|
|
10318
|
+
var E;
|
|
10319
|
+
const v = m(C);
|
|
10320
|
+
let S = r.get(C);
|
|
10321
|
+
if (S && !S.l.size && !Array.from(S.t).some((j) => {
|
|
10322
|
+
var T;
|
|
10323
|
+
return (T = r.get(j)) == null ? void 0 : T.d.has(C);
|
|
10410
10324
|
})) {
|
|
10411
|
-
|
|
10412
|
-
for (const
|
|
10413
|
-
const
|
|
10414
|
-
|
|
10325
|
+
S.u && i.add(S.u), S = void 0, r.delete(C), (E = c.u) == null || E.call(c, C);
|
|
10326
|
+
for (const j of v.d.keys()) {
|
|
10327
|
+
const T = N(j);
|
|
10328
|
+
T == null || T.t.delete(C);
|
|
10415
10329
|
}
|
|
10416
10330
|
return;
|
|
10417
10331
|
}
|
|
10418
|
-
return
|
|
10332
|
+
return S;
|
|
10419
10333
|
}), w = [
|
|
10420
10334
|
// store state
|
|
10421
10335
|
o,
|
|
@@ -10432,31 +10346,31 @@ const RootLayout = () => {
|
|
|
10432
10346
|
g,
|
|
10433
10347
|
// building-block functions
|
|
10434
10348
|
m,
|
|
10435
|
-
x,
|
|
10436
10349
|
f,
|
|
10437
|
-
|
|
10350
|
+
x,
|
|
10351
|
+
k,
|
|
10438
10352
|
b,
|
|
10439
|
-
B,
|
|
10440
|
-
E,
|
|
10441
10353
|
A,
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
|
|
10354
|
+
B,
|
|
10355
|
+
_,
|
|
10356
|
+
N
|
|
10357
|
+
], y = {
|
|
10358
|
+
get: (C) => returnAtomValue(k(C)),
|
|
10359
|
+
set: (C, ...E) => {
|
|
10446
10360
|
try {
|
|
10447
|
-
return
|
|
10361
|
+
return A(C, ...E);
|
|
10448
10362
|
} finally {
|
|
10449
|
-
|
|
10363
|
+
x(), f();
|
|
10450
10364
|
}
|
|
10451
10365
|
},
|
|
10452
|
-
sub: (
|
|
10453
|
-
const
|
|
10454
|
-
return
|
|
10455
|
-
|
|
10366
|
+
sub: (C, E) => {
|
|
10367
|
+
const S = _(C).l;
|
|
10368
|
+
return S.add(E), f(), () => {
|
|
10369
|
+
S.delete(E), N(C), f();
|
|
10456
10370
|
};
|
|
10457
10371
|
}
|
|
10458
10372
|
};
|
|
10459
|
-
return Object.defineProperty(
|
|
10373
|
+
return Object.defineProperty(y, BUILDING_BLOCKS, { value: w }), y;
|
|
10460
10374
|
}, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
|
|
10461
10375
|
let defaultStore;
|
|
10462
10376
|
const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
|
|
@@ -10668,7 +10582,7 @@ export {
|
|
|
10668
10582
|
useTheme,
|
|
10669
10583
|
useThemeOptions,
|
|
10670
10584
|
useToggleChaiFeatureFlag,
|
|
10671
|
-
|
|
10585
|
+
Ue as useTranslation,
|
|
10672
10586
|
useUndoManager,
|
|
10673
10587
|
useUpdateBlocksProps,
|
|
10674
10588
|
useUpdateBlocksPropsRealtime,
|