@chaibuilder/sdk 3.0.8 → 3.0.10
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/apply-binding-C4AQBX3p.cjs +1 -0
- package/dist/apply-binding-CSYk-NOA.js +641 -0
- package/dist/core.cjs +4 -4
- package/dist/core.js +1172 -1080
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +1 -15
- package/dist/render.js +92 -66
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +75 -63
- package/package.json +2 -3
- package/dist/apply-binding-HQ9gBNJP.cjs +0 -1
- package/dist/apply-binding-tfi-KyyV.js +0 -573
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ var $ = (o, n, r) => U(o, typeof n != "symbol" ? n + "" : n, r);
|
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
6
6
|
import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, sortBy, round } from "lodash-es";
|
|
7
|
-
import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, ExclamationTriangleIcon, Cross1Icon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, LetterCaseCapitalizeIcon, ValueIcon, LinkBreak1Icon, EnterFullScreenIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, ReloadIcon, MagicWandIcon, CircleIcon, MagnifyingGlassIcon, CaretRightIcon, FrameIcon, CheckIcon, LinkBreak2Icon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon,
|
|
7
|
+
import { SquareIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, ExclamationTriangleIcon, Cross1Icon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, LetterCaseCapitalizeIcon, ValueIcon, LinkBreak1Icon, EnterFullScreenIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, ReloadIcon, MagicWandIcon, CircleIcon, MagnifyingGlassIcon, CaretRightIcon, FrameIcon, CheckIcon, LinkBreak2Icon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, ImageIcon, PaperPlaneIcon, EraserIcon, LightningBoltIcon, ZoomInIcon, StackIcon } from "@radix-ui/react-icons";
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, lazy, useReducer, useDebugValue } from "react";
|
|
10
10
|
import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
@@ -14,7 +14,7 @@ import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as Dropd
|
|
|
14
14
|
import clsx$1, { clsx } from "clsx";
|
|
15
15
|
import { twMerge } from "tailwind-merge";
|
|
16
16
|
import TreeModel from "tree-model";
|
|
17
|
-
import { C as COLLECTION_PREFIX, S as STYLES_KEY,
|
|
17
|
+
import { C as COLLECTION_PREFIX, S as STYLES_KEY, i as getSplitChaiClasses, e as adjustSpacingInContentBlocks, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX, h as getBlocksFromHTML, j as ROOT_TEMP_KEY } from "./apply-binding-CSYk-NOA.js";
|
|
18
18
|
import { d as defaultThemeOptions, f as defaultThemeValues, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, h as getThemeFontsUrls, i as getThemeCustomFontFace } from "./plugin-BOcGV_IY.js";
|
|
19
19
|
import { isObject } from "@rjsf/utils";
|
|
20
20
|
import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
|
|
@@ -23,6 +23,8 @@ import { useTranslation, initReactI18next } from "react-i18next";
|
|
|
23
23
|
import { useTranslation as $e } from "react-i18next";
|
|
24
24
|
import Fuse from "fuse.js";
|
|
25
25
|
import UndoManager from "undo-manager";
|
|
26
|
+
import i18n, { t } from "i18next";
|
|
27
|
+
import { default as Ve } from "i18next";
|
|
26
28
|
import Link from "@tiptap/extension-link";
|
|
27
29
|
import TextAlign from "@tiptap/extension-text-align";
|
|
28
30
|
import Underline from "@tiptap/extension-underline";
|
|
@@ -34,8 +36,6 @@ import validator from "@rjsf/validator-ajv8";
|
|
|
34
36
|
import Autosuggest from "react-autosuggest";
|
|
35
37
|
import { useFeature } from "flagged";
|
|
36
38
|
import { Tree } from "react-arborist";
|
|
37
|
-
import i18n from "i18next";
|
|
38
|
-
import { default as Ve } from "i18next";
|
|
39
39
|
import "himalaya";
|
|
40
40
|
import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
|
|
41
41
|
import tailwindForms from "@tailwindcss/forms";
|
|
@@ -341,16 +341,16 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
341
341
|
_type: "Text",
|
|
342
342
|
content: u.content
|
|
343
343
|
};
|
|
344
|
-
Object.keys(u).forEach((
|
|
345
|
-
|
|
346
|
-
}), l.unshift(h), i = i.map((
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
return Object.keys(
|
|
350
|
-
y.startsWith("content-") && (
|
|
351
|
-
}),
|
|
344
|
+
Object.keys(u).forEach((x) => {
|
|
345
|
+
x.startsWith("content-") && (h[x] = u[x]);
|
|
346
|
+
}), l.unshift(h), i = i.map((x) => {
|
|
347
|
+
if (x._id === r) {
|
|
348
|
+
const f = { ...x, content: "" };
|
|
349
|
+
return Object.keys(f).forEach((y) => {
|
|
350
|
+
y.startsWith("content-") && (f[y] = "");
|
|
351
|
+
}), f;
|
|
352
352
|
}
|
|
353
|
-
return
|
|
353
|
+
return x;
|
|
354
354
|
});
|
|
355
355
|
}
|
|
356
356
|
}
|
|
@@ -478,15 +478,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
478
478
|
if (g.length === 2) {
|
|
479
479
|
const m = g.find((h) => h._id !== d);
|
|
480
480
|
if (m && m._type === "Text") {
|
|
481
|
-
const h = r.find((
|
|
482
|
-
h && "content" in h && (r = r.map((
|
|
483
|
-
if (
|
|
484
|
-
const
|
|
481
|
+
const h = r.find((x) => x._id === u);
|
|
482
|
+
h && "content" in h && (r = r.map((x) => {
|
|
483
|
+
if (x._id === u) {
|
|
484
|
+
const f = { ...x, content: m.content };
|
|
485
485
|
return Object.keys(m).forEach((y) => {
|
|
486
|
-
y.startsWith("content-") && (
|
|
487
|
-
}),
|
|
486
|
+
y.startsWith("content-") && (f[y] = m[y]);
|
|
487
|
+
}), f;
|
|
488
488
|
}
|
|
489
|
-
return
|
|
489
|
+
return x;
|
|
490
490
|
}), a.push(m._id));
|
|
491
491
|
}
|
|
492
492
|
}
|
|
@@ -569,32 +569,32 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
569
569
|
status: "idle",
|
|
570
570
|
props: {},
|
|
571
571
|
error: void 0
|
|
572
|
-
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (
|
|
572
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
|
|
573
573
|
return useEffect(() => {
|
|
574
574
|
if (n === "mock") {
|
|
575
575
|
if (isFunction(a)) {
|
|
576
|
-
i((
|
|
577
|
-
const
|
|
578
|
-
if (!isObject(
|
|
576
|
+
i((f) => ({ ...f, status: "loading", props: {} }));
|
|
577
|
+
const x = a({ block: o });
|
|
578
|
+
if (!isObject(x))
|
|
579
579
|
throw new Error("mockDataProvider should return an object");
|
|
580
|
-
i((
|
|
580
|
+
i((f) => ({ ...f, status: "loaded", props: x }));
|
|
581
581
|
}
|
|
582
582
|
return;
|
|
583
583
|
}
|
|
584
|
-
n === "live" && (!g && !m || (i((
|
|
585
|
-
g ? (p((
|
|
586
|
-
...
|
|
584
|
+
n === "live" && (!g && !m || (i((x) => ({ ...x, status: "loading", props: {} })), d({ block: o }).then((x = {}) => {
|
|
585
|
+
g ? (p((f) => ({
|
|
586
|
+
...f,
|
|
587
587
|
[o._id]: {
|
|
588
588
|
status: "loaded",
|
|
589
|
-
props: get(
|
|
589
|
+
props: get(x, "items", []),
|
|
590
590
|
repeaterItems: o.repeaterItems
|
|
591
591
|
}
|
|
592
|
-
})), i((
|
|
593
|
-
}).catch((
|
|
594
|
-
g ? (p((
|
|
595
|
-
...
|
|
596
|
-
[o._id]: { status: "error", error:
|
|
597
|
-
})), i((
|
|
592
|
+
})), i((f) => ({ ...f, status: "loaded", props: { totalItems: get(x, "totalItems") } })), c([o._id], { totalItems: get(x, "totalItems") })) : i((f) => ({ ...f, status: "loaded", props: isObject(x) ? x : {} }));
|
|
593
|
+
}).catch((x) => {
|
|
594
|
+
g ? (p((f) => ({
|
|
595
|
+
...f,
|
|
596
|
+
[o._id]: { status: "error", error: x, props: [] }
|
|
597
|
+
})), i((f) => ({ ...f, status: "error", error: x, props: {} }))) : i((f) => ({ ...f, status: "error", error: x, props: {} }));
|
|
598
598
|
})));
|
|
599
599
|
}, [o == null ? void 0 : o._id, u, g, m, a, n]), {
|
|
600
600
|
$loading: get(l, "status") === "loading",
|
|
@@ -749,20 +749,20 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
|
749
749
|
return console.warn(`Failed to get block definition for type: ${r._type}`, a), !1;
|
|
750
750
|
}
|
|
751
751
|
}) : !1, useSavePage = () => {
|
|
752
|
-
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (
|
|
752
|
+
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (x) => {
|
|
753
753
|
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
|
|
754
|
-
const
|
|
755
|
-
return !d || d === p ? !1 : checkMissingTranslations(
|
|
754
|
+
const x = l();
|
|
755
|
+
return !d || d === p ? !1 : checkMissingTranslations(x.blocks || [], d);
|
|
756
756
|
};
|
|
757
757
|
return { savePage: useThrottledCallback(
|
|
758
|
-
async (
|
|
758
|
+
async (x = !1) => {
|
|
759
759
|
if (!c("save_page") || !u)
|
|
760
760
|
return;
|
|
761
761
|
n("SAVING"), a("SAVING");
|
|
762
|
-
const
|
|
762
|
+
const f = l();
|
|
763
763
|
return await r({
|
|
764
|
-
autoSave:
|
|
765
|
-
blocks:
|
|
764
|
+
autoSave: x,
|
|
765
|
+
blocks: f.blocks,
|
|
766
766
|
theme: i,
|
|
767
767
|
needTranslations: g()
|
|
768
768
|
}), setTimeout(() => {
|
|
@@ -776,10 +776,10 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
|
776
776
|
if (!c("save_page") || !u)
|
|
777
777
|
return;
|
|
778
778
|
n("SAVING"), a("SAVING");
|
|
779
|
-
const
|
|
779
|
+
const x = l();
|
|
780
780
|
return await r({
|
|
781
781
|
autoSave: !0,
|
|
782
|
-
blocks:
|
|
782
|
+
blocks: x.blocks,
|
|
783
783
|
theme: i,
|
|
784
784
|
needTranslations: g()
|
|
785
785
|
}), setTimeout(() => {
|
|
@@ -837,65 +837,65 @@ const undoRedoStateAtom = atom({
|
|
|
837
837
|
updateBlocksProps: c
|
|
838
838
|
} = useBlocksStoreManager();
|
|
839
839
|
return {
|
|
840
|
-
moveBlocks: (
|
|
841
|
-
const
|
|
842
|
-
const
|
|
843
|
-
return { _id: j, oldParent:
|
|
844
|
-
}), B =
|
|
845
|
-
B && B.oldParent === y && B.oldPosition === b || (i(
|
|
846
|
-
undo: () => each(
|
|
847
|
-
i([j],
|
|
840
|
+
moveBlocks: (f, y, b) => {
|
|
841
|
+
const k = map(f, (j) => {
|
|
842
|
+
const C = n.find((I) => I._id === j)._parent || null, S = n.filter((I) => C ? I._parent === C : !I._parent).map((I) => I._id).indexOf(j);
|
|
843
|
+
return { _id: j, oldParent: C, oldPosition: S };
|
|
844
|
+
}), B = k.find(({ _id: j }) => j === f[0]);
|
|
845
|
+
B && B.oldParent === y && B.oldPosition === b || (i(f, y, b), o({
|
|
846
|
+
undo: () => each(k, ({ _id: j, oldParent: E, oldPosition: C }) => {
|
|
847
|
+
i([j], E, C);
|
|
848
848
|
}),
|
|
849
|
-
redo: () => i(
|
|
849
|
+
redo: () => i(f, y, b)
|
|
850
850
|
}));
|
|
851
851
|
},
|
|
852
|
-
addBlocks: (
|
|
853
|
-
a(
|
|
854
|
-
undo: () => l(map(
|
|
855
|
-
redo: () => a(
|
|
852
|
+
addBlocks: (f, y, b) => {
|
|
853
|
+
a(f, y, b), o({
|
|
854
|
+
undo: () => l(map(f, "_id")),
|
|
855
|
+
redo: () => a(f, y, b)
|
|
856
856
|
});
|
|
857
857
|
},
|
|
858
|
-
removeBlocks: (
|
|
858
|
+
removeBlocks: (f) => {
|
|
859
859
|
var B;
|
|
860
|
-
const y = (B = first(
|
|
861
|
-
l(map(
|
|
862
|
-
undo: () => a(
|
|
863
|
-
redo: () => l(map(
|
|
860
|
+
const y = (B = first(f)) == null ? void 0 : B._parent, k = n.filter((j) => y ? j._parent === y : !j._parent).indexOf(first(f));
|
|
861
|
+
l(map(f, "_id")), o({
|
|
862
|
+
undo: () => a(f, y, k),
|
|
863
|
+
redo: () => l(map(f, "_id"))
|
|
864
864
|
});
|
|
865
865
|
},
|
|
866
|
-
updateBlocks: (
|
|
867
|
-
let
|
|
866
|
+
updateBlocks: (f, y, b) => {
|
|
867
|
+
let k = [];
|
|
868
868
|
if (b)
|
|
869
|
-
|
|
869
|
+
k = map(f, (B) => ({ _id: B, ...b }));
|
|
870
870
|
else {
|
|
871
871
|
const B = keys(y);
|
|
872
|
-
|
|
873
|
-
const
|
|
874
|
-
return each(B, (
|
|
872
|
+
k = map(f, (j) => {
|
|
873
|
+
const E = n.find((v) => v._id === j), C = { _id: j };
|
|
874
|
+
return each(B, (v) => C[v] = E[v]), C;
|
|
875
875
|
});
|
|
876
876
|
}
|
|
877
|
-
c(map(
|
|
878
|
-
undo: () => c(
|
|
879
|
-
redo: () => c(map(
|
|
877
|
+
c(map(f, (B) => ({ _id: B, ...y }))), o({
|
|
878
|
+
undo: () => c(k),
|
|
879
|
+
redo: () => c(map(f, (B) => ({ _id: B, ...y })))
|
|
880
880
|
});
|
|
881
881
|
},
|
|
882
|
-
updateBlocksRuntime: (
|
|
883
|
-
c(map(
|
|
882
|
+
updateBlocksRuntime: (f, y) => {
|
|
883
|
+
c(map(f, (b) => ({ _id: b, ...y })));
|
|
884
884
|
},
|
|
885
|
-
setNewBlocks: (
|
|
886
|
-
r(
|
|
885
|
+
setNewBlocks: (f) => {
|
|
886
|
+
r(f), o({
|
|
887
887
|
undo: () => r(n),
|
|
888
|
-
redo: () => r(
|
|
888
|
+
redo: () => r(f)
|
|
889
889
|
});
|
|
890
890
|
},
|
|
891
|
-
updateMultipleBlocksProps: (
|
|
891
|
+
updateMultipleBlocksProps: (f) => {
|
|
892
892
|
let y = [];
|
|
893
|
-
y = map(
|
|
894
|
-
const
|
|
895
|
-
return each(
|
|
896
|
-
}), c(
|
|
893
|
+
y = map(f, (b) => {
|
|
894
|
+
const k = keys(b), B = n.find((E) => E._id === b._id), j = {};
|
|
895
|
+
return each(k, (E) => j[E] = B[E]), j;
|
|
896
|
+
}), c(f), o({
|
|
897
897
|
undo: () => c(y),
|
|
898
|
-
redo: () => c(
|
|
898
|
+
redo: () => c(f)
|
|
899
899
|
});
|
|
900
900
|
}
|
|
901
901
|
};
|
|
@@ -903,12 +903,12 @@ const undoRedoStateAtom = atom({
|
|
|
903
903
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
904
904
|
(i, c, d) => {
|
|
905
905
|
var h;
|
|
906
|
-
for (let
|
|
907
|
-
const { _id:
|
|
908
|
-
i[
|
|
909
|
-
const y = filter(i, { _parent:
|
|
906
|
+
for (let x = 0; x < i.length; x++) {
|
|
907
|
+
const { _id: f } = i[x];
|
|
908
|
+
i[x]._id = generateUUID();
|
|
909
|
+
const y = filter(i, { _parent: f });
|
|
910
910
|
for (let b = 0; b < y.length; b++)
|
|
911
|
-
y[b]._parent = i[
|
|
911
|
+
y[b]._parent = i[x]._id;
|
|
912
912
|
}
|
|
913
913
|
const p = first(i);
|
|
914
914
|
let u, g;
|
|
@@ -2361,40 +2361,40 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2361
2361
|
return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
|
|
2362
2362
|
})
|
|
2363
2363
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2364
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h,
|
|
2365
|
-
const
|
|
2366
|
-
for (const y in
|
|
2367
|
-
const b =
|
|
2364
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, x) => {
|
|
2365
|
+
const f = cloneDeep(x.find((y) => y._id === h));
|
|
2366
|
+
for (const y in f) {
|
|
2367
|
+
const b = f[y];
|
|
2368
2368
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
2369
|
-
const { baseClasses:
|
|
2370
|
-
|
|
2369
|
+
const { baseClasses: k, classes: B } = getSplitChaiClasses(b);
|
|
2370
|
+
f[y] = compact(flattenDeep([k, B])).join(" ");
|
|
2371
2371
|
} else
|
|
2372
|
-
y !== "_id" && delete
|
|
2372
|
+
y !== "_id" && delete f[y];
|
|
2373
2373
|
}
|
|
2374
|
-
return
|
|
2374
|
+
return f;
|
|
2375
2375
|
};
|
|
2376
2376
|
return {
|
|
2377
2377
|
askAi: useCallback(
|
|
2378
|
-
async (h,
|
|
2378
|
+
async (h, x, f, y) => {
|
|
2379
2379
|
if (l) {
|
|
2380
2380
|
n(!0), a(null);
|
|
2381
2381
|
try {
|
|
2382
2382
|
const b = p === u ? "" : p;
|
|
2383
|
-
console.log("prompt",
|
|
2384
|
-
const
|
|
2385
|
-
if (
|
|
2386
|
-
a(
|
|
2383
|
+
console.log("prompt", f);
|
|
2384
|
+
const k = f.toLowerCase().includes("translate the content"), B = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p, k) : [m(x, d)], j = await l(h, addLangToPrompt(f, g, h), B, b), { blocks: E, error: C } = j;
|
|
2385
|
+
if (C) {
|
|
2386
|
+
a(C);
|
|
2387
2387
|
return;
|
|
2388
2388
|
}
|
|
2389
2389
|
if (h === "styles") {
|
|
2390
|
-
const
|
|
2391
|
-
for (const
|
|
2392
|
-
|
|
2393
|
-
return
|
|
2390
|
+
const v = E.map((S) => {
|
|
2391
|
+
for (const I in S)
|
|
2392
|
+
I !== "_id" && (S[I] = `${STYLES_KEY},${S[I]}`);
|
|
2393
|
+
return S;
|
|
2394
2394
|
});
|
|
2395
|
-
c(
|
|
2395
|
+
c(v);
|
|
2396
2396
|
} else
|
|
2397
|
-
i(
|
|
2397
|
+
i(E);
|
|
2398
2398
|
y && y(j);
|
|
2399
2399
|
} catch (b) {
|
|
2400
2400
|
a(b);
|
|
@@ -2493,12 +2493,12 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2493
2493
|
if (!p)
|
|
2494
2494
|
return m;
|
|
2495
2495
|
let h = [];
|
|
2496
|
-
for (const
|
|
2497
|
-
if (
|
|
2498
|
-
let
|
|
2499
|
-
|
|
2496
|
+
for (const x of m)
|
|
2497
|
+
if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
|
|
2498
|
+
let f = l(x.partialBlockId);
|
|
2499
|
+
x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), h = [...h, ...f];
|
|
2500
2500
|
} else
|
|
2501
|
-
h.push(
|
|
2501
|
+
h.push(x);
|
|
2502
2502
|
return h;
|
|
2503
2503
|
})
|
|
2504
2504
|
};
|
|
@@ -2673,13 +2673,13 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2673
2673
|
const d = o(c), p = a;
|
|
2674
2674
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2675
2675
|
return each(p, (m) => {
|
|
2676
|
-
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2677
|
-
u = u.replace(
|
|
2678
|
-
const
|
|
2679
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2676
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2677
|
+
u = u.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2678
|
+
const f = first(m.split(":"));
|
|
2679
|
+
includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(m.split(":").pop().trim());
|
|
2680
2680
|
}), each(p, (m) => {
|
|
2681
|
-
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2682
|
-
g = g.replace(
|
|
2681
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2682
|
+
g = g.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2683
2683
|
}), {
|
|
2684
2684
|
ids: [d._id],
|
|
2685
2685
|
props: {
|
|
@@ -2828,21 +2828,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2828
2828
|
return "VERTICAL";
|
|
2829
2829
|
}
|
|
2830
2830
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
2831
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (
|
|
2832
|
-
(
|
|
2833
|
-
isDisabledControl(g, m,
|
|
2831
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (f) => c ? get(f, "_parent") === c : !get(f, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), x = useCallback(
|
|
2832
|
+
(f) => {
|
|
2833
|
+
isDisabledControl(g, m, f) || p || (f === "UP" || f === "LEFT" ? l([i], c || null, u - 1) : (f === "DOWN" || f === "RIGHT") && l([i], c || null, u + 2), n());
|
|
2834
2834
|
},
|
|
2835
2835
|
[g, m, p, u, i, c, n]
|
|
2836
2836
|
);
|
|
2837
2837
|
return useHotkeys(
|
|
2838
2838
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2839
|
-
({ key:
|
|
2839
|
+
({ key: f }) => {
|
|
2840
2840
|
var y;
|
|
2841
|
-
|
|
2841
|
+
x((y = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
|
|
2842
2842
|
},
|
|
2843
2843
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2844
|
-
[
|
|
2845
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock:
|
|
2844
|
+
[x]
|
|
2845
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: x, orientation: h };
|
|
2846
2846
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
2847
2847
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2848
2848
|
o,
|
|
@@ -2999,8 +2999,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2999
2999
|
}),
|
|
3000
3000
|
size({
|
|
3001
3001
|
boundary: u == null ? void 0 : u.body,
|
|
3002
|
-
apply({ availableWidth: y, availableHeight: b, elements:
|
|
3003
|
-
Object.assign(
|
|
3002
|
+
apply({ availableWidth: y, availableHeight: b, elements: k }) {
|
|
3003
|
+
Object.assign(k.floating.style, {
|
|
3004
3004
|
maxWidth: `${Math.max(200, y)}px`,
|
|
3005
3005
|
maxHeight: `${Math.max(100, b)}px`
|
|
3006
3006
|
});
|
|
@@ -3010,7 +3010,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3010
3010
|
elements: { reference: n }
|
|
3011
3011
|
});
|
|
3012
3012
|
useResizeObserver(n, () => h(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => h(), (u == null ? void 0 : u.body) !== null);
|
|
3013
|
-
const
|
|
3013
|
+
const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
3014
3014
|
return useEffect(() => {
|
|
3015
3015
|
if (n) {
|
|
3016
3016
|
const y = setTimeout(() => h(), 500);
|
|
@@ -3033,16 +3033,16 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3033
3033
|
onKeyDown: (y) => y.stopPropagation(),
|
|
3034
3034
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3035
3035
|
children: [
|
|
3036
|
-
|
|
3036
|
+
x && /* @__PURE__ */ jsx(
|
|
3037
3037
|
ArrowUpIcon,
|
|
3038
3038
|
{
|
|
3039
3039
|
className: "hover:scale-105",
|
|
3040
3040
|
onClick: () => {
|
|
3041
|
-
c([]), l([
|
|
3041
|
+
c([]), l([x]);
|
|
3042
3042
|
}
|
|
3043
3043
|
}
|
|
3044
3044
|
),
|
|
3045
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3045
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: o }),
|
|
3046
3046
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3047
3047
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3048
3048
|
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
|
|
@@ -3200,8 +3200,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3200
3200
|
i
|
|
3201
3201
|
]), useHotkeys(
|
|
3202
3202
|
"del, backspace",
|
|
3203
|
-
(
|
|
3204
|
-
|
|
3203
|
+
(x) => {
|
|
3204
|
+
x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3205
3205
|
},
|
|
3206
3206
|
h,
|
|
3207
3207
|
[n, l]
|
|
@@ -3503,8 +3503,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3503
3503
|
],
|
|
3504
3504
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3505
3505
|
onBlur: ({ editor: u, event: g }) => {
|
|
3506
|
-
const m = g.relatedTarget, h = i.querySelector(".ProseMirror"),
|
|
3507
|
-
if (!
|
|
3506
|
+
const m = g.relatedTarget, h = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = h == null ? void 0 : h.contains(m), y = x == null ? void 0 : x.contains(m);
|
|
3507
|
+
if (!f && !y) {
|
|
3508
3508
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3509
3509
|
r(b);
|
|
3510
3510
|
}
|
|
@@ -3559,14 +3559,14 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3559
3559
|
useEffect(() => {
|
|
3560
3560
|
if (a.current) {
|
|
3561
3561
|
a.current.innerText = n, a.current.focus();
|
|
3562
|
-
const h = c.createRange(),
|
|
3563
|
-
h.selectNodeContents(a.current), h.collapse(!1),
|
|
3562
|
+
const h = c.createRange(), x = d.getSelection();
|
|
3563
|
+
h.selectNodeContents(a.current), h.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(h), a.current.focus();
|
|
3564
3564
|
} else
|
|
3565
3565
|
r();
|
|
3566
3566
|
}, [c, d]);
|
|
3567
3567
|
const p = useMemo(() => {
|
|
3568
|
-
var
|
|
3569
|
-
const h = ((
|
|
3568
|
+
var x;
|
|
3569
|
+
const h = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
|
|
3570
3570
|
return h === "button" ? "div" : h;
|
|
3571
3571
|
}, [o]), u = useCallback(
|
|
3572
3572
|
(h) => {
|
|
@@ -3582,12 +3582,12 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3582
3582
|
contentEditable: !0,
|
|
3583
3583
|
className: `${((h = o == null ? void 0 : o.className) == null ? void 0 : h.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
|
|
3584
3584
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
3585
|
-
onInput: (
|
|
3586
|
-
const
|
|
3587
|
-
|
|
3585
|
+
onInput: (x) => {
|
|
3586
|
+
const f = x.target;
|
|
3587
|
+
f && (f.innerText.trim() === "" ? (f.setAttribute("data-placeholder", "Enter text here"), f.children.length > 0 && f.children[0].remove()) : x.target.removeAttribute("data-placeholder"), l(x.target.innerText));
|
|
3588
3588
|
},
|
|
3589
|
-
onClick: (
|
|
3590
|
-
|
|
3589
|
+
onClick: (x) => {
|
|
3590
|
+
x.stopPropagation(), x.preventDefault();
|
|
3591
3591
|
}
|
|
3592
3592
|
};
|
|
3593
3593
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
@@ -3600,62 +3600,62 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3600
3600
|
}
|
|
3601
3601
|
), WithBlockTextEditor = memo(
|
|
3602
3602
|
({ block: o, children: n }) => {
|
|
3603
|
-
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang:
|
|
3604
|
-
var
|
|
3605
|
-
const
|
|
3606
|
-
let
|
|
3607
|
-
const
|
|
3608
|
-
return
|
|
3609
|
-
}, [o,
|
|
3610
|
-
(
|
|
3611
|
-
var
|
|
3612
|
-
const
|
|
3613
|
-
h([b], { [r]:
|
|
3603
|
+
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: k, blockType: B } = useMemo(() => {
|
|
3604
|
+
var _;
|
|
3605
|
+
const S = o._type;
|
|
3606
|
+
let I = o[r];
|
|
3607
|
+
const A = getRegisteredChaiBlock(o._type);
|
|
3608
|
+
return x && ((_ = A == null ? void 0 : A.i18nProps) == null ? void 0 : _.includes(r)) && has(o, `${r}-${x}`) && (I = get(o, `${r}-${x}`)), { blockContent: I, blockType: S };
|
|
3609
|
+
}, [o, x]), j = useCallback(
|
|
3610
|
+
(S) => {
|
|
3611
|
+
var A;
|
|
3612
|
+
const I = S || ((A = g.current) == null ? void 0 : A.innerText);
|
|
3613
|
+
h([b], { [r]: I }), u(null), c(null), d(-1), f(b ? [b] : []);
|
|
3614
3614
|
},
|
|
3615
|
-
[b, h, c,
|
|
3616
|
-
),
|
|
3617
|
-
(
|
|
3618
|
-
h([b], { [r]:
|
|
3615
|
+
[b, h, c, f, x]
|
|
3616
|
+
), E = useDebouncedCallback(
|
|
3617
|
+
(S) => {
|
|
3618
|
+
h([b], { [r]: S });
|
|
3619
3619
|
},
|
|
3620
|
-
[b, o, h,
|
|
3620
|
+
[b, o, h, x],
|
|
3621
3621
|
1e3
|
|
3622
|
-
),
|
|
3623
|
-
(
|
|
3624
|
-
|
|
3625
|
-
const
|
|
3626
|
-
y.current = null,
|
|
3622
|
+
), C = useCallback(
|
|
3623
|
+
(S) => {
|
|
3624
|
+
S.preventDefault(), b && (y.current = b), j(), setTimeout(() => {
|
|
3625
|
+
const I = y.current;
|
|
3626
|
+
y.current = null, f([I]);
|
|
3627
3627
|
}, 100);
|
|
3628
3628
|
},
|
|
3629
|
-
[
|
|
3629
|
+
[f, b, x]
|
|
3630
3630
|
);
|
|
3631
3631
|
useEffect(() => {
|
|
3632
|
-
var
|
|
3632
|
+
var w;
|
|
3633
3633
|
if (!b) return;
|
|
3634
|
-
const
|
|
3635
|
-
|
|
3634
|
+
const S = `[data-block-id="${b}"]`, I = i >= 0 ? `[data-block-index="${i}"]` : "", A = a.querySelector(`${S}${I}`);
|
|
3635
|
+
A && ((w = A == null ? void 0 : A.classList) == null || w.add("sr-only"), u(A));
|
|
3636
3636
|
}, [b, B, a, i]);
|
|
3637
|
-
const
|
|
3637
|
+
const v = useMemo(() => p ? (m(), B === "RichText" ? /* @__PURE__ */ jsx(
|
|
3638
3638
|
RichTextEditor,
|
|
3639
3639
|
{
|
|
3640
|
-
blockContent:
|
|
3640
|
+
blockContent: k,
|
|
3641
3641
|
editingElement: p,
|
|
3642
|
-
onChange:
|
|
3642
|
+
onChange: E,
|
|
3643
3643
|
onClose: j,
|
|
3644
|
-
onEscape:
|
|
3644
|
+
onEscape: C
|
|
3645
3645
|
}
|
|
3646
3646
|
) : /* @__PURE__ */ jsx(
|
|
3647
3647
|
MemoizedEditor,
|
|
3648
3648
|
{
|
|
3649
3649
|
editorRef: g,
|
|
3650
|
-
blockContent:
|
|
3650
|
+
blockContent: k,
|
|
3651
3651
|
editingElement: p,
|
|
3652
3652
|
onClose: j,
|
|
3653
|
-
onChange:
|
|
3654
|
-
onEscape:
|
|
3653
|
+
onChange: E,
|
|
3654
|
+
onEscape: C
|
|
3655
3655
|
}
|
|
3656
|
-
)) : null, [p, b, B,
|
|
3656
|
+
)) : null, [p, b, B, k, j, x]);
|
|
3657
3657
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3658
|
-
|
|
3658
|
+
v,
|
|
3659
3659
|
n
|
|
3660
3660
|
] });
|
|
3661
3661
|
},
|
|
@@ -3688,23 +3688,23 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3688
3688
|
blockAtom: n,
|
|
3689
3689
|
children: r
|
|
3690
3690
|
}) => {
|
|
3691
|
-
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index:
|
|
3691
|
+
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: x, key: f } = useContext(RepeaterContext), y = useMemo(
|
|
3692
3692
|
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
3693
|
-
index:
|
|
3694
|
-
key:
|
|
3693
|
+
index: x,
|
|
3694
|
+
key: f
|
|
3695
3695
|
}) : applyLanguage(i, d, c),
|
|
3696
|
-
[i, d, c, g, m,
|
|
3697
|
-
), b = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]),
|
|
3696
|
+
[i, d, c, g, m, x, f]
|
|
3697
|
+
), b = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), k = useMemo(
|
|
3698
3698
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
3699
3699
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
3700
3700
|
), B = useMemo(
|
|
3701
3701
|
() => ({
|
|
3702
|
-
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index":
|
|
3702
|
+
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": x },
|
|
3703
3703
|
inBuilder: !0,
|
|
3704
3704
|
lang: d || p,
|
|
3705
3705
|
...y,
|
|
3706
3706
|
...b,
|
|
3707
|
-
...
|
|
3707
|
+
...k,
|
|
3708
3708
|
...o
|
|
3709
3709
|
}),
|
|
3710
3710
|
[
|
|
@@ -3714,12 +3714,12 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3714
3714
|
p,
|
|
3715
3715
|
y,
|
|
3716
3716
|
b,
|
|
3717
|
-
|
|
3717
|
+
k,
|
|
3718
3718
|
o
|
|
3719
3719
|
]
|
|
3720
|
-
), j = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]),
|
|
3721
|
-
if (isNull(h) || !
|
|
3722
|
-
let
|
|
3720
|
+
), j = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), E = useMemo(() => get(i, "_show", !0), [i]);
|
|
3721
|
+
if (isNull(h) || !E) return null;
|
|
3722
|
+
let C = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
|
|
3723
3723
|
...B,
|
|
3724
3724
|
children: r({
|
|
3725
3725
|
_id: i._id,
|
|
@@ -3732,8 +3732,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3732
3732
|
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
3733
3733
|
})
|
|
3734
3734
|
}) });
|
|
3735
|
-
const
|
|
3736
|
-
return j ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children:
|
|
3735
|
+
const v = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: C }) : C;
|
|
3736
|
+
return j ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: v }) : v;
|
|
3737
3737
|
}, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
|
|
3738
3738
|
const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
3739
3739
|
(d) => {
|
|
@@ -3758,22 +3758,25 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3758
3758
|
] });
|
|
3759
3759
|
}, PartialBlocksRenderer = ({ partialBlockId: o }) => {
|
|
3760
3760
|
const { getPartailBlocks: n } = usePartialBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom(r)), [r]);
|
|
3761
|
-
return isEmpty(r) ? null : /* @__PURE__ */ jsx(PartialWrapper$1, { partialBlockId: o, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r }) });
|
|
3761
|
+
return isEmpty(r) ? null : /* @__PURE__ */ jsx(PartialWrapper$1, { partialBlockId: o, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r, type: "PartialBlock" }) });
|
|
3762
3762
|
}, BlocksRenderer = ({
|
|
3763
3763
|
blocks: o,
|
|
3764
3764
|
parent: n = null,
|
|
3765
|
-
splitAtoms: r = void 0
|
|
3765
|
+
splitAtoms: r = void 0,
|
|
3766
|
+
type: a = ""
|
|
3766
3767
|
}) => {
|
|
3767
|
-
const
|
|
3768
|
-
|
|
3768
|
+
const l = useGetBlockAtom(r);
|
|
3769
|
+
let i = useMemo(
|
|
3770
|
+
() => filter(o, (d) => has(d, "_id") && (isEmpty(n) ? !d._parent : d._parent === n)),
|
|
3769
3771
|
[o, n]
|
|
3770
|
-
)
|
|
3771
|
-
|
|
3772
|
+
);
|
|
3773
|
+
const c = useCallback(
|
|
3774
|
+
(d) => filter(o, (p) => p._parent === d).length > 0,
|
|
3772
3775
|
[o]
|
|
3773
3776
|
);
|
|
3774
|
-
return map(
|
|
3775
|
-
const
|
|
3776
|
-
return
|
|
3777
|
+
return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (d) => {
|
|
3778
|
+
const p = l(d._id);
|
|
3779
|
+
return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: m, partialBlockId: h, repeaterItems: x, $repeaterItemsKey: f }) => m === "Repeater" ? isArray(x) && x.map((y, b) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: b, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) }, `${g}-${b}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) : null }) }, d._id) : null;
|
|
3777
3780
|
});
|
|
3778
3781
|
}, PageBlocksRenderer = () => {
|
|
3779
3782
|
const [o] = useBlocksStore();
|
|
@@ -3841,14 +3844,14 @@ const CanvasEventsWatcher = () => {
|
|
|
3841
3844
|
}, StaticCanvas = () => {
|
|
3842
3845
|
const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
|
|
3843
3846
|
(h) => {
|
|
3844
|
-
i((
|
|
3847
|
+
i((x) => ({ ...x, width: h }));
|
|
3845
3848
|
},
|
|
3846
3849
|
[i]
|
|
3847
3850
|
);
|
|
3848
3851
|
useEffect(() => {
|
|
3849
3852
|
if (!a.current) return;
|
|
3850
|
-
const { clientWidth: h, clientHeight:
|
|
3851
|
-
i({ width: h, height:
|
|
3853
|
+
const { clientWidth: h, clientHeight: x } = a.current;
|
|
3854
|
+
i({ width: h, height: x });
|
|
3852
3855
|
}, [a, o]);
|
|
3853
3856
|
const m = useMemo(() => {
|
|
3854
3857
|
let h = IframeInitialContent;
|
|
@@ -3895,10 +3898,13 @@ const CanvasEventsWatcher = () => {
|
|
|
3895
3898
|
)
|
|
3896
3899
|
}
|
|
3897
3900
|
) });
|
|
3898
|
-
}, FallbackError = () =>
|
|
3899
|
-
|
|
3900
|
-
/* @__PURE__ */ jsx("
|
|
3901
|
-
|
|
3901
|
+
}, FallbackError = () => {
|
|
3902
|
+
const { t: o } = useTranslation();
|
|
3903
|
+
return /* @__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: [
|
|
3904
|
+
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
|
|
3905
|
+
/* @__PURE__ */ jsx("p", { children: o("Please try again.") })
|
|
3906
|
+
] }) });
|
|
3907
|
+
}, CodeEditor$1 = React__default.lazy(() => import("./code-editor-GydqqBXp.js")), CanvasArea = () => {
|
|
3902
3908
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
3903
3909
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
|
|
3904
3910
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -3954,17 +3960,17 @@ const CanvasEventsWatcher = () => {
|
|
|
3954
3960
|
spellCheck: "false",
|
|
3955
3961
|
value: l,
|
|
3956
3962
|
onChange: (d) => c(d.target.value),
|
|
3957
|
-
placeholder: a("
|
|
3963
|
+
placeholder: a("SVG_code"),
|
|
3958
3964
|
rows: 2,
|
|
3959
3965
|
className: "no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
|
|
3960
3966
|
}
|
|
3961
3967
|
)
|
|
3962
3968
|
] }),
|
|
3963
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste
|
|
3969
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG_code") })
|
|
3964
3970
|
] });
|
|
3965
3971
|
}, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
|
|
3966
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (
|
|
3967
|
-
if (!
|
|
3972
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (x) => {
|
|
3973
|
+
if (!x.trim()) {
|
|
3968
3974
|
p(!1), g("Please enter a URL");
|
|
3969
3975
|
return;
|
|
3970
3976
|
}
|
|
@@ -3988,7 +3994,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3988
3994
|
{
|
|
3989
3995
|
placeholder: h(`Enter ${r} URL`),
|
|
3990
3996
|
value: a,
|
|
3991
|
-
onChange: (
|
|
3997
|
+
onChange: (x) => l(x.target.value),
|
|
3992
3998
|
onKeyUp: () => m(a)
|
|
3993
3999
|
}
|
|
3994
4000
|
),
|
|
@@ -4027,32 +4033,40 @@ const CanvasEventsWatcher = () => {
|
|
|
4027
4033
|
] });
|
|
4028
4034
|
};
|
|
4029
4035
|
MediaManagerModal.displayName = "MediaManagerModal";
|
|
4030
|
-
const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==",
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
+
const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==", getFileName = (o) => {
|
|
4037
|
+
var l;
|
|
4038
|
+
if (!o || startsWith(o, "data")) return "";
|
|
4039
|
+
const n = ((l = o.split("/").pop()) == null ? void 0 : l.split("?")[0]) || "";
|
|
4040
|
+
return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((i) => n.toLowerCase().endsWith(i)) ? n : "";
|
|
4041
|
+
}, ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
4042
|
+
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = r.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), m = get(c, u, g ? c == null ? void 0 : c.assetId : ""), h = !!m || o !== PLACEHOLDER_IMAGE, x = (b) => {
|
|
4043
|
+
const k = isArray(b) ? first(b) : b;
|
|
4044
|
+
if (k) {
|
|
4045
|
+
n(k == null ? void 0 : k.url);
|
|
4046
|
+
const B = k == null ? void 0 : k.width, j = k == null ? void 0 : k.height, E = u.includes("mobile");
|
|
4036
4047
|
if (c != null && c._id) {
|
|
4037
|
-
const
|
|
4038
|
-
...
|
|
4039
|
-
...
|
|
4040
|
-
...
|
|
4048
|
+
const C = {
|
|
4049
|
+
...B && { [E ? "mobileWidth" : "width"]: B },
|
|
4050
|
+
...j && { [E ? "mobileHeight" : "height"]: j },
|
|
4051
|
+
...k.description && { alt: k.description }
|
|
4041
4052
|
};
|
|
4042
|
-
if (set(
|
|
4043
|
-
d([c._id],
|
|
4053
|
+
if (set(C, u, k.id), isEmpty(C)) return;
|
|
4054
|
+
d([c._id], C);
|
|
4044
4055
|
}
|
|
4045
4056
|
}
|
|
4046
|
-
},
|
|
4047
|
-
n(PLACEHOLDER_IMAGE), c != null && c._id
|
|
4048
|
-
|
|
4057
|
+
}, f = useCallback(() => {
|
|
4058
|
+
if (n(PLACEHOLDER_IMAGE), c != null && c._id) {
|
|
4059
|
+
const b = { assetId: "" }, k = u.includes("mobile");
|
|
4060
|
+
set(b, k ? "mobileWidth" : "width", ""), set(b, k ? "mobileHeight" : "height", ""), d([c._id], b);
|
|
4061
|
+
}
|
|
4062
|
+
}, [n, c == null ? void 0 : c._id, d, u]), y = getFileName(o);
|
|
4049
4063
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
|
|
4050
4064
|
o ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
|
|
4051
4065
|
/* @__PURE__ */ jsx(
|
|
4052
4066
|
"img",
|
|
4053
4067
|
{
|
|
4054
4068
|
src: o,
|
|
4055
|
-
className: "h-
|
|
4069
|
+
className: "h-14 w-14 overflow-hidden rounded-md border border-border object-cover transition duration-200 " + (m && m !== "" ? "cursor-pointer group-hover:blur-sm" : ""),
|
|
4056
4070
|
alt: ""
|
|
4057
4071
|
}
|
|
4058
4072
|
),
|
|
@@ -4060,12 +4074,12 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4060
4074
|
"button",
|
|
4061
4075
|
{
|
|
4062
4076
|
type: "button",
|
|
4063
|
-
onClick:
|
|
4077
|
+
onClick: f,
|
|
4064
4078
|
className: "absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
|
|
4065
4079
|
children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" })
|
|
4066
4080
|
}
|
|
4067
4081
|
),
|
|
4068
|
-
m && m !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect:
|
|
4082
|
+
m && m !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, assetId: m, children: /* @__PURE__ */ jsx(
|
|
4069
4083
|
"button",
|
|
4070
4084
|
{
|
|
4071
4085
|
type: "button",
|
|
@@ -4073,11 +4087,11 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4073
4087
|
children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-4 w-4 text-white" })
|
|
4074
4088
|
}
|
|
4075
4089
|
) })
|
|
4076
|
-
] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect:
|
|
4090
|
+
] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, mode: "image", assetId: m, children: /* @__PURE__ */ jsx("div", { className: "h-14 w-14 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
|
|
4077
4091
|
/* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
|
|
4078
4092
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4079
|
-
/* @__PURE__ */ jsx(
|
|
4080
|
-
/* @__PURE__ */ jsx("small", { className: "-
|
|
4093
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 max-w-[250px] truncate pr-2 text-xs text-gray-400", children: y }),
|
|
4094
|
+
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 w-fit cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: !isEmpty(o) && o !== PLACEHOLDER_IMAGE ? l("Replace image") : l("Choose image") }) })
|
|
4081
4095
|
] }),
|
|
4082
4096
|
/* @__PURE__ */ jsx(
|
|
4083
4097
|
"input",
|
|
@@ -4087,11 +4101,11 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4087
4101
|
autoCorrect: "off",
|
|
4088
4102
|
spellCheck: "false",
|
|
4089
4103
|
type: "url",
|
|
4090
|
-
className: "text-xs",
|
|
4104
|
+
className: "!hidden text-xs",
|
|
4091
4105
|
placeholder: l("Enter image URL"),
|
|
4092
4106
|
value: o,
|
|
4093
|
-
onBlur: ({ target: { value:
|
|
4094
|
-
onChange: (
|
|
4107
|
+
onBlur: ({ target: { value: b } }) => a(r, b),
|
|
4108
|
+
onChange: (b) => n(b.target.value)
|
|
4095
4109
|
}
|
|
4096
4110
|
)
|
|
4097
4111
|
] })
|
|
@@ -4099,24 +4113,24 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4099
4113
|
}, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
|
|
4100
4114
|
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
|
|
4101
4115
|
(m) => {
|
|
4102
|
-
const h = (
|
|
4103
|
-
m.type === "object" ? (l((
|
|
4116
|
+
const h = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
|
|
4117
|
+
m.type === "object" ? (l((x) => [...x, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
|
|
4104
4118
|
},
|
|
4105
4119
|
[a, n, r]
|
|
4106
4120
|
), u = React__default.useCallback(() => {
|
|
4107
4121
|
if (a.length > 0) {
|
|
4108
4122
|
const m = a.slice(0, -1);
|
|
4109
|
-
l(m), c(m.reduce((h,
|
|
4123
|
+
l(m), c(m.reduce((h, x) => h[x], o));
|
|
4110
4124
|
}
|
|
4111
4125
|
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: d(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
|
|
4112
4126
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
4113
4127
|
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
4114
4128
|
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
4115
|
-
/* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
|
|
4129
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: t("No option found.") }),
|
|
4116
4130
|
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
4117
4131
|
a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: u, className: "flex items-center text-sm", children: [
|
|
4118
4132
|
/* @__PURE__ */ jsx(ChevronLeftIcon, { className: "mr-2 h-4 w-4" }),
|
|
4119
|
-
"Back"
|
|
4133
|
+
t("Back")
|
|
4120
4134
|
] }),
|
|
4121
4135
|
g.map((m) => /* @__PURE__ */ jsxs(
|
|
4122
4136
|
CommandItem,
|
|
@@ -4128,7 +4142,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4128
4142
|
children: [
|
|
4129
4143
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
|
|
4130
4144
|
startsWith(m.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(m.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(IdCardIcon, {}) : null,
|
|
4131
|
-
startsWith(m.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(m.key, COLLECTION_PREFIX) ? m.key.replace(COLLECTION_PREFIX, "") : m.key
|
|
4145
|
+
startsWith(m.key, REPEATER_PREFIX) ? t("Repeater Data") : startsWith(m.key, COLLECTION_PREFIX) ? m.key.replace(COLLECTION_PREFIX, "") : m.key
|
|
4132
4146
|
] }),
|
|
4133
4147
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4134
4148
|
r === "object" && m.type === "object" && /* @__PURE__ */ jsx(
|
|
@@ -4140,7 +4154,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4140
4154
|
onClick: (h) => {
|
|
4141
4155
|
h.stopPropagation(), n([...a, m.key].join("."), r);
|
|
4142
4156
|
},
|
|
4143
|
-
children: "Select"
|
|
4157
|
+
children: t("Select")
|
|
4144
4158
|
}
|
|
4145
4159
|
),
|
|
4146
4160
|
m.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 opacity-50" }) })
|
|
@@ -4161,7 +4175,7 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4161
4175
|
Button,
|
|
4162
4176
|
{
|
|
4163
4177
|
size: "sm",
|
|
4164
|
-
variant: "
|
|
4178
|
+
variant: "ghost",
|
|
4165
4179
|
className: "h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",
|
|
4166
4180
|
role: "combobox",
|
|
4167
4181
|
"aria-expanded": a,
|
|
@@ -4177,7 +4191,7 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4177
4191
|
) })
|
|
4178
4192
|
}
|
|
4179
4193
|
) }) }),
|
|
4180
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: "Add field" })
|
|
4194
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: t("Add field") })
|
|
4181
4195
|
] }),
|
|
4182
4196
|
/* @__PURE__ */ jsx(PopoverContent, { className: "z-[1000]! relative mr-3 w-[300px] p-0", children: /* @__PURE__ */ jsx(
|
|
4183
4197
|
PathDropdown,
|
|
@@ -4199,7 +4213,7 @@ const DataBindingSelector = ({
|
|
|
4199
4213
|
}) => {
|
|
4200
4214
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4201
4215
|
if (i.length === 1) return "";
|
|
4202
|
-
const g = i.find((
|
|
4216
|
+
const g = i.find((x) => x._type === "Repeater"), h = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4203
4217
|
return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${g._id}` : h}`;
|
|
4204
4218
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4205
4219
|
(g, m) => {
|
|
@@ -4207,44 +4221,44 @@ const DataBindingSelector = ({
|
|
|
4207
4221
|
n(`{{${g}}}`, {}, r);
|
|
4208
4222
|
return;
|
|
4209
4223
|
}
|
|
4210
|
-
const h = (b) => /[.,!?;:]/.test(b),
|
|
4211
|
-
let j = "",
|
|
4212
|
-
const
|
|
4213
|
-
return
|
|
4214
|
-
text: j + B +
|
|
4224
|
+
const h = (b) => /[.,!?;:]/.test(b), x = (b, k, B) => {
|
|
4225
|
+
let j = "", E = "";
|
|
4226
|
+
const C = k > 0 ? b[k - 1] : "", v = k < b.length ? b[k] : "";
|
|
4227
|
+
return k > 0 && (C === "." || !h(C) && C !== " ") && (j = " "), k < b.length && !h(v) && v !== " " && (E = " "), {
|
|
4228
|
+
text: j + B + E,
|
|
4215
4229
|
prefixLength: j.length,
|
|
4216
|
-
suffixLength:
|
|
4230
|
+
suffixLength: E.length
|
|
4217
4231
|
};
|
|
4218
|
-
},
|
|
4219
|
-
if (!
|
|
4232
|
+
}, f = document.getElementById(r);
|
|
4233
|
+
if (!f) return;
|
|
4220
4234
|
const y = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
|
|
4221
4235
|
if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
|
|
4222
4236
|
const b = y.__chaiRTE;
|
|
4223
4237
|
if (b) {
|
|
4224
|
-
const
|
|
4238
|
+
const k = `{{${g}}}`;
|
|
4225
4239
|
b.commands.focus();
|
|
4226
4240
|
const { from: B, to: j } = b.state.selection;
|
|
4227
4241
|
if (B !== j)
|
|
4228
|
-
b.chain().deleteSelection().insertContent(
|
|
4242
|
+
b.chain().deleteSelection().insertContent(k).run();
|
|
4229
4243
|
else {
|
|
4230
|
-
const { state:
|
|
4231
|
-
let
|
|
4232
|
-
|
|
4233
|
-
let
|
|
4234
|
-
|
|
4244
|
+
const { state: C } = b, v = C.selection.from, S = C.doc.textBetween(Math.max(0, v - 1), v), I = C.doc.textBetween(v, Math.min(v + 1, C.doc.content.size));
|
|
4245
|
+
let A = "";
|
|
4246
|
+
v > 0 && S !== " " && !h(S) && (A = " ");
|
|
4247
|
+
let w = "";
|
|
4248
|
+
I && I !== " " && !h(I) && (w = " "), b.chain().insertContent(A + k + w).run();
|
|
4235
4249
|
}
|
|
4236
4250
|
setTimeout(() => n(b.getHTML(), {}, r), 100);
|
|
4237
4251
|
return;
|
|
4238
4252
|
}
|
|
4239
4253
|
} else {
|
|
4240
|
-
const b =
|
|
4241
|
-
if (j >
|
|
4242
|
-
const
|
|
4243
|
-
n(
|
|
4254
|
+
const b = f, k = b.selectionStart || 0, B = b.value || "", j = b.selectionEnd || k;
|
|
4255
|
+
if (j > k) {
|
|
4256
|
+
const I = `{{${g}}}`, { text: A } = x(B, k, I), w = B.slice(0, k) + A + B.slice(j);
|
|
4257
|
+
n(w, {}, r);
|
|
4244
4258
|
return;
|
|
4245
4259
|
}
|
|
4246
|
-
const
|
|
4247
|
-
n(
|
|
4260
|
+
const C = `{{${g}}}`, { text: v } = x(B, k, C), S = B.slice(0, k) + v + B.slice(k);
|
|
4261
|
+
n(S, {}, r);
|
|
4248
4262
|
}
|
|
4249
4263
|
},
|
|
4250
4264
|
[r, n, a, c == null ? void 0 : c._id, d]
|
|
@@ -4265,112 +4279,118 @@ const DataBindingSelector = ({
|
|
|
4265
4279
|
pageTypes: n,
|
|
4266
4280
|
onChange: r
|
|
4267
4281
|
}) => {
|
|
4268
|
-
var
|
|
4269
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (
|
|
4282
|
+
var I;
|
|
4283
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (A, w) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [x, f] = useState([]), [y, b] = useState(-1), k = useRef(null), B = (I = n == null ? void 0 : n.find((A) => A.key === u)) == null ? void 0 : I.name;
|
|
4270
4284
|
useEffect(() => {
|
|
4271
|
-
if (h(""),
|
|
4272
|
-
const
|
|
4273
|
-
g(
|
|
4274
|
-
const
|
|
4275
|
-
|
|
4285
|
+
if (h(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4286
|
+
const A = split(o, ":"), w = get(A, 1, "page") || "page";
|
|
4287
|
+
g(w), (async () => {
|
|
4288
|
+
const _ = await l(w, [get(A, 2, "page")]);
|
|
4289
|
+
_ && Array.isArray(_) && h(get(_, [0, "name"], ""));
|
|
4276
4290
|
})();
|
|
4277
4291
|
}, [o]);
|
|
4278
4292
|
const j = useDebouncedCallback(
|
|
4279
|
-
async (
|
|
4280
|
-
if (isEmpty(
|
|
4281
|
-
|
|
4293
|
+
async (A) => {
|
|
4294
|
+
if (isEmpty(A))
|
|
4295
|
+
f([]);
|
|
4282
4296
|
else {
|
|
4283
|
-
const
|
|
4284
|
-
|
|
4297
|
+
const w = await l(u, A);
|
|
4298
|
+
f(w);
|
|
4285
4299
|
}
|
|
4286
4300
|
c(!1), b(-1);
|
|
4287
4301
|
},
|
|
4288
4302
|
[u],
|
|
4289
4303
|
300
|
|
4290
|
-
),
|
|
4291
|
-
const
|
|
4292
|
-
|
|
4293
|
-
},
|
|
4294
|
-
switch (
|
|
4304
|
+
), E = (A) => {
|
|
4305
|
+
const w = ["pageType", u, A.id];
|
|
4306
|
+
w[1] && (r(w.join(":")), h(A.name), p(!1), f([]), b(-1));
|
|
4307
|
+
}, C = (A) => {
|
|
4308
|
+
switch (A.key) {
|
|
4295
4309
|
case "ArrowDown":
|
|
4296
|
-
|
|
4310
|
+
A.preventDefault(), b((w) => w < x.length - 1 ? w + 1 : w);
|
|
4297
4311
|
break;
|
|
4298
4312
|
case "ArrowUp":
|
|
4299
|
-
|
|
4313
|
+
A.preventDefault(), b((w) => w > 0 ? w - 1 : w);
|
|
4300
4314
|
break;
|
|
4301
4315
|
case "Enter":
|
|
4302
|
-
if (
|
|
4303
|
-
y >= 0 &&
|
|
4316
|
+
if (A.preventDefault(), x.length === 0) return;
|
|
4317
|
+
y >= 0 && E(x[y]);
|
|
4304
4318
|
break;
|
|
4305
4319
|
case "Escape":
|
|
4306
|
-
|
|
4320
|
+
A.preventDefault(), v();
|
|
4307
4321
|
break;
|
|
4308
4322
|
}
|
|
4309
4323
|
};
|
|
4310
4324
|
useEffect(() => {
|
|
4311
|
-
if (y >= 0 &&
|
|
4312
|
-
const
|
|
4313
|
-
|
|
4325
|
+
if (y >= 0 && k.current) {
|
|
4326
|
+
const A = k.current.children[y];
|
|
4327
|
+
A == null || A.scrollIntoView({ block: "nearest" });
|
|
4314
4328
|
}
|
|
4315
4329
|
}, [y]);
|
|
4316
|
-
const
|
|
4317
|
-
h(""),
|
|
4318
|
-
},
|
|
4319
|
-
h(
|
|
4330
|
+
const v = () => {
|
|
4331
|
+
h(""), f([]), b(-1), p(!1), r("");
|
|
4332
|
+
}, S = (A) => {
|
|
4333
|
+
h(A), p(!isEmpty(A)), c(!0), j(A);
|
|
4320
4334
|
};
|
|
4321
4335
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4322
|
-
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (
|
|
4336
|
+
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (A) => g(A.target.value), children: map(n, (A) => /* @__PURE__ */ jsx("option", { value: A.key, children: A.name }, A.key)) }),
|
|
4323
4337
|
u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
|
|
4324
4338
|
/* @__PURE__ */ jsx(
|
|
4325
4339
|
"input",
|
|
4326
4340
|
{
|
|
4327
4341
|
type: "text",
|
|
4328
4342
|
value: m,
|
|
4329
|
-
onChange: (
|
|
4330
|
-
onKeyDown:
|
|
4343
|
+
onChange: (A) => S(A.target.value),
|
|
4344
|
+
onKeyDown: C,
|
|
4331
4345
|
placeholder: a(`Search ${B ?? ""}`),
|
|
4332
4346
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4333
4347
|
}
|
|
4334
4348
|
),
|
|
4335
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick:
|
|
4349
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: v, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
|
|
4336
4350
|
] }),
|
|
4337
|
-
(i || !isEmpty(
|
|
4351
|
+
(i || !isEmpty(x) || d && isEmpty(x)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4338
4352
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4339
4353
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4340
|
-
] }) : d && isEmpty(
|
|
4354
|
+
] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4341
4355
|
a("No results found for"),
|
|
4342
4356
|
' "',
|
|
4343
4357
|
m,
|
|
4344
4358
|
'"'
|
|
4345
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4359
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: k, children: map(x == null ? void 0 : x.slice(0, 20), (A, w) => /* @__PURE__ */ jsxs(
|
|
4346
4360
|
"li",
|
|
4347
4361
|
{
|
|
4348
|
-
onClick: () =>
|
|
4349
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(
|
|
4362
|
+
onClick: () => E(A),
|
|
4363
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(A.id) ? "bg-blue-200" : w === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4350
4364
|
children: [
|
|
4351
|
-
|
|
4365
|
+
A.name,
|
|
4352
4366
|
" ",
|
|
4353
|
-
|
|
4367
|
+
A.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
|
|
4354
4368
|
"( ",
|
|
4355
|
-
|
|
4369
|
+
A.slug,
|
|
4356
4370
|
" )"
|
|
4357
4371
|
] })
|
|
4358
4372
|
]
|
|
4359
4373
|
},
|
|
4360
|
-
|
|
4374
|
+
A.id
|
|
4361
4375
|
)) }) })
|
|
4362
4376
|
] });
|
|
4363
4377
|
}, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
|
|
4364
|
-
const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n, p = useBuilderProp("pageTypes", []), u
|
|
4378
|
+
const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: g, languages: m } = useLanguages(), h = useMemo(
|
|
4379
|
+
() => isEmpty(m) ? "" : isEmpty(u) ? g : u,
|
|
4380
|
+
[m, u, g]
|
|
4381
|
+
), x = useMemo(() => get(LANGUAGES, h, h), [h]), f = i === "pageType" && isEmpty(p) ? "url" : i;
|
|
4365
4382
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4366
4383
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-x-2 text-xs font-medium", children: [
|
|
4367
|
-
|
|
4384
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4385
|
+
(o == null ? void 0 : o.title) ?? "Link",
|
|
4386
|
+
/* @__PURE__ */ jsx("span", { className: "pl-1 text-[9px] text-zinc-400", children: x })
|
|
4387
|
+
] }),
|
|
4368
4388
|
/* @__PURE__ */ jsx(
|
|
4369
4389
|
DataBindingSelector,
|
|
4370
4390
|
{
|
|
4371
4391
|
schema: o,
|
|
4372
|
-
onChange: (
|
|
4373
|
-
|
|
4392
|
+
onChange: (y) => {
|
|
4393
|
+
r({ ...n, href: y, ...f === "pageType" ? { type: "url" } : {} });
|
|
4374
4394
|
},
|
|
4375
4395
|
id: `root.${a}.href`,
|
|
4376
4396
|
formData: n
|
|
@@ -4378,7 +4398,7 @@ const DataBindingSelector = ({
|
|
|
4378
4398
|
)
|
|
4379
4399
|
] }),
|
|
4380
4400
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1.5", children: [
|
|
4381
|
-
/* @__PURE__ */ jsx("select", { name: "type", value: i, onChange: (
|
|
4401
|
+
/* @__PURE__ */ jsx("select", { name: "type", value: i, onChange: (y) => r({ ...n, type: y.target.value }), children: map(
|
|
4382
4402
|
[
|
|
4383
4403
|
...isEmpty(p) ? [] : [{ const: "pageType", title: l("Goto Page") }],
|
|
4384
4404
|
{ const: "url", title: l("Open URL") },
|
|
@@ -4386,14 +4406,14 @@ const DataBindingSelector = ({
|
|
|
4386
4406
|
{ const: "telephone", title: l("Call Phone") },
|
|
4387
4407
|
{ const: "scroll", title: l("Scroll to element") }
|
|
4388
4408
|
],
|
|
4389
|
-
(
|
|
4409
|
+
(y) => /* @__PURE__ */ jsx("option", { value: y.const, children: y.title }, y.const)
|
|
4390
4410
|
) }),
|
|
4391
|
-
|
|
4411
|
+
f === "pageType" && !isEmpty(p) ? /* @__PURE__ */ jsx(
|
|
4392
4412
|
PageTypeField,
|
|
4393
4413
|
{
|
|
4394
4414
|
href: c,
|
|
4395
4415
|
pageTypes: p,
|
|
4396
|
-
onChange: (
|
|
4416
|
+
onChange: (y) => r({ ...n, href: y })
|
|
4397
4417
|
}
|
|
4398
4418
|
) : null,
|
|
4399
4419
|
/* @__PURE__ */ jsx(
|
|
@@ -4405,13 +4425,13 @@ const DataBindingSelector = ({
|
|
|
4405
4425
|
spellCheck: "false",
|
|
4406
4426
|
name: "href",
|
|
4407
4427
|
type: "text",
|
|
4408
|
-
className:
|
|
4428
|
+
className: f === "pageType" ? "!hidden" : "",
|
|
4409
4429
|
value: c,
|
|
4410
|
-
onChange: (
|
|
4430
|
+
onChange: (y) => r({ ...n, href: y.target.value }),
|
|
4411
4431
|
placeholder: l(i === "url" ? "Enter URL" : i === "scroll" ? "#ElementID" : "Enter details")
|
|
4412
4432
|
}
|
|
4413
4433
|
),
|
|
4414
|
-
|
|
4434
|
+
f === "url" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
4415
4435
|
/* @__PURE__ */ jsx(
|
|
4416
4436
|
"input",
|
|
4417
4437
|
{
|
|
@@ -4657,15 +4677,15 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4657
4677
|
if (!u) return;
|
|
4658
4678
|
const h = `{{${m}}}`;
|
|
4659
4679
|
u.commands.focus();
|
|
4660
|
-
const { from:
|
|
4661
|
-
if (
|
|
4680
|
+
const { from: x, to: f } = u.state.selection;
|
|
4681
|
+
if (x !== f)
|
|
4662
4682
|
u.chain().deleteSelection().insertContent(h).run();
|
|
4663
4683
|
else {
|
|
4664
|
-
const { state: b } = u,
|
|
4665
|
-
let
|
|
4666
|
-
|
|
4667
|
-
let
|
|
4668
|
-
j && j !== " " && !/[.,!?;:]/.test(j) && (
|
|
4684
|
+
const { state: b } = u, k = b.selection.from, B = b.doc.textBetween(Math.max(0, k - 1), k), j = b.doc.textBetween(k, Math.min(k + 1, b.doc.content.size));
|
|
4685
|
+
let E = "";
|
|
4686
|
+
k > 0 && B !== " " && !/[.,!?;:]/.test(B) && (E = " ");
|
|
4687
|
+
let C = "";
|
|
4688
|
+
j && j !== " " && !/[.,!?;:]/.test(j) && (C = " "), u.chain().insertContent(E + h + C).run();
|
|
4669
4689
|
}
|
|
4670
4690
|
};
|
|
4671
4691
|
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
@@ -4704,13 +4724,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4704
4724
|
})
|
|
4705
4725
|
],
|
|
4706
4726
|
content: r || "",
|
|
4707
|
-
onUpdate: ({ editor:
|
|
4708
|
-
const
|
|
4709
|
-
a(
|
|
4727
|
+
onUpdate: ({ editor: x }) => {
|
|
4728
|
+
const f = x.getHTML();
|
|
4729
|
+
a(f), c || u(f);
|
|
4710
4730
|
},
|
|
4711
|
-
onBlur: ({ editor:
|
|
4712
|
-
const
|
|
4713
|
-
l(o,
|
|
4731
|
+
onBlur: ({ editor: x }) => {
|
|
4732
|
+
const f = x.getHTML();
|
|
4733
|
+
l(o, f);
|
|
4714
4734
|
},
|
|
4715
4735
|
editorProps: {
|
|
4716
4736
|
attributes: {
|
|
@@ -4723,8 +4743,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4723
4743
|
}, [g]), useEffect(() => {
|
|
4724
4744
|
u(r || "");
|
|
4725
4745
|
}, [r]);
|
|
4726
|
-
const m = (
|
|
4727
|
-
a(
|
|
4746
|
+
const m = (x) => {
|
|
4747
|
+
a(x);
|
|
4728
4748
|
}, h = () => {
|
|
4729
4749
|
d(!1), g && g.commands.setContent(p);
|
|
4730
4750
|
};
|
|
@@ -4757,24 +4777,24 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4757
4777
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4758
4778
|
}, [o, u]);
|
|
4759
4779
|
const m = () => {
|
|
4760
|
-
const
|
|
4761
|
-
if (
|
|
4762
|
-
const y = (
|
|
4780
|
+
const f = findIndex(u, { _id: g });
|
|
4781
|
+
if (f > -1) {
|
|
4782
|
+
const y = (f + 1) % u.length, b = get(u, [y, "_id"]);
|
|
4763
4783
|
if (!b) return;
|
|
4764
4784
|
n({ ...o, currentSlide: b }), c([b]);
|
|
4765
4785
|
}
|
|
4766
4786
|
}, h = () => {
|
|
4767
|
-
const
|
|
4768
|
-
if (
|
|
4769
|
-
const y = (
|
|
4787
|
+
const f = findIndex(u, { _id: g });
|
|
4788
|
+
if (f > -1) {
|
|
4789
|
+
const y = (f - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
|
|
4770
4790
|
if (!b) return;
|
|
4771
4791
|
n({ ...o, currentSlide: b }), c([b]);
|
|
4772
4792
|
}
|
|
4773
|
-
},
|
|
4774
|
-
const
|
|
4793
|
+
}, x = () => {
|
|
4794
|
+
const f = i(
|
|
4775
4795
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4776
4796
|
p == null ? void 0 : p._id
|
|
4777
|
-
), y =
|
|
4797
|
+
), y = f == null ? void 0 : f._id;
|
|
4778
4798
|
y && (n({ ...o, currentSlide: y }), c([y]));
|
|
4779
4799
|
};
|
|
4780
4800
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
@@ -4792,7 +4812,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4792
4812
|
/* @__PURE__ */ jsxs(
|
|
4793
4813
|
"button",
|
|
4794
4814
|
{
|
|
4795
|
-
onClick:
|
|
4815
|
+
onClick: x,
|
|
4796
4816
|
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",
|
|
4797
4817
|
children: [
|
|
4798
4818
|
/* @__PURE__ */ jsx(PlusCircledIcon, { className: "h-3 w-3" }),
|
|
@@ -4853,8 +4873,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4853
4873
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4854
4874
|
className: "text-xs",
|
|
4855
4875
|
pattern: "[0-9]*",
|
|
4856
|
-
onChange: (
|
|
4857
|
-
let y =
|
|
4876
|
+
onChange: (f) => {
|
|
4877
|
+
let y = f.target.value;
|
|
4858
4878
|
y.length && (y = y.replace("-", "")), n({ ...o, autoplayInterval: y });
|
|
4859
4879
|
}
|
|
4860
4880
|
}
|
|
@@ -4949,98 +4969,116 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4949
4969
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
|
|
4950
4970
|
u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
|
|
4951
4971
|
] }) });
|
|
4952
|
-
}, JSONFormFieldTemplate = ({
|
|
4953
|
-
id: o,
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
schema: p,
|
|
4962
|
-
formData: u,
|
|
4963
|
-
onChange: g
|
|
4964
|
-
}) => {
|
|
4965
|
-
const { selectedLang: m, fallbackLang: h, languages: f } = useLanguages(), x = useMemo(
|
|
4966
|
-
() => isEmpty(f) ? "" : isEmpty(m) ? h : m,
|
|
4967
|
-
[f, m, h]
|
|
4968
|
-
), y = useMemo(() => get(LANGUAGES, x, x), [x]), b = usePageExternalData(), C = useSelectedBlock(), B = useRegisteredChaiBlocks(), j = useMemo(
|
|
4969
|
-
() => get(B, [C == null ? void 0 : C._type, "i18nProps"], []),
|
|
4970
|
-
[B, C == null ? void 0 : C._type]
|
|
4971
|
-
), [_, A] = useState(null);
|
|
4972
|
-
if (c)
|
|
4972
|
+
}, JSONFormFieldTemplate = (o) => {
|
|
4973
|
+
const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: g, onChange: m } = o, { selectedLang: h, fallbackLang: x, languages: f } = useLanguages(), y = useMemo(
|
|
4974
|
+
() => isEmpty(f) ? "" : isEmpty(h) ? x : h,
|
|
4975
|
+
[f, h, x]
|
|
4976
|
+
), b = useMemo(() => get(LANGUAGES, y, y), [y]), k = usePageExternalData(), B = useSelectedBlock(), j = useRegisteredChaiBlocks(), E = useMemo(
|
|
4977
|
+
() => get(j, [B == null ? void 0 : B._type, "i18nProps"], []),
|
|
4978
|
+
[j, B == null ? void 0 : B._type]
|
|
4979
|
+
), [C, v] = useState(null);
|
|
4980
|
+
if (d)
|
|
4973
4981
|
return null;
|
|
4974
|
-
if (
|
|
4975
|
-
const
|
|
4976
|
-
if (
|
|
4977
|
-
const
|
|
4978
|
-
return /* @__PURE__ */ jsxs("div", { className: `${
|
|
4979
|
-
|
|
4982
|
+
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
|
|
4983
|
+
const I = E == null ? void 0 : E.includes(n.replace("root.", ""));
|
|
4984
|
+
if (u.type === "array") {
|
|
4985
|
+
const _ = C === n;
|
|
4986
|
+
return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
|
|
4987
|
+
u.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
|
|
4980
4988
|
"label",
|
|
4981
4989
|
{
|
|
4982
|
-
htmlFor:
|
|
4983
|
-
onClick: () =>
|
|
4990
|
+
htmlFor: n,
|
|
4991
|
+
onClick: () => v(_ ? null : n),
|
|
4984
4992
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4985
4993
|
children: [
|
|
4986
|
-
|
|
4994
|
+
_ ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }),
|
|
4987
4995
|
/* @__PURE__ */ jsx(ListBulletIcon, { className: "h-3 w-3" }),
|
|
4988
|
-
/* @__PURE__ */ jsx("span", { className: "leading-tight", children:
|
|
4996
|
+
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: a }),
|
|
4989
4997
|
" ",
|
|
4990
|
-
/* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children:
|
|
4991
|
-
|
|
4998
|
+
/* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: g == null ? void 0 : g.length }) }),
|
|
4999
|
+
u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4992
5000
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
4993
5001
|
InfoCircledIcon,
|
|
4994
5002
|
{
|
|
4995
5003
|
className: "h-3 w-3 text-muted-foreground/70",
|
|
4996
|
-
onClick: (
|
|
4997
|
-
onMouseDown: (
|
|
5004
|
+
onClick: (L) => L.stopPropagation(),
|
|
5005
|
+
onMouseDown: (L) => L.stopPropagation()
|
|
4998
5006
|
}
|
|
4999
5007
|
) }),
|
|
5000
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children:
|
|
5008
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
|
|
5001
5009
|
] }) })
|
|
5002
5010
|
]
|
|
5003
5011
|
}
|
|
5004
5012
|
) }),
|
|
5005
|
-
(
|
|
5006
|
-
a,
|
|
5013
|
+
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: l }) : /* @__PURE__ */ jsxs("div", { className: `${_ ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
5007
5014
|
l,
|
|
5008
|
-
i
|
|
5015
|
+
i,
|
|
5016
|
+
c
|
|
5009
5017
|
] })
|
|
5010
5018
|
] });
|
|
5011
5019
|
}
|
|
5012
|
-
|
|
5013
|
-
|
|
5020
|
+
const A = n.replace("root.", ""), w = E.includes(A) && !isEmpty(h) && isEmpty(g);
|
|
5021
|
+
return /* @__PURE__ */ jsxs("div", { className: r, children: [
|
|
5022
|
+
u.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
5014
5023
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
5015
|
-
/* @__PURE__ */ jsxs("label", { htmlFor:
|
|
5016
|
-
|
|
5024
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: n, className: u.type === "object" ? "pb-2" : "", children: [
|
|
5025
|
+
a,
|
|
5017
5026
|
" ",
|
|
5018
|
-
|
|
5027
|
+
I && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5019
5028
|
" ",
|
|
5020
|
-
|
|
5029
|
+
b
|
|
5021
5030
|
] }),
|
|
5022
|
-
|
|
5031
|
+
p && u.type !== "object" ? " *" : null
|
|
5023
5032
|
] }),
|
|
5024
|
-
|
|
5033
|
+
u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5025
5034
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(InfoCircledIcon, { className: "h-3 w-3 text-muted-foreground/70" }) }),
|
|
5026
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children:
|
|
5035
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
|
|
5027
5036
|
] }) })
|
|
5028
5037
|
] }),
|
|
5029
|
-
!
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5038
|
+
!u.enum && !u.oneOf && k && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
|
|
5039
|
+
w ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5040
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
5041
|
+
"svg",
|
|
5042
|
+
{
|
|
5043
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5044
|
+
width: "24",
|
|
5045
|
+
height: "24",
|
|
5046
|
+
viewBox: "0 0 24 24",
|
|
5047
|
+
fill: "none",
|
|
5048
|
+
stroke: "currentColor",
|
|
5049
|
+
"stroke-width": "2",
|
|
5050
|
+
"stroke-linecap": "round",
|
|
5051
|
+
"stroke-linejoin": "round",
|
|
5052
|
+
className: "lucide lucide-triangle-alert-icon lucide-triangle-alert h-3 w-3 text-orange-400",
|
|
5053
|
+
children: [
|
|
5054
|
+
/* @__PURE__ */ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }),
|
|
5055
|
+
/* @__PURE__ */ jsx("path", { d: "M12 9v4" }),
|
|
5056
|
+
/* @__PURE__ */ jsx("path", { d: "M12 17h.01" })
|
|
5057
|
+
]
|
|
5058
|
+
}
|
|
5059
|
+
) }),
|
|
5060
|
+
/* @__PURE__ */ jsxs(TooltipContent, { className: "max-w-xs", children: [
|
|
5061
|
+
"No translation provided. ",
|
|
5062
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
5063
|
+
"Using default language value."
|
|
5064
|
+
] })
|
|
5065
|
+
] }) : null,
|
|
5066
|
+
/* @__PURE__ */ jsx(
|
|
5067
|
+
DataBindingSelector,
|
|
5068
|
+
{
|
|
5069
|
+
schema: u,
|
|
5070
|
+
onChange: (_) => {
|
|
5071
|
+
m(_, g, n);
|
|
5072
|
+
},
|
|
5073
|
+
id: n,
|
|
5074
|
+
formData: g
|
|
5075
|
+
}
|
|
5076
|
+
)
|
|
5077
|
+
] })
|
|
5040
5078
|
] }),
|
|
5041
|
-
a,
|
|
5042
5079
|
l,
|
|
5043
|
-
i
|
|
5080
|
+
i,
|
|
5081
|
+
c
|
|
5044
5082
|
] });
|
|
5045
5083
|
}, RepeaterBindingWidget = ({ value: o, onChange: n }) => {
|
|
5046
5084
|
var i;
|
|
@@ -5137,43 +5175,43 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5137
5175
|
}), a;
|
|
5138
5176
|
};
|
|
5139
5177
|
function BlockSettings() {
|
|
5140
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m),
|
|
5141
|
-
|
|
5142
|
-
},
|
|
5143
|
-
debounce(({ formData:
|
|
5144
|
-
|
|
5178
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), x = ({ formData: C }, v, S) => {
|
|
5179
|
+
v && (c == null ? void 0 : c._id) === n._id && a([n._id], { [v]: get(C, v) }, S);
|
|
5180
|
+
}, f = useCallback(
|
|
5181
|
+
debounce(({ formData: C }, v, S) => {
|
|
5182
|
+
x({ formData: C }, v, S), d(C);
|
|
5145
5183
|
}, 1500),
|
|
5146
5184
|
[n == null ? void 0 : n._id, o]
|
|
5147
|
-
), y = ({ formData:
|
|
5148
|
-
|
|
5149
|
-
}, b = ({ formData:
|
|
5150
|
-
|
|
5151
|
-
}, { schema:
|
|
5152
|
-
const
|
|
5153
|
-
if (!
|
|
5185
|
+
), y = ({ formData: C }, v) => {
|
|
5186
|
+
v && (r([n._id], { [v]: get(C, v) }), f({ formData: C }, v, { [v]: get(c, v) }));
|
|
5187
|
+
}, b = ({ formData: C }, v) => {
|
|
5188
|
+
v && (r([g._id], { [v]: get(C, v) }), f({ formData: C }, v, { [v]: get(c, v) }));
|
|
5189
|
+
}, { schema: k, uiSchema: B } = useMemo(() => {
|
|
5190
|
+
const C = n == null ? void 0 : n._type;
|
|
5191
|
+
if (!C)
|
|
5154
5192
|
return { schema: {}, uiSchema: {} };
|
|
5155
5193
|
try {
|
|
5156
|
-
const { schema:
|
|
5157
|
-
if (
|
|
5158
|
-
const
|
|
5159
|
-
startsWith(
|
|
5194
|
+
const { schema: v, uiSchema: S } = getBlockFormSchemas(C);
|
|
5195
|
+
if (C === "Repeater") {
|
|
5196
|
+
const I = get(n, "repeaterItems", "");
|
|
5197
|
+
startsWith(I, `{{${COLLECTION_PREFIX}`) ? (set(S, "filter", { "ui:widget": "collectionSelect" }), set(S, "sort", { "ui:widget": "collectionSelect" })) : (set(S, "filter", { "ui:widget": "hidden" }), set(S, "sort", { "ui:widget": "hidden" }));
|
|
5160
5198
|
}
|
|
5161
|
-
return { schema:
|
|
5199
|
+
return { schema: v, uiSchema: S };
|
|
5162
5200
|
} catch {
|
|
5163
5201
|
return { schema: {}, uiSchema: {} };
|
|
5164
5202
|
}
|
|
5165
|
-
}, [n]), { wrapperSchema: j, wrapperUiSchema:
|
|
5203
|
+
}, [n]), { wrapperSchema: j, wrapperUiSchema: E } = useMemo(() => {
|
|
5166
5204
|
if (!g || !(g != null && g._type))
|
|
5167
5205
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5168
|
-
const
|
|
5169
|
-
return { wrapperSchema:
|
|
5206
|
+
const C = g == null ? void 0 : g._type, { schema: v = {}, uiSchema: S = {} } = getBlockFormSchemas(C);
|
|
5207
|
+
return { wrapperSchema: v, wrapperUiSchema: S };
|
|
5170
5208
|
}, [g]);
|
|
5171
5209
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5172
5210
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5173
5211
|
/* @__PURE__ */ jsxs(
|
|
5174
5212
|
"div",
|
|
5175
5213
|
{
|
|
5176
|
-
onClick: () => u((
|
|
5214
|
+
onClick: () => u((C) => !C),
|
|
5177
5215
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5178
5216
|
children: [
|
|
5179
5217
|
p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
|
|
@@ -5195,44 +5233,44 @@ function BlockSettings() {
|
|
|
5195
5233
|
onChange: b,
|
|
5196
5234
|
formData: h,
|
|
5197
5235
|
schema: j,
|
|
5198
|
-
uiSchema:
|
|
5236
|
+
uiSchema: E
|
|
5199
5237
|
}
|
|
5200
5238
|
) })
|
|
5201
5239
|
] }),
|
|
5202
|
-
isEmpty(
|
|
5240
|
+
isEmpty(k) ? null : /* @__PURE__ */ jsx(
|
|
5203
5241
|
JSONForm,
|
|
5204
5242
|
{
|
|
5205
5243
|
blockId: n == null ? void 0 : n._id,
|
|
5206
5244
|
onChange: y,
|
|
5207
5245
|
formData: i,
|
|
5208
|
-
schema:
|
|
5246
|
+
schema: k,
|
|
5209
5247
|
uiSchema: B
|
|
5210
5248
|
}
|
|
5211
5249
|
)
|
|
5212
5250
|
] });
|
|
5213
5251
|
}
|
|
5214
5252
|
const BlockStylingProps = () => {
|
|
5215
|
-
var
|
|
5253
|
+
var x;
|
|
5216
5254
|
const o = useSelectedBlock(), [n, r] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
|
|
5217
5255
|
if (!o) return null;
|
|
5218
5256
|
const c = Object.keys(o).filter(
|
|
5219
|
-
(
|
|
5220
|
-
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (
|
|
5257
|
+
(f) => typeof o[f] == "string" && o[f].startsWith("#styles:")
|
|
5258
|
+
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (x = n[0]) == null ? void 0 : x.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((f) => !isEmpty(f)) : [], h = (f) => find(n, (y) => y.prop === f);
|
|
5221
5259
|
return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5222
5260
|
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5223
5261
|
i("Style element"),
|
|
5224
5262
|
":"
|
|
5225
5263
|
] }),
|
|
5226
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (
|
|
5264
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (f) => /* @__PURE__ */ jsxs(
|
|
5227
5265
|
Badge,
|
|
5228
5266
|
{
|
|
5229
5267
|
className: "flex cursor-pointer items-center gap-1 pr-1",
|
|
5230
|
-
variant: h(
|
|
5268
|
+
variant: h(f) ? "default" : "secondary",
|
|
5231
5269
|
onClick: () => {
|
|
5232
|
-
r([{ id: `${
|
|
5270
|
+
r([{ id: `${f}-${o._id}`, blockId: o._id, prop: f }]);
|
|
5233
5271
|
},
|
|
5234
5272
|
children: [
|
|
5235
|
-
startCase(
|
|
5273
|
+
startCase(f),
|
|
5236
5274
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5237
5275
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5238
5276
|
"button",
|
|
@@ -5249,7 +5287,7 @@ const BlockStylingProps = () => {
|
|
|
5249
5287
|
{
|
|
5250
5288
|
className: "text-xs",
|
|
5251
5289
|
onClick: () => {
|
|
5252
|
-
d(
|
|
5290
|
+
d(f);
|
|
5253
5291
|
},
|
|
5254
5292
|
children: i("Reset style")
|
|
5255
5293
|
}
|
|
@@ -5268,7 +5306,7 @@ const BlockStylingProps = () => {
|
|
|
5268
5306
|
] })
|
|
5269
5307
|
]
|
|
5270
5308
|
},
|
|
5271
|
-
|
|
5309
|
+
f
|
|
5272
5310
|
)) }),
|
|
5273
5311
|
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5274
5312
|
] }) });
|
|
@@ -5417,50 +5455,50 @@ const BlockStylingProps = () => {
|
|
|
5417
5455
|
},
|
|
5418
5456
|
a
|
|
5419
5457
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5420
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [
|
|
5458
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [k, B] = useState(!1), [j, E] = useState(!1);
|
|
5421
5459
|
useEffect(() => {
|
|
5422
|
-
const { value:
|
|
5423
|
-
if (
|
|
5424
|
-
l(
|
|
5460
|
+
const { value: A, unit: w } = getClassValueAndUnit(i);
|
|
5461
|
+
if (w === "") {
|
|
5462
|
+
l(A), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5425
5463
|
return;
|
|
5426
5464
|
}
|
|
5427
|
-
h(
|
|
5465
|
+
h(w), l(w === "class" || isEmpty(A) ? "" : A);
|
|
5428
5466
|
}, [i, p, u]);
|
|
5429
|
-
const
|
|
5430
|
-
(
|
|
5431
|
-
const
|
|
5432
|
-
if (get(
|
|
5433
|
-
|
|
5467
|
+
const C = useThrottledCallback((A) => c(A), [c], THROTTLE_TIME), v = useThrottledCallback((A) => c(A, !1), [c], THROTTLE_TIME), S = useCallback(
|
|
5468
|
+
(A = !1) => {
|
|
5469
|
+
const w = getUserInputValues(`${a}`, u);
|
|
5470
|
+
if (get(w, "error", !1)) {
|
|
5471
|
+
f(!0);
|
|
5434
5472
|
return;
|
|
5435
5473
|
}
|
|
5436
|
-
const
|
|
5437
|
-
if (
|
|
5438
|
-
|
|
5474
|
+
const _ = get(w, "unit") !== "" ? get(w, "unit") : m;
|
|
5475
|
+
if (_ === "auto" || _ === "none") {
|
|
5476
|
+
C(`${d}${_}`);
|
|
5439
5477
|
return;
|
|
5440
5478
|
}
|
|
5441
|
-
if (get(
|
|
5479
|
+
if (get(w, "value") === "")
|
|
5442
5480
|
return;
|
|
5443
|
-
const T = `${get(
|
|
5444
|
-
|
|
5481
|
+
const T = `${get(w, "value", "").startsWith("-") ? "-" : ""}${d}[${get(w, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
|
|
5482
|
+
A ? v(T) : C(T);
|
|
5445
5483
|
},
|
|
5446
|
-
[
|
|
5447
|
-
),
|
|
5448
|
-
(
|
|
5449
|
-
const
|
|
5450
|
-
if (get(
|
|
5451
|
-
|
|
5484
|
+
[C, v, a, m, d, u]
|
|
5485
|
+
), I = useCallback(
|
|
5486
|
+
(A) => {
|
|
5487
|
+
const w = getUserInputValues(`${a}`, u);
|
|
5488
|
+
if (get(w, "error", !1)) {
|
|
5489
|
+
f(!0);
|
|
5452
5490
|
return;
|
|
5453
5491
|
}
|
|
5454
|
-
if (
|
|
5455
|
-
|
|
5492
|
+
if (A === "auto" || A === "none") {
|
|
5493
|
+
C(`${d}${A}`);
|
|
5456
5494
|
return;
|
|
5457
5495
|
}
|
|
5458
|
-
if (get(
|
|
5496
|
+
if (get(w, "value") === "")
|
|
5459
5497
|
return;
|
|
5460
|
-
const
|
|
5461
|
-
|
|
5498
|
+
const _ = get(w, "unit") !== "" ? get(w, "unit") : A, T = `${get(w, "value", "").startsWith("-") ? "-" : ""}${d}[${get(w, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
|
|
5499
|
+
C(T);
|
|
5462
5500
|
},
|
|
5463
|
-
[
|
|
5501
|
+
[C, a, d, u]
|
|
5464
5502
|
);
|
|
5465
5503
|
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5466
5504
|
/* @__PURE__ */ jsx(
|
|
@@ -5475,40 +5513,40 @@ const BlockStylingProps = () => {
|
|
|
5475
5513
|
/* @__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, {}) }) }),
|
|
5476
5514
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
5477
5515
|
] })
|
|
5478
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
5516
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${k ? "z-auto" : ""}`, children: [
|
|
5479
5517
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
5480
5518
|
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
5481
5519
|
"input",
|
|
5482
5520
|
{
|
|
5483
5521
|
readOnly: m === "class",
|
|
5484
|
-
onKeyPress: (
|
|
5485
|
-
|
|
5522
|
+
onKeyPress: (A) => {
|
|
5523
|
+
A.key === "Enter" && S();
|
|
5486
5524
|
},
|
|
5487
|
-
onKeyDown: (
|
|
5488
|
-
if (
|
|
5525
|
+
onKeyDown: (A) => {
|
|
5526
|
+
if (A.keyCode !== 38 && A.keyCode !== 40)
|
|
5489
5527
|
return;
|
|
5490
|
-
|
|
5491
|
-
const
|
|
5492
|
-
let
|
|
5493
|
-
|
|
5494
|
-
const L = `${
|
|
5495
|
-
|
|
5528
|
+
A.preventDefault(), E(!0);
|
|
5529
|
+
const w = parseInt$1(A.target.value);
|
|
5530
|
+
let _ = isNaN$1(w) ? 0 : w;
|
|
5531
|
+
A.keyCode === 38 && (_ += 1), A.keyCode === 40 && (_ -= 1);
|
|
5532
|
+
const L = `${_}`, P = `${L.startsWith("-") ? "-" : ""}${d}[${L.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5533
|
+
v(P);
|
|
5496
5534
|
},
|
|
5497
|
-
onKeyUp: (
|
|
5498
|
-
j && (
|
|
5535
|
+
onKeyUp: (A) => {
|
|
5536
|
+
j && (A.preventDefault(), E(!1));
|
|
5499
5537
|
},
|
|
5500
|
-
onBlur: () =>
|
|
5501
|
-
onChange: (
|
|
5502
|
-
|
|
5538
|
+
onBlur: () => S(),
|
|
5539
|
+
onChange: (A) => {
|
|
5540
|
+
f(!1), l(A.target.value);
|
|
5503
5541
|
},
|
|
5504
|
-
onClick: (
|
|
5505
|
-
var
|
|
5506
|
-
(
|
|
5542
|
+
onClick: (A) => {
|
|
5543
|
+
var w;
|
|
5544
|
+
(w = A == null ? void 0 : A.target) == null || w.select(), r(!1);
|
|
5507
5545
|
},
|
|
5508
|
-
value:
|
|
5546
|
+
value: k ? y : a,
|
|
5509
5547
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5510
5548
|
" ",
|
|
5511
|
-
|
|
5549
|
+
x ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
5512
5550
|
)
|
|
5513
5551
|
}
|
|
5514
5552
|
),
|
|
@@ -5530,29 +5568,29 @@ const BlockStylingProps = () => {
|
|
|
5530
5568
|
{
|
|
5531
5569
|
units: u,
|
|
5532
5570
|
current: m,
|
|
5533
|
-
onSelect: (
|
|
5534
|
-
r(!1), h(
|
|
5571
|
+
onSelect: (A) => {
|
|
5572
|
+
r(!1), h(A), I(A);
|
|
5535
5573
|
}
|
|
5536
5574
|
}
|
|
5537
5575
|
) })
|
|
5538
5576
|
] })
|
|
5539
5577
|
] }),
|
|
5540
|
-
["none", "auto"].indexOf(m) !== -1 ||
|
|
5578
|
+
["none", "auto"].indexOf(m) !== -1 || k ? null : /* @__PURE__ */ jsx(
|
|
5541
5579
|
DragStyleButton,
|
|
5542
5580
|
{
|
|
5543
5581
|
onDragStart: () => B(!0),
|
|
5544
|
-
onDragEnd: (
|
|
5545
|
-
if (b(() => ""), B(!1), isEmpty(
|
|
5582
|
+
onDragEnd: (A) => {
|
|
5583
|
+
if (b(() => ""), B(!1), isEmpty(A))
|
|
5546
5584
|
return;
|
|
5547
|
-
const
|
|
5548
|
-
|
|
5585
|
+
const w = `${A}`, L = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5586
|
+
C(L);
|
|
5549
5587
|
},
|
|
5550
|
-
onDrag: (
|
|
5551
|
-
if (isEmpty(
|
|
5588
|
+
onDrag: (A) => {
|
|
5589
|
+
if (isEmpty(A))
|
|
5552
5590
|
return;
|
|
5553
|
-
b(
|
|
5554
|
-
const
|
|
5555
|
-
|
|
5591
|
+
b(A);
|
|
5592
|
+
const w = `${A}`, L = `${w.startsWith("-") ? "-" : ""}${d}[${w.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5593
|
+
v(L);
|
|
5556
5594
|
},
|
|
5557
5595
|
currentValue: a,
|
|
5558
5596
|
unit: m,
|
|
@@ -5627,7 +5665,7 @@ const COLOR_PROP = {
|
|
|
5627
5665
|
return c([]);
|
|
5628
5666
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5629
5667
|
}, [g]);
|
|
5630
|
-
const
|
|
5668
|
+
const x = useCallback(
|
|
5631
5669
|
// eslint-disable-next-line no-shadow
|
|
5632
5670
|
(y) => {
|
|
5633
5671
|
p({ color: g, shade: y });
|
|
@@ -5637,11 +5675,11 @@ const COLOR_PROP = {
|
|
|
5637
5675
|
useEffect(() => {
|
|
5638
5676
|
p({ color: "", shade: "" });
|
|
5639
5677
|
}, [r]);
|
|
5640
|
-
const { match:
|
|
5678
|
+
const { match: f } = useTailwindClassList();
|
|
5641
5679
|
return useEffect(() => {
|
|
5642
5680
|
const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5643
|
-
|
|
5644
|
-
}, [
|
|
5681
|
+
f(o, b) && n(b, o);
|
|
5682
|
+
}, [f, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5645
5683
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5646
5684
|
DropDown,
|
|
5647
5685
|
{
|
|
@@ -5681,7 +5719,7 @@ const COLOR_PROP = {
|
|
|
5681
5719
|
]
|
|
5682
5720
|
}
|
|
5683
5721
|
) }),
|
|
5684
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange:
|
|
5722
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: x, options: i }) })
|
|
5685
5723
|
] });
|
|
5686
5724
|
}, EDITOR_ICONS = {
|
|
5687
5725
|
"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" }) }),
|
|
@@ -6015,22 +6053,22 @@ const COLOR_PROP = {
|
|
|
6015
6053
|
"2xl": "1536px"
|
|
6016
6054
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6017
6055
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6018
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(),
|
|
6019
|
-
(
|
|
6020
|
-
const
|
|
6021
|
-
(p || u !== "") && (
|
|
6022
|
-
const
|
|
6023
|
-
h(
|
|
6056
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), y = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
|
|
6057
|
+
(v, S = !0) => {
|
|
6058
|
+
const I = { dark: p, mq: g, mod: u, cls: v, property: l, fullCls: "" };
|
|
6059
|
+
(p || u !== "") && (I.mq = "xs");
|
|
6060
|
+
const A = generateFullClsName(I);
|
|
6061
|
+
h(f, [A], S);
|
|
6024
6062
|
},
|
|
6025
|
-
[
|
|
6026
|
-
),
|
|
6027
|
-
f
|
|
6028
|
-
}, [
|
|
6063
|
+
[f, p, g, u, l, h]
|
|
6064
|
+
), k = useCallback(() => {
|
|
6065
|
+
x(f, [y], !0);
|
|
6066
|
+
}, [f, y, x]), B = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6029
6067
|
useEffect(() => {
|
|
6030
6068
|
i(B, m);
|
|
6031
6069
|
}, [B, i, m]);
|
|
6032
|
-
const [, , j] = useScreenSizeWidth(),
|
|
6033
|
-
(
|
|
6070
|
+
const [, , j] = useScreenSizeWidth(), E = useCallback(
|
|
6071
|
+
(v) => {
|
|
6034
6072
|
j({
|
|
6035
6073
|
xs: 400,
|
|
6036
6074
|
sm: 640,
|
|
@@ -6038,12 +6076,12 @@ const COLOR_PROP = {
|
|
|
6038
6076
|
lg: 1024,
|
|
6039
6077
|
xl: 1420,
|
|
6040
6078
|
"2xl": 1920
|
|
6041
|
-
}[
|
|
6079
|
+
}[v]);
|
|
6042
6080
|
},
|
|
6043
6081
|
[j]
|
|
6044
|
-
),
|
|
6045
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m &&
|
|
6046
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !
|
|
6082
|
+
), C = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6083
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && C, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6084
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !C ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6047
6085
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6048
6086
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6049
6087
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
@@ -6062,7 +6100,7 @@ const COLOR_PROP = {
|
|
|
6062
6100
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
6063
6101
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
6064
6102
|
] }),
|
|
6065
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children:
|
|
6103
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: C ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => k(), 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 && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6066
6104
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6067
6105
|
"button",
|
|
6068
6106
|
{
|
|
@@ -6082,7 +6120,7 @@ const COLOR_PROP = {
|
|
|
6082
6120
|
"button",
|
|
6083
6121
|
{
|
|
6084
6122
|
type: "button",
|
|
6085
|
-
onClick: () =>
|
|
6123
|
+
onClick: () => E(get(m, "mq")),
|
|
6086
6124
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6087
6125
|
children: [
|
|
6088
6126
|
"Switch to ",
|
|
@@ -6111,23 +6149,23 @@ const COLOR_PROP = {
|
|
|
6111
6149
|
children: [
|
|
6112
6150
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6113
6151
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6114
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key:
|
|
6152
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: x }, f) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6115
6153
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6116
6154
|
"button",
|
|
6117
6155
|
{
|
|
6118
6156
|
type: "button",
|
|
6119
|
-
onClick: () => u(
|
|
6120
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6157
|
+
onClick: () => u(x),
|
|
6158
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6121
6159
|
children: [
|
|
6122
6160
|
React__default.createElement("div", {
|
|
6123
|
-
className: m(
|
|
6161
|
+
className: m(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6124
6162
|
}),
|
|
6125
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6163
|
+
React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6126
6164
|
]
|
|
6127
6165
|
}
|
|
6128
6166
|
) }),
|
|
6129
6167
|
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
|
|
6130
|
-
] }) }, `option-${
|
|
6168
|
+
] }) }, `option-${f}`)) })
|
|
6131
6169
|
] }),
|
|
6132
6170
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6133
6171
|
BlockStyle,
|
|
@@ -6282,9 +6320,9 @@ const COLOR_PROP = {
|
|
|
6282
6320
|
canvas: n = !1,
|
|
6283
6321
|
tooltip: r = !0
|
|
6284
6322
|
}) => {
|
|
6285
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS),
|
|
6286
|
-
u.includes(b) ? u.length > 2 && g(u.filter((
|
|
6287
|
-
},
|
|
6323
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
|
|
6324
|
+
u.includes(b) ? u.length > 2 && g(u.filter((k) => k !== b)) : g((k) => [...k, b]);
|
|
6325
|
+
}, f = (b) => {
|
|
6288
6326
|
n || l(b), c(b);
|
|
6289
6327
|
}, y = getBreakpointValue(n ? i : a).toLowerCase();
|
|
6290
6328
|
return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (b) => /* @__PURE__ */ createElement(
|
|
@@ -6292,7 +6330,7 @@ const COLOR_PROP = {
|
|
|
6292
6330
|
{
|
|
6293
6331
|
canvas: n,
|
|
6294
6332
|
...b,
|
|
6295
|
-
onClick:
|
|
6333
|
+
onClick: f,
|
|
6296
6334
|
key: b.breakpoint,
|
|
6297
6335
|
currentBreakpoint: y
|
|
6298
6336
|
}
|
|
@@ -6306,7 +6344,7 @@ const COLOR_PROP = {
|
|
|
6306
6344
|
openDelay: o,
|
|
6307
6345
|
tooltip: r,
|
|
6308
6346
|
...b,
|
|
6309
|
-
onClick:
|
|
6347
|
+
onClick: f,
|
|
6310
6348
|
key: b.breakpoint,
|
|
6311
6349
|
currentBreakpoint: y
|
|
6312
6350
|
}
|
|
@@ -6321,7 +6359,7 @@ const COLOR_PROP = {
|
|
|
6321
6359
|
DropdownMenuCheckboxItem,
|
|
6322
6360
|
{
|
|
6323
6361
|
disabled: b.breakpoint === "xs",
|
|
6324
|
-
onCheckedChange: () =>
|
|
6362
|
+
onCheckedChange: () => x(toUpper(b.breakpoint)),
|
|
6325
6363
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6326
6364
|
children: m(b.title)
|
|
6327
6365
|
},
|
|
@@ -6406,8 +6444,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6406
6444
|
(h = d.current) == null || h.focus();
|
|
6407
6445
|
}, []);
|
|
6408
6446
|
const m = (h) => {
|
|
6409
|
-
const { usage:
|
|
6410
|
-
!l &&
|
|
6447
|
+
const { usage: x } = h || {};
|
|
6448
|
+
!l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6411
6449
|
};
|
|
6412
6450
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6413
6451
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -6463,10 +6501,10 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6463
6501
|
};
|
|
6464
6502
|
function ManualClasses() {
|
|
6465
6503
|
var L;
|
|
6466
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [
|
|
6467
|
-
const T =
|
|
6468
|
-
u(m, T, !0),
|
|
6469
|
-
}, [j,
|
|
6504
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), y = (L = first(d)) == null ? void 0 : L.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), k = b.split(" ").filter((T) => !isEmpty(T)), B = () => {
|
|
6505
|
+
const T = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6506
|
+
u(m, T, !0), f("");
|
|
6507
|
+
}, [j, E] = useState([]), C = ({ value: T }) => {
|
|
6470
6508
|
const P = T.trim().toLowerCase(), R = P.match(/.+:/g);
|
|
6471
6509
|
let N = [];
|
|
6472
6510
|
if (R && R.length > 0) {
|
|
@@ -6477,10 +6515,10 @@ function ManualClasses() {
|
|
|
6477
6515
|
}));
|
|
6478
6516
|
} else
|
|
6479
6517
|
N = i.search(P);
|
|
6480
|
-
return
|
|
6481
|
-
},
|
|
6482
|
-
|
|
6483
|
-
},
|
|
6518
|
+
return E(map(N, "item"));
|
|
6519
|
+
}, v = () => {
|
|
6520
|
+
E([]);
|
|
6521
|
+
}, S = (T) => T.name, I = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), A = useMemo(
|
|
6484
6522
|
() => ({
|
|
6485
6523
|
ref: o,
|
|
6486
6524
|
autoComplete: "off",
|
|
@@ -6488,36 +6526,36 @@ function ManualClasses() {
|
|
|
6488
6526
|
autoCapitalize: "off",
|
|
6489
6527
|
spellCheck: !1,
|
|
6490
6528
|
placeholder: c("Enter classes separated by space"),
|
|
6491
|
-
value:
|
|
6529
|
+
value: x,
|
|
6492
6530
|
onFocus: (T) => {
|
|
6493
6531
|
setTimeout(() => {
|
|
6494
6532
|
T.target && T.target.select();
|
|
6495
6533
|
}, 0);
|
|
6496
6534
|
},
|
|
6497
6535
|
onKeyDown: (T) => {
|
|
6498
|
-
T.key === "Enter" &&
|
|
6536
|
+
T.key === "Enter" && x.trim() !== "" && B();
|
|
6499
6537
|
},
|
|
6500
|
-
onChange: (T, { newValue: P }) =>
|
|
6538
|
+
onChange: (T, { newValue: P }) => f(P),
|
|
6501
6539
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6502
6540
|
}),
|
|
6503
|
-
[
|
|
6504
|
-
),
|
|
6541
|
+
[x, c, o]
|
|
6542
|
+
), w = (T) => {
|
|
6505
6543
|
debugger;
|
|
6506
6544
|
const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6507
6545
|
g(m, [T]), u(m, P, !0), r(""), l(-1);
|
|
6508
|
-
},
|
|
6546
|
+
}, _ = () => {
|
|
6509
6547
|
if (navigator.clipboard === void 0) {
|
|
6510
6548
|
toast.error(c("Clipboard not supported"));
|
|
6511
6549
|
return;
|
|
6512
6550
|
}
|
|
6513
|
-
navigator.clipboard.writeText(
|
|
6551
|
+
navigator.clipboard.writeText(k.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
6514
6552
|
};
|
|
6515
6553
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
6516
6554
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
6517
6555
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
6518
6556
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
6519
6557
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6520
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
6558
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: _, className: "cursor-pointer" }) }),
|
|
6521
6559
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
6522
6560
|
] })
|
|
6523
6561
|
] }),
|
|
@@ -6534,11 +6572,11 @@ function ManualClasses() {
|
|
|
6534
6572
|
Autosuggest,
|
|
6535
6573
|
{
|
|
6536
6574
|
suggestions: j,
|
|
6537
|
-
onSuggestionsFetchRequested:
|
|
6538
|
-
onSuggestionsClearRequested:
|
|
6539
|
-
getSuggestionValue:
|
|
6540
|
-
renderSuggestion:
|
|
6541
|
-
inputProps:
|
|
6575
|
+
onSuggestionsFetchRequested: C,
|
|
6576
|
+
onSuggestionsClearRequested: v,
|
|
6577
|
+
getSuggestionValue: S,
|
|
6578
|
+
renderSuggestion: I,
|
|
6579
|
+
inputProps: A,
|
|
6542
6580
|
containerProps: {
|
|
6543
6581
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
6544
6582
|
},
|
|
@@ -6555,13 +6593,13 @@ function ManualClasses() {
|
|
|
6555
6593
|
variant: "outline",
|
|
6556
6594
|
className: "h-6 border-border",
|
|
6557
6595
|
onClick: B,
|
|
6558
|
-
disabled:
|
|
6596
|
+
disabled: x.trim() === "",
|
|
6559
6597
|
size: "sm",
|
|
6560
6598
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
6561
6599
|
}
|
|
6562
6600
|
)
|
|
6563
6601
|
] }),
|
|
6564
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
6602
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: k.map(
|
|
6565
6603
|
(T, P) => a === P ? /* @__PURE__ */ jsx(
|
|
6566
6604
|
"input",
|
|
6567
6605
|
{
|
|
@@ -6569,10 +6607,10 @@ function ManualClasses() {
|
|
|
6569
6607
|
value: n,
|
|
6570
6608
|
onChange: (R) => r(R.target.value),
|
|
6571
6609
|
onBlur: () => {
|
|
6572
|
-
|
|
6610
|
+
w(T);
|
|
6573
6611
|
},
|
|
6574
6612
|
onKeyDown: (R) => {
|
|
6575
|
-
R.key === "Enter" &&
|
|
6613
|
+
R.key === "Enter" && w(T);
|
|
6576
6614
|
},
|
|
6577
6615
|
onFocus: (R) => {
|
|
6578
6616
|
setTimeout(() => {
|
|
@@ -6586,7 +6624,7 @@ function ManualClasses() {
|
|
|
6586
6624
|
"button",
|
|
6587
6625
|
{
|
|
6588
6626
|
onDoubleClick: () => {
|
|
6589
|
-
|
|
6627
|
+
f(T), g(m, [T]), setTimeout(() => {
|
|
6590
6628
|
o.current && o.current.focus();
|
|
6591
6629
|
}, 10);
|
|
6592
6630
|
},
|
|
@@ -6742,9 +6780,9 @@ function BlockStyling() {
|
|
|
6742
6780
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6743
6781
|
let h = parseFloat(i.dragStartValue);
|
|
6744
6782
|
h = isNaN(h) ? 0 : h;
|
|
6745
|
-
let
|
|
6746
|
-
(startsWith(m, "scale") || m === "opacity") && (
|
|
6747
|
-
let y = (i.dragStartY - u.pageY) /
|
|
6783
|
+
let x = MAPPER[i.dragUnit];
|
|
6784
|
+
(startsWith(m, "scale") || m === "opacity") && (x = 10);
|
|
6785
|
+
let y = (i.dragStartY - u.pageY) / x + h;
|
|
6748
6786
|
g && y < 0 && (y = 0), m === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
|
|
6749
6787
|
},
|
|
6750
6788
|
[i],
|
|
@@ -6793,7 +6831,7 @@ const CoreBlock = ({
|
|
|
6793
6831
|
} else
|
|
6794
6832
|
p(o, r || null, a);
|
|
6795
6833
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6796
|
-
},
|
|
6834
|
+
}, x = useFeature("dnd"), { t: f } = useTranslation();
|
|
6797
6835
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6798
6836
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6799
6837
|
"button",
|
|
@@ -6806,15 +6844,15 @@ const CoreBlock = ({
|
|
|
6806
6844
|
g([]), m();
|
|
6807
6845
|
}, 200);
|
|
6808
6846
|
},
|
|
6809
|
-
draggable:
|
|
6847
|
+
draggable: x ? "true" : "false",
|
|
6810
6848
|
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",
|
|
6811
6849
|
children: [
|
|
6812
6850
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6813
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6851
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(f(d || i)) })
|
|
6814
6852
|
]
|
|
6815
6853
|
}
|
|
6816
6854
|
) }),
|
|
6817
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6855
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f(d || i) }) })
|
|
6818
6856
|
] }) });
|
|
6819
6857
|
}, DefaultChaiBlocks = ({
|
|
6820
6858
|
parentId: o,
|
|
@@ -6925,7 +6963,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
6925
6963
|
parentId: r = void 0,
|
|
6926
6964
|
position: a = -1
|
|
6927
6965
|
}) => {
|
|
6928
|
-
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""),
|
|
6966
|
+
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (B) => {
|
|
6929
6967
|
const j = has(B, "styles_attrs.data-page-section");
|
|
6930
6968
|
return B._type === "Box" && j;
|
|
6931
6969
|
}, b = useCallback(
|
|
@@ -6946,20 +6984,20 @@ const registerChaiLibrary = (o, n) => {
|
|
|
6946
6984
|
{
|
|
6947
6985
|
onClick: l ? () => {
|
|
6948
6986
|
} : b,
|
|
6949
|
-
draggable:
|
|
6987
|
+
draggable: x ? "true" : "false",
|
|
6950
6988
|
onDragStart: async (B) => {
|
|
6951
6989
|
const j = await c({ library: n, block: o });
|
|
6952
|
-
let
|
|
6953
|
-
if (y(first(j)) && (
|
|
6954
|
-
const
|
|
6955
|
-
if (B.dataTransfer.setData("text/plain", JSON.stringify(
|
|
6956
|
-
const
|
|
6957
|
-
|
|
6958
|
-
B.dataTransfer.setDragImage(
|
|
6990
|
+
let E = r;
|
|
6991
|
+
if (y(first(j)) && (E = null), !isEmpty(j)) {
|
|
6992
|
+
const C = { blocks: j, uiLibrary: !0, parent: E };
|
|
6993
|
+
if (B.dataTransfer.setData("text/plain", JSON.stringify(C)), o.preview) {
|
|
6994
|
+
const v = new Image();
|
|
6995
|
+
v.src = o.preview, v.onload = () => {
|
|
6996
|
+
B.dataTransfer.setDragImage(v, 0, 0);
|
|
6959
6997
|
};
|
|
6960
6998
|
} else
|
|
6961
6999
|
B.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
6962
|
-
|
|
7000
|
+
f(C), setTimeout(() => {
|
|
6963
7001
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6964
7002
|
}, 200);
|
|
6965
7003
|
}
|
|
@@ -6979,45 +7017,42 @@ const registerChaiLibrary = (o, n) => {
|
|
|
6979
7017
|
]
|
|
6980
7018
|
}
|
|
6981
7019
|
) }),
|
|
6982
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */
|
|
6983
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium", children: m }),
|
|
6984
|
-
h && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: h })
|
|
6985
|
-
] }) })
|
|
7020
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: m }) }) })
|
|
6986
7021
|
] });
|
|
6987
7022
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
6988
|
-
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((
|
|
7023
|
+
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((w) => w.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), x = useRef(null);
|
|
6989
7024
|
useEffect(() => {
|
|
6990
|
-
c && c.length > 0 && (
|
|
7025
|
+
c && c.length > 0 && (x.current = new Fuse(c, {
|
|
6991
7026
|
keys: ["name", "label", "description", "group"],
|
|
6992
7027
|
threshold: 0.4,
|
|
6993
7028
|
ignoreLocation: !0
|
|
6994
7029
|
}));
|
|
6995
7030
|
}, [c]), useEffect(() => {
|
|
6996
|
-
if (!u.trim() || !
|
|
7031
|
+
if (!u.trim() || !x.current) {
|
|
6997
7032
|
h([]);
|
|
6998
7033
|
return;
|
|
6999
7034
|
}
|
|
7000
|
-
const
|
|
7001
|
-
h(
|
|
7035
|
+
const w = x.current.search(u).map((_) => _.item);
|
|
7036
|
+
h(w);
|
|
7002
7037
|
}, [u]);
|
|
7003
|
-
const
|
|
7038
|
+
const f = u.trim() && !isEmpty(m) ? m : c, y = groupBy(f, "group"), [b, k] = useState(null);
|
|
7004
7039
|
useEffect(() => {
|
|
7005
7040
|
if (isEmpty(keys(y))) {
|
|
7006
|
-
|
|
7041
|
+
k(null);
|
|
7007
7042
|
return;
|
|
7008
7043
|
}
|
|
7009
7044
|
if (!b || !y[b]) {
|
|
7010
|
-
|
|
7045
|
+
k(first(keys(y)));
|
|
7011
7046
|
return;
|
|
7012
7047
|
}
|
|
7013
7048
|
}, [y, b]);
|
|
7014
|
-
const B = get(y, b, []), j = useRef(null), { t:
|
|
7049
|
+
const B = get(y, b, []), j = useRef(null), { t: E } = useTranslation(), C = (w) => {
|
|
7015
7050
|
j.current && (clearTimeout(j.current), j.current = null), j.current = setTimeout(() => {
|
|
7016
|
-
j.current &&
|
|
7051
|
+
j.current && k(w);
|
|
7017
7052
|
}, 400);
|
|
7018
|
-
},
|
|
7053
|
+
}, v = () => {
|
|
7019
7054
|
i != null && i.id && p(i.id);
|
|
7020
|
-
},
|
|
7055
|
+
}, S = () => {
|
|
7021
7056
|
g("");
|
|
7022
7057
|
};
|
|
7023
7058
|
if (d)
|
|
@@ -7025,23 +7060,23 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7025
7060
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7026
7061
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7027
7062
|
] });
|
|
7028
|
-
const
|
|
7063
|
+
const I = filter(B, (w, _) => _ % 2 === 0), A = filter(B, (w, _) => _ % 2 === 1);
|
|
7029
7064
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7030
7065
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7031
7066
|
/* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
7032
7067
|
/* @__PURE__ */ jsx(
|
|
7033
7068
|
Input$1,
|
|
7034
7069
|
{
|
|
7035
|
-
placeholder:
|
|
7070
|
+
placeholder: E("Search blocks..."),
|
|
7036
7071
|
value: u,
|
|
7037
|
-
onChange: (
|
|
7072
|
+
onChange: (w) => g(w.target.value),
|
|
7038
7073
|
className: "w-full pl-8 pr-8"
|
|
7039
7074
|
}
|
|
7040
7075
|
),
|
|
7041
7076
|
u && /* @__PURE__ */ jsx(
|
|
7042
7077
|
"button",
|
|
7043
7078
|
{
|
|
7044
|
-
onClick:
|
|
7079
|
+
onClick: S,
|
|
7045
7080
|
className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
|
|
7046
7081
|
children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" })
|
|
7047
7082
|
}
|
|
@@ -7051,31 +7086,31 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7051
7086
|
/* @__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: [
|
|
7052
7087
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
|
|
7053
7088
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7054
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7089
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: E("Groups") }),
|
|
7055
7090
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7056
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(y) ? /* @__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:
|
|
7057
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm", children:
|
|
7058
|
-
/* @__PURE__ */ jsxs(Button, { onClick:
|
|
7091
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(y) ? /* @__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: E("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7092
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm", children: E("Failed to load the UI library. Try again") }),
|
|
7093
|
+
/* @__PURE__ */ jsxs(Button, { onClick: v, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7059
7094
|
/* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4" }),
|
|
7060
|
-
|
|
7095
|
+
E("Retry")
|
|
7061
7096
|
] })
|
|
7062
|
-
] }) }) : map(y, (
|
|
7097
|
+
] }) }) : map(y, (w, _) => /* @__PURE__ */ jsxs(
|
|
7063
7098
|
"div",
|
|
7064
7099
|
{
|
|
7065
|
-
onMouseEnter: () =>
|
|
7100
|
+
onMouseEnter: () => C(_),
|
|
7066
7101
|
onMouseLeave: () => clearTimeout(j.current),
|
|
7067
7102
|
role: "button",
|
|
7068
|
-
onClick: () =>
|
|
7103
|
+
onClick: () => k(_),
|
|
7069
7104
|
className: cn$2(
|
|
7070
7105
|
"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",
|
|
7071
|
-
|
|
7106
|
+
_ === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
|
|
7072
7107
|
),
|
|
7073
7108
|
children: [
|
|
7074
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(_
|
|
7109
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(E(_.toLowerCase())) }),
|
|
7075
7110
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7076
7111
|
]
|
|
7077
7112
|
},
|
|
7078
|
-
|
|
7113
|
+
_
|
|
7079
7114
|
)) })
|
|
7080
7115
|
] })
|
|
7081
7116
|
] }),
|
|
@@ -7085,26 +7120,26 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7085
7120
|
onMouseEnter: () => j.current ? clearTimeout(j.current) : null,
|
|
7086
7121
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7087
7122
|
children: [
|
|
7088
|
-
isEmpty(B) && !isEmpty(y) ? /* @__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:
|
|
7089
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7123
|
+
isEmpty(B) && !isEmpty(y) ? /* @__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: E("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
|
|
7124
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: I.map((w, _) => /* @__PURE__ */ jsx(
|
|
7090
7125
|
BlockCard,
|
|
7091
7126
|
{
|
|
7092
7127
|
parentId: o,
|
|
7093
7128
|
position: n,
|
|
7094
|
-
block:
|
|
7129
|
+
block: w,
|
|
7095
7130
|
library: i
|
|
7096
7131
|
},
|
|
7097
|
-
`block-${
|
|
7132
|
+
`block-${_}`
|
|
7098
7133
|
)) }),
|
|
7099
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7134
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((w, _) => /* @__PURE__ */ jsx(
|
|
7100
7135
|
BlockCard,
|
|
7101
7136
|
{
|
|
7102
7137
|
parentId: o,
|
|
7103
7138
|
position: n,
|
|
7104
|
-
block:
|
|
7139
|
+
block: w,
|
|
7105
7140
|
library: i
|
|
7106
7141
|
},
|
|
7107
|
-
`block-second-${
|
|
7142
|
+
`block-second-${_}`
|
|
7108
7143
|
)) })
|
|
7109
7144
|
] }),
|
|
7110
7145
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7140,25 +7175,25 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7140
7175
|
error: c
|
|
7141
7176
|
}), g(!0);
|
|
7142
7177
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7143
|
-
const h = Object.entries(a).map(([
|
|
7144
|
-
const b = y,
|
|
7178
|
+
const h = Object.entries(a).map(([f, y]) => {
|
|
7179
|
+
const b = y, k = b.type || "partial", B = formatReadableName(k);
|
|
7145
7180
|
return {
|
|
7146
7181
|
type: "PartialBlock",
|
|
7147
7182
|
// Set the type to PartialBlock
|
|
7148
|
-
label: formatReadableName(b.name ||
|
|
7183
|
+
label: formatReadableName(b.name || f),
|
|
7149
7184
|
description: b.description || "",
|
|
7150
7185
|
icon: FrameIcon,
|
|
7151
7186
|
group: B,
|
|
7152
7187
|
// Use formatted type as group
|
|
7153
7188
|
category: "partial",
|
|
7154
|
-
partialBlockId:
|
|
7189
|
+
partialBlockId: f,
|
|
7155
7190
|
// Store the original ID as partialBlockId
|
|
7156
7191
|
_name: b.name
|
|
7157
7192
|
};
|
|
7158
|
-
}),
|
|
7193
|
+
}), x = uniq(map(h, "group"));
|
|
7159
7194
|
p({
|
|
7160
7195
|
blocks: h,
|
|
7161
|
-
groups:
|
|
7196
|
+
groups: x,
|
|
7162
7197
|
isLoading: !1,
|
|
7163
7198
|
error: null
|
|
7164
7199
|
}), g(!0);
|
|
@@ -7203,44 +7238,44 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7203
7238
|
}, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, n) => {
|
|
7204
7239
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
|
|
7205
7240
|
}, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7206
|
-
var
|
|
7207
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (
|
|
7241
|
+
var A;
|
|
7242
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (A = find(c, (w) => w._id === r)) == null ? void 0 : A._type, [h, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
|
|
7208
7243
|
useEffect(() => {
|
|
7209
|
-
const
|
|
7210
|
-
var
|
|
7211
|
-
(
|
|
7244
|
+
const w = setTimeout(() => {
|
|
7245
|
+
var _;
|
|
7246
|
+
(_ = u.current) == null || _.focus();
|
|
7212
7247
|
}, 0);
|
|
7213
|
-
return () => clearTimeout(
|
|
7248
|
+
return () => clearTimeout(w);
|
|
7214
7249
|
}, [g]), useEffect(() => {
|
|
7215
|
-
d && (
|
|
7216
|
-
}, [d]), useEffect(() => (b.current = debounce((
|
|
7217
|
-
|
|
7250
|
+
d && (x("all"), y(null));
|
|
7251
|
+
}, [d]), useEffect(() => (b.current = debounce((w) => {
|
|
7252
|
+
x(w);
|
|
7218
7253
|
}, 500), () => {
|
|
7219
7254
|
b.current && b.current.cancel();
|
|
7220
7255
|
}), []);
|
|
7221
|
-
const
|
|
7222
|
-
y(
|
|
7256
|
+
const k = useCallback((w) => {
|
|
7257
|
+
y(w), b.current && b.current(w);
|
|
7223
7258
|
}, []), B = useCallback(() => {
|
|
7224
7259
|
y(null), b.current && b.current.cancel();
|
|
7225
|
-
}, []), j = useCallback((
|
|
7226
|
-
b.current && b.current.cancel(),
|
|
7227
|
-
}, []),
|
|
7260
|
+
}, []), j = useCallback((w) => {
|
|
7261
|
+
b.current && b.current.cancel(), x(w), y(null);
|
|
7262
|
+
}, []), E = useMemo(
|
|
7228
7263
|
() => d ? values(n).filter(
|
|
7229
|
-
(
|
|
7230
|
-
var
|
|
7231
|
-
return (((
|
|
7264
|
+
(w) => {
|
|
7265
|
+
var _, L;
|
|
7266
|
+
return (((_ = w.label) == null ? void 0 : _.toLowerCase()) + " " + ((L = w.type) == null ? void 0 : L.toLowerCase())).includes(d.toLowerCase());
|
|
7232
7267
|
}
|
|
7233
7268
|
) : n,
|
|
7234
7269
|
[n, d]
|
|
7235
|
-
),
|
|
7270
|
+
), C = useMemo(
|
|
7236
7271
|
() => d ? o.filter(
|
|
7237
|
-
(
|
|
7238
|
-
) : o.filter((
|
|
7239
|
-
[n,
|
|
7240
|
-
),
|
|
7241
|
-
() => sortBy(
|
|
7242
|
-
[
|
|
7243
|
-
),
|
|
7272
|
+
(w) => reject(filter(values(E), { group: w }), { hidden: !0 }).length > 0
|
|
7273
|
+
) : o.filter((w) => reject(filter(values(n), { group: w }), { hidden: !0 }).length > 0),
|
|
7274
|
+
[n, E, o, d]
|
|
7275
|
+
), v = useMemo(
|
|
7276
|
+
() => sortBy(C, (w) => CORE_GROUPS.indexOf(w) === -1 ? 99 : CORE_GROUPS.indexOf(w)),
|
|
7277
|
+
[C]
|
|
7278
|
+
), S = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), I = useMemo(() => h === "all" ? v : [h], [v, h]);
|
|
7244
7279
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7245
7280
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7246
7281
|
Input$1,
|
|
@@ -7250,55 +7285,55 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7250
7285
|
placeholder: i("Search blocks..."),
|
|
7251
7286
|
value: d,
|
|
7252
7287
|
className: "-ml-2",
|
|
7253
|
-
onChange: (
|
|
7288
|
+
onChange: (w) => p(w.target.value)
|
|
7254
7289
|
}
|
|
7255
7290
|
) }),
|
|
7256
7291
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7257
|
-
|
|
7292
|
+
v.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: [
|
|
7258
7293
|
/* @__PURE__ */ jsx(
|
|
7259
7294
|
"button",
|
|
7260
7295
|
{
|
|
7261
7296
|
onClick: () => j("all"),
|
|
7262
|
-
onMouseEnter: () =>
|
|
7297
|
+
onMouseEnter: () => k("all"),
|
|
7263
7298
|
onMouseLeave: B,
|
|
7264
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" ||
|
|
7299
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7265
7300
|
children: i("All")
|
|
7266
7301
|
},
|
|
7267
7302
|
"sidebar-all"
|
|
7268
7303
|
),
|
|
7269
|
-
|
|
7304
|
+
v.map((w) => /* @__PURE__ */ jsx(
|
|
7270
7305
|
"button",
|
|
7271
7306
|
{
|
|
7272
|
-
onClick: () => j(
|
|
7273
|
-
onMouseEnter: () =>
|
|
7307
|
+
onClick: () => j(w),
|
|
7308
|
+
onMouseEnter: () => k(w),
|
|
7274
7309
|
onMouseLeave: B,
|
|
7275
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h ===
|
|
7276
|
-
children: capitalize(i(
|
|
7310
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === w || f === w ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7311
|
+
children: capitalize(i(w.toLowerCase()))
|
|
7277
7312
|
},
|
|
7278
|
-
`sidebar-${
|
|
7313
|
+
`sidebar-${w}`
|
|
7279
7314
|
))
|
|
7280
7315
|
] }) }) }),
|
|
7281
|
-
/* @__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:
|
|
7316
|
+
/* @__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: C.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: [
|
|
7282
7317
|
i("No blocks found matching"),
|
|
7283
7318
|
' "',
|
|
7284
7319
|
d,
|
|
7285
7320
|
'"'
|
|
7286
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children:
|
|
7287
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7321
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: I.map((w) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7322
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(w.toLowerCase())) }),
|
|
7288
7323
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7289
|
-
h === "all" ? filter(values(
|
|
7324
|
+
h === "all" ? filter(values(S), { group: w }) : values(S),
|
|
7290
7325
|
{ hidden: !0 }
|
|
7291
|
-
).map((
|
|
7326
|
+
).map((_) => /* @__PURE__ */ jsx(
|
|
7292
7327
|
CoreBlock,
|
|
7293
7328
|
{
|
|
7294
7329
|
parentId: r,
|
|
7295
7330
|
position: a,
|
|
7296
|
-
block:
|
|
7297
|
-
disabled: !canAcceptChildBlock(m,
|
|
7331
|
+
block: _,
|
|
7332
|
+
disabled: !canAcceptChildBlock(m, _.type) || !canBeNestedInside(m, _.type)
|
|
7298
7333
|
},
|
|
7299
|
-
|
|
7334
|
+
_.type
|
|
7300
7335
|
)) })
|
|
7301
|
-
] },
|
|
7336
|
+
] }, w)) }) }) })
|
|
7302
7337
|
] })
|
|
7303
7338
|
] });
|
|
7304
7339
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
@@ -7313,7 +7348,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7313
7348
|
}, [i, g, c]);
|
|
7314
7349
|
const h = useCallback(() => {
|
|
7315
7350
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7316
|
-
}, []),
|
|
7351
|
+
}, []), x = useChaiAddBlockTabs(), f = p && m(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
|
|
7317
7352
|
return useEffect(() => {
|
|
7318
7353
|
i === "library" && !b && c("core");
|
|
7319
7354
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7324,8 +7359,8 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7324
7359
|
/* @__PURE__ */ jsxs(
|
|
7325
7360
|
Tabs,
|
|
7326
7361
|
{
|
|
7327
|
-
onValueChange: (
|
|
7328
|
-
d(""), c(
|
|
7362
|
+
onValueChange: (k) => {
|
|
7363
|
+
d(""), c(k);
|
|
7329
7364
|
},
|
|
7330
7365
|
value: i,
|
|
7331
7366
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -7334,14 +7369,14 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7334
7369
|
b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7335
7370
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7336
7371
|
g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7337
|
-
|
|
7338
|
-
map(
|
|
7372
|
+
f ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7373
|
+
map(x, (k) => /* @__PURE__ */ jsx(TabsTrigger, { value: k.id, children: React__default.createElement(k.tab) }, `tab-add-block-${k.id}`))
|
|
7339
7374
|
] }),
|
|
7340
7375
|
/* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7341
7376
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7342
7377
|
g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7343
|
-
|
|
7344
|
-
map(
|
|
7378
|
+
f ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7379
|
+
map(x, (k) => /* @__PURE__ */ jsx(TabsContent, { value: k.id, children: React__default.createElement(k.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${k.id}`))
|
|
7345
7380
|
]
|
|
7346
7381
|
}
|
|
7347
7382
|
)
|
|
@@ -7651,33 +7686,33 @@ const Input = ({ node: o }) => {
|
|
|
7651
7686
|
var R;
|
|
7652
7687
|
const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
|
|
7653
7688
|
let d = null;
|
|
7654
|
-
const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected:
|
|
7689
|
+
const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: f, isDragging: y, isEditing: b, handleClick: k } = o, B = get(h, "_show", !0), j = (N) => {
|
|
7655
7690
|
N.stopPropagation(), B && o.toggle();
|
|
7656
|
-
},
|
|
7691
|
+
}, E = (N) => {
|
|
7657
7692
|
N.isInternal && (d = N.isOpen, N.isOpen && N.close());
|
|
7658
|
-
},
|
|
7693
|
+
}, C = (N) => {
|
|
7659
7694
|
N.isInternal && d !== null && (d ? N.open() : N.close(), d = null);
|
|
7660
|
-
}, [
|
|
7695
|
+
}, [v, S] = useAtom$1(currentAddSelection), I = () => {
|
|
7661
7696
|
var N;
|
|
7662
|
-
|
|
7663
|
-
},
|
|
7664
|
-
|
|
7665
|
-
},
|
|
7666
|
-
|
|
7697
|
+
A(), o.parent.isSelected || S((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
|
|
7698
|
+
}, A = () => {
|
|
7699
|
+
S(null);
|
|
7700
|
+
}, w = (N) => {
|
|
7701
|
+
A(), N.stopPropagation(), !o.isOpen && B && o.toggle(), k(N);
|
|
7667
7702
|
};
|
|
7668
7703
|
useEffect(() => {
|
|
7669
7704
|
const N = setTimeout(() => {
|
|
7670
|
-
|
|
7705
|
+
f && !o.isOpen && !y && B && o.toggle();
|
|
7671
7706
|
}, 500);
|
|
7672
7707
|
return () => clearTimeout(N);
|
|
7673
|
-
}, [
|
|
7674
|
-
const
|
|
7708
|
+
}, [f, o, y]);
|
|
7709
|
+
const _ = (N, D) => {
|
|
7675
7710
|
const F = i.contentDocument || i.contentWindow.document, O = F.querySelector(`[data-block-id=${N}]`);
|
|
7676
7711
|
O && O.setAttribute("data-drop", D);
|
|
7677
7712
|
const M = O.getBoundingClientRect(), H = i.getBoundingClientRect();
|
|
7678
7713
|
M.top >= H.top && M.left >= H.left && M.bottom <= H.bottom && M.right <= H.right || (F.documentElement.scrollTop = O.offsetTop - H.top);
|
|
7679
7714
|
}, L = (N) => {
|
|
7680
|
-
|
|
7715
|
+
A();
|
|
7681
7716
|
const D = get(o, "parent.id");
|
|
7682
7717
|
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
|
|
7683
7718
|
};
|
|
@@ -7705,20 +7740,20 @@ const Input = ({ node: o }) => {
|
|
|
7705
7740
|
{
|
|
7706
7741
|
onMouseEnter: () => u(m),
|
|
7707
7742
|
onMouseLeave: () => g(),
|
|
7708
|
-
onClick:
|
|
7743
|
+
onClick: w,
|
|
7709
7744
|
style: n,
|
|
7710
7745
|
"data-node-id": m,
|
|
7711
7746
|
ref: r,
|
|
7712
|
-
onDragStart: () =>
|
|
7713
|
-
onDragEnd: () =>
|
|
7747
|
+
onDragStart: () => E(o),
|
|
7748
|
+
onDragEnd: () => C(o),
|
|
7714
7749
|
onDragOver: (N) => {
|
|
7715
|
-
N.preventDefault(),
|
|
7750
|
+
N.preventDefault(), _(m, "yes");
|
|
7716
7751
|
},
|
|
7717
7752
|
onDragLeave: (N) => {
|
|
7718
|
-
N.preventDefault(),
|
|
7753
|
+
N.preventDefault(), _(m, "no");
|
|
7719
7754
|
},
|
|
7720
7755
|
onDrop: (N) => {
|
|
7721
|
-
N.preventDefault(),
|
|
7756
|
+
N.preventDefault(), _(m, "no");
|
|
7722
7757
|
},
|
|
7723
7758
|
children: [
|
|
7724
7759
|
c(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(
|
|
@@ -7727,8 +7762,8 @@ const Input = ({ node: o }) => {
|
|
|
7727
7762
|
onClick: (N) => {
|
|
7728
7763
|
N.stopPropagation(), L(o.childIndex);
|
|
7729
7764
|
},
|
|
7730
|
-
onMouseEnter:
|
|
7731
|
-
onMouseLeave:
|
|
7765
|
+
onMouseEnter: I,
|
|
7766
|
+
onMouseLeave: A,
|
|
7732
7767
|
className: "absolute -top-0.5 h-0.5 w-[90%] rounded bg-primary/80 opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7733
7768
|
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/80 p-1 outline outline-2 outline-white hover:bg-primary/80", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[2] text-white" }) })
|
|
7734
7769
|
}
|
|
@@ -7738,12 +7773,12 @@ const Input = ({ node: o }) => {
|
|
|
7738
7773
|
{
|
|
7739
7774
|
className: cn(
|
|
7740
7775
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
(o == null ? void 0 : o.id) ===
|
|
7776
|
+
x ? "bg-primary/20" : "hover:bg-primary/10",
|
|
7777
|
+
f && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
|
|
7778
|
+
(o == null ? void 0 : o.id) === v ? "bg-primary/10" : "",
|
|
7744
7779
|
y && "opacity-20",
|
|
7745
7780
|
B ? "" : "line-through opacity-50",
|
|
7746
|
-
T &&
|
|
7781
|
+
T && x && "bg-primary/20 text-primary"
|
|
7747
7782
|
),
|
|
7748
7783
|
children: [
|
|
7749
7784
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7760,9 +7795,9 @@ const Input = ({ node: o }) => {
|
|
|
7760
7795
|
className: cn(
|
|
7761
7796
|
"leading-1 flex items-center",
|
|
7762
7797
|
T && "text-orange-600/90",
|
|
7763
|
-
T &&
|
|
7798
|
+
T && x && "text-orange-800",
|
|
7764
7799
|
P && "text-purple-600/90",
|
|
7765
|
-
P &&
|
|
7800
|
+
P && x && "text-purple-800"
|
|
7766
7801
|
),
|
|
7767
7802
|
children: [
|
|
7768
7803
|
/* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
|
|
@@ -8225,23 +8260,23 @@ const Input = ({ node: o }) => {
|
|
|
8225
8260
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8226
8261
|
const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
|
|
8227
8262
|
if (d) {
|
|
8228
|
-
const
|
|
8229
|
-
DEFAULT_THEME_PRESET.forEach((
|
|
8230
|
-
const
|
|
8231
|
-
|
|
8263
|
+
const C = d.map((v) => Object.keys(v)[0]);
|
|
8264
|
+
DEFAULT_THEME_PRESET.forEach((v) => {
|
|
8265
|
+
const S = Object.keys(v)[0];
|
|
8266
|
+
C.includes(S) || d.push(v);
|
|
8232
8267
|
});
|
|
8233
8268
|
}
|
|
8234
|
-
const [g, m] = useTheme(), h = useThemeOptions(), { t:
|
|
8235
|
-
(
|
|
8236
|
-
const
|
|
8237
|
-
setPreviousTheme(
|
|
8269
|
+
const [g, m] = useTheme(), h = useThemeOptions(), { t: x } = useTranslation(), f = React.useCallback(
|
|
8270
|
+
(C) => {
|
|
8271
|
+
const v = { ...g };
|
|
8272
|
+
setPreviousTheme(v), m(C), toast.success("Theme updated", {
|
|
8238
8273
|
action: {
|
|
8239
8274
|
label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8240
8275
|
/* @__PURE__ */ jsx(ResetIcon, { className: "h-4 w-4" }),
|
|
8241
8276
|
" Undo"
|
|
8242
8277
|
] }),
|
|
8243
8278
|
onClick: () => {
|
|
8244
|
-
m(
|
|
8279
|
+
m(v), clearPreviousTheme(), toast.dismiss();
|
|
8245
8280
|
}
|
|
8246
8281
|
},
|
|
8247
8282
|
closeButton: !0,
|
|
@@ -8250,81 +8285,81 @@ const Input = ({ node: o }) => {
|
|
|
8250
8285
|
},
|
|
8251
8286
|
[g, m]
|
|
8252
8287
|
), y = () => {
|
|
8253
|
-
const
|
|
8254
|
-
if (
|
|
8255
|
-
const
|
|
8256
|
-
|
|
8288
|
+
const C = d.find((v) => Object.keys(v)[0] === a);
|
|
8289
|
+
if (C) {
|
|
8290
|
+
const v = Object.values(C)[0];
|
|
8291
|
+
v && typeof v == "object" && "fontFamily" in v && "borderRadius" in v && "colors" in v ? (f(v), l("")) : console.error("Invalid preset structure:", v);
|
|
8257
8292
|
} else
|
|
8258
8293
|
console.error("Preset not found:", a);
|
|
8259
|
-
}, b = (
|
|
8260
|
-
|
|
8261
|
-
},
|
|
8262
|
-
(
|
|
8294
|
+
}, b = (C) => {
|
|
8295
|
+
f(C), l("");
|
|
8296
|
+
}, k = useDebouncedCallback(
|
|
8297
|
+
(C, v) => {
|
|
8263
8298
|
m(() => ({
|
|
8264
8299
|
...g,
|
|
8265
8300
|
fontFamily: {
|
|
8266
8301
|
...g.fontFamily,
|
|
8267
|
-
[
|
|
8302
|
+
[C.replace(/font-/g, "")]: v
|
|
8268
8303
|
}
|
|
8269
8304
|
}));
|
|
8270
8305
|
},
|
|
8271
8306
|
[g],
|
|
8272
8307
|
200
|
|
8273
8308
|
), B = React.useCallback(
|
|
8274
|
-
(
|
|
8309
|
+
(C) => {
|
|
8275
8310
|
m(() => ({
|
|
8276
8311
|
...g,
|
|
8277
|
-
borderRadius: `${
|
|
8312
|
+
borderRadius: `${C}px`
|
|
8278
8313
|
}));
|
|
8279
8314
|
},
|
|
8280
8315
|
[g]
|
|
8281
8316
|
), j = useDebouncedCallback(
|
|
8282
|
-
(
|
|
8317
|
+
(C, v) => {
|
|
8283
8318
|
m(() => {
|
|
8284
|
-
const
|
|
8285
|
-
return n ? set(
|
|
8319
|
+
const S = get(g, `colors.${C}`);
|
|
8320
|
+
return n ? set(S, 1, v) : set(S, 0, v), {
|
|
8286
8321
|
...g,
|
|
8287
8322
|
colors: {
|
|
8288
8323
|
...g.colors,
|
|
8289
|
-
[
|
|
8324
|
+
[C]: S
|
|
8290
8325
|
}
|
|
8291
8326
|
};
|
|
8292
8327
|
});
|
|
8293
8328
|
},
|
|
8294
8329
|
[g],
|
|
8295
8330
|
200
|
|
8296
|
-
),
|
|
8297
|
-
const
|
|
8298
|
-
return
|
|
8331
|
+
), E = (C) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(C.items).map(([v]) => {
|
|
8332
|
+
const S = get(g, `colors.${v}.${n ? 1 : 0}`);
|
|
8333
|
+
return S ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8299
8334
|
/* @__PURE__ */ jsx(
|
|
8300
8335
|
ColorPickerInput,
|
|
8301
8336
|
{
|
|
8302
|
-
value:
|
|
8303
|
-
onChange: (
|
|
8337
|
+
value: S,
|
|
8338
|
+
onChange: (I) => j(v, I)
|
|
8304
8339
|
}
|
|
8305
8340
|
),
|
|
8306
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children:
|
|
8307
|
-
] },
|
|
8341
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: v.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((I) => I.charAt(0).toUpperCase() + I.slice(1)).join(" ") + (!v.toLowerCase().includes("foreground") && !v.toLowerCase().includes("border") && !v.toLowerCase().includes("input") && !v.toLowerCase().includes("ring") && !v.toLowerCase().includes("background") ? " Background" : "") })
|
|
8342
|
+
] }, v) : null;
|
|
8308
8343
|
}) });
|
|
8309
8344
|
return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8310
8345
|
/* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8311
8346
|
d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
|
|
8312
8347
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
8313
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8348
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: x("Presets") }),
|
|
8314
8349
|
/* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
|
|
8315
8350
|
/* @__PURE__ */ jsx(UploadIcon, { className: "h-4 w-4" }),
|
|
8316
|
-
|
|
8351
|
+
x("Import theme")
|
|
8317
8352
|
] }) })
|
|
8318
8353
|
] }),
|
|
8319
8354
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
|
|
8320
8355
|
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
|
|
8321
8356
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
|
|
8322
|
-
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((
|
|
8323
|
-
const
|
|
8324
|
-
return /* @__PURE__ */ jsx(SelectItem, { value:
|
|
8357
|
+
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((C) => {
|
|
8358
|
+
const v = Object.keys(C)[0], S = v.replaceAll("_", " ");
|
|
8359
|
+
return /* @__PURE__ */ jsx(SelectItem, { value: v, children: capitalize(S) }, v);
|
|
8325
8360
|
}) })
|
|
8326
8361
|
] }) }),
|
|
8327
|
-
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children:
|
|
8362
|
+
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children: x("Apply") }) })
|
|
8328
8363
|
] })
|
|
8329
8364
|
] }),
|
|
8330
8365
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
@@ -8333,14 +8368,14 @@ const Input = ({ node: o }) => {
|
|
|
8333
8368
|
/* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 text-gray-600" }),
|
|
8334
8369
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
|
|
8335
8370
|
] }),
|
|
8336
|
-
(h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([
|
|
8371
|
+
(h == null ? void 0 : h.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(h.fontFamily).map(([C, v]) => /* @__PURE__ */ jsx(
|
|
8337
8372
|
FontSelector,
|
|
8338
8373
|
{
|
|
8339
|
-
label:
|
|
8340
|
-
value: g.fontFamily[
|
|
8341
|
-
onChange: (
|
|
8374
|
+
label: C,
|
|
8375
|
+
value: g.fontFamily[C.replace(/font-/g, "")] || v[Object.keys(v)[0]],
|
|
8376
|
+
onChange: (S) => k(C, S)
|
|
8342
8377
|
},
|
|
8343
|
-
|
|
8378
|
+
C
|
|
8344
8379
|
)) }),
|
|
8345
8380
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
8346
8381
|
(h == null ? void 0 : h.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
@@ -8366,7 +8401,7 @@ const Input = ({ node: o }) => {
|
|
|
8366
8401
|
Switch,
|
|
8367
8402
|
{
|
|
8368
8403
|
checked: n,
|
|
8369
|
-
onCheckedChange: (
|
|
8404
|
+
onCheckedChange: (C) => r(C),
|
|
8370
8405
|
"aria-label": "Toggle dark mode",
|
|
8371
8406
|
className: "mx-1"
|
|
8372
8407
|
}
|
|
@@ -8374,7 +8409,7 @@ const Input = ({ node: o }) => {
|
|
|
8374
8409
|
/* @__PURE__ */ jsx(MoonIcon, { className: "h-4 w-4" })
|
|
8375
8410
|
] }) })
|
|
8376
8411
|
] }),
|
|
8377
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((
|
|
8412
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: h.colors.map((C) => E(C)) })
|
|
8378
8413
|
] }),
|
|
8379
8414
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && /* @__PURE__ */ jsx(
|
|
8380
8415
|
LazyCssImportModal,
|
|
@@ -8392,9 +8427,15 @@ const Input = ({ node: o }) => {
|
|
|
8392
8427
|
] }),
|
|
8393
8428
|
p && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(p) })
|
|
8394
8429
|
] }) : /* @__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." }) }) }) });
|
|
8395
|
-
}), Core = "Core", Import = "Import", Breakpoints = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "
|
|
8430
|
+
}), Core = "Core", Import = "Import", Breakpoints = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Style", SVG_code = "Enter SVG code here", 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", URL = "URL", 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", Classes = "Classes", All = "All", Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", Apply = "Apply", Back = "Back", Insert = "Insert", Rename = "Rename", Partials = "Partials", Happy = "Happy", Sad = "Sad", Retry = "Retry", canvas_empty = "Canvas is empty", Presets = "Presets", No = "No", Saving = "Saving", 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" }, lngEn = {
|
|
8396
8431
|
"Add block": "Add Block",
|
|
8432
|
+
"Add Block": "Add Block",
|
|
8397
8433
|
"Add blocks": "Add blocks",
|
|
8434
|
+
"Add inside": "Add inside",
|
|
8435
|
+
"Add before": "Add before",
|
|
8436
|
+
"Add after": "Add after",
|
|
8437
|
+
"Add block inside": "Add block inside",
|
|
8438
|
+
"Add field": "Add field",
|
|
8398
8439
|
"Enter or paste TailwindCSS HTML snippet": "Enter or paste TailwindCSS HTML snippet",
|
|
8399
8440
|
"Click to add block to page": "Click to add block to page",
|
|
8400
8441
|
Core,
|
|
@@ -8435,6 +8476,9 @@ const Input = ({ node: o }) => {
|
|
|
8435
8476
|
Preview,
|
|
8436
8477
|
Settings,
|
|
8437
8478
|
Styling,
|
|
8479
|
+
SVG_code,
|
|
8480
|
+
"Paste SVG_code": "Paste SVG code to use as an icon",
|
|
8481
|
+
"Enter Key": "Enter Key",
|
|
8438
8482
|
"Data Provider": "Data Provider",
|
|
8439
8483
|
"Remove Provider Confirmation": "Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?",
|
|
8440
8484
|
"Your data provider will be removed from this page and all added data binding will be not visible on blocks.": "Your data provider will be removed from this page and all added data binding will be not visible on blocks.",
|
|
@@ -8486,6 +8530,8 @@ const Input = ({ node: o }) => {
|
|
|
8486
8530
|
Value,
|
|
8487
8531
|
"Background Image": "Background Image",
|
|
8488
8532
|
"Enter image URL": "Enter image URL",
|
|
8533
|
+
"Enter URL": "Enter URL",
|
|
8534
|
+
URL,
|
|
8489
8535
|
"Replace image": "Replace image",
|
|
8490
8536
|
"Choose image": "Choose image",
|
|
8491
8537
|
Images,
|
|
@@ -8520,14 +8566,128 @@ const Input = ({ node: o }) => {
|
|
|
8520
8566
|
"Saving...": "Saving...",
|
|
8521
8567
|
"Improve writing": "Improve writing",
|
|
8522
8568
|
"Replace placeholder content": "Replace placeholder content",
|
|
8569
|
+
"Discard current placeholder content and replace with meaningful relevant content.": "Discard current placeholder content and replace with meaningful relevant content.",
|
|
8523
8570
|
"Fix grammar": "Fix grammar",
|
|
8571
|
+
"Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.": "Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.",
|
|
8524
8572
|
"Make longer": "Make longer",
|
|
8573
|
+
"Make all text elements longer.": "Make all text elements longer.",
|
|
8525
8574
|
"Make shorter": "Make shorter",
|
|
8575
|
+
"Make all text elements shorter.": "Make all text elements shorter.",
|
|
8526
8576
|
"Add emojis": "Add emojis",
|
|
8577
|
+
"Add emojis to text elements if relevant.": "Add emojis to text elements if relevant.",
|
|
8527
8578
|
Randomize,
|
|
8579
|
+
"Randomize all text elements.": "Randomize all text elements.",
|
|
8528
8580
|
"Edit Block": "Edit Block",
|
|
8529
8581
|
"AI Assistant": "AI Assistant",
|
|
8530
|
-
"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)" },
|
|
8582
|
+
"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)", "Reset styles": "Reset styles" },
|
|
8583
|
+
"Copy classes to clipboard": "Copy classes to clipboard",
|
|
8584
|
+
"Classes copied to clipboard": "Classes copied to clipboard",
|
|
8585
|
+
Classes,
|
|
8586
|
+
All,
|
|
8587
|
+
"Enter classes separated by space": "Enter classes separated by space",
|
|
8588
|
+
"Show hidden blocks": "Show hidden blocks",
|
|
8589
|
+
"Expand all": "Expand all",
|
|
8590
|
+
"Collapse all": "Collapse all",
|
|
8591
|
+
"Choose library": "Choose library",
|
|
8592
|
+
"Close Preview": "Close Preview",
|
|
8593
|
+
Error: "Error",
|
|
8594
|
+
"Failed to copy template": "Failed to copy template",
|
|
8595
|
+
"Total tokens used": "Total tokens used",
|
|
8596
|
+
"Updated AI Context": "Updated AI Context",
|
|
8597
|
+
"You can now Ask AI to edit your content": "You can now Ask AI to edit your content",
|
|
8598
|
+
"Tell about this page eg this page is about": "Tell about this page eg this page is about..",
|
|
8599
|
+
"Delete Context": "Delete Context",
|
|
8600
|
+
"Keyboard shortcuts": "Keyboard shortcuts",
|
|
8601
|
+
Undo,
|
|
8602
|
+
Redo,
|
|
8603
|
+
Duplicate,
|
|
8604
|
+
"Deselect blocks": "Deselect blocks",
|
|
8605
|
+
"Delete block": "Delete block",
|
|
8606
|
+
"Save page": "Save page",
|
|
8607
|
+
"Scripts will be only executed in preview and live mode.": "Scripts will be only executed in preview and live mode.",
|
|
8608
|
+
"HTML Code Editor |": "HTML Code Editor |",
|
|
8609
|
+
Close,
|
|
8610
|
+
"Coming soon": "Coming soon",
|
|
8611
|
+
Selected,
|
|
8612
|
+
Select,
|
|
8613
|
+
"Choose Builder Layout": "Choose Builder Layout",
|
|
8614
|
+
"Single side panel": "Single side panel",
|
|
8615
|
+
"Suitable for smaller screens. Bigger canvas size.": "Suitable for smaller screens. Bigger canvas size.",
|
|
8616
|
+
"Dual side panel": "Dual side panel",
|
|
8617
|
+
"Suitable for larger screens. Smaller canvas size.": "Suitable for larger screens. Smaller canvas size.",
|
|
8618
|
+
"Dual side panel advanced": "Dual side panel advanced",
|
|
8619
|
+
"Suitable for heavy styling & block editing. Setting are always visible.": "Suitable for heavy styling & block editing. Setting are always visible.",
|
|
8620
|
+
"Block Settings": "Block Settings",
|
|
8621
|
+
"Visibility settings": "Visibility settings",
|
|
8622
|
+
"Show on canvas": "Show on canvas",
|
|
8623
|
+
Attributes,
|
|
8624
|
+
"Apply Presets": "Apply Presets",
|
|
8625
|
+
apply,
|
|
8626
|
+
presets,
|
|
8627
|
+
"Global presets": "Global presets",
|
|
8628
|
+
Orientation,
|
|
8629
|
+
Color,
|
|
8630
|
+
"Please select an image": "Please select an image",
|
|
8631
|
+
"click to upload": "click to upload",
|
|
8632
|
+
"SVG, PNG, JPG or GIF (Max. 2mb)": "SVG, PNG, JPG or GIF (Max. 2mb)",
|
|
8633
|
+
"Uploading...": "Uploading...",
|
|
8634
|
+
Upload,
|
|
8635
|
+
"Something went wrong": "Something went wrong",
|
|
8636
|
+
"Fetching...": "Fetching...",
|
|
8637
|
+
"No images found": "No images found",
|
|
8638
|
+
"It looks like you haven't uploaded any images yet. Start by clicking the upload button above.": "It looks like you haven't uploaded any images yet. Start by clicking the upload button above.",
|
|
8639
|
+
"Open Code Editor": "Open Code Editor",
|
|
8640
|
+
"Clear search": "Clear search",
|
|
8641
|
+
"No results found for": "No results found for",
|
|
8642
|
+
"Search {{pageTypeName}}": "Search {{pageTypeName}}",
|
|
8643
|
+
"Goto Page": "Goto Page",
|
|
8644
|
+
"Open URL": "Open URL",
|
|
8645
|
+
"Compose Email": "Compose Email",
|
|
8646
|
+
"Call Phone": "Call Phone",
|
|
8647
|
+
"Scroll to element": "Scroll to element",
|
|
8648
|
+
"#ElementID": "#ElementID",
|
|
8649
|
+
"Enter details": "Enter details",
|
|
8650
|
+
"Open in new tab": "Open in new tab",
|
|
8651
|
+
Apply,
|
|
8652
|
+
Back,
|
|
8653
|
+
Insert,
|
|
8654
|
+
Rename,
|
|
8655
|
+
"Unlink from library": "Unlink from library",
|
|
8656
|
+
"Save to Library": "Save to Library",
|
|
8657
|
+
"No blocks found in this group": "No blocks found in this group",
|
|
8658
|
+
"No blocks found matching": "No blocks found matching",
|
|
8659
|
+
"No matching blocks found": "No matching blocks found",
|
|
8660
|
+
"Search blocks...": "Search blocks...",
|
|
8661
|
+
Partials,
|
|
8662
|
+
Happy,
|
|
8663
|
+
Sad,
|
|
8664
|
+
"Importing...": "Importing...",
|
|
8665
|
+
"Failed to load the UI library. Try again": "Failed to load the UI library. Try again",
|
|
8666
|
+
Retry,
|
|
8667
|
+
"Oops! Something went wrong.": "Oops! Something went wrong.",
|
|
8668
|
+
"Please try again.": "Please try again.",
|
|
8669
|
+
"No option found.": "No option found.",
|
|
8670
|
+
"Clipboard not supported": "Clipboard not supported",
|
|
8671
|
+
"Are you sure you want to clear the page?": "Are you sure you want to clear the page?",
|
|
8672
|
+
canvas_empty,
|
|
8673
|
+
Presets,
|
|
8674
|
+
"Reset style": "Reset style",
|
|
8675
|
+
"Reset styles": "Reset styles",
|
|
8676
|
+
"Clear styles": "Clear styles",
|
|
8677
|
+
"Open code editor": "Open code editor",
|
|
8678
|
+
"Style element": "Style element",
|
|
8679
|
+
"Repeater Data": "Repeater Data",
|
|
8680
|
+
"Toggle Data Binding": "Toggle Data Binding",
|
|
8681
|
+
No,
|
|
8682
|
+
Saving,
|
|
8683
|
+
"Screen sizes": "Screen sizes",
|
|
8684
|
+
"Theme Settings": "Theme Settings",
|
|
8685
|
+
"Import CSS Theme": "Import CSS Theme",
|
|
8686
|
+
"Import theme": "Import theme",
|
|
8687
|
+
"Import Theme": "Import Theme",
|
|
8688
|
+
"CSS Variables": "CSS Variables",
|
|
8689
|
+
"You don't have permission to edit settings or styles": "You don't have permission to edit settings or styles",
|
|
8690
|
+
"Please contact your administrator to get access": "Please contact your administrator to get access",
|
|
8531
8691
|
"flex.heading": "Flex Child",
|
|
8532
8692
|
"flex.basis": "Basis",
|
|
8533
8693
|
"flex.order": "Order",
|
|
@@ -8697,64 +8857,7 @@ const Input = ({ node: o }) => {
|
|
|
8697
8857
|
"effect.delay": "Delay",
|
|
8698
8858
|
"classes.heading": "Classes",
|
|
8699
8859
|
theme_config,
|
|
8700
|
-
web_blocks
|
|
8701
|
-
"Copy classes to clipboard": "Copy classes to clipboard",
|
|
8702
|
-
"Classes copied to clipboard": "Classes copied to clipboard",
|
|
8703
|
-
"Show hidden blocks": "Show hidden blocks",
|
|
8704
|
-
"Expand all": "Expand all",
|
|
8705
|
-
"Collapse all": "Collapse all",
|
|
8706
|
-
"Choose library": "Choose library",
|
|
8707
|
-
"Close Preview": "Close Preview",
|
|
8708
|
-
Error: "Error",
|
|
8709
|
-
"Failed to copy template": "Failed to copy template",
|
|
8710
|
-
"Total tokens used": "Total tokens used",
|
|
8711
|
-
"Updated AI Context": "Updated AI Context",
|
|
8712
|
-
"You can now Ask AI to edit your content": "You can now Ask AI to edit your content",
|
|
8713
|
-
"Tell about this page eg this page is about": "Tell about this page eg this page is about..",
|
|
8714
|
-
"Delete Context": "Delete Context",
|
|
8715
|
-
"Keyboard shortcuts": "Keyboard shortcuts",
|
|
8716
|
-
Undo,
|
|
8717
|
-
Redo,
|
|
8718
|
-
Duplicate,
|
|
8719
|
-
"Deselect blocks": "Deselect blocks",
|
|
8720
|
-
"Delete block": "Delete block",
|
|
8721
|
-
"Save page": "Save page",
|
|
8722
|
-
"Scripts will be only executed in preview and live mode.": "Scripts will be only executed in preview and live mode.",
|
|
8723
|
-
"HTML Code Editor |": "HTML Code Editor |",
|
|
8724
|
-
Close,
|
|
8725
|
-
"Coming soon": "Coming soon",
|
|
8726
|
-
Selected,
|
|
8727
|
-
Select,
|
|
8728
|
-
"Choose Builder Layout": "Choose Builder Layout",
|
|
8729
|
-
"Single side panel": "Single side panel",
|
|
8730
|
-
"Suitable for smaller screens. Bigger canvas size.": "Suitable for smaller screens. Bigger canvas size.",
|
|
8731
|
-
"Dual side panel": "Dual side panel",
|
|
8732
|
-
"Suitable for larger screens. Smaller canvas size.": "Suitable for larger screens. Smaller canvas size.",
|
|
8733
|
-
"Dual side panel advanced": "Dual side panel advanced",
|
|
8734
|
-
"Suitable for heavy styling & block editing. Setting are always visible.": "Suitable for heavy styling & block editing. Setting are always visible.",
|
|
8735
|
-
"Block Settings": "Block Settings",
|
|
8736
|
-
"Visibility settings": "Visibility settings",
|
|
8737
|
-
"Show on canvas": "Show on canvas",
|
|
8738
|
-
Attributes,
|
|
8739
|
-
"Apply Presets": "Apply Presets",
|
|
8740
|
-
apply,
|
|
8741
|
-
presets,
|
|
8742
|
-
"Global presets": "Global presets",
|
|
8743
|
-
Orientation,
|
|
8744
|
-
Color,
|
|
8745
|
-
"Please select an image": "Please select an image",
|
|
8746
|
-
"click to upload": "click to upload",
|
|
8747
|
-
"SVG, PNG, JPG or GIF (Max. 2mb)": "SVG, PNG, JPG or GIF (Max. 2mb)",
|
|
8748
|
-
"Uploading...": "Uploading...",
|
|
8749
|
-
Upload,
|
|
8750
|
-
"Something went wrong": "Something went wrong",
|
|
8751
|
-
"Fetching...": "Fetching...",
|
|
8752
|
-
"No images found": "No images found",
|
|
8753
|
-
"It looks like you haven't uploaded any images yet. Start by clicking the upload button above.": "It looks like you haven't uploaded any images yet. Start by clicking the upload button above.",
|
|
8754
|
-
"Open Code Editor": "Open Code Editor",
|
|
8755
|
-
"Clear search": "Clear search",
|
|
8756
|
-
"No results found for": "No results found for",
|
|
8757
|
-
"Search {pageTypeName}": "Search {pageTypeName}"
|
|
8860
|
+
web_blocks
|
|
8758
8861
|
};
|
|
8759
8862
|
i18n.use(initReactI18next).init({
|
|
8760
8863
|
// the translations
|
|
@@ -8795,106 +8898,103 @@ const CHAI_FEATURE_FLAGS = {}, registerChaiFeatureFlag = (o, n) => {
|
|
|
8795
8898
|
registerChaiFeatureFlag("enable-ai-chat-left", {
|
|
8796
8899
|
description: "Enable AI chat on the left side"
|
|
8797
8900
|
});
|
|
8798
|
-
}
|
|
8799
|
-
{
|
|
8800
|
-
name: "Improve writing",
|
|
8801
|
-
icon: Pencil2Icon,
|
|
8802
|
-
prompt: "Improving writing in all text elements. Replacing placeholder content with meaningful relevant content."
|
|
8803
|
-
},
|
|
8804
|
-
{
|
|
8805
|
-
name: "Replace placeholder content",
|
|
8806
|
-
icon: LoopIcon,
|
|
8807
|
-
prompt: "Discard current placeholder content and replace with meaningful relevant content."
|
|
8808
|
-
},
|
|
8809
|
-
//TODO: Add tone options
|
|
8810
|
-
// {
|
|
8811
|
-
// name: "Change tone",
|
|
8812
|
-
// icon: MegaphoneIcon,
|
|
8813
|
-
// subMenus: ["joyful", "serious", "angry", "sad", "excited", "relaxed", "confident", "assertive", "polite"],
|
|
8814
|
-
// prompt: "Change tone in all text elements. Rewrite all text elements in a more _TONE_ tone.",
|
|
8815
|
-
// },
|
|
8816
|
-
{
|
|
8817
|
-
name: "Fix grammar",
|
|
8818
|
-
icon: CheckIcon,
|
|
8819
|
-
prompt: "Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors."
|
|
8820
|
-
},
|
|
8821
|
-
{
|
|
8822
|
-
name: "Make longer",
|
|
8823
|
-
icon: ArrowUpIcon,
|
|
8824
|
-
prompt: "Make all text elements longer."
|
|
8825
|
-
},
|
|
8826
|
-
{
|
|
8827
|
-
name: "Make shorter",
|
|
8828
|
-
icon: ArrowDownIcon,
|
|
8829
|
-
prompt: "Make all text elements shorter."
|
|
8830
|
-
},
|
|
8831
|
-
{
|
|
8832
|
-
name: "Add emojis",
|
|
8833
|
-
icon: FaceIcon,
|
|
8834
|
-
prompt: "Add emojis to text elements if relevant."
|
|
8835
|
-
},
|
|
8836
|
-
{
|
|
8837
|
-
name: "Randomize",
|
|
8838
|
-
icon: ShuffleIcon,
|
|
8839
|
-
prompt: "Randomize all text elements."
|
|
8840
|
-
}
|
|
8841
|
-
];
|
|
8901
|
+
};
|
|
8842
8902
|
function QuickPrompts({ onClick: o }) {
|
|
8843
|
-
const { loading: n } = useAskAi(), { t: r } = useTranslation(), { selectedLang: a, fallbackLang: l } = useLanguages(),
|
|
8844
|
-
|
|
8845
|
-
|
|
8903
|
+
const { loading: n } = useAskAi(), { t: r } = useTranslation(), { selectedLang: a, fallbackLang: l } = useLanguages(), c = [...[
|
|
8904
|
+
{
|
|
8905
|
+
name: r("Improve writing"),
|
|
8906
|
+
icon: Pencil2Icon,
|
|
8907
|
+
prompt: r(
|
|
8908
|
+
"Improving writing in all text elements. Replacing placeholder content with meaningful relevant content."
|
|
8909
|
+
)
|
|
8910
|
+
},
|
|
8911
|
+
{
|
|
8912
|
+
name: r("Replace placeholder content"),
|
|
8913
|
+
icon: LoopIcon,
|
|
8914
|
+
prompt: r("Discard current placeholder content and replace with meaningful relevant content.")
|
|
8915
|
+
},
|
|
8916
|
+
{
|
|
8917
|
+
name: r("Fix grammar"),
|
|
8918
|
+
icon: CheckIcon,
|
|
8919
|
+
prompt: r("Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.")
|
|
8920
|
+
},
|
|
8921
|
+
{
|
|
8922
|
+
name: r("Make longer"),
|
|
8923
|
+
icon: ArrowUpIcon,
|
|
8924
|
+
prompt: r("Make all text elements longer.")
|
|
8925
|
+
},
|
|
8926
|
+
{
|
|
8927
|
+
name: r("Make shorter"),
|
|
8928
|
+
icon: ArrowDownIcon,
|
|
8929
|
+
prompt: r("Make all text elements shorter.")
|
|
8930
|
+
},
|
|
8931
|
+
{
|
|
8932
|
+
name: r("Add emojis"),
|
|
8933
|
+
icon: FaceIcon,
|
|
8934
|
+
prompt: r("Add emojis to text elements if relevant.")
|
|
8935
|
+
},
|
|
8936
|
+
{
|
|
8937
|
+
name: r("Randomize"),
|
|
8938
|
+
icon: ShuffleIcon,
|
|
8939
|
+
prompt: r("Randomize all text elements.")
|
|
8940
|
+
}
|
|
8941
|
+
]];
|
|
8942
|
+
return a && a !== l && c.splice(0, 0, {
|
|
8943
|
+
name: r("Translate to %s", get(LANGUAGES, a, a)),
|
|
8846
8944
|
icon: ChatBubbleIcon,
|
|
8847
|
-
prompt:
|
|
8848
|
-
|
|
8849
|
-
|
|
8945
|
+
prompt: r(
|
|
8946
|
+
"Translate the content to %s. Maintain same tone, style and length.",
|
|
8947
|
+
get(LANGUAGES, a, a)
|
|
8948
|
+
)
|
|
8949
|
+
}), /* @__PURE__ */ jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: c.map(
|
|
8950
|
+
({ name: d, icon: p, subMenus: u, prompt: g }) => u ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
8850
8951
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
8851
8952
|
"li",
|
|
8852
8953
|
{
|
|
8853
8954
|
className: "flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
8854
8955
|
children: [
|
|
8855
|
-
/* @__PURE__ */ jsx(
|
|
8856
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
8956
|
+
/* @__PURE__ */ jsx(p, { className: "h-4 w-4" }),
|
|
8957
|
+
/* @__PURE__ */ jsx("span", { children: d })
|
|
8857
8958
|
]
|
|
8858
8959
|
},
|
|
8859
|
-
|
|
8960
|
+
d
|
|
8860
8961
|
) }),
|
|
8861
|
-
/* @__PURE__ */ jsx(PopoverContent, { side: "right", children: /* @__PURE__ */ jsx("ul", { children: /* @__PURE__ */ jsx("li", { children: "Happy" }) }) })
|
|
8962
|
+
/* @__PURE__ */ jsx(PopoverContent, { side: "right", children: /* @__PURE__ */ jsx("ul", { children: /* @__PURE__ */ jsx("li", { children: r("Happy") }) }) })
|
|
8862
8963
|
] }) : /* @__PURE__ */ jsxs(
|
|
8863
8964
|
"li",
|
|
8864
8965
|
{
|
|
8865
|
-
onClick: () => o(
|
|
8966
|
+
onClick: () => o(g),
|
|
8866
8967
|
className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
8867
8968
|
children: [
|
|
8868
|
-
/* @__PURE__ */ jsx(
|
|
8869
|
-
/* @__PURE__ */ jsx("span", { children: r(
|
|
8969
|
+
/* @__PURE__ */ jsx(p, { className: "h-4 w-4" }),
|
|
8970
|
+
/* @__PURE__ */ jsx("span", { children: r(d) })
|
|
8870
8971
|
]
|
|
8871
8972
|
},
|
|
8872
|
-
|
|
8973
|
+
d
|
|
8873
8974
|
)
|
|
8874
8975
|
) }) });
|
|
8875
8976
|
}
|
|
8876
8977
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8877
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""),
|
|
8978
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null);
|
|
8878
8979
|
useEffect(() => {
|
|
8879
|
-
var
|
|
8880
|
-
(
|
|
8980
|
+
var g;
|
|
8981
|
+
(g = d.current) == null || g.focus();
|
|
8881
8982
|
}, []);
|
|
8882
|
-
const
|
|
8883
|
-
|
|
8884
|
-
!l && f && p(f), g.current = setTimeout(() => p(void 0), 1e4), l || c("");
|
|
8983
|
+
const u = () => {
|
|
8984
|
+
l || c("");
|
|
8885
8985
|
};
|
|
8886
8986
|
return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "mt-2", children: [
|
|
8887
8987
|
/* @__PURE__ */ jsx(
|
|
8888
8988
|
Textarea,
|
|
8889
8989
|
{
|
|
8890
|
-
ref:
|
|
8990
|
+
ref: d,
|
|
8891
8991
|
value: i,
|
|
8892
|
-
onChange: (
|
|
8992
|
+
onChange: (g) => c(g.target.value),
|
|
8893
8993
|
placeholder: n("Ask AI to edit content"),
|
|
8894
8994
|
className: "w-full",
|
|
8895
8995
|
rows: 3,
|
|
8896
|
-
onKeyDown: (
|
|
8897
|
-
|
|
8996
|
+
onKeyDown: (g) => {
|
|
8997
|
+
g.key === "Enter" && (g.preventDefault(), p.current && clearTimeout(p.current), r("content", o, i, u));
|
|
8898
8998
|
}
|
|
8899
8999
|
}
|
|
8900
9000
|
),
|
|
@@ -8904,7 +9004,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8904
9004
|
{
|
|
8905
9005
|
disabled: i.trim().length < 5 || a,
|
|
8906
9006
|
onClick: () => {
|
|
8907
|
-
|
|
9007
|
+
p.current && clearTimeout(p.current), r("content", o, i, u);
|
|
8908
9008
|
},
|
|
8909
9009
|
variant: "default",
|
|
8910
9010
|
className: "w-fit",
|
|
@@ -8923,21 +9023,13 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8923
9023
|
/* @__PURE__ */ jsx(Button, { variant: "destructive", onClick: () => stop(), className: "hidden w-fit", size: "sm", children: n("Stop") })
|
|
8924
9024
|
] }) : null
|
|
8925
9025
|
] }),
|
|
8926
|
-
d ? /* @__PURE__ */ jsx("div", { className: "max-w-full", children: /* @__PURE__ */ jsxs("p", { className: "mb-1 flex justify-between break-words rounded border border-blue-500 bg-blue-100 p-1 text-xs text-blue-500", children: [
|
|
8927
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
8928
|
-
n("Total tokens used"),
|
|
8929
|
-
": ",
|
|
8930
|
-
d.totalTokens
|
|
8931
|
-
] }),
|
|
8932
|
-
/* @__PURE__ */ jsx(Countdown, {})
|
|
8933
|
-
] }) }) : null,
|
|
8934
9026
|
/* @__PURE__ */ jsx("div", { className: "max-w-full", children: l && /* @__PURE__ */ jsx("p", { className: "break-words rounded border border-red-500 bg-red-100 p-1 text-xs text-red-500", children: l.message }) }),
|
|
8935
9027
|
/* @__PURE__ */ jsx("br", {}),
|
|
8936
9028
|
/* @__PURE__ */ jsx(
|
|
8937
9029
|
QuickPrompts,
|
|
8938
9030
|
{
|
|
8939
|
-
onClick: (
|
|
8940
|
-
|
|
9031
|
+
onClick: (g) => {
|
|
9032
|
+
p.current && clearTimeout(p.current), r("content", o, g, u);
|
|
8941
9033
|
}
|
|
8942
9034
|
}
|
|
8943
9035
|
)
|
|
@@ -8997,28 +9089,28 @@ function AIChatPanel() {
|
|
|
8997
9089
|
content: r,
|
|
8998
9090
|
timestamp: /* @__PURE__ */ new Date()
|
|
8999
9091
|
};
|
|
9000
|
-
n((
|
|
9001
|
-
const
|
|
9092
|
+
n((k) => [...k, b]), a(""), i(!0), setTimeout(() => {
|
|
9093
|
+
const k = {
|
|
9002
9094
|
id: (Date.now() + 1).toString(),
|
|
9003
9095
|
role: "assistant",
|
|
9004
9096
|
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.",
|
|
9005
9097
|
timestamp: /* @__PURE__ */ new Date()
|
|
9006
9098
|
};
|
|
9007
|
-
n((B) => [...B,
|
|
9099
|
+
n((B) => [...B, k]), i(!1), d(null);
|
|
9008
9100
|
}, 1500);
|
|
9009
9101
|
}, h = (b) => {
|
|
9010
9102
|
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), m());
|
|
9011
|
-
},
|
|
9103
|
+
}, x = (b) => {
|
|
9012
9104
|
var B;
|
|
9013
|
-
const
|
|
9014
|
-
if (
|
|
9105
|
+
const k = (B = b.target.files) == null ? void 0 : B[0];
|
|
9106
|
+
if (k) {
|
|
9015
9107
|
const j = new FileReader();
|
|
9016
|
-
j.onload = (
|
|
9017
|
-
var
|
|
9018
|
-
d((
|
|
9019
|
-
}, j.readAsDataURL(
|
|
9108
|
+
j.onload = (E) => {
|
|
9109
|
+
var C;
|
|
9110
|
+
d((C = E.target) == null ? void 0 : C.result);
|
|
9111
|
+
}, j.readAsDataURL(k);
|
|
9020
9112
|
}
|
|
9021
|
-
},
|
|
9113
|
+
}, f = () => {
|
|
9022
9114
|
var b;
|
|
9023
9115
|
(b = p.current) == null || b.click();
|
|
9024
9116
|
}, y = () => {
|
|
@@ -9085,14 +9177,14 @@ function AIChatPanel() {
|
|
|
9085
9177
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9086
9178
|
}
|
|
9087
9179
|
),
|
|
9088
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange:
|
|
9180
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: x, accept: "image/*", className: "hidden" }),
|
|
9089
9181
|
/* @__PURE__ */ jsx(
|
|
9090
9182
|
Button,
|
|
9091
9183
|
{
|
|
9092
9184
|
size: "icon",
|
|
9093
9185
|
variant: "ghost",
|
|
9094
9186
|
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9095
|
-
onClick:
|
|
9187
|
+
onClick: f,
|
|
9096
9188
|
children: /* @__PURE__ */ jsx(ImageIcon, { className: "h-4 w-4 text-muted-foreground" })
|
|
9097
9189
|
}
|
|
9098
9190
|
)
|
|
@@ -9144,7 +9236,7 @@ const AiAssistant = () => {
|
|
|
9144
9236
|
] }) }),
|
|
9145
9237
|
/* @__PURE__ */ jsxs(AlertDialogContent, { className: "border-border", children: [
|
|
9146
9238
|
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
9147
|
-
/* @__PURE__ */ jsx(AlertDialogTitle, { className: "text-foreground", children: o("Clear whole canvas?
|
|
9239
|
+
/* @__PURE__ */ jsx(AlertDialogTitle, { className: "text-foreground", children: o("Clear whole canvas?") }),
|
|
9148
9240
|
/* @__PURE__ */ jsx(AlertDialogDescription, { children: o("Are you sure you want to clear the page?") })
|
|
9149
9241
|
] }),
|
|
9150
9242
|
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
@@ -9210,62 +9302,62 @@ const AiAssistant = () => {
|
|
|
9210
9302
|
preloadedAttributes: n = [],
|
|
9211
9303
|
onAttributesChange: r
|
|
9212
9304
|
}) {
|
|
9213
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""),
|
|
9305
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), x = useRef(null), f = useRef(null), y = usePageExternalData(), { t: b } = useTranslation();
|
|
9214
9306
|
useEffect(() => {
|
|
9215
9307
|
l(n);
|
|
9216
9308
|
}, [n]);
|
|
9217
|
-
const
|
|
9309
|
+
const k = () => {
|
|
9218
9310
|
if (i.startsWith("@")) {
|
|
9219
9311
|
h("Attribute keys cannot start with '@'");
|
|
9220
9312
|
return;
|
|
9221
9313
|
}
|
|
9222
9314
|
if (i) {
|
|
9223
|
-
const
|
|
9224
|
-
r(
|
|
9315
|
+
const S = [...a, { key: i, value: d }];
|
|
9316
|
+
r(S), l(a), c(""), p(""), h("");
|
|
9225
9317
|
}
|
|
9226
|
-
},
|
|
9227
|
-
const
|
|
9228
|
-
r(
|
|
9229
|
-
},
|
|
9230
|
-
g(
|
|
9231
|
-
},
|
|
9318
|
+
}, B = (S) => {
|
|
9319
|
+
const I = a.filter((A, w) => w !== S);
|
|
9320
|
+
r(I), l(I);
|
|
9321
|
+
}, j = (S) => {
|
|
9322
|
+
g(S), c(a[S].key), p(a[S].value);
|
|
9323
|
+
}, E = () => {
|
|
9232
9324
|
if (i.startsWith("@")) {
|
|
9233
9325
|
h("Attribute keys cannot start with '@'");
|
|
9234
9326
|
return;
|
|
9235
9327
|
}
|
|
9236
9328
|
if (u !== null && i) {
|
|
9237
|
-
const
|
|
9238
|
-
|
|
9329
|
+
const S = [...a];
|
|
9330
|
+
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), h("");
|
|
9239
9331
|
}
|
|
9240
|
-
},
|
|
9241
|
-
|
|
9242
|
-
},
|
|
9243
|
-
const
|
|
9244
|
-
let
|
|
9245
|
-
const
|
|
9246
|
-
return
|
|
9247
|
-
text:
|
|
9248
|
-
prefixLength:
|
|
9249
|
-
suffixLength:
|
|
9332
|
+
}, C = (S) => {
|
|
9333
|
+
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? E() : k());
|
|
9334
|
+
}, v = useCallback((S) => {
|
|
9335
|
+
const I = (_) => /[.,!?;:]/.test(_), A = (_, L, T) => {
|
|
9336
|
+
let P = "", R = "";
|
|
9337
|
+
const N = L > 0 ? _[L - 1] : "", D = L < _.length ? _[L] : "";
|
|
9338
|
+
return L > 0 && (N === "." || !I(N) && N !== " ") && (P = " "), L < _.length && !I(D) && D !== " " && (R = " "), {
|
|
9339
|
+
text: P + T + R,
|
|
9340
|
+
prefixLength: P.length,
|
|
9341
|
+
suffixLength: R.length
|
|
9250
9342
|
};
|
|
9251
|
-
},
|
|
9252
|
-
if (
|
|
9253
|
-
const
|
|
9254
|
-
if (
|
|
9255
|
-
const
|
|
9256
|
-
p(
|
|
9343
|
+
}, w = f.current;
|
|
9344
|
+
if (w) {
|
|
9345
|
+
const _ = w.selectionStart || 0, L = w.value || "", T = w.selectionEnd || _;
|
|
9346
|
+
if (T > _) {
|
|
9347
|
+
const F = `{{${S}}}`, { text: O } = A(L, _, F), M = L.slice(0, _) + O + L.slice(T);
|
|
9348
|
+
p(M);
|
|
9257
9349
|
return;
|
|
9258
9350
|
}
|
|
9259
|
-
const
|
|
9260
|
-
p(
|
|
9351
|
+
const R = `{{${S}}}`, { text: N } = A(L, _, R), D = L.slice(0, _) + N + L.slice(_);
|
|
9352
|
+
p(D);
|
|
9261
9353
|
}
|
|
9262
9354
|
}, []);
|
|
9263
9355
|
return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
|
|
9264
9356
|
/* @__PURE__ */ jsxs(
|
|
9265
9357
|
"form",
|
|
9266
9358
|
{
|
|
9267
|
-
onSubmit: (
|
|
9268
|
-
|
|
9359
|
+
onSubmit: (S) => {
|
|
9360
|
+
S.preventDefault(), u !== null ? E() : k();
|
|
9269
9361
|
},
|
|
9270
9362
|
className: "space-y-3",
|
|
9271
9363
|
children: [
|
|
@@ -9279,10 +9371,10 @@ const AiAssistant = () => {
|
|
|
9279
9371
|
autoCorrect: "off",
|
|
9280
9372
|
spellCheck: "false",
|
|
9281
9373
|
id: "attrKey",
|
|
9282
|
-
ref:
|
|
9374
|
+
ref: x,
|
|
9283
9375
|
value: i,
|
|
9284
|
-
onChange: (
|
|
9285
|
-
placeholder: "Enter Key",
|
|
9376
|
+
onChange: (S) => c(S.target.value),
|
|
9377
|
+
placeholder: b("Enter Key"),
|
|
9286
9378
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9287
9379
|
}
|
|
9288
9380
|
)
|
|
@@ -9290,7 +9382,7 @@ const AiAssistant = () => {
|
|
|
9290
9382
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9291
9383
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9292
9384
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9293
|
-
!isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect:
|
|
9385
|
+
!isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: v })
|
|
9294
9386
|
] }),
|
|
9295
9387
|
/* @__PURE__ */ jsx(
|
|
9296
9388
|
Textarea,
|
|
@@ -9300,10 +9392,10 @@ const AiAssistant = () => {
|
|
|
9300
9392
|
spellCheck: "false",
|
|
9301
9393
|
id: "attrValue",
|
|
9302
9394
|
rows: 2,
|
|
9303
|
-
ref:
|
|
9395
|
+
ref: f,
|
|
9304
9396
|
value: d,
|
|
9305
|
-
onChange: (
|
|
9306
|
-
onKeyDown:
|
|
9397
|
+
onChange: (S) => p(S.target.value),
|
|
9398
|
+
onKeyDown: C,
|
|
9307
9399
|
placeholder: "Enter Value",
|
|
9308
9400
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9309
9401
|
}
|
|
@@ -9315,16 +9407,16 @@ const AiAssistant = () => {
|
|
|
9315
9407
|
]
|
|
9316
9408
|
}
|
|
9317
9409
|
),
|
|
9318
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
9410
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, I) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9319
9411
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9320
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9321
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children:
|
|
9412
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
|
|
9413
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
|
|
9322
9414
|
] }),
|
|
9323
9415
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9324
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9325
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9416
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => j(I), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
|
|
9417
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(I), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
|
|
9326
9418
|
] })
|
|
9327
|
-
] },
|
|
9419
|
+
] }, I)) })
|
|
9328
9420
|
] });
|
|
9329
9421
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9330
9422
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -9429,9 +9521,9 @@ const PartialWrapper = ({ partialBlockId: o }) => {
|
|
|
9429
9521
|
/* @__PURE__ */ jsx("br", {})
|
|
9430
9522
|
] }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "settings", className: "flex flex-1 flex-col", children: [
|
|
9431
9523
|
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
|
|
9432
|
-
/* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: "Settings" }),
|
|
9524
|
+
/* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: n("Settings") }),
|
|
9433
9525
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "styles", className: "text-xs", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
9434
|
-
/* @__PURE__ */ jsx("span", { className: "w-[90%] text-center", children: "
|
|
9526
|
+
/* @__PURE__ */ jsx("span", { className: "w-[90%] text-center", children: n("Styling") }),
|
|
9435
9527
|
/* @__PURE__ */ jsx("span", { className: "w-[10%]", children: /* @__PURE__ */ jsx(ResetStylesButton, {}) })
|
|
9436
9528
|
] }) })
|
|
9437
9529
|
] }) }),
|
|
@@ -9494,40 +9586,40 @@ function useSidebarDefaultPanels() {
|
|
|
9494
9586
|
}, [o, n, r]);
|
|
9495
9587
|
}
|
|
9496
9588
|
const RootLayout = () => {
|
|
9497
|
-
const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = reverse([...g ?? []]), h = useCallback((
|
|
9498
|
-
|
|
9499
|
-
}, []),
|
|
9500
|
-
(
|
|
9501
|
-
console.log("handleMenuItemClick",
|
|
9589
|
+
const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = reverse([...g ?? []]), h = useCallback((S) => {
|
|
9590
|
+
S.preventDefault();
|
|
9591
|
+
}, []), x = useCallback(
|
|
9592
|
+
(S) => {
|
|
9593
|
+
console.log("handleMenuItemClick", S, n), r(n === S ? null : S);
|
|
9502
9594
|
},
|
|
9503
9595
|
[n, r]
|
|
9504
|
-
), { t:
|
|
9596
|
+
), { t: f } = useTranslation(), y = useMemo(
|
|
9505
9597
|
() => [...p, ...u, ...g],
|
|
9506
9598
|
[p, u, g]
|
|
9507
|
-
), b = useBuilderProp("htmlDir", "ltr"),
|
|
9599
|
+
), b = useBuilderProp("htmlDir", "ltr"), k = find(y, { id: n }) ?? first(y), B = get(k, "width", DEFAULT_PANEL_WIDTH);
|
|
9508
9600
|
useEffect(() => {
|
|
9509
9601
|
if (n !== null) {
|
|
9510
|
-
const
|
|
9511
|
-
|
|
9602
|
+
const S = find(y, { id: n });
|
|
9603
|
+
S && get(S, "view", "standard") === "standard" && (a.current = n, i(get(S, "width", DEFAULT_PANEL_WIDTH)));
|
|
9512
9604
|
}
|
|
9513
9605
|
}, [n, y]);
|
|
9514
9606
|
const j = useMemo(() => {
|
|
9515
9607
|
if (n === null) return 0;
|
|
9516
|
-
const
|
|
9517
|
-
return get(
|
|
9518
|
-
}, [n, B, l, y]),
|
|
9608
|
+
const S = find(y, { id: n });
|
|
9609
|
+
return get(S, "view", "standard") === "standard" ? B : l;
|
|
9610
|
+
}, [n, B, l, y]), E = useCallback(() => {
|
|
9519
9611
|
r(a.current);
|
|
9520
|
-
}, [r, n]),
|
|
9612
|
+
}, [r, n]), C = useCallback(() => {
|
|
9521
9613
|
r("outline");
|
|
9522
9614
|
}, [r]);
|
|
9523
9615
|
useEffect(() => {
|
|
9524
9616
|
n !== null && !find(y, { id: n }) && r("outline");
|
|
9525
9617
|
}, [n, y]);
|
|
9526
|
-
const
|
|
9527
|
-
(
|
|
9528
|
-
|
|
9618
|
+
const v = useCallback(
|
|
9619
|
+
(S) => {
|
|
9620
|
+
x(S);
|
|
9529
9621
|
},
|
|
9530
|
-
[
|
|
9622
|
+
[x]
|
|
9531
9623
|
);
|
|
9532
9624
|
return /* @__PURE__ */ jsx("div", { dir: b, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9533
9625
|
/* @__PURE__ */ jsxs(
|
|
@@ -9539,25 +9631,25 @@ const RootLayout = () => {
|
|
|
9539
9631
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9540
9632
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9541
9633
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9542
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((
|
|
9543
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9634
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((S, I) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9635
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
|
|
9544
9636
|
position: "top",
|
|
9545
|
-
panelId:
|
|
9546
|
-
isActive: n ===
|
|
9547
|
-
show: () =>
|
|
9637
|
+
panelId: S.id,
|
|
9638
|
+
isActive: n === S.id,
|
|
9639
|
+
show: () => v(S.id)
|
|
9548
9640
|
}) }),
|
|
9549
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9550
|
-
] }, "button-top-" +
|
|
9641
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
|
|
9642
|
+
] }, "button-top-" + I)) }),
|
|
9551
9643
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9552
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m == null ? void 0 : m.map((
|
|
9553
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9644
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m == null ? void 0 : m.map((S, I) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9645
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
|
|
9554
9646
|
position: "bottom",
|
|
9555
|
-
panelId:
|
|
9556
|
-
isActive: n ===
|
|
9557
|
-
show: () =>
|
|
9647
|
+
panelId: S.id,
|
|
9648
|
+
isActive: n === S.id,
|
|
9649
|
+
show: () => v(S.id)
|
|
9558
9650
|
}) }),
|
|
9559
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9560
|
-
] }, "button-bottom-" +
|
|
9651
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
|
|
9652
|
+
] }, "button-bottom-" + I)) })
|
|
9561
9653
|
] }),
|
|
9562
9654
|
/* @__PURE__ */ jsx(
|
|
9563
9655
|
motion.div,
|
|
@@ -9567,15 +9659,15 @@ const RootLayout = () => {
|
|
|
9567
9659
|
initial: { width: j },
|
|
9568
9660
|
animate: { width: j },
|
|
9569
9661
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
9570
|
-
children: n !== null && get(
|
|
9662
|
+
children: n !== null && get(k, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
|
|
9571
9663
|
/* @__PURE__ */ jsx(
|
|
9572
9664
|
"div",
|
|
9573
9665
|
{
|
|
9574
|
-
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(
|
|
9575
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9666
|
+
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(k, "isInternal", !1) ? "" : "w-64"}`,
|
|
9667
|
+
children: /* @__PURE__ */ jsx("span", { children: f(get(k, "label", "")) })
|
|
9576
9668
|
}
|
|
9577
9669
|
),
|
|
9578
|
-
/* @__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(
|
|
9670
|
+
/* @__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(k, "panel", NoopComponent), {}) }) })
|
|
9579
9671
|
] })
|
|
9580
9672
|
}
|
|
9581
9673
|
),
|
|
@@ -9595,11 +9687,11 @@ const RootLayout = () => {
|
|
|
9595
9687
|
/* @__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: [
|
|
9596
9688
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9597
9689
|
" ",
|
|
9598
|
-
|
|
9690
|
+
f("AI Assistant")
|
|
9599
9691
|
] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9600
9692
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9601
9693
|
/* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "h-4 w-4 text-gray-600" }),
|
|
9602
|
-
|
|
9694
|
+
f("Theme Settings")
|
|
9603
9695
|
] }),
|
|
9604
9696
|
/* @__PURE__ */ jsx(
|
|
9605
9697
|
Button,
|
|
@@ -9621,7 +9713,7 @@ const RootLayout = () => {
|
|
|
9621
9713
|
}
|
|
9622
9714
|
),
|
|
9623
9715
|
/* @__PURE__ */ jsx(AddBlocksDialog, {}),
|
|
9624
|
-
n !== null && get(
|
|
9716
|
+
n !== null && get(k, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => E(), children: /* @__PURE__ */ jsxs(
|
|
9625
9717
|
SheetContent,
|
|
9626
9718
|
{
|
|
9627
9719
|
side: "left",
|
|
@@ -9629,26 +9721,26 @@ const RootLayout = () => {
|
|
|
9629
9721
|
style: { width: `${B}px` },
|
|
9630
9722
|
children: [
|
|
9631
9723
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
9632
|
-
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(
|
|
9633
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9724
|
+
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(k, "icon", null) }),
|
|
9725
|
+
/* @__PURE__ */ jsx("span", { children: f(get(k, "label", "")) })
|
|
9634
9726
|
] }) }),
|
|
9635
|
-
/* @__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(
|
|
9636
|
-
close:
|
|
9727
|
+
/* @__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(k, "panel", NoopComponent), {
|
|
9728
|
+
close: C
|
|
9637
9729
|
}) }) })
|
|
9638
9730
|
]
|
|
9639
9731
|
}
|
|
9640
9732
|
) }),
|
|
9641
9733
|
" ",
|
|
9642
|
-
n !== null && get(
|
|
9734
|
+
n !== null && get(k, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => E(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${B}px` }, children: [
|
|
9643
9735
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
9644
|
-
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(
|
|
9645
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9736
|
+
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(k, "icon", null) }),
|
|
9737
|
+
/* @__PURE__ */ jsx("span", { children: f(get(k, "label", "")) })
|
|
9646
9738
|
] }) }),
|
|
9647
|
-
/* @__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(
|
|
9648
|
-
close:
|
|
9739
|
+
/* @__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(k, "panel", NoopComponent), {
|
|
9740
|
+
close: C
|
|
9649
9741
|
}) }) })
|
|
9650
9742
|
] }) }),
|
|
9651
|
-
n !== null && get(
|
|
9743
|
+
n !== null && get(k, "view") === "overlay" && /* @__PURE__ */ jsx(
|
|
9652
9744
|
motion.div,
|
|
9653
9745
|
{
|
|
9654
9746
|
className: "absolute bottom-0 left-12 right-0 top-0 z-50",
|
|
@@ -9667,13 +9759,13 @@ const RootLayout = () => {
|
|
|
9667
9759
|
children: [
|
|
9668
9760
|
/* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
|
|
9669
9761
|
/* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
|
|
9670
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
9671
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9762
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(k, "icon", null) }),
|
|
9763
|
+
/* @__PURE__ */ jsx("span", { children: f(get(k, "label", "")) })
|
|
9672
9764
|
] }),
|
|
9673
|
-
/* @__PURE__ */ jsx(Button, { onClick: () =>
|
|
9765
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => E(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
|
|
9674
9766
|
] }),
|
|
9675
|
-
/* @__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(
|
|
9676
|
-
close:
|
|
9767
|
+
/* @__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(k, "panel", NoopComponent), {
|
|
9768
|
+
close: C
|
|
9677
9769
|
}) }) })
|
|
9678
9770
|
]
|
|
9679
9771
|
}
|
|
@@ -9712,36 +9804,36 @@ const RootLayout = () => {
|
|
|
9712
9804
|
}) => {
|
|
9713
9805
|
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
|
|
9714
9806
|
if (!l.trim()) return a;
|
|
9715
|
-
const
|
|
9807
|
+
const f = l.toLowerCase();
|
|
9716
9808
|
return Object.fromEntries(
|
|
9717
9809
|
Object.entries(a).filter(([y, b]) => {
|
|
9718
|
-
var
|
|
9719
|
-
return (y == null ? void 0 : y.toLowerCase().includes(
|
|
9810
|
+
var k;
|
|
9811
|
+
return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((k = b == null ? void 0 : b.description) == null ? void 0 : k.toLowerCase().includes(f));
|
|
9720
9812
|
})
|
|
9721
9813
|
);
|
|
9722
|
-
}, [a, l]), m = (
|
|
9814
|
+
}, [a, l]), m = (f) => {
|
|
9723
9815
|
d(!0), u({
|
|
9724
|
-
x:
|
|
9725
|
-
y:
|
|
9816
|
+
x: f.clientX - n.x,
|
|
9817
|
+
y: f.clientY - n.y
|
|
9726
9818
|
});
|
|
9727
|
-
}, h = (
|
|
9819
|
+
}, h = (f) => {
|
|
9728
9820
|
if (!c) return;
|
|
9729
|
-
const y =
|
|
9730
|
-
r(
|
|
9731
|
-
},
|
|
9821
|
+
const y = f.clientX - p.x, b = f.clientY - p.y, k = f.currentTarget, B = k.offsetWidth, j = k.offsetHeight, E = window.innerWidth - B, C = window.innerHeight - j, v = Math.max(0, Math.min(y, E)), S = Math.max(0, Math.min(b, C));
|
|
9822
|
+
r(v, S);
|
|
9823
|
+
}, x = () => {
|
|
9732
9824
|
d(!1);
|
|
9733
9825
|
};
|
|
9734
9826
|
return useEffect(() => {
|
|
9735
|
-
const
|
|
9827
|
+
const f = () => {
|
|
9736
9828
|
c && d(!1);
|
|
9737
9829
|
};
|
|
9738
|
-
return window.addEventListener("mouseup",
|
|
9830
|
+
return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
|
|
9739
9831
|
}, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
9740
9832
|
"div",
|
|
9741
9833
|
{
|
|
9742
9834
|
onMouseDown: m,
|
|
9743
9835
|
onMouseMove: h,
|
|
9744
|
-
onMouseUp:
|
|
9836
|
+
onMouseUp: x,
|
|
9745
9837
|
className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
|
|
9746
9838
|
style: {
|
|
9747
9839
|
left: n.x,
|
|
@@ -9783,13 +9875,13 @@ const RootLayout = () => {
|
|
|
9783
9875
|
placeholder: "Search features...",
|
|
9784
9876
|
className: "w-full pl-8",
|
|
9785
9877
|
value: l,
|
|
9786
|
-
onChange: (
|
|
9878
|
+
onChange: (f) => i(f.target.value),
|
|
9787
9879
|
autoFocus: !0
|
|
9788
9880
|
}
|
|
9789
9881
|
)
|
|
9790
9882
|
] })
|
|
9791
9883
|
] }),
|
|
9792
|
-
/* @__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(([
|
|
9884
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, y]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: y }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
|
|
9793
9885
|
'No features found matching "',
|
|
9794
9886
|
l,
|
|
9795
9887
|
'"'
|
|
@@ -9933,8 +10025,8 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
9933
10025
|
c.f && u(c.f);
|
|
9934
10026
|
const g = /* @__PURE__ */ new Set(), m = g.add.bind(g);
|
|
9935
10027
|
a.forEach((h) => {
|
|
9936
|
-
var
|
|
9937
|
-
return (
|
|
10028
|
+
var x;
|
|
10029
|
+
return (x = r.get(h)) == null ? void 0 : x.l.forEach(m);
|
|
9938
10030
|
}), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(u), a.size && d(o);
|
|
9939
10031
|
} while (a.size || i.size || l.size);
|
|
9940
10032
|
if (p.length)
|
|
@@ -9942,86 +10034,86 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
9942
10034
|
}, recomputeInvalidatedAtoms = (o) => {
|
|
9943
10035
|
const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
|
|
9944
10036
|
for (; m.length; ) {
|
|
9945
|
-
const h = m[m.length - 1],
|
|
10037
|
+
const h = m[m.length - 1], x = i(o, h);
|
|
9946
10038
|
if (g.has(h)) {
|
|
9947
10039
|
m.pop();
|
|
9948
10040
|
continue;
|
|
9949
10041
|
}
|
|
9950
10042
|
if (u.has(h)) {
|
|
9951
|
-
a.get(h) ===
|
|
10043
|
+
a.get(h) === x.n && p.push([h, x]), g.add(h), m.pop();
|
|
9952
10044
|
continue;
|
|
9953
10045
|
}
|
|
9954
10046
|
u.add(h);
|
|
9955
|
-
for (const
|
|
9956
|
-
u.has(
|
|
10047
|
+
for (const f of getMountedOrPendingDependents(h, x, r))
|
|
10048
|
+
u.has(f) || m.push(f);
|
|
9957
10049
|
}
|
|
9958
10050
|
for (let h = p.length - 1; h >= 0; --h) {
|
|
9959
|
-
const [
|
|
10051
|
+
const [x, f] = p[h];
|
|
9960
10052
|
let y = !1;
|
|
9961
|
-
for (const b of
|
|
9962
|
-
if (b !==
|
|
10053
|
+
for (const b of f.d.keys())
|
|
10054
|
+
if (b !== x && l.has(b)) {
|
|
9963
10055
|
y = !0;
|
|
9964
10056
|
break;
|
|
9965
10057
|
}
|
|
9966
|
-
y && (c(o,
|
|
10058
|
+
y && (c(o, x), d(o, x)), a.delete(x);
|
|
9967
10059
|
}
|
|
9968
10060
|
}, readAtomState = (o, n) => {
|
|
9969
10061
|
var r;
|
|
9970
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14],
|
|
10062
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14], x = a[16], f = a[17], y = u(o, n);
|
|
9971
10063
|
if (isAtomStateInitialized(y) && (l.has(n) && i.get(n) !== y.n || Array.from(y.d).every(
|
|
9972
|
-
([
|
|
10064
|
+
([S, I]) => (
|
|
9973
10065
|
// Recursively, read the atom state of the dependency, and
|
|
9974
10066
|
// check if the atom epoch number is unchanged
|
|
9975
|
-
h(o,
|
|
10067
|
+
h(o, S).n === I
|
|
9976
10068
|
)
|
|
9977
10069
|
)))
|
|
9978
10070
|
return y;
|
|
9979
10071
|
y.d.clear();
|
|
9980
10072
|
let b = !0;
|
|
9981
|
-
function
|
|
9982
|
-
l.has(n) && (
|
|
10073
|
+
function k() {
|
|
10074
|
+
l.has(n) && (f(o, n), m(o), g(o));
|
|
9983
10075
|
}
|
|
9984
|
-
function B(
|
|
9985
|
-
var
|
|
9986
|
-
if (isSelfAtom(n,
|
|
9987
|
-
const
|
|
9988
|
-
if (!isAtomStateInitialized(
|
|
9989
|
-
if (hasInitialValue(
|
|
9990
|
-
setAtomStateValueOrPromise(o,
|
|
10076
|
+
function B(S) {
|
|
10077
|
+
var I;
|
|
10078
|
+
if (isSelfAtom(n, S)) {
|
|
10079
|
+
const w = u(o, S);
|
|
10080
|
+
if (!isAtomStateInitialized(w))
|
|
10081
|
+
if (hasInitialValue(S))
|
|
10082
|
+
setAtomStateValueOrPromise(o, S, S.init);
|
|
9991
10083
|
else
|
|
9992
10084
|
throw new Error("no atom init");
|
|
9993
|
-
return returnAtomValue(
|
|
10085
|
+
return returnAtomValue(w);
|
|
9994
10086
|
}
|
|
9995
|
-
const
|
|
10087
|
+
const A = h(o, S);
|
|
9996
10088
|
try {
|
|
9997
|
-
return returnAtomValue(
|
|
10089
|
+
return returnAtomValue(A);
|
|
9998
10090
|
} finally {
|
|
9999
|
-
y.d.set(
|
|
10091
|
+
y.d.set(S, A.n), isPendingPromise(y.v) && addPendingPromiseToDependency(n, y.v, A), (I = l.get(S)) == null || I.t.add(n), b || k();
|
|
10000
10092
|
}
|
|
10001
10093
|
}
|
|
10002
|
-
let j,
|
|
10003
|
-
const
|
|
10094
|
+
let j, E;
|
|
10095
|
+
const C = {
|
|
10004
10096
|
get signal() {
|
|
10005
10097
|
return j || (j = new AbortController()), j.signal;
|
|
10006
10098
|
},
|
|
10007
10099
|
get setSelf() {
|
|
10008
|
-
return !
|
|
10100
|
+
return !E && isActuallyWritableAtom(n) && (E = (...S) => {
|
|
10009
10101
|
if (!b)
|
|
10010
10102
|
try {
|
|
10011
|
-
return
|
|
10103
|
+
return x(o, n, ...S);
|
|
10012
10104
|
} finally {
|
|
10013
10105
|
m(o), g(o);
|
|
10014
10106
|
}
|
|
10015
|
-
}),
|
|
10107
|
+
}), E;
|
|
10016
10108
|
}
|
|
10017
|
-
},
|
|
10109
|
+
}, v = y.n;
|
|
10018
10110
|
try {
|
|
10019
|
-
const
|
|
10020
|
-
return setAtomStateValueOrPromise(o, n,
|
|
10021
|
-
} catch (
|
|
10022
|
-
return delete y.v, y.e =
|
|
10111
|
+
const S = p(o, n, B, C);
|
|
10112
|
+
return setAtomStateValueOrPromise(o, n, S), isPromiseLike$1(S) && (registerAbortHandler(S, () => j == null ? void 0 : j.abort()), S.then(k, k)), y;
|
|
10113
|
+
} catch (S) {
|
|
10114
|
+
return delete y.v, y.e = S, ++y.n, y;
|
|
10023
10115
|
} finally {
|
|
10024
|
-
b = !1,
|
|
10116
|
+
b = !1, v !== y.n && i.get(n) === v && (i.set(n, y.n), c.add(n), (r = d.c) == null || r.call(d, n));
|
|
10025
10117
|
}
|
|
10026
10118
|
}, invalidateDependents = (o, n) => {
|
|
10027
10119
|
const r = getBuildingBlocks(o), a = r[1], l = r[2], i = r[11], c = [n];
|
|
@@ -10034,60 +10126,60 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10034
10126
|
}
|
|
10035
10127
|
}, writeAtomState = (o, n, ...r) => {
|
|
10036
10128
|
const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], m = a[15], h = a[17];
|
|
10037
|
-
let
|
|
10038
|
-
const
|
|
10129
|
+
let x = !0;
|
|
10130
|
+
const f = (b) => returnAtomValue(g(o, b)), y = (b, ...k) => {
|
|
10039
10131
|
var B;
|
|
10040
10132
|
const j = d(o, b);
|
|
10041
10133
|
try {
|
|
10042
10134
|
if (isSelfAtom(n, b)) {
|
|
10043
10135
|
if (!hasInitialValue(b))
|
|
10044
10136
|
throw new Error("atom not writable");
|
|
10045
|
-
const
|
|
10046
|
-
setAtomStateValueOrPromise(o, b,
|
|
10137
|
+
const E = j.n, C = k[0];
|
|
10138
|
+
setAtomStateValueOrPromise(o, b, C), h(o, b), E !== j.n && (l.add(b), (B = i.c) == null || B.call(i, b), m(o, b));
|
|
10047
10139
|
return;
|
|
10048
10140
|
} else
|
|
10049
|
-
return writeAtomState(o, b, ...
|
|
10141
|
+
return writeAtomState(o, b, ...k);
|
|
10050
10142
|
} finally {
|
|
10051
|
-
|
|
10143
|
+
x || (u(o), p(o));
|
|
10052
10144
|
}
|
|
10053
10145
|
};
|
|
10054
10146
|
try {
|
|
10055
|
-
return c(o, n,
|
|
10147
|
+
return c(o, n, f, y, ...r);
|
|
10056
10148
|
} finally {
|
|
10057
|
-
|
|
10149
|
+
x = !1;
|
|
10058
10150
|
}
|
|
10059
10151
|
}, mountDependencies = (o, n) => {
|
|
10060
10152
|
var r;
|
|
10061
10153
|
const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], m = d(o, n), h = l.get(n);
|
|
10062
10154
|
if (h && !isPendingPromise(m.v)) {
|
|
10063
|
-
for (const [
|
|
10064
|
-
if (!h.d.has(
|
|
10065
|
-
const y = d(o,
|
|
10066
|
-
u(o,
|
|
10155
|
+
for (const [x, f] of m.d)
|
|
10156
|
+
if (!h.d.has(x)) {
|
|
10157
|
+
const y = d(o, x);
|
|
10158
|
+
u(o, x).t.add(n), h.d.add(x), f !== y.n && (i.add(x), (r = c.c) == null || r.call(c, x), p(o, x));
|
|
10067
10159
|
}
|
|
10068
|
-
for (const
|
|
10069
|
-
if (!m.d.has(
|
|
10070
|
-
h.d.delete(
|
|
10071
|
-
const
|
|
10072
|
-
|
|
10160
|
+
for (const x of h.d || [])
|
|
10161
|
+
if (!m.d.has(x)) {
|
|
10162
|
+
h.d.delete(x);
|
|
10163
|
+
const f = g(o, x);
|
|
10164
|
+
f == null || f.t.delete(n);
|
|
10073
10165
|
}
|
|
10074
10166
|
}
|
|
10075
10167
|
}, mountAtom = (o, n) => {
|
|
10076
10168
|
var r;
|
|
10077
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16],
|
|
10078
|
-
let
|
|
10079
|
-
if (!
|
|
10169
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16], x = p(o, n);
|
|
10170
|
+
let f = l.get(n);
|
|
10171
|
+
if (!f) {
|
|
10080
10172
|
m(o, n);
|
|
10081
|
-
for (const y of
|
|
10173
|
+
for (const y of x.d.keys())
|
|
10082
10174
|
mountAtom(o, y).t.add(n);
|
|
10083
|
-
if (
|
|
10175
|
+
if (f = {
|
|
10084
10176
|
l: /* @__PURE__ */ new Set(),
|
|
10085
|
-
d: new Set(
|
|
10177
|
+
d: new Set(x.d.keys()),
|
|
10086
10178
|
t: /* @__PURE__ */ new Set()
|
|
10087
|
-
}, l.set(n,
|
|
10179
|
+
}, l.set(n, f), (r = c.m) == null || r.call(c, n), isActuallyWritableAtom(n)) {
|
|
10088
10180
|
const y = () => {
|
|
10089
10181
|
let b = !0;
|
|
10090
|
-
const
|
|
10182
|
+
const k = (...B) => {
|
|
10091
10183
|
try {
|
|
10092
10184
|
return h(o, n, ...B);
|
|
10093
10185
|
} finally {
|
|
@@ -10095,8 +10187,8 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10095
10187
|
}
|
|
10096
10188
|
};
|
|
10097
10189
|
try {
|
|
10098
|
-
const B = d(o, n,
|
|
10099
|
-
B && (
|
|
10190
|
+
const B = d(o, n, k);
|
|
10191
|
+
B && (f.u = () => {
|
|
10100
10192
|
b = !0;
|
|
10101
10193
|
try {
|
|
10102
10194
|
B();
|
|
@@ -10111,7 +10203,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10111
10203
|
i.add(y);
|
|
10112
10204
|
}
|
|
10113
10205
|
}
|
|
10114
|
-
return
|
|
10206
|
+
return f;
|
|
10115
10207
|
}, unmountAtom = (o, n) => {
|
|
10116
10208
|
var r;
|
|
10117
10209
|
const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);
|