@chaibuilder/sdk 2.2.19 → 2.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +4 -4
- package/dist/core.d.ts +3 -1
- package/dist/core.js +393 -382
- package/dist/web-blocks.cjs +2 -2
- package/dist/web-blocks.js +186 -172
- package/package.json +3 -3
package/dist/core.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var F = (o, r, n) => r in o ? V(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
|
|
3
|
-
var
|
|
3
|
+
var U = (o, r, n) => F(o, typeof r != "symbol" ? r + "" : r, n);
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
6
6
|
import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
|
|
7
|
-
import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isArray, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize,
|
|
7
|
+
import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isUndefined, isFunction, isArray, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, 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";
|
|
@@ -285,7 +285,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
|
|
|
285
285
|
});
|
|
286
286
|
class PubSub {
|
|
287
287
|
constructor() {
|
|
288
|
-
|
|
288
|
+
U(this, "subscribers", /* @__PURE__ */ new Map());
|
|
289
289
|
}
|
|
290
290
|
subscribe(r, n) {
|
|
291
291
|
return this.subscribers.has(r) || this.subscribers.set(r, /* @__PURE__ */ new Set()), this.subscribers.get(r).add(n), () => {
|
|
@@ -299,20 +299,20 @@ class PubSub {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
|
|
302
|
-
const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (
|
|
303
|
-
if (
|
|
302
|
+
const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (g) => c ? get(g, "_parent") === c : !get(g, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), m = (g) => {
|
|
303
|
+
if (g === "CHILD")
|
|
304
304
|
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
305
305
|
else {
|
|
306
306
|
const h = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
307
|
-
|
|
307
|
+
g === "BEFORE" ? h.position = Math.max(u, 0) : g === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
310
|
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
311
311
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { children: r }),
|
|
312
312
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-primary text-white shadow-2xl", children: [
|
|
313
|
-
p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () =>
|
|
314
|
-
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () =>
|
|
315
|
-
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () =>
|
|
313
|
+
p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("CHILD"), children: n("Add inside") }),
|
|
314
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("BEFORE"), children: n("Add before") }),
|
|
315
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("AFTER"), children: n("Add after") })
|
|
316
316
|
] })
|
|
317
317
|
] }) : null;
|
|
318
318
|
}, draggedBlockAtom = atom(null);
|
|
@@ -338,8 +338,8 @@ function insertBlocksAtPosition(o, r, n, a) {
|
|
|
338
338
|
const l = [...r];
|
|
339
339
|
let i = [...o];
|
|
340
340
|
if (n) {
|
|
341
|
-
const u = o.find((
|
|
342
|
-
if (u && u.content !== void 0 && u.content !== "" && !o.some((
|
|
341
|
+
const u = o.find((m) => m._id === n);
|
|
342
|
+
if (u && u.content !== void 0 && u.content !== "" && !o.some((g) => g._parent === n)) {
|
|
343
343
|
const h = {
|
|
344
344
|
_id: generateUUID(),
|
|
345
345
|
_parent: n,
|
|
@@ -363,13 +363,13 @@ function insertBlocksAtPosition(o, r, n, a) {
|
|
|
363
363
|
n && (c = i.filter((u) => u._parent === n));
|
|
364
364
|
const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
|
|
365
365
|
let p = i.length;
|
|
366
|
-
for (let u = 0,
|
|
366
|
+
for (let u = 0, m = 0; u < i.length; u++)
|
|
367
367
|
if (n !== void 0 ? i[u]._parent === n : !i[u]._parent) {
|
|
368
|
-
if (
|
|
368
|
+
if (m === d) {
|
|
369
369
|
p = u;
|
|
370
370
|
break;
|
|
371
371
|
}
|
|
372
|
-
|
|
372
|
+
m++;
|
|
373
373
|
}
|
|
374
374
|
return !n && a !== void 0 && a >= c.length && (p = i.length), [...i.slice(0, p), ...l, ...i.slice(p)];
|
|
375
375
|
}
|
|
@@ -384,17 +384,17 @@ function findNodeById(o, r) {
|
|
|
384
384
|
return o.first((n) => n.model._id === r) || null;
|
|
385
385
|
}
|
|
386
386
|
function moveNode(o, r, n, a) {
|
|
387
|
-
var u,
|
|
387
|
+
var u, m;
|
|
388
388
|
const l = findNodeById(o, r), i = findNodeById(o, n);
|
|
389
389
|
if (!l || !i) return !1;
|
|
390
390
|
i.children || (i.model.children = []);
|
|
391
|
-
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((
|
|
391
|
+
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((g) => g.model._id === r);
|
|
392
392
|
l.drop(), c = Math.max(c, 0);
|
|
393
|
-
const p = (((
|
|
393
|
+
const p = (((m = l == null ? void 0 : l.model) == null ? void 0 : m._parent) || "root") === n && c <= a ? a - 1 : a;
|
|
394
394
|
try {
|
|
395
395
|
i.addChildAtIndex(l, p);
|
|
396
|
-
} catch (
|
|
397
|
-
return console.error("Error adding child to parent:",
|
|
396
|
+
} catch (g) {
|
|
397
|
+
return console.error("Error adding child to parent:", g), !1;
|
|
398
398
|
}
|
|
399
399
|
return !0;
|
|
400
400
|
}
|
|
@@ -434,10 +434,10 @@ function handleNewParentTextBlock(o, r, n) {
|
|
|
434
434
|
});
|
|
435
435
|
const d = o.map((u) => {
|
|
436
436
|
if (u._id === n) {
|
|
437
|
-
const
|
|
438
|
-
return Object.keys(
|
|
439
|
-
|
|
440
|
-
}),
|
|
437
|
+
const m = { ...u, content: "" };
|
|
438
|
+
return Object.keys(m).forEach((g) => {
|
|
439
|
+
g.startsWith("content-") && (m[g] = "");
|
|
440
|
+
}), m;
|
|
441
441
|
}
|
|
442
442
|
return u;
|
|
443
443
|
}), p = d.findIndex((u) => u._id === r._id);
|
|
@@ -453,8 +453,8 @@ function moveBlocksWithChildren(o, r, n, a) {
|
|
|
453
453
|
const c = n || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
|
|
454
454
|
if (moveNode(p, r, c, a)) {
|
|
455
455
|
let u = flattenTree(p);
|
|
456
|
-
const
|
|
457
|
-
return
|
|
456
|
+
const m = u.find((g) => g._id === r);
|
|
457
|
+
return m && (m._parent = c === "root" ? null : c), u.shift(), n && (u = handleNewParentTextBlock(u, l, n)), u;
|
|
458
458
|
}
|
|
459
459
|
return i;
|
|
460
460
|
}
|
|
@@ -477,22 +477,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
477
477
|
}, removeNestedBlocks = (o, r) => {
|
|
478
478
|
let n = [...o], a = [];
|
|
479
479
|
r.forEach((d) => {
|
|
480
|
-
const p = n.find((
|
|
480
|
+
const p = n.find((g) => g._id === d);
|
|
481
481
|
if (!p || !p._parent) return;
|
|
482
|
-
const u = p._parent,
|
|
483
|
-
if (
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
482
|
+
const u = p._parent, m = n.filter((g) => g._parent === u);
|
|
483
|
+
if (m.length === 2) {
|
|
484
|
+
const g = m.find((h) => h._id !== d);
|
|
485
|
+
if (g && g._type === "Text") {
|
|
486
486
|
const h = n.find((f) => f._id === u);
|
|
487
487
|
h && "content" in h && (n = n.map((f) => {
|
|
488
488
|
if (f._id === u) {
|
|
489
|
-
const x = { ...f, content:
|
|
490
|
-
return Object.keys(
|
|
491
|
-
y.startsWith("content-") && (x[y] =
|
|
489
|
+
const x = { ...f, content: g.content };
|
|
490
|
+
return Object.keys(g).forEach((y) => {
|
|
491
|
+
y.startsWith("content-") && (x[y] = g[y]);
|
|
492
492
|
}), x;
|
|
493
493
|
}
|
|
494
494
|
return f;
|
|
495
|
-
}), a.push(
|
|
495
|
+
}), a.push(g._id));
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
});
|
|
@@ -555,7 +555,7 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
555
555
|
for (let p = 0; p < a.length; p++)
|
|
556
556
|
d = moveBlocksWithChildren(d, a[p], l, i);
|
|
557
557
|
return each(a, (p) => {
|
|
558
|
-
const u = find(d, (
|
|
558
|
+
const u = find(d, (m) => m._id === p);
|
|
559
559
|
u && n({ id: p, props: { _parent: u._parent || null } });
|
|
560
560
|
}), r({ type: "blocks-updated", blocks: d }), d;
|
|
561
561
|
});
|
|
@@ -569,27 +569,37 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
569
569
|
};
|
|
570
570
|
}, blockRepeaterDataAtom = atom({});
|
|
571
571
|
blockRepeaterDataAtom.debugLabel = "blockRepeaterDataAtom";
|
|
572
|
-
const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyncProps = (o, r
|
|
573
|
-
const [
|
|
572
|
+
const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyncProps = (o, r, n) => {
|
|
573
|
+
const [a, l] = useState({
|
|
574
574
|
status: "idle",
|
|
575
575
|
props: {},
|
|
576
576
|
error: void 0
|
|
577
|
-
}),
|
|
577
|
+
}), i = useBuilderProp("getBlockAsyncProps", async (g) => ({})), c = useSetAtom$1(blockRepeaterDataAtom), d = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), p = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), u = (o == null ? void 0 : o._type) !== "Repeater" && !isUndefined(r);
|
|
578
578
|
return useEffect(() => {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
...
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
579
|
+
if (o) {
|
|
580
|
+
if (isFunction(n)) {
|
|
581
|
+
l((h) => ({ ...h, status: "loading", props: {} }));
|
|
582
|
+
const g = n({ block: o });
|
|
583
|
+
if (!isObject(g))
|
|
584
|
+
throw new Error("mockDataProvider should return an object");
|
|
585
|
+
l((h) => ({ ...h, status: "loaded", props: g }));
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
!p && !u || (l((g) => ({ ...g, status: "loading", props: {} })), i({ block: o }).then((g = {}) => {
|
|
589
|
+
p ? (c((h) => ({
|
|
590
|
+
...h,
|
|
591
|
+
[o._id]: { status: "loaded", props: isArray(g) ? g : [], repeaterItems: o.repeaterItems }
|
|
592
|
+
})), l((h) => ({ ...h, status: "loaded" }))) : l((h) => ({ ...h, status: "loaded", props: isObject(g) ? g : {} }));
|
|
593
|
+
}).catch((g) => {
|
|
594
|
+
p ? (c((h) => ({
|
|
595
|
+
...h,
|
|
596
|
+
[o._id]: { status: "error", error: g, props: [] }
|
|
597
|
+
})), l((h) => ({ ...h, status: "error", error: g }))) : l((h) => ({ ...h, status: "error", error: g, props: {} }));
|
|
598
|
+
}));
|
|
599
|
+
}
|
|
600
|
+
}, [o == null ? void 0 : o._id, d, p, u, n]), {
|
|
601
|
+
$loading: get(a, "status") === "loading",
|
|
602
|
+
...o ? get(a, "props", {}) : {}
|
|
593
603
|
};
|
|
594
604
|
}, chaiBuilderPropsAtom = atom(null);
|
|
595
605
|
chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
|
|
@@ -861,8 +871,8 @@ const undoRedoStateAtom = atom({
|
|
|
861
871
|
y[b]._parent = i[f]._id;
|
|
862
872
|
}
|
|
863
873
|
const p = first(i);
|
|
864
|
-
let u,
|
|
865
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c,
|
|
874
|
+
let u, m;
|
|
875
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, m = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, m = u._parent), n(i, m, d), r([(h = first(i)) == null ? void 0 : h._id]), first(i);
|
|
866
876
|
},
|
|
867
877
|
[n, o, r]
|
|
868
878
|
);
|
|
@@ -872,15 +882,15 @@ const undoRedoStateAtom = atom({
|
|
|
872
882
|
const y = i.blocks;
|
|
873
883
|
return a(y, c, d);
|
|
874
884
|
}
|
|
875
|
-
const p = generateUUID(), u = getDefaultBlockProps(i.type),
|
|
885
|
+
const p = generateUUID(), u = getDefaultBlockProps(i.type), m = {
|
|
876
886
|
_type: i.type,
|
|
877
887
|
_id: p,
|
|
878
888
|
...u,
|
|
879
889
|
...has(i, "_name") && { _name: i._name },
|
|
880
890
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
881
891
|
};
|
|
882
|
-
let
|
|
883
|
-
return c && (
|
|
892
|
+
let g, h;
|
|
893
|
+
return c && (g = find(o, { _id: c }), m._parent = c, h = c), !canAcceptChildBlock(g == null ? void 0 : g._type, m._type) && g && (m._parent = g._parent, h = g._parent), n([m], h, d), r([m._id]), m;
|
|
884
894
|
},
|
|
885
895
|
[n, a, o, r]
|
|
886
896
|
), addPredefinedBlock: a };
|
|
@@ -1997,7 +2007,7 @@ function removeDuplicateClasses(o) {
|
|
|
1997
2007
|
for (const l of n) {
|
|
1998
2008
|
const i = l.property, c = r.indexOf(l.mq);
|
|
1999
2009
|
for (let d = c + 1; d < r.length; d++) {
|
|
2000
|
-
const p = r[d], u = n.find((
|
|
2010
|
+
const p = r[d], u = n.find((m) => m.property === i && m.mq === p);
|
|
2001
2011
|
if (u && u.cls === l.cls)
|
|
2002
2012
|
a = a.replace(u.fullCls, "");
|
|
2003
2013
|
else if (u && u.cls !== l.cls)
|
|
@@ -2282,7 +2292,7 @@ const useLanguages = () => {
|
|
|
2282
2292
|
let p = "";
|
|
2283
2293
|
o([r], { [i]: "" });
|
|
2284
2294
|
for (let u = 0; u < d.length; u++)
|
|
2285
|
-
p += d[u].join(""), o([r], { [i]: p }), await new Promise((
|
|
2295
|
+
p += d[u].join(""), o([r], { [i]: p }), await new Promise((m) => setTimeout(m, a));
|
|
2286
2296
|
}
|
|
2287
2297
|
}
|
|
2288
2298
|
},
|
|
@@ -2326,7 +2336,7 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2326
2336
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2327
2337
|
})
|
|
2328
2338
|
), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2329
|
-
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(),
|
|
2339
|
+
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), m = p.length ? p : u, g = (h, f) => {
|
|
2330
2340
|
const x = cloneDeep(f.find((y) => y._id === h));
|
|
2331
2341
|
for (const y in x) {
|
|
2332
2342
|
const b = x[y];
|
|
@@ -2344,7 +2354,7 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2344
2354
|
if (l) {
|
|
2345
2355
|
r(!0), a(null);
|
|
2346
2356
|
try {
|
|
2347
|
-
const b = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [
|
|
2357
|
+
const b = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [g(f, d)], A = await l(h, addLangToPrompt(x, m, h), v, b), { blocks: w, error: E } = A;
|
|
2348
2358
|
if (E) {
|
|
2349
2359
|
a(E);
|
|
2350
2360
|
return;
|
|
@@ -2372,7 +2382,7 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2372
2382
|
p,
|
|
2373
2383
|
u,
|
|
2374
2384
|
d,
|
|
2375
|
-
|
|
2385
|
+
m,
|
|
2376
2386
|
c,
|
|
2377
2387
|
i
|
|
2378
2388
|
]
|
|
@@ -2443,19 +2453,19 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2443
2453
|
return [o, a];
|
|
2444
2454
|
}, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
|
|
2445
2455
|
const [o] = useBlocksStore(), [r, n] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useCallback(
|
|
2446
|
-
(d) => d.some((p) => getDuplicatedBlocks(o, p, null).some((
|
|
2456
|
+
(d) => d.some((p) => getDuplicatedBlocks(o, p, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
|
|
2447
2457
|
[o]
|
|
2448
2458
|
), c = useCallback(
|
|
2449
2459
|
async (d, p = !1) => {
|
|
2450
2460
|
try {
|
|
2451
2461
|
n(d), a([]);
|
|
2452
2462
|
const u = {
|
|
2453
|
-
_chai_copied_blocks: d.flatMap((
|
|
2454
|
-
const
|
|
2463
|
+
_chai_copied_blocks: d.flatMap((m) => {
|
|
2464
|
+
const g = getDuplicatedBlocks(o, m, null);
|
|
2455
2465
|
if (!p)
|
|
2456
|
-
return
|
|
2466
|
+
return g;
|
|
2457
2467
|
let h = [];
|
|
2458
|
-
for (const f of
|
|
2468
|
+
for (const f of g)
|
|
2459
2469
|
if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
|
|
2460
2470
|
let x = l(f.partialBlockId);
|
|
2461
2471
|
f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((y) => (isEmpty(y._parent) && set(y, "_parent", f._parent), y))), h = [...h, ...x];
|
|
@@ -2501,11 +2511,11 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2501
2511
|
each(a, (c) => {
|
|
2502
2512
|
const d = o.find((h) => h._id === c);
|
|
2503
2513
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
2504
|
-
const
|
|
2514
|
+
const m = filter(
|
|
2505
2515
|
o,
|
|
2506
2516
|
(h) => isString(l) ? h._parent === l : !h._parent
|
|
2507
|
-
).indexOf(d) + 1,
|
|
2508
|
-
n(
|
|
2517
|
+
).indexOf(d) + 1, g = getDuplicatedBlocks(o, c, l);
|
|
2518
|
+
n(g, l, m), i.push(get(g, "0._id", ""));
|
|
2509
2519
|
}), r(i);
|
|
2510
2520
|
},
|
|
2511
2521
|
[o, r]
|
|
@@ -2641,19 +2651,19 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2641
2651
|
);
|
|
2642
2652
|
return map(i, (c) => {
|
|
2643
2653
|
const d = o(c), p = a;
|
|
2644
|
-
let { classes: u, baseClasses:
|
|
2645
|
-
return each(p, (
|
|
2646
|
-
const h =
|
|
2654
|
+
let { classes: u, baseClasses: m } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2655
|
+
return each(p, (g) => {
|
|
2656
|
+
const h = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2647
2657
|
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2648
|
-
const x = first(
|
|
2649
|
-
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(
|
|
2650
|
-
}), each(p, (
|
|
2651
|
-
const h =
|
|
2652
|
-
|
|
2658
|
+
const x = first(g.split(":"));
|
|
2659
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(g.split(":").pop().trim());
|
|
2660
|
+
}), each(p, (g) => {
|
|
2661
|
+
const h = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2662
|
+
m = m.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2653
2663
|
}), {
|
|
2654
2664
|
ids: [d._id],
|
|
2655
2665
|
props: {
|
|
2656
|
-
[l.prop]: `${STYLES_KEY}${
|
|
2666
|
+
[l.prop]: `${STYLES_KEY}${m},${u}`
|
|
2657
2667
|
}
|
|
2658
2668
|
};
|
|
2659
2669
|
});
|
|
@@ -2752,11 +2762,11 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2752
2762
|
return "VERTICAL";
|
|
2753
2763
|
}
|
|
2754
2764
|
}, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
|
|
2755
|
-
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }),
|
|
2765
|
+
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), m = u <= 0, g = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
2756
2766
|
(x) => {
|
|
2757
|
-
isDisabledControl(
|
|
2767
|
+
isDisabledControl(m, g, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), r());
|
|
2758
2768
|
},
|
|
2759
|
-
[
|
|
2769
|
+
[m, g, p, u, i, c, r]
|
|
2760
2770
|
);
|
|
2761
2771
|
return useHotkeys(
|
|
2762
2772
|
"shift+up, shift+down, shift+left, shift+right",
|
|
@@ -2766,7 +2776,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2766
2776
|
},
|
|
2767
2777
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2768
2778
|
[f]
|
|
2769
|
-
), { isOnlyChild: p, isFirstBlock:
|
|
2779
|
+
), { isOnlyChild: p, isFirstBlock: m, isLastBlock: g, moveBlock: f, orientation: h };
|
|
2770
2780
|
}, BlockController = ({ block: o, updateFloatingBar: r }) => {
|
|
2771
2781
|
const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2772
2782
|
o,
|
|
@@ -2774,12 +2784,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2774
2784
|
);
|
|
2775
2785
|
return n ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
|
|
2776
2786
|
if (c !== p) return null;
|
|
2777
|
-
const
|
|
2778
|
-
return
|
|
2787
|
+
const m = isDisabledControl(a, l, u);
|
|
2788
|
+
return m ? null : /* @__PURE__ */ jsx(
|
|
2779
2789
|
d,
|
|
2780
2790
|
{
|
|
2781
2791
|
onClick: () => i(u),
|
|
2782
|
-
className: `${
|
|
2792
|
+
className: `${m ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
|
|
2783
2793
|
},
|
|
2784
2794
|
u
|
|
2785
2795
|
);
|
|
@@ -2901,7 +2911,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2901
2911
|
i([null]);
|
|
2902
2912
|
}, [n, r]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
|
|
2903
2913
|
}, BlockFloatingSelector = ({ block: o, selectedBlockElement: r }) => {
|
|
2904
|
-
const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles:
|
|
2914
|
+
const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: m, refs: g, update: h } = useFloating({
|
|
2905
2915
|
placement: "top-start",
|
|
2906
2916
|
middleware: [shift(), flip()],
|
|
2907
2917
|
elements: { reference: r }
|
|
@@ -2913,8 +2923,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2913
2923
|
{
|
|
2914
2924
|
role: "button",
|
|
2915
2925
|
tabIndex: 0,
|
|
2916
|
-
ref:
|
|
2917
|
-
style:
|
|
2926
|
+
ref: g.setFloating,
|
|
2927
|
+
style: m,
|
|
2918
2928
|
onClick: (y) => {
|
|
2919
2929
|
y.stopPropagation(), y.preventDefault();
|
|
2920
2930
|
},
|
|
@@ -3012,17 +3022,17 @@ class Content extends Component {
|
|
|
3012
3022
|
class Frame extends Component {
|
|
3013
3023
|
constructor(n, a) {
|
|
3014
3024
|
super(n, a);
|
|
3015
|
-
|
|
3025
|
+
U(this, "setRef", (n) => {
|
|
3016
3026
|
this.nodeRef.current = n;
|
|
3017
3027
|
const { forwardedRef: a } = this.props;
|
|
3018
3028
|
typeof a == "function" ? a(n) : a && (a.current = n);
|
|
3019
3029
|
});
|
|
3020
|
-
|
|
3030
|
+
U(this, "handleLoad", () => {
|
|
3021
3031
|
clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
|
|
3022
3032
|
});
|
|
3023
3033
|
// In certain situations on a cold cache DOMContentLoaded never gets called
|
|
3024
3034
|
// fallback to an interval to check if that's the case
|
|
3025
|
-
|
|
3035
|
+
U(this, "loadCheck", () => setInterval(() => {
|
|
3026
3036
|
this.handleLoad();
|
|
3027
3037
|
}, 500));
|
|
3028
3038
|
this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
|
|
@@ -3059,7 +3069,7 @@ class Frame extends Component {
|
|
|
3059
3069
|
return delete n.head, delete n.initialContent, delete n.mountTarget, delete n.contentDidMount, delete n.contentDidUpdate, delete n.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...n, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
|
|
3060
3070
|
}
|
|
3061
3071
|
}
|
|
3062
|
-
|
|
3072
|
+
U(Frame, "defaultProps", {
|
|
3063
3073
|
style: {},
|
|
3064
3074
|
head: null,
|
|
3065
3075
|
children: void 0,
|
|
@@ -3071,14 +3081,14 @@ H(Frame, "defaultProps", {
|
|
|
3071
3081
|
initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
|
|
3072
3082
|
});
|
|
3073
3083
|
const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: r })), useKeyEventWatcher = (o) => {
|
|
3074
|
-
const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste:
|
|
3084
|
+
const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: m, pasteBlocks: g } = usePasteBlocks(), h = o ? { document: o } : {};
|
|
3075
3085
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(r), {}, [r, p]), useHotkeys("ctrl+c,command+c", () => u(r), {}, [r, u]), useHotkeys(
|
|
3076
3086
|
"ctrl+v,command+v",
|
|
3077
3087
|
() => {
|
|
3078
|
-
|
|
3088
|
+
m(r[0]) && g(r);
|
|
3079
3089
|
},
|
|
3080
3090
|
{ ...h, preventDefault: !0 },
|
|
3081
|
-
[r,
|
|
3091
|
+
[r, m, g]
|
|
3082
3092
|
), useHotkeys("esc", () => n([]), h, [n]), useHotkeys("ctrl+d,command+d", () => i(r), { ...h, preventDefault: !0 }, [
|
|
3083
3093
|
r,
|
|
3084
3094
|
i
|
|
@@ -3202,11 +3212,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3202
3212
|
}, [a, l]);
|
|
3203
3213
|
return /* @__PURE__ */ jsx("div", { id: "main-content", onClick: d, className: "h-full w-full p-8 pb-0", ref: i, children: o });
|
|
3204
3214
|
}, MayBeAsyncPropsWrapper = ({ children: o, block: r }) => {
|
|
3205
|
-
const n = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), a = has(n, "
|
|
3215
|
+
const n = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), a = has(n, "dataProviderDependencies"), l = get(n, "dataProvider"), i = useAsyncProps(
|
|
3206
3216
|
a ? r : void 0,
|
|
3207
|
-
get(n, "
|
|
3217
|
+
get(n, "dataProviderDependencies"),
|
|
3218
|
+
l ?? void 0
|
|
3208
3219
|
);
|
|
3209
|
-
return o(
|
|
3220
|
+
return o(i);
|
|
3210
3221
|
}, ErrorFallback = () => /* @__PURE__ */ jsx("div", { className: "flex min-h-[100px] items-center justify-center bg-red-50 p-2 text-center text-red-500", children: "Something went wrong." }), useBlockRuntimeProps = () => {
|
|
3211
3222
|
const [o] = useBlocksStore();
|
|
3212
3223
|
return useCallback(
|
|
@@ -3380,8 +3391,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3380
3391
|
})
|
|
3381
3392
|
],
|
|
3382
3393
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3383
|
-
onBlur: ({ editor: u, event:
|
|
3384
|
-
const
|
|
3394
|
+
onBlur: ({ editor: u, event: m }) => {
|
|
3395
|
+
const g = m.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = h == null ? void 0 : h.contains(g), y = f == null ? void 0 : f.contains(g);
|
|
3385
3396
|
if (!x && !y) {
|
|
3386
3397
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3387
3398
|
n(b);
|
|
@@ -3399,11 +3410,11 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3399
3410
|
});
|
|
3400
3411
|
}, [c]);
|
|
3401
3412
|
const d = useMemo(() => {
|
|
3402
|
-
var
|
|
3413
|
+
var g;
|
|
3403
3414
|
const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
|
|
3404
3415
|
if (!r) return u;
|
|
3405
|
-
const
|
|
3406
|
-
return `${u} ${
|
|
3416
|
+
const m = ((g = r == null ? void 0 : r.className) == null ? void 0 : g.replace("sr-only", "")) || "";
|
|
3417
|
+
return `${u} ${m}`;
|
|
3407
3418
|
}, [r]), p = useCallback(
|
|
3408
3419
|
(u) => {
|
|
3409
3420
|
u.key === "Escape" && l(u);
|
|
@@ -3451,9 +3462,9 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3451
3462
|
(h.key === "Enter" || h.key === "Escape") && i(h);
|
|
3452
3463
|
},
|
|
3453
3464
|
[i]
|
|
3454
|
-
),
|
|
3465
|
+
), m = useCallback(() => {
|
|
3455
3466
|
n();
|
|
3456
|
-
}, [n]),
|
|
3467
|
+
}, [n]), g = useMemo(() => {
|
|
3457
3468
|
var h;
|
|
3458
3469
|
return {
|
|
3459
3470
|
id: "active-inline-editing-element",
|
|
@@ -3471,31 +3482,31 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3471
3482
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
3472
3483
|
return /* @__PURE__ */ jsx(Fragment, { children: createElement(p, {
|
|
3473
3484
|
ref: a,
|
|
3474
|
-
onBlur:
|
|
3485
|
+
onBlur: m,
|
|
3475
3486
|
onKeyDown: u,
|
|
3476
|
-
...
|
|
3487
|
+
...g
|
|
3477
3488
|
}) });
|
|
3478
3489
|
}
|
|
3479
3490
|
), WithBlockTextEditor = memo(
|
|
3480
3491
|
({ block: o, children: r }) => {
|
|
3481
|
-
const n = "content", { document: a } = useFrame(), [l, i] = useAtom$1(inlineEditingActiveAtom), [c, d] = useState(null), p = useRef(null), { clearHighlight: u } = useBlockHighlight(),
|
|
3492
|
+
const n = "content", { document: a } = useFrame(), [l, i] = useAtom$1(inlineEditingActiveAtom), [c, d] = useState(null), p = useRef(null), { clearHighlight: u } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: g } = useLanguages(), [, h] = useSelectedBlockIds(), f = useRef(null), x = l, { blockContent: y, blockType: b } = useMemo(() => {
|
|
3482
3493
|
var C;
|
|
3483
3494
|
const _ = o._type;
|
|
3484
3495
|
let S = o[n];
|
|
3485
3496
|
const B = getRegisteredChaiBlock(o._type);
|
|
3486
|
-
return
|
|
3487
|
-
}, [o,
|
|
3497
|
+
return g && ((C = B == null ? void 0 : B.i18nProps) == null ? void 0 : C.includes(n)) && has(o, `${n}-${g}`) && (S = get(o, `${n}-${g}`)), { blockContent: S, blockType: _ };
|
|
3498
|
+
}, [o, g]), v = useCallback(
|
|
3488
3499
|
(_) => {
|
|
3489
3500
|
var B;
|
|
3490
3501
|
const S = _ || ((B = p.current) == null ? void 0 : B.innerText);
|
|
3491
|
-
|
|
3502
|
+
m([x], { [n]: S }), d(null), i(null), h([]);
|
|
3492
3503
|
},
|
|
3493
|
-
[x,
|
|
3504
|
+
[x, m, i, h, g]
|
|
3494
3505
|
), A = useDebouncedCallback(
|
|
3495
3506
|
(_) => {
|
|
3496
|
-
|
|
3507
|
+
m([x], { [n]: _ });
|
|
3497
3508
|
},
|
|
3498
|
-
[x, o,
|
|
3509
|
+
[x, o, m, g],
|
|
3499
3510
|
1e3
|
|
3500
3511
|
), w = useCallback(
|
|
3501
3512
|
(_) => {
|
|
@@ -3504,7 +3515,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3504
3515
|
f.current = null, h([S]);
|
|
3505
3516
|
}, 100);
|
|
3506
3517
|
},
|
|
3507
|
-
[h, x,
|
|
3518
|
+
[h, x, g]
|
|
3508
3519
|
);
|
|
3509
3520
|
useEffect(() => {
|
|
3510
3521
|
var S;
|
|
@@ -3531,7 +3542,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3531
3542
|
onChange: A,
|
|
3532
3543
|
onEscape: w
|
|
3533
3544
|
}
|
|
3534
|
-
)) : null, [c, x, b, y, v,
|
|
3545
|
+
)) : null, [c, x, b, y, v, g]);
|
|
3535
3546
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3536
3547
|
E,
|
|
3537
3548
|
r
|
|
@@ -3566,12 +3577,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3566
3577
|
blockAtom: r,
|
|
3567
3578
|
children: n
|
|
3568
3579
|
}) => {
|
|
3569
|
-
const [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(r), i = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: c, fallbackLang: d } = useLanguages(), p = useBlockRuntimeProps(), u = usePageExternalData(), [
|
|
3570
|
-
() =>
|
|
3580
|
+
const [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(r), i = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: c, fallbackLang: d } = useLanguages(), p = useBlockRuntimeProps(), u = usePageExternalData(), [m] = useHiddenBlockIds(), [g] = useAtom$1(dataBindingActiveAtom), h = get(i, "component", null), { index: f, key: x } = useContext(RepeaterContext), y = useMemo(
|
|
3581
|
+
() => g ? applyBindingToBlockProps(applyLanguage(l, c, i), u, {
|
|
3571
3582
|
index: f,
|
|
3572
3583
|
key: x
|
|
3573
3584
|
}) : applyLanguage(l, c, i),
|
|
3574
|
-
[l, c, i, u,
|
|
3585
|
+
[l, c, i, u, g, f, x]
|
|
3575
3586
|
), b = useMemo(() => getBlockTagAttributes(l), [l, getBlockTagAttributes]), v = useMemo(
|
|
3576
3587
|
() => p(l._id, getBlockRuntimeProps(l._type)),
|
|
3577
3588
|
[l._id, l._type, p, getBlockRuntimeProps]
|
|
@@ -3596,7 +3607,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3596
3607
|
o
|
|
3597
3608
|
]
|
|
3598
3609
|
), w = useMemo(() => !CORE_BLOCKS.includes(l._type), [l._type]);
|
|
3599
|
-
if (isNull(h) ||
|
|
3610
|
+
if (isNull(h) || m.includes(l._id)) return null;
|
|
3600
3611
|
let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
|
|
3601
3612
|
...A,
|
|
3602
3613
|
children: n({
|
|
@@ -3629,7 +3640,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3629
3640
|
);
|
|
3630
3641
|
return map(l, (c) => {
|
|
3631
3642
|
const d = a(c._id);
|
|
3632
|
-
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type:
|
|
3643
|
+
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: m, partialBlockId: g, repeaterItems: h, $repeaterItemsKey: f }) => m === "Repeater" ? isArray(h) && h.map((x, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: g }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
|
|
3633
3644
|
});
|
|
3634
3645
|
}, PageBlocksRenderer = () => {
|
|
3635
3646
|
const [o] = useBlocksStore();
|
|
@@ -3642,18 +3653,18 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3642
3653
|
const { width: d, height: p } = o;
|
|
3643
3654
|
if (d < r) {
|
|
3644
3655
|
const u = parseFloat((d / r).toFixed(2).toString());
|
|
3645
|
-
let
|
|
3646
|
-
const
|
|
3647
|
-
p && (
|
|
3656
|
+
let m = {};
|
|
3657
|
+
const g = p * u, h = d * u;
|
|
3658
|
+
p && (m = {
|
|
3648
3659
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3649
|
-
height: 100 + (p -
|
|
3660
|
+
height: 100 + (p - g) / g * 100 + "%",
|
|
3650
3661
|
width: 100 + (d - h) / h * 100 + "%"
|
|
3651
3662
|
}), i({
|
|
3652
3663
|
position: "relative",
|
|
3653
3664
|
top: 0,
|
|
3654
3665
|
transform: `scale(${u})`,
|
|
3655
3666
|
transformOrigin: a === "rtl" ? "top right" : "top left",
|
|
3656
|
-
...
|
|
3667
|
+
...m,
|
|
3657
3668
|
maxWidth: "none"
|
|
3658
3669
|
// TODO: Add max-width to the wrapper
|
|
3659
3670
|
}), n(u * 100);
|
|
@@ -3680,8 +3691,8 @@ const CanvasEventsWatcher = () => {
|
|
|
3680
3691
|
if (d) {
|
|
3681
3692
|
const p = d.getAttribute("data-style-prop");
|
|
3682
3693
|
if (p) {
|
|
3683
|
-
const u = d.getAttribute("data-style-id"),
|
|
3684
|
-
n([{ id: u, prop: p, blockId:
|
|
3694
|
+
const u = d.getAttribute("data-style-id"), m = d.getAttribute("data-block-parent");
|
|
3695
|
+
n([{ id: u, prop: p, blockId: m }]);
|
|
3685
3696
|
}
|
|
3686
3697
|
}
|
|
3687
3698
|
}, 100);
|
|
@@ -3691,13 +3702,13 @@ const CanvasEventsWatcher = () => {
|
|
|
3691
3702
|
i.includes(p) || c == null || c.closeAll(), o([p]);
|
|
3692
3703
|
}), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
|
|
3693
3704
|
if (!d) return;
|
|
3694
|
-
const { blockId: p, styleId: u, styleProp:
|
|
3695
|
-
p && (i.includes(p) || c == null || c.closeAll(), n([{ id: u, prop:
|
|
3705
|
+
const { blockId: p, styleId: u, styleProp: m } = d;
|
|
3706
|
+
p && (i.includes(p) || c == null || c.closeAll(), n([{ id: u, prop: m, blockId: p }]), o([p]));
|
|
3696
3707
|
}), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
|
|
3697
3708
|
l(), o([]), n([]);
|
|
3698
3709
|
}), null;
|
|
3699
3710
|
}, StaticCanvas = () => {
|
|
3700
|
-
const [o] = useCanvasDisplayWidth(), [, r] = useHighlightBlockId(), n = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"),
|
|
3711
|
+
const [o] = useCanvasDisplayWidth(), [, r] = useHighlightBlockId(), n = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), m = useCallback(
|
|
3701
3712
|
(h) => {
|
|
3702
3713
|
i((f) => ({ ...f, width: h }));
|
|
3703
3714
|
},
|
|
@@ -3708,11 +3719,11 @@ const CanvasEventsWatcher = () => {
|
|
|
3708
3719
|
const { clientWidth: h, clientHeight: f } = a.current;
|
|
3709
3720
|
i({ width: h, height: f });
|
|
3710
3721
|
}, [a, o]);
|
|
3711
|
-
const
|
|
3722
|
+
const g = useMemo(() => {
|
|
3712
3723
|
let h = IframeInitialContent;
|
|
3713
3724
|
return h = h.replace("__HTML_DIR__", u), h;
|
|
3714
3725
|
}, [u]);
|
|
3715
|
-
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount:
|
|
3726
|
+
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: m, onResize: m, children: /* @__PURE__ */ jsx(
|
|
3716
3727
|
"div",
|
|
3717
3728
|
{
|
|
3718
3729
|
onMouseLeave: () => setTimeout(() => r(""), 300),
|
|
@@ -3726,7 +3737,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3726
3737
|
id: "canvas-iframe",
|
|
3727
3738
|
style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
|
|
3728
3739
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
3729
|
-
initialContent:
|
|
3740
|
+
initialContent: g,
|
|
3730
3741
|
children: [
|
|
3731
3742
|
/* @__PURE__ */ jsx(KeyboardHandler, {}),
|
|
3732
3743
|
/* @__PURE__ */ jsx(BlockSelectionHighlighter, {}),
|
|
@@ -3821,15 +3832,15 @@ const CanvasEventsWatcher = () => {
|
|
|
3821
3832
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3822
3833
|
] });
|
|
3823
3834
|
}, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
|
|
3824
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u,
|
|
3835
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState(null), g = async (f) => {
|
|
3825
3836
|
if (!f.trim()) {
|
|
3826
|
-
p(!1),
|
|
3837
|
+
p(!1), m("Please enter a URL");
|
|
3827
3838
|
return;
|
|
3828
3839
|
}
|
|
3829
3840
|
try {
|
|
3830
|
-
c(!0),
|
|
3841
|
+
c(!0), m(null), p(!0), m(null);
|
|
3831
3842
|
} catch {
|
|
3832
|
-
p(!1),
|
|
3843
|
+
p(!1), m("Error validating URL");
|
|
3833
3844
|
} finally {
|
|
3834
3845
|
c(!1);
|
|
3835
3846
|
}
|
|
@@ -3847,7 +3858,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3847
3858
|
placeholder: h(`Enter ${n} URL`),
|
|
3848
3859
|
value: a,
|
|
3849
3860
|
onChange: (f) => l(f.target.value),
|
|
3850
|
-
onKeyUp: () =>
|
|
3861
|
+
onKeyUp: () => g(a)
|
|
3851
3862
|
}
|
|
3852
3863
|
),
|
|
3853
3864
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
@@ -3883,17 +3894,17 @@ const CanvasEventsWatcher = () => {
|
|
|
3883
3894
|
};
|
|
3884
3895
|
MediaManagerModal.displayName = "MediaManagerModal";
|
|
3885
3896
|
const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
3886
|
-
const { t: l } = useTranslation(), i = useSelectedBlock(), c = useUpdateBlocksProps(), d = (
|
|
3887
|
-
const
|
|
3888
|
-
if (
|
|
3889
|
-
r(
|
|
3890
|
-
const h =
|
|
3897
|
+
const { t: l } = useTranslation(), i = useSelectedBlock(), c = useUpdateBlocksProps(), d = (m) => {
|
|
3898
|
+
const g = isArray(m) ? first(m) : m;
|
|
3899
|
+
if (g) {
|
|
3900
|
+
r(g == null ? void 0 : g.url);
|
|
3901
|
+
const h = g == null ? void 0 : g.width, f = g == null ? void 0 : g.height;
|
|
3891
3902
|
if (i != null && i._id) {
|
|
3892
3903
|
const x = {
|
|
3893
3904
|
...h && { width: h },
|
|
3894
3905
|
...f && { height: f },
|
|
3895
|
-
...
|
|
3896
|
-
...
|
|
3906
|
+
...g.description && { alt: g.description },
|
|
3907
|
+
...g.id && { assetId: g.id }
|
|
3897
3908
|
};
|
|
3898
3909
|
if (isEmpty(x)) return;
|
|
3899
3910
|
c([i._id], x);
|
|
@@ -3931,25 +3942,25 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
3931
3942
|
className: "text-xs",
|
|
3932
3943
|
placeholder: l("Enter image URL"),
|
|
3933
3944
|
value: o,
|
|
3934
|
-
onBlur: ({ target: { value:
|
|
3935
|
-
onChange: (
|
|
3945
|
+
onBlur: ({ target: { value: m } }) => a(n, m),
|
|
3946
|
+
onChange: (m) => r(m.target.value)
|
|
3936
3947
|
}
|
|
3937
3948
|
)
|
|
3938
3949
|
] })
|
|
3939
3950
|
] });
|
|
3940
3951
|
}, PathDropdown = ({ data: o, onSelect: r, dataType: n }) => {
|
|
3941
|
-
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (
|
|
3942
|
-
(
|
|
3952
|
+
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (g) => Array.isArray(g) ? "array" : typeof g == "object" && g !== null ? "object" : "value", p = React__default.useCallback(
|
|
3953
|
+
(g) => {
|
|
3943
3954
|
const h = (f) => n === "value" ? f === "value" || f === "object" : n === "array" ? f === "array" : f === n;
|
|
3944
|
-
|
|
3955
|
+
g.type === "object" ? (l((f) => [...f, g.key]), c(g.value)) : h(g.type) && r([...a, g.key].join("."), n);
|
|
3945
3956
|
},
|
|
3946
3957
|
[a, r, n]
|
|
3947
3958
|
), u = React__default.useCallback(() => {
|
|
3948
3959
|
if (a.length > 0) {
|
|
3949
|
-
const
|
|
3950
|
-
l(
|
|
3960
|
+
const g = a.slice(0, -1);
|
|
3961
|
+
l(g), c(g.reduce((h, f) => h[f], o));
|
|
3951
3962
|
}
|
|
3952
|
-
}, [a, o]),
|
|
3963
|
+
}, [a, o]), m = React__default.useMemo(() => i ? Object.entries(i).map(([g, h]) => ({ key: g, value: h, type: d(h) })).filter((g) => !startsWith(g.key, REPEATER_PREFIX) && g.key.includes("/") ? !1 : n === "value" ? g.type === "value" || g.type === "object" : n === "array" ? g.type === "array" || g.type === "object" : n === "object" ? g.type === "object" : !0) : [], [i, n]);
|
|
3953
3964
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
3954
3965
|
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
3955
3966
|
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
@@ -3959,36 +3970,36 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
3959
3970
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
3960
3971
|
"Back"
|
|
3961
3972
|
] }),
|
|
3962
|
-
|
|
3973
|
+
m.map((g) => /* @__PURE__ */ jsxs(
|
|
3963
3974
|
CommandItem,
|
|
3964
3975
|
{
|
|
3965
|
-
value:
|
|
3976
|
+
value: g.key,
|
|
3966
3977
|
disabled: !1,
|
|
3967
|
-
onSelect: () => p(
|
|
3978
|
+
onSelect: () => p(g),
|
|
3968
3979
|
className: "flex items-center justify-between",
|
|
3969
3980
|
children: [
|
|
3970
3981
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
|
|
3971
|
-
startsWith(
|
|
3972
|
-
startsWith(
|
|
3982
|
+
startsWith(g.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(g.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(DatabaseIcon, {}) : null,
|
|
3983
|
+
startsWith(g.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(g.key, COLLECTION_PREFIX) ? g.key.replace(COLLECTION_PREFIX, "") : g.key
|
|
3973
3984
|
] }),
|
|
3974
3985
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3975
|
-
n === "object" &&
|
|
3986
|
+
n === "object" && g.type === "object" && /* @__PURE__ */ jsx(
|
|
3976
3987
|
Button,
|
|
3977
3988
|
{
|
|
3978
3989
|
size: "sm",
|
|
3979
3990
|
variant: "ghost",
|
|
3980
3991
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
3981
3992
|
onClick: (h) => {
|
|
3982
|
-
h.stopPropagation(), r([...a,
|
|
3993
|
+
h.stopPropagation(), r([...a, g.key].join("."), n);
|
|
3983
3994
|
},
|
|
3984
3995
|
children: "Select"
|
|
3985
3996
|
}
|
|
3986
3997
|
),
|
|
3987
|
-
|
|
3998
|
+
g.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
|
|
3988
3999
|
] })
|
|
3989
4000
|
]
|
|
3990
4001
|
},
|
|
3991
|
-
|
|
4002
|
+
g.key
|
|
3992
4003
|
))
|
|
3993
4004
|
] })
|
|
3994
4005
|
] })
|
|
@@ -4040,12 +4051,12 @@ const DataBindingSelector = ({
|
|
|
4040
4051
|
}) => {
|
|
4041
4052
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4042
4053
|
if (i.length === 1) return "";
|
|
4043
|
-
const
|
|
4044
|
-
return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${
|
|
4054
|
+
const m = i.find((f) => f._type === "Repeater"), h = get(m, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4055
|
+
return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${m._id}` : h}`;
|
|
4045
4056
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4046
|
-
(
|
|
4047
|
-
if (
|
|
4048
|
-
r(`{{${
|
|
4057
|
+
(m, g) => {
|
|
4058
|
+
if (m = isEmpty(d) ? m : m.replace(`${d}`, "$index"), g === "array" || g === "object") {
|
|
4059
|
+
r(`{{${m}}}`, {}, n);
|
|
4049
4060
|
return;
|
|
4050
4061
|
}
|
|
4051
4062
|
const h = (b) => /[.,!?;:]/.test(b), f = (b, v, A) => {
|
|
@@ -4062,7 +4073,7 @@ const DataBindingSelector = ({
|
|
|
4062
4073
|
if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
|
|
4063
4074
|
const b = y.__chaiRTE;
|
|
4064
4075
|
if (b) {
|
|
4065
|
-
const v = `{{${
|
|
4076
|
+
const v = `{{${m}}}`;
|
|
4066
4077
|
b.commands.focus();
|
|
4067
4078
|
const { from: A, to: w } = b.state.selection;
|
|
4068
4079
|
if (A !== w)
|
|
@@ -4080,11 +4091,11 @@ const DataBindingSelector = ({
|
|
|
4080
4091
|
} else {
|
|
4081
4092
|
const b = x, v = b.selectionStart || 0, A = b.value || "", w = b.selectionEnd || v;
|
|
4082
4093
|
if (w > v) {
|
|
4083
|
-
const N = `{{${
|
|
4094
|
+
const N = `{{${m}}}`, { text: C } = f(A, v, N), k = A.slice(0, v) + C + A.slice(w);
|
|
4084
4095
|
r(k, {}, n);
|
|
4085
4096
|
return;
|
|
4086
4097
|
}
|
|
4087
|
-
const _ = `{{${
|
|
4098
|
+
const _ = `{{${m}}}`, { text: S } = f(A, v, _), B = A.slice(0, v) + S + A.slice(v);
|
|
4088
4099
|
r(B, {}, n);
|
|
4089
4100
|
}
|
|
4090
4101
|
},
|
|
@@ -4107,11 +4118,11 @@ const DataBindingSelector = ({
|
|
|
4107
4118
|
onChange: n
|
|
4108
4119
|
}) => {
|
|
4109
4120
|
var N;
|
|
4110
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u,
|
|
4121
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState("page"), [g, h] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), v = useRef(null), A = (N = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : N.name;
|
|
4111
4122
|
useEffect(() => {
|
|
4112
4123
|
if (h(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4113
4124
|
const C = split(o, ":"), k = get(C, 1, "page") || "page";
|
|
4114
|
-
|
|
4125
|
+
m(k), (async () => {
|
|
4115
4126
|
const j = await l(k, [get(C, 2, "page")]);
|
|
4116
4127
|
j && Array.isArray(j) && h(get(j, [0, "name"], ""));
|
|
4117
4128
|
})();
|
|
@@ -4160,20 +4171,20 @@ const DataBindingSelector = ({
|
|
|
4160
4171
|
h(C), p(!isEmpty(C)), c(!0), w(C);
|
|
4161
4172
|
};
|
|
4162
4173
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4163
|
-
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) =>
|
|
4174
|
+
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => m(C.target.value), children: map(r, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
|
|
4164
4175
|
u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
|
|
4165
4176
|
/* @__PURE__ */ jsx(
|
|
4166
4177
|
"input",
|
|
4167
4178
|
{
|
|
4168
4179
|
type: "text",
|
|
4169
|
-
value:
|
|
4180
|
+
value: g,
|
|
4170
4181
|
onChange: (C) => B(C.target.value),
|
|
4171
4182
|
onKeyDown: _,
|
|
4172
4183
|
placeholder: a(`Search ${A ?? ""}`),
|
|
4173
4184
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4174
4185
|
}
|
|
4175
4186
|
),
|
|
4176
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
4187
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: g && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4177
4188
|
] }),
|
|
4178
4189
|
(i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4179
4190
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -4181,7 +4192,7 @@ const DataBindingSelector = ({
|
|
|
4181
4192
|
] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4182
4193
|
a("No results found for"),
|
|
4183
4194
|
' "',
|
|
4184
|
-
|
|
4195
|
+
g,
|
|
4185
4196
|
'"'
|
|
4186
4197
|
] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
|
|
4187
4198
|
"li",
|
|
@@ -4210,8 +4221,8 @@ const DataBindingSelector = ({
|
|
|
4210
4221
|
DataBindingSelector,
|
|
4211
4222
|
{
|
|
4212
4223
|
schema: o,
|
|
4213
|
-
onChange: (
|
|
4214
|
-
console.log("value", r,
|
|
4224
|
+
onChange: (m) => {
|
|
4225
|
+
console.log("value", r, m), n({ ...r, href: m, ...u === "pageType" ? { type: "url" } : {} });
|
|
4215
4226
|
},
|
|
4216
4227
|
id: `root.${a}.href`,
|
|
4217
4228
|
formData: r
|
|
@@ -4219,7 +4230,7 @@ const DataBindingSelector = ({
|
|
|
4219
4230
|
)
|
|
4220
4231
|
] }),
|
|
4221
4232
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1.5", children: [
|
|
4222
|
-
/* @__PURE__ */ jsx("select", { name: "type", value: i, onChange: (
|
|
4233
|
+
/* @__PURE__ */ jsx("select", { name: "type", value: i, onChange: (m) => n({ ...r, type: m.target.value }), children: map(
|
|
4223
4234
|
[
|
|
4224
4235
|
...isEmpty(p) ? [] : [{ const: "pageType", title: l("Goto Page") }],
|
|
4225
4236
|
{ const: "url", title: l("Open URL") },
|
|
@@ -4227,14 +4238,14 @@ const DataBindingSelector = ({
|
|
|
4227
4238
|
{ const: "telephone", title: l("Call Phone") },
|
|
4228
4239
|
{ const: "scroll", title: l("Scroll to element") }
|
|
4229
4240
|
],
|
|
4230
|
-
(
|
|
4241
|
+
(m) => /* @__PURE__ */ jsx("option", { value: m.const, children: m.title }, m.const)
|
|
4231
4242
|
) }),
|
|
4232
4243
|
u === "pageType" && !isEmpty(p) ? /* @__PURE__ */ jsx(
|
|
4233
4244
|
PageTypeField,
|
|
4234
4245
|
{
|
|
4235
4246
|
href: c,
|
|
4236
4247
|
pageTypes: p,
|
|
4237
|
-
onChange: (
|
|
4248
|
+
onChange: (m) => n({ ...r, href: m })
|
|
4238
4249
|
}
|
|
4239
4250
|
) : null,
|
|
4240
4251
|
/* @__PURE__ */ jsx(
|
|
@@ -4248,7 +4259,7 @@ const DataBindingSelector = ({
|
|
|
4248
4259
|
type: "text",
|
|
4249
4260
|
className: u === "pageType" ? "!hidden" : "",
|
|
4250
4261
|
value: c,
|
|
4251
|
-
onChange: (
|
|
4262
|
+
onChange: (m) => n({ ...r, href: m.target.value }),
|
|
4252
4263
|
placeholder: l(i === "url" ? "Enter URL" : i === "scroll" ? "#ElementID" : "Enter details")
|
|
4253
4264
|
}
|
|
4254
4265
|
),
|
|
@@ -4439,14 +4450,14 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4439
4450
|
const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
|
|
4440
4451
|
useEffect(() => {
|
|
4441
4452
|
if (o) {
|
|
4442
|
-
const
|
|
4443
|
-
return
|
|
4453
|
+
const g = document.createElement("style");
|
|
4454
|
+
return g.id = "rte-modal-styles", g.innerHTML = `
|
|
4444
4455
|
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
4445
4456
|
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
4446
4457
|
[data-radix-popper-content-wrapper] {
|
|
4447
4458
|
z-index: 9999 !important;
|
|
4448
4459
|
}
|
|
4449
|
-
`, document.head.appendChild(
|
|
4460
|
+
`, document.head.appendChild(g), () => {
|
|
4450
4461
|
const h = document.getElementById("rte-modal-styles");
|
|
4451
4462
|
h && h.remove();
|
|
4452
4463
|
};
|
|
@@ -4473,12 +4484,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4473
4484
|
})
|
|
4474
4485
|
],
|
|
4475
4486
|
content: a || "",
|
|
4476
|
-
onUpdate: ({ editor:
|
|
4477
|
-
const h =
|
|
4487
|
+
onUpdate: ({ editor: g }) => {
|
|
4488
|
+
const h = g.getHTML();
|
|
4478
4489
|
l(h);
|
|
4479
4490
|
},
|
|
4480
|
-
onBlur: ({ editor:
|
|
4481
|
-
const h =
|
|
4491
|
+
onBlur: ({ editor: g }) => {
|
|
4492
|
+
const h = g.getHTML();
|
|
4482
4493
|
i(n, h);
|
|
4483
4494
|
},
|
|
4484
4495
|
editorProps: {
|
|
@@ -4494,9 +4505,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4494
4505
|
}, [o, u]), useEffect(() => {
|
|
4495
4506
|
c.current && u && (c.current.__chaiRTE = u);
|
|
4496
4507
|
}, [u, o]);
|
|
4497
|
-
const
|
|
4508
|
+
const m = (g) => {
|
|
4498
4509
|
if (!u) return;
|
|
4499
|
-
const h = `{{${
|
|
4510
|
+
const h = `{{${g}}}`;
|
|
4500
4511
|
u.commands.focus();
|
|
4501
4512
|
const { from: f, to: x } = u.state.selection;
|
|
4502
4513
|
if (f !== x)
|
|
@@ -4509,12 +4520,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4509
4520
|
w && w !== " " && !/[.,!?;:]/.test(w) && (_ = " "), u.chain().insertContent(E + h + _).run();
|
|
4510
4521
|
}
|
|
4511
4522
|
};
|
|
4512
|
-
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (
|
|
4523
|
+
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (g) => !g && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
4513
4524
|
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
|
|
4514
4525
|
/* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
|
|
4515
4526
|
Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
4516
4527
|
/* @__PURE__ */ jsx("span", { className: "mr-2 text-sm text-muted-foreground", children: "Add field:" }),
|
|
4517
|
-
/* @__PURE__ */ jsx("div", { className: "rte-path-selector", children: /* @__PURE__ */ jsx(NestedPathSelector, { data: p, onSelect:
|
|
4528
|
+
/* @__PURE__ */ jsx("div", { className: "rte-path-selector", children: /* @__PURE__ */ jsx(NestedPathSelector, { data: p, onSelect: m }) })
|
|
4518
4529
|
] })
|
|
4519
4530
|
] }) }),
|
|
4520
4531
|
/* @__PURE__ */ jsxs("div", { id: `chai-rte-modal-${n}`, ref: c, className: "rounded-md border border-input", children: [
|
|
@@ -4524,7 +4535,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4524
4535
|
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ jsx(Button, { onClick: r, children: "Done" }) })
|
|
4525
4536
|
] }) });
|
|
4526
4537
|
}, RichTextEditorField = ({ id: o, placeholder: r, value: n, onChange: a, onBlur: l }) => {
|
|
4527
|
-
const i = useRef(null), [c, d] = useState(!1), [p, u] = useState(""),
|
|
4538
|
+
const i = useRef(null), [c, d] = useState(!1), [p, u] = useState(""), m = useEditor({
|
|
4528
4539
|
extensions: [
|
|
4529
4540
|
StarterKit,
|
|
4530
4541
|
Link.configure({
|
|
@@ -4560,19 +4571,19 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4560
4571
|
}
|
|
4561
4572
|
});
|
|
4562
4573
|
useEffect(() => {
|
|
4563
|
-
i.current.__chaiRTE =
|
|
4564
|
-
}, [
|
|
4574
|
+
i.current.__chaiRTE = m;
|
|
4575
|
+
}, [m]), useEffect(() => {
|
|
4565
4576
|
u(n || "");
|
|
4566
4577
|
}, [n]);
|
|
4567
|
-
const
|
|
4578
|
+
const g = (f) => {
|
|
4568
4579
|
a(f);
|
|
4569
4580
|
}, h = () => {
|
|
4570
|
-
d(!1),
|
|
4581
|
+
d(!1), m && m.commands.setContent(p);
|
|
4571
4582
|
};
|
|
4572
4583
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4573
4584
|
/* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs("div", { id: `chai-rte-${o}`, ref: i, className: "mt-1 rounded-md border border-input", children: [
|
|
4574
|
-
/* @__PURE__ */ jsx(MenuBar, { editor:
|
|
4575
|
-
/* @__PURE__ */ jsx(EditorContent, { editor:
|
|
4585
|
+
/* @__PURE__ */ jsx(MenuBar, { editor: m, onExpand: () => d(!0) }),
|
|
4586
|
+
/* @__PURE__ */ jsx(EditorContent, { editor: m, id: o, placeholder: r })
|
|
4576
4587
|
] }) }),
|
|
4577
4588
|
c && /* @__PURE__ */ jsx(
|
|
4578
4589
|
RTEModal,
|
|
@@ -4581,7 +4592,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4581
4592
|
onClose: h,
|
|
4582
4593
|
id: o,
|
|
4583
4594
|
value: p,
|
|
4584
|
-
onChange:
|
|
4595
|
+
onChange: g,
|
|
4585
4596
|
onBlur: l
|
|
4586
4597
|
}
|
|
4587
4598
|
)
|
|
@@ -4591,21 +4602,21 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4591
4602
|
if (!a && !l) return null;
|
|
4592
4603
|
const d = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(n, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
|
|
4593
4604
|
if (!p) return null;
|
|
4594
|
-
const u = filter(n, { _parent: p == null ? void 0 : p._id, _type: "Slide" }),
|
|
4605
|
+
const u = filter(n, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), m = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
|
|
4595
4606
|
useEffect(() => {
|
|
4596
4607
|
(a == null ? void 0 : a._type) === "Slide" && (o == null ? void 0 : o.currentSlide) !== (a == null ? void 0 : a._id) && r({ ...o, currentSlide: a == null ? void 0 : a._id });
|
|
4597
4608
|
}, [a]), useEffect(() => {
|
|
4598
4609
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
|
|
4599
4610
|
}, [o, u]);
|
|
4600
|
-
const
|
|
4601
|
-
const x = findIndex(u, { _id:
|
|
4611
|
+
const g = () => {
|
|
4612
|
+
const x = findIndex(u, { _id: m });
|
|
4602
4613
|
if (x > -1) {
|
|
4603
4614
|
const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
|
|
4604
4615
|
if (!b) return;
|
|
4605
4616
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4606
4617
|
}
|
|
4607
4618
|
}, h = () => {
|
|
4608
|
-
const x = findIndex(u, { _id:
|
|
4619
|
+
const x = findIndex(u, { _id: m });
|
|
4609
4620
|
if (x > -1) {
|
|
4610
4621
|
const y = (x - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
|
|
4611
4622
|
if (!b) return;
|
|
@@ -4621,15 +4632,15 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4621
4632
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4622
4633
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4623
4634
|
/* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4624
|
-
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children:
|
|
4635
|
+
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: m ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4625
4636
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4626
4637
|
" ",
|
|
4627
|
-
findIndex(u, { _id:
|
|
4638
|
+
findIndex(u, { _id: m }) + 1
|
|
4628
4639
|
] }),
|
|
4629
4640
|
"/",
|
|
4630
4641
|
u.length
|
|
4631
4642
|
] }) : "-" }),
|
|
4632
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4643
|
+
/* @__PURE__ */ jsx("button", { onClick: g, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4633
4644
|
/* @__PURE__ */ jsxs(
|
|
4634
4645
|
"button",
|
|
4635
4646
|
{
|
|
@@ -4707,7 +4718,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4707
4718
|
const n = get(o, "srcsets", []) || [], a = (c, d) => {
|
|
4708
4719
|
const p = c.target.name, u = c.target.value;
|
|
4709
4720
|
r({
|
|
4710
|
-
srcsets: map(n, (
|
|
4721
|
+
srcsets: map(n, (m, g) => g === d ? { ...m, [p]: u } : m)
|
|
4711
4722
|
});
|
|
4712
4723
|
}, l = () => {
|
|
4713
4724
|
r({ srcsets: [...n, {}] });
|
|
@@ -4786,9 +4797,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4786
4797
|
] });
|
|
4787
4798
|
}, CollectionFilterSortField = ({ id: o, value: r, onChange: n, onBlur: a }) => {
|
|
4788
4799
|
const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(l, { id: c }), u = get(d, o === "root.filter" ? "filters" : "sorts", []);
|
|
4789
|
-
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: r, onChange: (
|
|
4800
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: r, onChange: (m) => n(m.target.value), onBlur: (m) => a(o, m.target.value), children: [
|
|
4790
4801
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
|
|
4791
|
-
u.map((
|
|
4802
|
+
u.map((m) => /* @__PURE__ */ jsx("option", { value: m.id, children: m.name }, m.id))
|
|
4792
4803
|
] }) });
|
|
4793
4804
|
}, JSONFormFieldTemplate = ({
|
|
4794
4805
|
id: o,
|
|
@@ -4801,8 +4812,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4801
4812
|
hidden: d,
|
|
4802
4813
|
required: p,
|
|
4803
4814
|
schema: u,
|
|
4804
|
-
formData:
|
|
4805
|
-
onChange:
|
|
4815
|
+
formData: m,
|
|
4816
|
+
onChange: g
|
|
4806
4817
|
}) => {
|
|
4807
4818
|
const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), y = useMemo(
|
|
4808
4819
|
() => isEmpty(x) ? "" : isEmpty(h) ? f : h,
|
|
@@ -4829,11 +4840,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4829
4840
|
/* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
|
|
4830
4841
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
|
|
4831
4842
|
" ",
|
|
4832
|
-
/* @__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:
|
|
4843
|
+
/* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: m == null ? void 0 : m.length }) })
|
|
4833
4844
|
]
|
|
4834
4845
|
}
|
|
4835
4846
|
),
|
|
4836
|
-
(
|
|
4847
|
+
(m == null ? void 0 : m.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${C ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
4837
4848
|
c,
|
|
4838
4849
|
a,
|
|
4839
4850
|
l,
|
|
@@ -4857,10 +4868,10 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4857
4868
|
{
|
|
4858
4869
|
schema: u,
|
|
4859
4870
|
onChange: (C) => {
|
|
4860
|
-
|
|
4871
|
+
g(C, m, o);
|
|
4861
4872
|
},
|
|
4862
4873
|
id: o,
|
|
4863
|
-
formData:
|
|
4874
|
+
formData: m
|
|
4864
4875
|
}
|
|
4865
4876
|
) })
|
|
4866
4877
|
] }),
|
|
@@ -4875,8 +4886,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4875
4886
|
/* @__PURE__ */ jsx("span", { children: "Add" })
|
|
4876
4887
|
] }) }), JSONForm = memo(({ blockId: o, schema: r, uiSchema: n, formData: a, onChange: l }) => {
|
|
4877
4888
|
const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
|
|
4878
|
-
async ({ formData:
|
|
4879
|
-
l({ formData:
|
|
4889
|
+
async ({ formData: m }, g) => {
|
|
4890
|
+
l({ formData: m }, g);
|
|
4880
4891
|
},
|
|
4881
4892
|
[l, i],
|
|
4882
4893
|
400
|
|
@@ -4916,10 +4927,10 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4916
4927
|
uiSchema: n,
|
|
4917
4928
|
schema: r,
|
|
4918
4929
|
formData: a,
|
|
4919
|
-
onChange: ({ formData:
|
|
4920
|
-
if (!
|
|
4921
|
-
const h = take(
|
|
4922
|
-
u({ formData:
|
|
4930
|
+
onChange: ({ formData: m }, g) => {
|
|
4931
|
+
if (!g || o !== (m == null ? void 0 : m._id)) return;
|
|
4932
|
+
const h = take(g.split("."), 2).join(".").replace("root.", "");
|
|
4933
|
+
u({ formData: m }, h);
|
|
4923
4934
|
}
|
|
4924
4935
|
},
|
|
4925
4936
|
i
|
|
@@ -4931,7 +4942,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4931
4942
|
}), a;
|
|
4932
4943
|
};
|
|
4933
4944
|
function BlockSettings() {
|
|
4934
|
-
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1),
|
|
4945
|
+
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), m = useWrapperBlock(), g = getRegisteredChaiBlock(m == null ? void 0 : m._type), h = formDataWithSelectedLang(m, o, g), f = ({ formData: _ }, S, B) => {
|
|
4935
4946
|
S && (c == null ? void 0 : c._id) === r._id && a([r._id], { [S]: get(_, S) }, B);
|
|
4936
4947
|
}, x = useCallback(
|
|
4937
4948
|
debounce(({ formData: _ }, S, B) => {
|
|
@@ -4941,7 +4952,7 @@ function BlockSettings() {
|
|
|
4941
4952
|
), y = ({ formData: _ }, S) => {
|
|
4942
4953
|
S && (n([r._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
|
|
4943
4954
|
}, b = ({ formData: _ }, S) => {
|
|
4944
|
-
S && (n([
|
|
4955
|
+
S && (n([m._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
|
|
4945
4956
|
}, { schema: v, uiSchema: A } = useMemo(() => {
|
|
4946
4957
|
const _ = r == null ? void 0 : r._type;
|
|
4947
4958
|
if (!_)
|
|
@@ -4952,13 +4963,13 @@ function BlockSettings() {
|
|
|
4952
4963
|
return { schema: {}, uiSchema: {} };
|
|
4953
4964
|
}
|
|
4954
4965
|
}, [r]), { wrapperSchema: w, wrapperUiSchema: E } = useMemo(() => {
|
|
4955
|
-
if (!
|
|
4966
|
+
if (!m || !(m != null && m._type))
|
|
4956
4967
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
4957
|
-
const _ =
|
|
4968
|
+
const _ = m == null ? void 0 : m._type, { schema: S = {}, uiSchema: B = {} } = getBlockFormSchemas(_);
|
|
4958
4969
|
return { wrapperSchema: S, wrapperUiSchema: B };
|
|
4959
|
-
}, [
|
|
4970
|
+
}, [m]);
|
|
4960
4971
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
4961
|
-
!isEmpty(
|
|
4972
|
+
!isEmpty(m) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
4962
4973
|
/* @__PURE__ */ jsxs(
|
|
4963
4974
|
"div",
|
|
4964
4975
|
{
|
|
@@ -4966,12 +4977,12 @@ function BlockSettings() {
|
|
|
4966
4977
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
4967
4978
|
children: [
|
|
4968
4979
|
p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
|
|
4969
|
-
startCase(
|
|
4980
|
+
startCase(m._type),
|
|
4970
4981
|
" settings",
|
|
4971
4982
|
" ",
|
|
4972
|
-
|
|
4983
|
+
m._name && /* @__PURE__ */ jsxs("span", { className: "text-[11px] font-light text-slate-400", children: [
|
|
4973
4984
|
"(",
|
|
4974
|
-
|
|
4985
|
+
m._name,
|
|
4975
4986
|
")"
|
|
4976
4987
|
] })
|
|
4977
4988
|
]
|
|
@@ -4980,7 +4991,7 @@ function BlockSettings() {
|
|
|
4980
4991
|
/* @__PURE__ */ jsx("div", { className: p ? "h-auto" : "invisible h-0", children: /* @__PURE__ */ jsx(
|
|
4981
4992
|
JSONForm,
|
|
4982
4993
|
{
|
|
4983
|
-
blockId:
|
|
4994
|
+
blockId: m == null ? void 0 : m._id,
|
|
4984
4995
|
onChange: b,
|
|
4985
4996
|
formData: h,
|
|
4986
4997
|
schema: w,
|
|
@@ -5172,7 +5183,7 @@ const BlockStylingProps = () => {
|
|
|
5172
5183
|
},
|
|
5173
5184
|
a
|
|
5174
5185
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5175
|
-
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative:
|
|
5186
|
+
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: m } = o, [g, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [v, A] = useState(!1), [w, E] = useState(!1);
|
|
5176
5187
|
useEffect(() => {
|
|
5177
5188
|
const { value: C, unit: k } = getClassValueAndUnit(i);
|
|
5178
5189
|
if (k === "") {
|
|
@@ -5188,7 +5199,7 @@ const BlockStylingProps = () => {
|
|
|
5188
5199
|
x(!0);
|
|
5189
5200
|
return;
|
|
5190
5201
|
}
|
|
5191
|
-
const j = get(k, "unit") !== "" ? get(k, "unit") :
|
|
5202
|
+
const j = get(k, "unit") !== "" ? get(k, "unit") : g;
|
|
5192
5203
|
if (j === "auto" || j === "none") {
|
|
5193
5204
|
_(`${d}${j}`);
|
|
5194
5205
|
return;
|
|
@@ -5198,7 +5209,7 @@ const BlockStylingProps = () => {
|
|
|
5198
5209
|
const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5199
5210
|
C ? S(I) : _(I);
|
|
5200
5211
|
},
|
|
5201
|
-
[_, S, a,
|
|
5212
|
+
[_, S, a, g, d, u]
|
|
5202
5213
|
), N = useCallback(
|
|
5203
5214
|
(C) => {
|
|
5204
5215
|
const k = getUserInputValues(`${a}`, u);
|
|
@@ -5217,7 +5228,7 @@ const BlockStylingProps = () => {
|
|
|
5217
5228
|
},
|
|
5218
5229
|
[_, a, d, u]
|
|
5219
5230
|
);
|
|
5220
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children:
|
|
5231
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: g === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5221
5232
|
/* @__PURE__ */ jsx(
|
|
5222
5233
|
"input",
|
|
5223
5234
|
{
|
|
@@ -5232,10 +5243,10 @@ const BlockStylingProps = () => {
|
|
|
5232
5243
|
] })
|
|
5233
5244
|
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
|
|
5234
5245
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
5235
|
-
["none", "auto"].indexOf(
|
|
5246
|
+
["none", "auto"].indexOf(g) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
5236
5247
|
"input",
|
|
5237
5248
|
{
|
|
5238
|
-
readOnly:
|
|
5249
|
+
readOnly: g === "class",
|
|
5239
5250
|
onKeyPress: (C) => {
|
|
5240
5251
|
C.key === "Enter" && B();
|
|
5241
5252
|
},
|
|
@@ -5246,7 +5257,7 @@ const BlockStylingProps = () => {
|
|
|
5246
5257
|
const k = parseInt$1(C.target.value);
|
|
5247
5258
|
let j = isNaN$1(k) ? 0 : k;
|
|
5248
5259
|
C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
|
|
5249
|
-
const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${
|
|
5260
|
+
const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5250
5261
|
S(P);
|
|
5251
5262
|
},
|
|
5252
5263
|
onKeyUp: (C) => {
|
|
@@ -5275,7 +5286,7 @@ const BlockStylingProps = () => {
|
|
|
5275
5286
|
onClick: () => n(!r),
|
|
5276
5287
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
5277
5288
|
children: [
|
|
5278
|
-
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
5289
|
+
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: g }),
|
|
5279
5290
|
u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
|
|
5280
5291
|
]
|
|
5281
5292
|
}
|
|
@@ -5284,7 +5295,7 @@ const BlockStylingProps = () => {
|
|
|
5284
5295
|
UnitSelection,
|
|
5285
5296
|
{
|
|
5286
5297
|
units: u,
|
|
5287
|
-
current:
|
|
5298
|
+
current: g,
|
|
5288
5299
|
onSelect: (C) => {
|
|
5289
5300
|
n(!1), h(C), N(C);
|
|
5290
5301
|
}
|
|
@@ -5292,26 +5303,26 @@ const BlockStylingProps = () => {
|
|
|
5292
5303
|
) })
|
|
5293
5304
|
] })
|
|
5294
5305
|
] }),
|
|
5295
|
-
["none", "auto"].indexOf(
|
|
5306
|
+
["none", "auto"].indexOf(g) !== -1 || v ? null : /* @__PURE__ */ jsx(
|
|
5296
5307
|
DragStyleButton,
|
|
5297
5308
|
{
|
|
5298
5309
|
onDragStart: () => A(!0),
|
|
5299
5310
|
onDragEnd: (C) => {
|
|
5300
5311
|
if (b(() => ""), A(!1), isEmpty(C))
|
|
5301
5312
|
return;
|
|
5302
|
-
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${
|
|
5313
|
+
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5303
5314
|
_(T);
|
|
5304
5315
|
},
|
|
5305
5316
|
onDrag: (C) => {
|
|
5306
5317
|
if (isEmpty(C))
|
|
5307
5318
|
return;
|
|
5308
5319
|
b(C);
|
|
5309
|
-
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${
|
|
5320
|
+
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5310
5321
|
S(T);
|
|
5311
5322
|
},
|
|
5312
5323
|
currentValue: a,
|
|
5313
|
-
unit:
|
|
5314
|
-
negative:
|
|
5324
|
+
unit: g,
|
|
5325
|
+
negative: m,
|
|
5315
5326
|
cssProperty: p
|
|
5316
5327
|
}
|
|
5317
5328
|
)
|
|
@@ -5370,7 +5381,7 @@ const COLOR_PROP = {
|
|
|
5370
5381
|
ringColor: "ring",
|
|
5371
5382
|
ringOffsetColor: "ring-offset"
|
|
5372
5383
|
}, ColorChoice = ({ property: o, onChange: r }) => {
|
|
5373
|
-
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"),
|
|
5384
|
+
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), m = get(u, "1", ""), g = get(u, "2", ""), h = useCallback(
|
|
5374
5385
|
// eslint-disable-next-line no-shadow
|
|
5375
5386
|
(y) => {
|
|
5376
5387
|
["current", "inherit", "transparent", "black", "white"].includes(y) ? (c([]), p({ color: y })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
|
|
@@ -5378,16 +5389,16 @@ const COLOR_PROP = {
|
|
|
5378
5389
|
[c, p]
|
|
5379
5390
|
);
|
|
5380
5391
|
useEffect(() => {
|
|
5381
|
-
if (["current", "inherit", "transparent", "black", "white"].includes(
|
|
5392
|
+
if (["current", "inherit", "transparent", "black", "white"].includes(m))
|
|
5382
5393
|
return c([]);
|
|
5383
5394
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5384
|
-
}, [
|
|
5395
|
+
}, [m]);
|
|
5385
5396
|
const f = useCallback(
|
|
5386
5397
|
// eslint-disable-next-line no-shadow
|
|
5387
5398
|
(y) => {
|
|
5388
|
-
p({ color:
|
|
5399
|
+
p({ color: m, shade: y });
|
|
5389
5400
|
},
|
|
5390
|
-
[
|
|
5401
|
+
[m]
|
|
5391
5402
|
);
|
|
5392
5403
|
useEffect(() => {
|
|
5393
5404
|
p({ color: "", shade: "" });
|
|
@@ -5402,7 +5413,7 @@ const COLOR_PROP = {
|
|
|
5402
5413
|
{
|
|
5403
5414
|
disabled: !l,
|
|
5404
5415
|
rounded: !0,
|
|
5405
|
-
selected:
|
|
5416
|
+
selected: m,
|
|
5406
5417
|
onChange: h,
|
|
5407
5418
|
options: [
|
|
5408
5419
|
"current",
|
|
@@ -5436,7 +5447,7 @@ const COLOR_PROP = {
|
|
|
5436
5447
|
]
|
|
5437
5448
|
}
|
|
5438
5449
|
) }),
|
|
5439
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected:
|
|
5450
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: g, disabled: !m || !l, onChange: f, options: i }) })
|
|
5440
5451
|
] });
|
|
5441
5452
|
}, EDITOR_ICONS = {
|
|
5442
5453
|
"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" }) }),
|
|
@@ -5770,20 +5781,20 @@ const COLOR_PROP = {
|
|
|
5770
5781
|
"2xl": "1536px"
|
|
5771
5782
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
5772
5783
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
5773
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [,
|
|
5784
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, m] = useScreenSizeWidth(), g = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(g, "fullCls", ""), [g]), b = useCallback(
|
|
5774
5785
|
(S, B = !0) => {
|
|
5775
|
-
const N = { dark: p, mq:
|
|
5786
|
+
const N = { dark: p, mq: m, mod: u, cls: S, property: l, fullCls: "" };
|
|
5776
5787
|
(p || u !== "") && (N.mq = "xs");
|
|
5777
5788
|
const C = generateFullClsName(N);
|
|
5778
5789
|
h(x, [C], B);
|
|
5779
5790
|
},
|
|
5780
|
-
[x, p,
|
|
5791
|
+
[x, p, m, u, l, h]
|
|
5781
5792
|
), v = useCallback(() => {
|
|
5782
5793
|
f(x, [y], !0);
|
|
5783
|
-
}, [x, y, f]), A = useMemo(() => canChangeClass(
|
|
5794
|
+
}, [x, y, f]), A = useMemo(() => canChangeClass(g, m), [g, m]);
|
|
5784
5795
|
useEffect(() => {
|
|
5785
|
-
i(A,
|
|
5786
|
-
}, [A, i,
|
|
5796
|
+
i(A, g);
|
|
5797
|
+
}, [A, i, g]);
|
|
5787
5798
|
const [, , w] = useScreenSizeWidth(), E = useCallback(
|
|
5788
5799
|
(S) => {
|
|
5789
5800
|
w({
|
|
@@ -5796,15 +5807,15 @@ const COLOR_PROP = {
|
|
|
5796
5807
|
}[S]);
|
|
5797
5808
|
},
|
|
5798
5809
|
[w]
|
|
5799
|
-
), _ = get(
|
|
5800
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: A, canReset:
|
|
5801
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${
|
|
5810
|
+
), _ = get(g, "dark", null) === p && get(g, "mod", null) === u && get(g, "mq", null) === m;
|
|
5811
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: A, canReset: g && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
5812
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${g && !_ ? "text-foreground" : ""}`, children: r(a) }) }),
|
|
5802
5813
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
5803
5814
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
5804
5815
|
n === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
5805
5816
|
AdvanceChoices,
|
|
5806
5817
|
{
|
|
5807
|
-
currentClass: get(
|
|
5818
|
+
currentClass: get(g, "cls", ""),
|
|
5808
5819
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
5809
5820
|
units: c || [],
|
|
5810
5821
|
onChange: b,
|
|
@@ -5817,7 +5828,7 @@ const COLOR_PROP = {
|
|
|
5817
5828
|
n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
5818
5829
|
n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
5819
5830
|
] }),
|
|
5820
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : A &&
|
|
5831
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : A && g ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
5821
5832
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5822
5833
|
"button",
|
|
5823
5834
|
{
|
|
@@ -5829,19 +5840,19 @@ const COLOR_PROP = {
|
|
|
5829
5840
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
5830
5841
|
"Current style is set at ",
|
|
5831
5842
|
/* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
|
|
5832
|
-
getBreakpoint(get(
|
|
5833
|
-
p && !
|
|
5843
|
+
getBreakpoint(get(g, "mq")),
|
|
5844
|
+
p && !g.dark ? "(Light mode)" : ""
|
|
5834
5845
|
] }),
|
|
5835
5846
|
/* @__PURE__ */ jsx("br", {}),
|
|
5836
5847
|
/* @__PURE__ */ jsxs(
|
|
5837
5848
|
"button",
|
|
5838
5849
|
{
|
|
5839
5850
|
type: "button",
|
|
5840
|
-
onClick: () => E(get(
|
|
5851
|
+
onClick: () => E(get(g, "mq")),
|
|
5841
5852
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
5842
5853
|
children: [
|
|
5843
5854
|
"Switch to ",
|
|
5844
|
-
get(
|
|
5855
|
+
get(g, "mq").toUpperCase()
|
|
5845
5856
|
]
|
|
5846
5857
|
}
|
|
5847
5858
|
)
|
|
@@ -5858,7 +5869,7 @@ const COLOR_PROP = {
|
|
|
5858
5869
|
units: i = basicUnits,
|
|
5859
5870
|
negative: c = !1
|
|
5860
5871
|
}) => {
|
|
5861
|
-
const { t: d } = useTranslation(), [p, u] = useState(r[0].key),
|
|
5872
|
+
const { t: d } = useTranslation(), [p, u] = useState(r[0].key), m = useSelectedBlockCurrentClasses(), g = useCallback((h) => map(m, "property").includes(h), [m]);
|
|
5862
5873
|
return /* @__PURE__ */ jsxs(
|
|
5863
5874
|
"div",
|
|
5864
5875
|
{
|
|
@@ -5875,7 +5886,7 @@ const COLOR_PROP = {
|
|
|
5875
5886
|
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
5876
5887
|
children: [
|
|
5877
5888
|
React__default.createElement("div", {
|
|
5878
|
-
className:
|
|
5889
|
+
className: g(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
5879
5890
|
}),
|
|
5880
5891
|
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
5881
5892
|
]
|
|
@@ -6006,7 +6017,7 @@ const COLOR_PROP = {
|
|
|
6006
6017
|
icon: p,
|
|
6007
6018
|
onClick: u
|
|
6008
6019
|
}) => {
|
|
6009
|
-
const { t:
|
|
6020
|
+
const { t: m } = useTranslation();
|
|
6010
6021
|
return n ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: r, children: [
|
|
6011
6022
|
/* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6012
6023
|
Button,
|
|
@@ -6019,8 +6030,8 @@ const COLOR_PROP = {
|
|
|
6019
6030
|
}
|
|
6020
6031
|
) }),
|
|
6021
6032
|
/* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
6022
|
-
/* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children:
|
|
6023
|
-
o && /* @__PURE__ */ jsx("p", { className: "text-xs", children:
|
|
6033
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: m(a) }),
|
|
6034
|
+
o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: m(l) })
|
|
6024
6035
|
] }) }) })
|
|
6025
6036
|
] }) : /* @__PURE__ */ jsx(
|
|
6026
6037
|
Button,
|
|
@@ -6037,8 +6048,8 @@ const COLOR_PROP = {
|
|
|
6037
6048
|
canvas: r = !1,
|
|
6038
6049
|
tooltip: n = !0
|
|
6039
6050
|
}) => {
|
|
6040
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d,
|
|
6041
|
-
u.includes(b) ? u.length > 2 &&
|
|
6051
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, m = p, { t: g } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
|
|
6052
|
+
u.includes(b) ? u.length > 2 && m(u.filter((v) => v !== b)) : m((v) => [...v, b]);
|
|
6042
6053
|
}, x = (b) => {
|
|
6043
6054
|
r || l(b), c(b);
|
|
6044
6055
|
}, y = getBreakpointValue(r ? i : a).toLowerCase();
|
|
@@ -6070,7 +6081,7 @@ const COLOR_PROP = {
|
|
|
6070
6081
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
6071
6082
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
|
|
6072
6083
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
6073
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { children:
|
|
6084
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
|
|
6074
6085
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
6075
6086
|
map(h, (b) => /* @__PURE__ */ jsx(
|
|
6076
6087
|
DropdownMenuCheckboxItem,
|
|
@@ -6078,7 +6089,7 @@ const COLOR_PROP = {
|
|
|
6078
6089
|
disabled: b.breakpoint === "xs",
|
|
6079
6090
|
onCheckedChange: () => f(toUpper(b.breakpoint)),
|
|
6080
6091
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6081
|
-
children:
|
|
6092
|
+
children: g(b.title)
|
|
6082
6093
|
},
|
|
6083
6094
|
b.breakpoint
|
|
6084
6095
|
))
|
|
@@ -6155,14 +6166,14 @@ function Countdown() {
|
|
|
6155
6166
|
] });
|
|
6156
6167
|
}
|
|
6157
6168
|
const AskAIStyles = ({ blockId: o }) => {
|
|
6158
|
-
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u,
|
|
6169
|
+
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, m] = useState();
|
|
6159
6170
|
useEffect(() => {
|
|
6160
6171
|
var h;
|
|
6161
6172
|
(h = d.current) == null || h.focus();
|
|
6162
6173
|
}, []);
|
|
6163
|
-
const
|
|
6174
|
+
const g = (h) => {
|
|
6164
6175
|
const { usage: f } = h || {};
|
|
6165
|
-
!l && f &&
|
|
6176
|
+
!l && f && m(f), p.current = setTimeout(() => m(void 0), 1e4), l || c("");
|
|
6166
6177
|
};
|
|
6167
6178
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6168
6179
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
|
|
@@ -6176,7 +6187,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6176
6187
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
6177
6188
|
rows: 4,
|
|
6178
6189
|
onKeyDown: (h) => {
|
|
6179
|
-
h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current),
|
|
6190
|
+
h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), m(void 0), n("styles", o, i, g));
|
|
6180
6191
|
}
|
|
6181
6192
|
}
|
|
6182
6193
|
),
|
|
@@ -6186,7 +6197,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6186
6197
|
{
|
|
6187
6198
|
disabled: i.trim().length < 5 || a,
|
|
6188
6199
|
onClick: () => {
|
|
6189
|
-
p.current && clearTimeout(p.current),
|
|
6200
|
+
p.current && clearTimeout(p.current), m(void 0), n("styles", o, i, g);
|
|
6190
6201
|
},
|
|
6191
6202
|
variant: "default",
|
|
6192
6203
|
className: "w-fit",
|
|
@@ -6218,9 +6229,9 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6218
6229
|
};
|
|
6219
6230
|
function ManualClasses() {
|
|
6220
6231
|
var T;
|
|
6221
|
-
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(),
|
|
6232
|
+
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), m = useRemoveClassesFromBlocks(), [g] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((I) => !isEmpty(I)), A = () => {
|
|
6222
6233
|
const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6223
|
-
u(
|
|
6234
|
+
u(g, I, !0), x("");
|
|
6224
6235
|
}, [w, E] = useState([]), _ = ({ value: I }) => {
|
|
6225
6236
|
const P = I.trim().toLowerCase(), L = P.match(/.+:/g);
|
|
6226
6237
|
let D = [];
|
|
@@ -6259,7 +6270,7 @@ function ManualClasses() {
|
|
|
6259
6270
|
), k = (I) => {
|
|
6260
6271
|
debugger;
|
|
6261
6272
|
const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6262
|
-
g
|
|
6273
|
+
m(g, [I]), u(g, P, !0), n(""), l(-1);
|
|
6263
6274
|
}, j = () => {
|
|
6264
6275
|
if (navigator.clipboard === void 0) {
|
|
6265
6276
|
toast.error(c("Clipboard not supported"));
|
|
@@ -6341,7 +6352,7 @@ function ManualClasses() {
|
|
|
6341
6352
|
"button",
|
|
6342
6353
|
{
|
|
6343
6354
|
onDoubleClick: () => {
|
|
6344
|
-
x(I), g
|
|
6355
|
+
x(I), m(g, [I]), setTimeout(() => {
|
|
6345
6356
|
o.current && o.current.focus();
|
|
6346
6357
|
}, 10);
|
|
6347
6358
|
},
|
|
@@ -6351,7 +6362,7 @@ function ManualClasses() {
|
|
|
6351
6362
|
r !== I && /* @__PURE__ */ jsx(
|
|
6352
6363
|
Cross2Icon,
|
|
6353
6364
|
{
|
|
6354
|
-
onClick: () => g
|
|
6365
|
+
onClick: () => m(g, [I], !0),
|
|
6355
6366
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
6356
6367
|
}
|
|
6357
6368
|
)
|
|
@@ -6471,13 +6482,13 @@ function BlockStyling() {
|
|
|
6471
6482
|
cssProperty: ""
|
|
6472
6483
|
}), d = useThrottledCallback(
|
|
6473
6484
|
(u) => {
|
|
6474
|
-
const
|
|
6485
|
+
const m = !get(i, "negative", !1), g = get(i, "cssProperty", "");
|
|
6475
6486
|
let h = parseFloat(i.dragStartValue);
|
|
6476
6487
|
h = isNaN(h) ? 0 : h;
|
|
6477
6488
|
let f = MAPPER[i.dragUnit];
|
|
6478
|
-
(startsWith(
|
|
6489
|
+
(startsWith(g, "scale") || g === "opacity") && (f = 10);
|
|
6479
6490
|
let y = (i.dragStartY - u.pageY) / f + h;
|
|
6480
|
-
|
|
6491
|
+
m && y < 0 && (y = 0), g === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
|
|
6481
6492
|
},
|
|
6482
6493
|
[i],
|
|
6483
6494
|
50
|
|
@@ -6518,7 +6529,7 @@ const CoreBlock = ({
|
|
|
6518
6529
|
parentId: n,
|
|
6519
6530
|
position: a
|
|
6520
6531
|
}) => {
|
|
6521
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [,
|
|
6532
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, m] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = () => {
|
|
6522
6533
|
if (has(o, "blocks")) {
|
|
6523
6534
|
const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
6524
6535
|
u(syncBlocksWithDefaults(y), n || null, a);
|
|
@@ -6535,7 +6546,7 @@ const CoreBlock = ({
|
|
|
6535
6546
|
type: "button",
|
|
6536
6547
|
onDragStart: (y) => {
|
|
6537
6548
|
y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6538
|
-
|
|
6549
|
+
m([]), g();
|
|
6539
6550
|
}, 200);
|
|
6540
6551
|
},
|
|
6541
6552
|
draggable: f ? "true" : "false",
|
|
@@ -6734,7 +6745,7 @@ const CoreBlock = ({
|
|
|
6734
6745
|
}
|
|
6735
6746
|
}
|
|
6736
6747
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
6737
|
-
var
|
|
6748
|
+
var g, h, f, x, y, b, v, A;
|
|
6738
6749
|
if (n.type === "comment") return [];
|
|
6739
6750
|
console.log("node ===>", n);
|
|
6740
6751
|
let a = { _id: generateUUID() };
|
|
@@ -6775,7 +6786,7 @@ const CoreBlock = ({
|
|
|
6775
6786
|
];
|
|
6776
6787
|
a = {
|
|
6777
6788
|
...a,
|
|
6778
|
-
href: ((
|
|
6789
|
+
href: ((g = l.find((E) => E.key === "href")) == null ? void 0 : g.value) || "",
|
|
6779
6790
|
hrefType: ((h = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
|
|
6780
6791
|
autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
6781
6792
|
maxWidth: ((y = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
|
|
@@ -6817,8 +6828,8 @@ const CoreBlock = ({
|
|
|
6817
6828
|
label: getTextContent(n.children),
|
|
6818
6829
|
...getAttrs(n)
|
|
6819
6830
|
}), [];
|
|
6820
|
-
const
|
|
6821
|
-
return [a, ...
|
|
6831
|
+
const m = traverseNodes(n.children, { block: a, node: n });
|
|
6832
|
+
return [a, ...m];
|
|
6822
6833
|
}), getSvgDimensions = (o, r, n) => {
|
|
6823
6834
|
const a = get(o, "attributes", []), l = find(a, { key: "height" }), i = find(a, { key: "width" });
|
|
6824
6835
|
return {
|
|
@@ -6869,8 +6880,8 @@ const CoreBlock = ({
|
|
|
6869
6880
|
height: i = ""
|
|
6870
6881
|
}) => {
|
|
6871
6882
|
const [c, d] = useState(o), p = (u) => {
|
|
6872
|
-
const
|
|
6873
|
-
d(
|
|
6883
|
+
const m = u.target.value;
|
|
6884
|
+
d(m), r(m);
|
|
6874
6885
|
};
|
|
6875
6886
|
return /* @__PURE__ */ jsx("div", { className: cn$2("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
|
|
6876
6887
|
"select",
|
|
@@ -6916,7 +6927,7 @@ const BlockCard = ({
|
|
|
6916
6927
|
parentId: n = void 0,
|
|
6917
6928
|
position: a = -1
|
|
6918
6929
|
}) => {
|
|
6919
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight:
|
|
6930
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), g = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (A) => {
|
|
6920
6931
|
const w = has(A, "styles_attrs.data-page-section");
|
|
6921
6932
|
return A._type === "Box" && w;
|
|
6922
6933
|
}, b = useCallback(
|
|
@@ -6951,7 +6962,7 @@ const BlockCard = ({
|
|
|
6951
6962
|
} else
|
|
6952
6963
|
A.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
6953
6964
|
x(_), setTimeout(() => {
|
|
6954
|
-
u([]),
|
|
6965
|
+
u([]), m(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6955
6966
|
}, 200);
|
|
6956
6967
|
}
|
|
6957
6968
|
},
|
|
@@ -6963,20 +6974,20 @@ const BlockCard = ({
|
|
|
6963
6974
|
/* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
|
|
6964
6975
|
/* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
6965
6976
|
] }),
|
|
6966
|
-
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
6967
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children:
|
|
6977
|
+
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: g }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
|
|
6978
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: g }),
|
|
6968
6979
|
h && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: h })
|
|
6969
6980
|
] })
|
|
6970
6981
|
]
|
|
6971
6982
|
}
|
|
6972
6983
|
) }),
|
|
6973
6984
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
|
|
6974
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium", children:
|
|
6985
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: g }),
|
|
6975
6986
|
h && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: h })
|
|
6976
6987
|
] }) })
|
|
6977
6988
|
] });
|
|
6978
6989
|
}, UILibrarySection = ({ parentId: o, position: r }) => {
|
|
6979
|
-
const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((k) => k.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u,
|
|
6990
|
+
const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((k) => k.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, m] = useState(""), [g, h] = useState([]), f = useRef(null);
|
|
6980
6991
|
useEffect(() => {
|
|
6981
6992
|
c && c.length > 0 && (f.current = new Fuse(c, {
|
|
6982
6993
|
keys: ["name", "label", "description", "group"],
|
|
@@ -6991,7 +7002,7 @@ const BlockCard = ({
|
|
|
6991
7002
|
const k = f.current.search(u).map((j) => j.item);
|
|
6992
7003
|
h(k);
|
|
6993
7004
|
}, [u]);
|
|
6994
|
-
const x = u.trim() && !isEmpty(
|
|
7005
|
+
const x = u.trim() && !isEmpty(g) ? g : c, y = groupBy(x, "group"), [b, v] = useState(null);
|
|
6995
7006
|
useEffect(() => {
|
|
6996
7007
|
if (isEmpty(keys(y))) {
|
|
6997
7008
|
v(null);
|
|
@@ -7009,7 +7020,7 @@ const BlockCard = ({
|
|
|
7009
7020
|
}, S = () => {
|
|
7010
7021
|
i != null && i.id && p(i.id);
|
|
7011
7022
|
}, B = () => {
|
|
7012
|
-
|
|
7023
|
+
m("");
|
|
7013
7024
|
};
|
|
7014
7025
|
if (d)
|
|
7015
7026
|
return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
|
|
@@ -7025,7 +7036,7 @@ const BlockCard = ({
|
|
|
7025
7036
|
{
|
|
7026
7037
|
placeholder: E("Search blocks..."),
|
|
7027
7038
|
value: u,
|
|
7028
|
-
onChange: (k) =>
|
|
7039
|
+
onChange: (k) => m(k.target.value),
|
|
7029
7040
|
className: "w-full pl-8 pr-8"
|
|
7030
7041
|
}
|
|
7031
7042
|
),
|
|
@@ -7120,7 +7131,7 @@ const BlockCard = ({
|
|
|
7120
7131
|
position: r,
|
|
7121
7132
|
gridCols: n = "grid-cols-2"
|
|
7122
7133
|
}) => {
|
|
7123
|
-
const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u,
|
|
7134
|
+
const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, m] = useAtom$1(hasInitializedPartialBlocksAtom);
|
|
7124
7135
|
useEffect(() => {
|
|
7125
7136
|
if (!u || Object.keys(d.blocks).length === 0)
|
|
7126
7137
|
if (c)
|
|
@@ -7129,7 +7140,7 @@ const BlockCard = ({
|
|
|
7129
7140
|
groups: [],
|
|
7130
7141
|
isLoading: !1,
|
|
7131
7142
|
error: c
|
|
7132
|
-
}),
|
|
7143
|
+
}), m(!0);
|
|
7133
7144
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7134
7145
|
const h = Object.entries(a).map(([x, y]) => {
|
|
7135
7146
|
const b = y, v = b.type || "partial", A = formatReadableName(v);
|
|
@@ -7152,31 +7163,31 @@ const BlockCard = ({
|
|
|
7152
7163
|
groups: f,
|
|
7153
7164
|
isLoading: !1,
|
|
7154
7165
|
error: null
|
|
7155
|
-
}),
|
|
7166
|
+
}), m(!0);
|
|
7156
7167
|
} else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7157
7168
|
blocks: [],
|
|
7158
7169
|
groups: [],
|
|
7159
7170
|
isLoading: !1,
|
|
7160
7171
|
error: "No partial blocks available"
|
|
7161
|
-
}),
|
|
7172
|
+
}), m(!0));
|
|
7162
7173
|
}, [
|
|
7163
7174
|
l,
|
|
7164
7175
|
a,
|
|
7165
7176
|
u,
|
|
7166
|
-
|
|
7177
|
+
m,
|
|
7167
7178
|
p,
|
|
7168
7179
|
d.blocks,
|
|
7169
7180
|
c
|
|
7170
7181
|
]);
|
|
7171
|
-
const
|
|
7172
|
-
p((h) => ({ ...h, isLoading: !0, error: null })),
|
|
7182
|
+
const g = () => {
|
|
7183
|
+
p((h) => ({ ...h, isLoading: !0, error: null })), m(!1), i();
|
|
7173
7184
|
};
|
|
7174
7185
|
return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
|
|
7175
7186
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
7176
7187
|
/* @__PURE__ */ jsx(
|
|
7177
7188
|
"button",
|
|
7178
7189
|
{
|
|
7179
|
-
onClick:
|
|
7190
|
+
onClick: g,
|
|
7180
7191
|
className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
|
|
7181
7192
|
children: "Refresh"
|
|
7182
7193
|
}
|
|
@@ -7195,14 +7206,14 @@ const BlockCard = ({
|
|
|
7195
7206
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
|
|
7196
7207
|
}, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7197
7208
|
var C;
|
|
7198
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [
|
|
7209
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [m] = useAtom$1(addBlockTabAtom), g = (C = find(c, (k) => k._id === n)) == null ? void 0 : C._type, [h, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
|
|
7199
7210
|
useEffect(() => {
|
|
7200
7211
|
const k = setTimeout(() => {
|
|
7201
7212
|
var j;
|
|
7202
7213
|
(j = u.current) == null || j.focus();
|
|
7203
7214
|
}, 0);
|
|
7204
7215
|
return () => clearTimeout(k);
|
|
7205
|
-
}, [
|
|
7216
|
+
}, [m]), useEffect(() => {
|
|
7206
7217
|
d && (f("all"), y(null));
|
|
7207
7218
|
}, [d]), useEffect(() => (b.current = debounce((k) => {
|
|
7208
7219
|
f(k);
|
|
@@ -7285,7 +7296,7 @@ const BlockCard = ({
|
|
|
7285
7296
|
parentId: n,
|
|
7286
7297
|
position: a,
|
|
7287
7298
|
block: j,
|
|
7288
|
-
disabled: !canAcceptChildBlock(
|
|
7299
|
+
disabled: !canAcceptChildBlock(g, j.type) || !canBeNestedInside(g, j.type)
|
|
7289
7300
|
},
|
|
7290
7301
|
j.type
|
|
7291
7302
|
)) })
|
|
@@ -7298,13 +7309,13 @@ const BlockCard = ({
|
|
|
7298
7309
|
parentId: n = void 0,
|
|
7299
7310
|
position: a = -1
|
|
7300
7311
|
}) => {
|
|
7301
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(),
|
|
7312
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), m = Object.keys(u || {}).length > 0, { hasPermission: g } = usePermissions();
|
|
7302
7313
|
useEffect(() => {
|
|
7303
|
-
i === "partials" && !
|
|
7304
|
-
}, [i,
|
|
7314
|
+
i === "partials" && !m && c("library");
|
|
7315
|
+
}, [i, m, c]);
|
|
7305
7316
|
const h = useCallback(() => {
|
|
7306
7317
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7307
|
-
}, []), f = useChaiAddBlockTabs(), x = p &&
|
|
7318
|
+
}, []), f = useChaiAddBlockTabs(), x = p && g(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
|
|
7308
7319
|
return useEffect(() => {
|
|
7309
7320
|
i === "library" && !b && c("core");
|
|
7310
7321
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7324,13 +7335,13 @@ const BlockCard = ({
|
|
|
7324
7335
|
/* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
|
|
7325
7336
|
b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7326
7337
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7327
|
-
|
|
7338
|
+
m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7328
7339
|
x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7329
7340
|
map(f, (v) => /* @__PURE__ */ jsx(TabsTrigger, { value: v.id, children: React__default.createElement(v.tab) }, `tab-add-block-${v.id}`))
|
|
7330
7341
|
] }),
|
|
7331
7342
|
/* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
|
|
7332
7343
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
|
|
7333
|
-
|
|
7344
|
+
m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
|
|
7334
7345
|
x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
|
|
7335
7346
|
map(f, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: h, parentId: n, position: a }) }, `panel-add-block-${v.id}`))
|
|
7336
7347
|
]
|
|
@@ -7454,10 +7465,10 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7454
7465
|
}, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
|
|
7455
7466
|
const [o] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: n } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useCallback(() => {
|
|
7456
7467
|
const p = r.map((u) => {
|
|
7457
|
-
const
|
|
7468
|
+
const m = o.find((g) => g._id === u);
|
|
7458
7469
|
return {
|
|
7459
7470
|
id: u,
|
|
7460
|
-
data:
|
|
7471
|
+
data: m
|
|
7461
7472
|
};
|
|
7462
7473
|
});
|
|
7463
7474
|
l(p.map((u) => u.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
|
|
@@ -7639,7 +7650,7 @@ const Input = ({ node: o }) => {
|
|
|
7639
7650
|
var P;
|
|
7640
7651
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7641
7652
|
let p = null;
|
|
7642
|
-
const u = o.children.length > 0, { highlightBlock:
|
|
7653
|
+
const u = o.children.length > 0, { highlightBlock: m, clearHighlight: g } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: A } = o, w = (L) => {
|
|
7643
7654
|
L.stopPropagation(), !l.includes(h) && o.toggle();
|
|
7644
7655
|
}, E = (L) => {
|
|
7645
7656
|
L.isInternal && (p = L.isOpen, L.isOpen && L.close());
|
|
@@ -7691,8 +7702,8 @@ const Input = ({ node: o }) => {
|
|
|
7691
7702
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7692
7703
|
"div",
|
|
7693
7704
|
{
|
|
7694
|
-
onMouseEnter: () =>
|
|
7695
|
-
onMouseLeave: () =>
|
|
7705
|
+
onMouseEnter: () => m(h),
|
|
7706
|
+
onMouseLeave: () => g(),
|
|
7696
7707
|
onClick: k,
|
|
7697
7708
|
style: r,
|
|
7698
7709
|
"data-node-id": h,
|
|
@@ -8058,7 +8069,7 @@ const Input = ({ node: o }) => {
|
|
|
8058
8069
|
)
|
|
8059
8070
|
] });
|
|
8060
8071
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8061
|
-
const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t:
|
|
8072
|
+
const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: m } = useTranslation(), g = (v) => {
|
|
8062
8073
|
a(v);
|
|
8063
8074
|
}, h = () => {
|
|
8064
8075
|
const v = l.find((A) => Object.keys(A)[0] === n);
|
|
@@ -8120,12 +8131,12 @@ const Input = ({ node: o }) => {
|
|
|
8120
8131
|
/* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8121
8132
|
l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
|
|
8122
8133
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
8123
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8134
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Presets") }),
|
|
8124
8135
|
/* @__PURE__ */ jsxs(
|
|
8125
8136
|
"select",
|
|
8126
8137
|
{
|
|
8127
8138
|
value: n,
|
|
8128
|
-
onChange: (v) =>
|
|
8139
|
+
onChange: (v) => g(v.target.value),
|
|
8129
8140
|
className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8130
8141
|
children: [
|
|
8131
8142
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
@@ -8141,7 +8152,7 @@ const Input = ({ node: o }) => {
|
|
|
8141
8152
|
disabled: n === "",
|
|
8142
8153
|
variant: "default",
|
|
8143
8154
|
onClick: h,
|
|
8144
|
-
children:
|
|
8155
|
+
children: m("Apply")
|
|
8145
8156
|
}
|
|
8146
8157
|
) })
|
|
8147
8158
|
] }),
|
|
@@ -8156,14 +8167,14 @@ const Input = ({ node: o }) => {
|
|
|
8156
8167
|
v
|
|
8157
8168
|
)) }),
|
|
8158
8169
|
(u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
8159
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8170
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Border Radius") }),
|
|
8160
8171
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
8161
8172
|
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: x }),
|
|
8162
8173
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
|
|
8163
8174
|
] })
|
|
8164
8175
|
] }),
|
|
8165
8176
|
(u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
8166
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8177
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Colors") }),
|
|
8167
8178
|
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((v) => b(v)) }, r ? "dark" : "light")
|
|
8168
8179
|
] })
|
|
8169
8180
|
] }),
|
|
@@ -8634,14 +8645,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8634
8645
|
) }) });
|
|
8635
8646
|
}
|
|
8636
8647
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8637
|
-
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u,
|
|
8648
|
+
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, m] = useState(), g = useRef(null), h = useRef(null);
|
|
8638
8649
|
useEffect(() => {
|
|
8639
8650
|
var x;
|
|
8640
|
-
(x =
|
|
8651
|
+
(x = g.current) == null || x.focus();
|
|
8641
8652
|
}, []);
|
|
8642
8653
|
const f = (x) => {
|
|
8643
8654
|
const { usage: y } = x || {};
|
|
8644
|
-
!l && y &&
|
|
8655
|
+
!l && y && m(y), h.current = setTimeout(() => m(void 0), 1e4), l || c("");
|
|
8645
8656
|
};
|
|
8646
8657
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8647
8658
|
/* @__PURE__ */ jsxs(
|
|
@@ -8659,14 +8670,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8659
8670
|
/* @__PURE__ */ jsx(
|
|
8660
8671
|
Textarea,
|
|
8661
8672
|
{
|
|
8662
|
-
ref:
|
|
8673
|
+
ref: g,
|
|
8663
8674
|
value: i,
|
|
8664
8675
|
onChange: (x) => c(x.target.value),
|
|
8665
8676
|
placeholder: r("Ask AI to edit content"),
|
|
8666
8677
|
className: "w-full",
|
|
8667
8678
|
rows: 3,
|
|
8668
8679
|
onKeyDown: (x) => {
|
|
8669
|
-
x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.current),
|
|
8680
|
+
x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.current), m(void 0), n("content", o, i, f));
|
|
8670
8681
|
}
|
|
8671
8682
|
}
|
|
8672
8683
|
),
|
|
@@ -8676,7 +8687,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8676
8687
|
{
|
|
8677
8688
|
disabled: i.trim().length < 5 || a,
|
|
8678
8689
|
onClick: () => {
|
|
8679
|
-
h.current && clearTimeout(h.current),
|
|
8690
|
+
h.current && clearTimeout(h.current), m(void 0), n("content", o, i, f);
|
|
8680
8691
|
},
|
|
8681
8692
|
variant: "default",
|
|
8682
8693
|
className: "w-fit",
|
|
@@ -8709,7 +8720,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8709
8720
|
QuickPrompts,
|
|
8710
8721
|
{
|
|
8711
8722
|
onClick: (x) => {
|
|
8712
|
-
h.current && clearTimeout(h.current),
|
|
8723
|
+
h.current && clearTimeout(h.current), m(void 0), n("content", o, x, f);
|
|
8713
8724
|
}
|
|
8714
8725
|
}
|
|
8715
8726
|
)
|
|
@@ -8719,13 +8730,13 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8719
8730
|
] }) }) : null
|
|
8720
8731
|
] });
|
|
8721
8732
|
}, AISetContext = () => {
|
|
8722
|
-
const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [,
|
|
8733
|
+
const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, m] = useState(!1), g = useRef(null);
|
|
8723
8734
|
useEffect(() => {
|
|
8724
8735
|
r && a(r);
|
|
8725
8736
|
}, [r]);
|
|
8726
8737
|
const h = async () => {
|
|
8727
8738
|
try {
|
|
8728
|
-
d(!0), u(null), await i(n), toast.success(o("Updated AI Context")),
|
|
8739
|
+
d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), g.current.click();
|
|
8729
8740
|
} catch (f) {
|
|
8730
8741
|
u(f);
|
|
8731
8742
|
} finally {
|
|
@@ -8736,12 +8747,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8736
8747
|
Accordion,
|
|
8737
8748
|
{
|
|
8738
8749
|
onValueChange: (f) => {
|
|
8739
|
-
|
|
8750
|
+
m(f !== "");
|
|
8740
8751
|
},
|
|
8741
8752
|
type: "single",
|
|
8742
8753
|
collapsible: !0,
|
|
8743
8754
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8744
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8755
|
+
/* @__PURE__ */ jsx(AccordionTrigger, { ref: g, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
8745
8756
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
8746
8757
|
/* @__PURE__ */ jsx(
|
|
8747
8758
|
Textarea,
|
|
@@ -8848,14 +8859,14 @@ const UndoRedo = () => {
|
|
|
8848
8859
|
] });
|
|
8849
8860
|
};
|
|
8850
8861
|
function AIChatPanel() {
|
|
8851
|
-
const [o, r] = useState([]), [n, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null),
|
|
8862
|
+
const [o, r] = useState([]), [n, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null), m = useRef(null);
|
|
8852
8863
|
useEffect(() => {
|
|
8853
8864
|
var b;
|
|
8854
8865
|
(b = u.current) == null || b.scrollIntoView({ behavior: "smooth" });
|
|
8855
8866
|
}, [o]), useEffect(() => {
|
|
8856
|
-
|
|
8867
|
+
m.current && (m.current.style.height = "auto", m.current.style.height = `${Math.min(m.current.scrollHeight, 120)}px`);
|
|
8857
8868
|
}, [n]);
|
|
8858
|
-
const
|
|
8869
|
+
const g = async () => {
|
|
8859
8870
|
if (!n.trim() && !c) return;
|
|
8860
8871
|
const b = {
|
|
8861
8872
|
id: Date.now().toString(),
|
|
@@ -8873,7 +8884,7 @@ function AIChatPanel() {
|
|
|
8873
8884
|
r((A) => [...A, v]), i(!1), d(null);
|
|
8874
8885
|
}, 1500);
|
|
8875
8886
|
}, h = (b) => {
|
|
8876
|
-
b.key === "Enter" && !b.shiftKey && (b.preventDefault(),
|
|
8887
|
+
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), g());
|
|
8877
8888
|
}, f = (b) => {
|
|
8878
8889
|
var A;
|
|
8879
8890
|
const v = (A = b.target.files) == null ? void 0 : A[0];
|
|
@@ -8943,7 +8954,7 @@ function AIChatPanel() {
|
|
|
8943
8954
|
/* @__PURE__ */ jsx(
|
|
8944
8955
|
Textarea,
|
|
8945
8956
|
{
|
|
8946
|
-
ref:
|
|
8957
|
+
ref: m,
|
|
8947
8958
|
value: n,
|
|
8948
8959
|
onChange: (b) => a(b.target.value),
|
|
8949
8960
|
onKeyDown: h,
|
|
@@ -8968,7 +8979,7 @@ function AIChatPanel() {
|
|
|
8968
8979
|
{
|
|
8969
8980
|
size: "sm",
|
|
8970
8981
|
className: "h-10 px-3",
|
|
8971
|
-
onClick:
|
|
8982
|
+
onClick: g,
|
|
8972
8983
|
disabled: l || !n.trim() && !c,
|
|
8973
8984
|
children: [
|
|
8974
8985
|
/* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
|
|
@@ -9076,7 +9087,7 @@ const AiAssistant = () => {
|
|
|
9076
9087
|
preloadedAttributes: r = [],
|
|
9077
9088
|
onAttributesChange: n
|
|
9078
9089
|
}) {
|
|
9079
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u,
|
|
9090
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, m] = useState(null), [g, h] = useState(""), f = useRef(null), x = useRef(null), y = usePageExternalData();
|
|
9080
9091
|
useEffect(() => {
|
|
9081
9092
|
l(r);
|
|
9082
9093
|
}, [r]);
|
|
@@ -9093,7 +9104,7 @@ const AiAssistant = () => {
|
|
|
9093
9104
|
const B = a.filter((N, C) => C !== S);
|
|
9094
9105
|
n(B), l(B);
|
|
9095
9106
|
}, A = (S) => {
|
|
9096
|
-
|
|
9107
|
+
m(S), c(a[S].key), p(a[S].value);
|
|
9097
9108
|
}, w = () => {
|
|
9098
9109
|
if (i.startsWith("@")) {
|
|
9099
9110
|
h("Attribute keys cannot start with '@'");
|
|
@@ -9101,7 +9112,7 @@ const AiAssistant = () => {
|
|
|
9101
9112
|
}
|
|
9102
9113
|
if (u !== null && i) {
|
|
9103
9114
|
const S = [...a];
|
|
9104
|
-
S[u] = { key: i, value: d }, n(S), l(S),
|
|
9115
|
+
S[u] = { key: i, value: d }, n(S), l(S), m(null), c(""), p(""), h("");
|
|
9105
9116
|
}
|
|
9106
9117
|
}, E = (S) => {
|
|
9107
9118
|
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
|
|
@@ -9177,7 +9188,7 @@ const AiAssistant = () => {
|
|
|
9177
9188
|
] })
|
|
9178
9189
|
] }),
|
|
9179
9190
|
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
|
|
9180
|
-
|
|
9191
|
+
g && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: g })
|
|
9181
9192
|
]
|
|
9182
9193
|
}
|
|
9183
9194
|
),
|
|
@@ -9308,9 +9319,9 @@ const RootLayout = () => {
|
|
|
9308
9319
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9309
9320
|
n("outline");
|
|
9310
9321
|
});
|
|
9311
|
-
const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"),
|
|
9322
|
+
const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), m = useCallback((S) => {
|
|
9312
9323
|
S.preventDefault();
|
|
9313
|
-
}, []),
|
|
9324
|
+
}, []), g = useCallback((S) => {
|
|
9314
9325
|
n(r === S ? null : S);
|
|
9315
9326
|
}, []), h = useSidebarMenuItems(), { t: f } = useTranslation(), x = useMemo(() => [...h, ...p], [h, p]), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
|
|
9316
9327
|
useEffect(() => {
|
|
@@ -9333,15 +9344,15 @@ const RootLayout = () => {
|
|
|
9333
9344
|
}, [r, x]);
|
|
9334
9345
|
const _ = useCallback(
|
|
9335
9346
|
(S) => {
|
|
9336
|
-
|
|
9347
|
+
g(S);
|
|
9337
9348
|
},
|
|
9338
|
-
[
|
|
9349
|
+
[g]
|
|
9339
9350
|
);
|
|
9340
9351
|
return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9341
9352
|
/* @__PURE__ */ jsxs(
|
|
9342
9353
|
"div",
|
|
9343
9354
|
{
|
|
9344
|
-
onContextMenu:
|
|
9355
|
+
onContextMenu: m,
|
|
9345
9356
|
className: "flex h-screen max-h-full flex-col bg-background text-foreground",
|
|
9346
9357
|
children: [
|
|
9347
9358
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
@@ -9573,14 +9584,14 @@ const FEATURE_TOGGLES = {
|
|
|
9573
9584
|
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...f) => h.read(...f), p = (h, ...f) => h.write(...f), u = (h, f) => {
|
|
9574
9585
|
var x;
|
|
9575
9586
|
return (x = h.unstable_onInit) == null ? void 0 : x.call(h, f);
|
|
9576
|
-
},
|
|
9587
|
+
}, m = (h, f) => {
|
|
9577
9588
|
var x;
|
|
9578
9589
|
return (x = h.onMount) == null ? void 0 : x.call(h, f);
|
|
9579
|
-
}, ...
|
|
9580
|
-
const h =
|
|
9590
|
+
}, ...g) => {
|
|
9591
|
+
const h = g[0] || ((B) => {
|
|
9581
9592
|
let N = o.get(B);
|
|
9582
9593
|
return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(B, N), u == null || u(B, S)), N;
|
|
9583
|
-
}), f =
|
|
9594
|
+
}), f = g[1] || (() => {
|
|
9584
9595
|
let B, N;
|
|
9585
9596
|
const C = (k) => {
|
|
9586
9597
|
try {
|
|
@@ -9599,7 +9610,7 @@ const FEATURE_TOGGLES = {
|
|
|
9599
9610
|
} while (a.size || i.size || l.size);
|
|
9600
9611
|
if (B)
|
|
9601
9612
|
throw N;
|
|
9602
|
-
}), x =
|
|
9613
|
+
}), x = g[2] || (() => {
|
|
9603
9614
|
const B = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
|
|
9604
9615
|
for (; k.length; ) {
|
|
9605
9616
|
const j = k[k.length - 1], T = h(j);
|
|
@@ -9625,7 +9636,7 @@ const FEATURE_TOGGLES = {
|
|
|
9625
9636
|
}
|
|
9626
9637
|
P && (y(T), A(T)), n.delete(T);
|
|
9627
9638
|
}
|
|
9628
|
-
}), y =
|
|
9639
|
+
}), y = g[3] || ((B) => {
|
|
9629
9640
|
var N, C;
|
|
9630
9641
|
const k = h(B);
|
|
9631
9642
|
if (isAtomStateInitialized(k) && (r.has(B) && n.get(B) !== k.n || Array.from(k.d).every(
|
|
@@ -9643,13 +9654,13 @@ const FEATURE_TOGGLES = {
|
|
|
9643
9654
|
}, I = (R) => {
|
|
9644
9655
|
var $;
|
|
9645
9656
|
if (isSelfAtom(B, R)) {
|
|
9646
|
-
const
|
|
9647
|
-
if (!isAtomStateInitialized(
|
|
9657
|
+
const H = h(R);
|
|
9658
|
+
if (!isAtomStateInitialized(H))
|
|
9648
9659
|
if (hasInitialValue(R))
|
|
9649
9660
|
setAtomStateValueOrPromise(R, R.init, h);
|
|
9650
9661
|
else
|
|
9651
9662
|
throw new Error("no atom init");
|
|
9652
|
-
return returnAtomValue(
|
|
9663
|
+
return returnAtomValue(H);
|
|
9653
9664
|
}
|
|
9654
9665
|
const M = y(R);
|
|
9655
9666
|
try {
|
|
@@ -9685,7 +9696,7 @@ const FEATURE_TOGGLES = {
|
|
|
9685
9696
|
} finally {
|
|
9686
9697
|
j = !1, O !== k.n && n.get(B) === O && (n.set(B, k.n), a.add(B), (C = c.c) == null || C.call(c, B));
|
|
9687
9698
|
}
|
|
9688
|
-
}), b =
|
|
9699
|
+
}), b = g[4] || ((B) => {
|
|
9689
9700
|
const N = [B];
|
|
9690
9701
|
for (; N.length; ) {
|
|
9691
9702
|
const C = N.pop(), k = h(C);
|
|
@@ -9694,7 +9705,7 @@ const FEATURE_TOGGLES = {
|
|
|
9694
9705
|
n.set(j, T.n), N.push(j);
|
|
9695
9706
|
}
|
|
9696
9707
|
}
|
|
9697
|
-
}), v =
|
|
9708
|
+
}), v = g[5] || ((B, ...N) => {
|
|
9698
9709
|
let C = !0;
|
|
9699
9710
|
const k = (T) => returnAtomValue(y(T)), j = (T, ...I) => {
|
|
9700
9711
|
var P;
|
|
@@ -9717,7 +9728,7 @@ const FEATURE_TOGGLES = {
|
|
|
9717
9728
|
} finally {
|
|
9718
9729
|
C = !1;
|
|
9719
9730
|
}
|
|
9720
|
-
}), A =
|
|
9731
|
+
}), A = g[6] || ((B) => {
|
|
9721
9732
|
var N;
|
|
9722
9733
|
const C = h(B), k = r.get(B);
|
|
9723
9734
|
if (k && !isPendingPromise(C.v)) {
|
|
@@ -9733,7 +9744,7 @@ const FEATURE_TOGGLES = {
|
|
|
9733
9744
|
T == null || T.t.delete(B);
|
|
9734
9745
|
}
|
|
9735
9746
|
}
|
|
9736
|
-
}), w =
|
|
9747
|
+
}), w = g[7] || ((B) => {
|
|
9737
9748
|
var N;
|
|
9738
9749
|
const C = h(B);
|
|
9739
9750
|
let k = r.get(B);
|
|
@@ -9756,7 +9767,7 @@ const FEATURE_TOGGLES = {
|
|
|
9756
9767
|
}
|
|
9757
9768
|
};
|
|
9758
9769
|
try {
|
|
9759
|
-
const P =
|
|
9770
|
+
const P = m(B, I);
|
|
9760
9771
|
P && (k.u = () => {
|
|
9761
9772
|
T = !0;
|
|
9762
9773
|
try {
|
|
@@ -9773,7 +9784,7 @@ const FEATURE_TOGGLES = {
|
|
|
9773
9784
|
}
|
|
9774
9785
|
}
|
|
9775
9786
|
return k;
|
|
9776
|
-
}), E =
|
|
9787
|
+
}), E = g[8] || ((B) => {
|
|
9777
9788
|
var N;
|
|
9778
9789
|
const C = h(B);
|
|
9779
9790
|
let k = r.get(B);
|
|
@@ -9802,7 +9813,7 @@ const FEATURE_TOGGLES = {
|
|
|
9802
9813
|
d,
|
|
9803
9814
|
p,
|
|
9804
9815
|
u,
|
|
9805
|
-
|
|
9816
|
+
m,
|
|
9806
9817
|
// building-block functions
|
|
9807
9818
|
h,
|
|
9808
9819
|
f,
|
|
@@ -9868,8 +9879,8 @@ const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), d
|
|
|
9868
9879
|
function useAtomValue(o, r) {
|
|
9869
9880
|
const n = useStore(), [[a, l, i], c] = useReducer(
|
|
9870
9881
|
(u) => {
|
|
9871
|
-
const
|
|
9872
|
-
return Object.is(u[0],
|
|
9882
|
+
const m = n.get(o);
|
|
9883
|
+
return Object.is(u[0], m) && u[1] === n && u[2] === o ? u : [m, n, o];
|
|
9873
9884
|
},
|
|
9874
9885
|
void 0,
|
|
9875
9886
|
() => [n.get(o), n, o]
|