@chaibuilder/sdk 2.4.6 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +4 -4
- package/dist/core.js +801 -803
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +1 -7
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -343,16 +343,16 @@ function insertBlocksAtPosition(o, r, n, a) {
|
|
|
343
343
|
_type: "Text",
|
|
344
344
|
content: u.content
|
|
345
345
|
};
|
|
346
|
-
Object.keys(u).forEach((
|
|
347
|
-
|
|
348
|
-
}), l.unshift(m), i = i.map((
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
return Object.keys(
|
|
352
|
-
|
|
353
|
-
}),
|
|
346
|
+
Object.keys(u).forEach((f) => {
|
|
347
|
+
f.startsWith("content-") && (m[f] = u[f]);
|
|
348
|
+
}), l.unshift(m), i = i.map((f) => {
|
|
349
|
+
if (f._id === n) {
|
|
350
|
+
const x = { ...f, content: "" };
|
|
351
|
+
return Object.keys(x).forEach((y) => {
|
|
352
|
+
y.startsWith("content-") && (x[y] = "");
|
|
353
|
+
}), x;
|
|
354
354
|
}
|
|
355
|
-
return
|
|
355
|
+
return f;
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
358
|
}
|
|
@@ -480,15 +480,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
480
480
|
if (g.length === 2) {
|
|
481
481
|
const h = g.find((m) => m._id !== d);
|
|
482
482
|
if (h && h._type === "Text") {
|
|
483
|
-
const m = n.find((
|
|
484
|
-
m && "content" in m && (n = n.map((
|
|
485
|
-
if (
|
|
486
|
-
const
|
|
487
|
-
return Object.keys(h).forEach((
|
|
488
|
-
|
|
489
|
-
}),
|
|
483
|
+
const m = n.find((f) => f._id === u);
|
|
484
|
+
m && "content" in m && (n = n.map((f) => {
|
|
485
|
+
if (f._id === u) {
|
|
486
|
+
const x = { ...f, content: h.content };
|
|
487
|
+
return Object.keys(h).forEach((y) => {
|
|
488
|
+
y.startsWith("content-") && (x[y] = h[y]);
|
|
489
|
+
}), x;
|
|
490
490
|
}
|
|
491
|
-
return
|
|
491
|
+
return f;
|
|
492
492
|
}), a.push(h._id));
|
|
493
493
|
}
|
|
494
494
|
}
|
|
@@ -571,32 +571,32 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
571
571
|
status: "idle",
|
|
572
572
|
props: {},
|
|
573
573
|
error: void 0
|
|
574
|
-
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (
|
|
574
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, n ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), h = (o == null ? void 0 : o._type) !== "Repeater" && r === "live";
|
|
575
575
|
return useEffect(() => {
|
|
576
576
|
if (r === "mock") {
|
|
577
577
|
if (isFunction(a)) {
|
|
578
|
-
i((
|
|
579
|
-
const
|
|
580
|
-
if (!isObject(
|
|
578
|
+
i((x) => ({ ...x, status: "loading", props: {} }));
|
|
579
|
+
const f = a({ block: o });
|
|
580
|
+
if (!isObject(f))
|
|
581
581
|
throw new Error("mockDataProvider should return an object");
|
|
582
|
-
i((
|
|
582
|
+
i((x) => ({ ...x, status: "loaded", props: f }));
|
|
583
583
|
}
|
|
584
584
|
return;
|
|
585
585
|
}
|
|
586
|
-
r === "live" && (!g && !h || (i((
|
|
587
|
-
g ? (p((
|
|
588
|
-
...
|
|
586
|
+
r === "live" && (!g && !h || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
|
|
587
|
+
g ? (p((x) => ({
|
|
588
|
+
...x,
|
|
589
589
|
[o._id]: {
|
|
590
590
|
status: "loaded",
|
|
591
|
-
props: get(
|
|
591
|
+
props: get(f, "items", []),
|
|
592
592
|
repeaterItems: o.repeaterItems
|
|
593
593
|
}
|
|
594
|
-
})), i((
|
|
595
|
-
}).catch((
|
|
596
|
-
g ? (p((
|
|
597
|
-
...
|
|
598
|
-
[o._id]: { status: "error", error:
|
|
599
|
-
})), i((
|
|
594
|
+
})), i((x) => ({ ...x, status: "loaded", props: { totalItems: get(f, "totalItems") } })), c([o._id], { totalItems: get(f, "totalItems") })) : i((x) => ({ ...x, status: "loaded", props: isObject(f) ? f : {} }));
|
|
595
|
+
}).catch((f) => {
|
|
596
|
+
g ? (p((x) => ({
|
|
597
|
+
...x,
|
|
598
|
+
[o._id]: { status: "error", error: f, props: [] }
|
|
599
|
+
})), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
|
|
600
600
|
})));
|
|
601
601
|
}, [o == null ? void 0 : o._id, u, g, h, a, r]), {
|
|
602
602
|
$loading: get(l, "status") === "loading",
|
|
@@ -761,10 +761,10 @@ const checkMissingTranslations = (o, r) => r ? o.some((n) => {
|
|
|
761
761
|
if (!c("save_page"))
|
|
762
762
|
return;
|
|
763
763
|
r("SAVING"), a("SAVING");
|
|
764
|
-
const
|
|
764
|
+
const f = l();
|
|
765
765
|
return await n({
|
|
766
766
|
autoSave: m,
|
|
767
|
-
blocks:
|
|
767
|
+
blocks: f.blocks,
|
|
768
768
|
theme: i,
|
|
769
769
|
needTranslations: u()
|
|
770
770
|
}), setTimeout(() => {
|
|
@@ -839,65 +839,65 @@ const undoRedoStateAtom = atom({
|
|
|
839
839
|
updateBlocksProps: c
|
|
840
840
|
} = useBlocksStoreManager();
|
|
841
841
|
return {
|
|
842
|
-
moveBlocks: (
|
|
843
|
-
const A = map(
|
|
844
|
-
const w = r.find((
|
|
845
|
-
return { _id:
|
|
846
|
-
}),
|
|
847
|
-
|
|
848
|
-
undo: () => each(A, ({ _id:
|
|
849
|
-
i([
|
|
842
|
+
moveBlocks: (x, y, b) => {
|
|
843
|
+
const A = map(x, (B) => {
|
|
844
|
+
const w = r.find((E) => E._id === B)._parent || null, S = r.filter((E) => w ? E._parent === w : !E._parent).map((E) => E._id).indexOf(B);
|
|
845
|
+
return { _id: B, oldParent: w, oldPosition: S };
|
|
846
|
+
}), _ = A.find(({ _id: B }) => B === x[0]);
|
|
847
|
+
_ && _.oldParent === y && _.oldPosition === b || (i(x, y, b), o({
|
|
848
|
+
undo: () => each(A, ({ _id: B, oldParent: N, oldPosition: w }) => {
|
|
849
|
+
i([B], N, w);
|
|
850
850
|
}),
|
|
851
|
-
redo: () => i(
|
|
851
|
+
redo: () => i(x, y, b)
|
|
852
852
|
}));
|
|
853
853
|
},
|
|
854
|
-
addBlocks: (
|
|
855
|
-
a(
|
|
856
|
-
undo: () => l(map(
|
|
857
|
-
redo: () => a(
|
|
854
|
+
addBlocks: (x, y, b) => {
|
|
855
|
+
a(x, y, b), o({
|
|
856
|
+
undo: () => l(map(x, "_id")),
|
|
857
|
+
redo: () => a(x, y, b)
|
|
858
858
|
});
|
|
859
859
|
},
|
|
860
|
-
removeBlocks: (
|
|
861
|
-
var
|
|
862
|
-
const
|
|
863
|
-
l(map(
|
|
864
|
-
undo: () => a(
|
|
865
|
-
redo: () => l(map(
|
|
860
|
+
removeBlocks: (x) => {
|
|
861
|
+
var _;
|
|
862
|
+
const y = (_ = first(x)) == null ? void 0 : _._parent, A = r.filter((B) => y ? B._parent === y : !B._parent).indexOf(first(x));
|
|
863
|
+
l(map(x, "_id")), o({
|
|
864
|
+
undo: () => a(x, y, A),
|
|
865
|
+
redo: () => l(map(x, "_id"))
|
|
866
866
|
});
|
|
867
867
|
},
|
|
868
|
-
updateBlocks: (
|
|
868
|
+
updateBlocks: (x, y, b) => {
|
|
869
869
|
let A = [];
|
|
870
870
|
if (b)
|
|
871
|
-
A = map(
|
|
871
|
+
A = map(x, (_) => ({ _id: _, ...b }));
|
|
872
872
|
else {
|
|
873
|
-
const
|
|
874
|
-
A = map(
|
|
875
|
-
const N = r.find((
|
|
876
|
-
return each(
|
|
873
|
+
const _ = keys(y);
|
|
874
|
+
A = map(x, (B) => {
|
|
875
|
+
const N = r.find((k) => k._id === B), w = { _id: B };
|
|
876
|
+
return each(_, (k) => w[k] = N[k]), w;
|
|
877
877
|
});
|
|
878
878
|
}
|
|
879
|
-
c(map(
|
|
879
|
+
c(map(x, (_) => ({ _id: _, ...y }))), o({
|
|
880
880
|
undo: () => c(A),
|
|
881
|
-
redo: () => c(map(
|
|
881
|
+
redo: () => c(map(x, (_) => ({ _id: _, ...y })))
|
|
882
882
|
});
|
|
883
883
|
},
|
|
884
|
-
updateBlocksRuntime: (
|
|
885
|
-
c(map(
|
|
884
|
+
updateBlocksRuntime: (x, y) => {
|
|
885
|
+
c(map(x, (b) => ({ _id: b, ...y })));
|
|
886
886
|
},
|
|
887
|
-
setNewBlocks: (
|
|
888
|
-
n(
|
|
887
|
+
setNewBlocks: (x) => {
|
|
888
|
+
n(x), o({
|
|
889
889
|
undo: () => n(r),
|
|
890
|
-
redo: () => n(
|
|
890
|
+
redo: () => n(x)
|
|
891
891
|
});
|
|
892
892
|
},
|
|
893
|
-
updateMultipleBlocksProps: (
|
|
894
|
-
let
|
|
895
|
-
|
|
896
|
-
const A = keys(b),
|
|
897
|
-
return each(A, (N) =>
|
|
898
|
-
}), c(
|
|
899
|
-
undo: () => c(
|
|
900
|
-
redo: () => c(
|
|
893
|
+
updateMultipleBlocksProps: (x) => {
|
|
894
|
+
let y = [];
|
|
895
|
+
y = map(x, (b) => {
|
|
896
|
+
const A = keys(b), _ = r.find((N) => N._id === b._id), B = {};
|
|
897
|
+
return each(A, (N) => B[N] = _[N]), B;
|
|
898
|
+
}), c(x), o({
|
|
899
|
+
undo: () => c(y),
|
|
900
|
+
redo: () => c(x)
|
|
901
901
|
});
|
|
902
902
|
}
|
|
903
903
|
};
|
|
@@ -905,12 +905,12 @@ const undoRedoStateAtom = atom({
|
|
|
905
905
|
const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
906
906
|
(i, c, d) => {
|
|
907
907
|
var m;
|
|
908
|
-
for (let
|
|
909
|
-
const { _id:
|
|
910
|
-
i[
|
|
911
|
-
const
|
|
912
|
-
for (let b = 0; b <
|
|
913
|
-
|
|
908
|
+
for (let f = 0; f < i.length; f++) {
|
|
909
|
+
const { _id: x } = i[f];
|
|
910
|
+
i[f]._id = generateUUID();
|
|
911
|
+
const y = filter(i, { _parent: x });
|
|
912
|
+
for (let b = 0; b < y.length; b++)
|
|
913
|
+
y[b]._parent = i[f]._id;
|
|
914
914
|
}
|
|
915
915
|
const p = first(i);
|
|
916
916
|
let u, g;
|
|
@@ -921,8 +921,8 @@ const undoRedoStateAtom = atom({
|
|
|
921
921
|
return { addCoreBlock: useCallback(
|
|
922
922
|
(i, c, d) => {
|
|
923
923
|
if (has(i, "blocks")) {
|
|
924
|
-
const
|
|
925
|
-
return a(
|
|
924
|
+
const y = i.blocks;
|
|
925
|
+
return a(y, c, d);
|
|
926
926
|
}
|
|
927
927
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
928
928
|
_type: i.type,
|
|
@@ -2360,43 +2360,43 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2360
2360
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2361
2361
|
})
|
|
2362
2362
|
), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2363
|
-
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m,
|
|
2364
|
-
const
|
|
2365
|
-
for (const
|
|
2366
|
-
const b =
|
|
2363
|
+
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, f) => {
|
|
2364
|
+
const x = cloneDeep(f.find((y) => y._id === m));
|
|
2365
|
+
for (const y in x) {
|
|
2366
|
+
const b = x[y];
|
|
2367
2367
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
2368
|
-
const { baseClasses: A, classes:
|
|
2369
|
-
|
|
2368
|
+
const { baseClasses: A, classes: _ } = getSplitChaiClasses(b);
|
|
2369
|
+
x[y] = compact(flattenDeep([A, _])).join(" ");
|
|
2370
2370
|
} else
|
|
2371
|
-
|
|
2371
|
+
y !== "_id" && delete x[y];
|
|
2372
2372
|
}
|
|
2373
|
-
return
|
|
2373
|
+
return x;
|
|
2374
2374
|
};
|
|
2375
2375
|
return {
|
|
2376
2376
|
askAi: useCallback(
|
|
2377
|
-
async (m,
|
|
2377
|
+
async (m, f, x, y) => {
|
|
2378
2378
|
if (l) {
|
|
2379
2379
|
r(!0), a(null);
|
|
2380
2380
|
try {
|
|
2381
|
-
const b = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(
|
|
2381
|
+
const b = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], _ = await l(m, addLangToPrompt(x, g, m), A, b), { blocks: B, error: N } = _;
|
|
2382
2382
|
if (N) {
|
|
2383
2383
|
a(N);
|
|
2384
2384
|
return;
|
|
2385
2385
|
}
|
|
2386
2386
|
if (m === "styles") {
|
|
2387
|
-
const w =
|
|
2388
|
-
for (const S in
|
|
2389
|
-
S !== "_id" && (
|
|
2390
|
-
return
|
|
2387
|
+
const w = B.map((k) => {
|
|
2388
|
+
for (const S in k)
|
|
2389
|
+
S !== "_id" && (k[S] = `${STYLES_KEY},${k[S]}`);
|
|
2390
|
+
return k;
|
|
2391
2391
|
});
|
|
2392
2392
|
c(w);
|
|
2393
2393
|
} else
|
|
2394
|
-
i(
|
|
2395
|
-
|
|
2394
|
+
i(B);
|
|
2395
|
+
y && y(_);
|
|
2396
2396
|
} catch (b) {
|
|
2397
2397
|
a(b);
|
|
2398
2398
|
} finally {
|
|
2399
|
-
r(!1),
|
|
2399
|
+
r(!1), y && y();
|
|
2400
2400
|
}
|
|
2401
2401
|
}
|
|
2402
2402
|
},
|
|
@@ -2490,12 +2490,12 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2490
2490
|
if (!p)
|
|
2491
2491
|
return h;
|
|
2492
2492
|
let m = [];
|
|
2493
|
-
for (const
|
|
2494
|
-
if (
|
|
2495
|
-
let
|
|
2496
|
-
|
|
2493
|
+
for (const f of h)
|
|
2494
|
+
if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
|
|
2495
|
+
let x = l(f.partialBlockId);
|
|
2496
|
+
f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((y) => (isEmpty(y._parent) && set(y, "_parent", f._parent), y))), m = [...m, ...x];
|
|
2497
2497
|
} else
|
|
2498
|
-
m.push(
|
|
2498
|
+
m.push(f);
|
|
2499
2499
|
return m;
|
|
2500
2500
|
})
|
|
2501
2501
|
};
|
|
@@ -2678,13 +2678,13 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2678
2678
|
const d = o(c), p = a;
|
|
2679
2679
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2680
2680
|
return each(p, (h) => {
|
|
2681
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2682
|
-
u = u.replace(
|
|
2683
|
-
const
|
|
2684
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2681
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2682
|
+
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2683
|
+
const x = first(h.split(":"));
|
|
2684
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
|
|
2685
2685
|
}), each(p, (h) => {
|
|
2686
|
-
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
2687
|
-
g = g.replace(
|
|
2686
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2687
|
+
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2688
2688
|
}), {
|
|
2689
2689
|
ids: [d._id],
|
|
2690
2690
|
props: {
|
|
@@ -2833,21 +2833,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2833
2833
|
return "VERTICAL";
|
|
2834
2834
|
}
|
|
2835
2835
|
}, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
|
|
2836
|
-
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (
|
|
2837
|
-
(
|
|
2838
|
-
isDisabledControl(g, h,
|
|
2836
|
+
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
2837
|
+
(x) => {
|
|
2838
|
+
isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), r());
|
|
2839
2839
|
},
|
|
2840
2840
|
[g, h, p, u, i, c, r]
|
|
2841
2841
|
);
|
|
2842
2842
|
return useHotkeys(
|
|
2843
2843
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2844
|
-
({ key:
|
|
2845
|
-
var
|
|
2846
|
-
|
|
2844
|
+
({ key: x }) => {
|
|
2845
|
+
var y;
|
|
2846
|
+
f((y = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
|
|
2847
2847
|
},
|
|
2848
2848
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2849
|
-
[
|
|
2850
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock:
|
|
2849
|
+
[f]
|
|
2850
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
|
|
2851
2851
|
}, BlockController = ({ block: o, updateFloatingBar: r }) => {
|
|
2852
2852
|
const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2853
2853
|
o,
|
|
@@ -3004,9 +3004,9 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3004
3004
|
}),
|
|
3005
3005
|
size({
|
|
3006
3006
|
boundary: u == null ? void 0 : u.body,
|
|
3007
|
-
apply({ availableWidth:
|
|
3007
|
+
apply({ availableWidth: y, availableHeight: b, elements: A }) {
|
|
3008
3008
|
Object.assign(A.floating.style, {
|
|
3009
|
-
maxWidth: `${Math.max(200,
|
|
3009
|
+
maxWidth: `${Math.max(200, y)}px`,
|
|
3010
3010
|
maxHeight: `${Math.max(100, b)}px`
|
|
3011
3011
|
});
|
|
3012
3012
|
}
|
|
@@ -3015,11 +3015,11 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3015
3015
|
elements: { reference: r }
|
|
3016
3016
|
});
|
|
3017
3017
|
useResizeObserver(r, () => m(), r !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
|
|
3018
|
-
const
|
|
3018
|
+
const f = get(o, "_parent", null), x = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
3019
3019
|
return useEffect(() => {
|
|
3020
3020
|
if (r) {
|
|
3021
|
-
const
|
|
3022
|
-
return () => clearTimeout(
|
|
3021
|
+
const y = setTimeout(() => m(), 500);
|
|
3022
|
+
return () => clearTimeout(y);
|
|
3023
3023
|
} else
|
|
3024
3024
|
m();
|
|
3025
3025
|
}, [r]), !r || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
@@ -3029,25 +3029,25 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
3029
3029
|
tabIndex: 0,
|
|
3030
3030
|
ref: h.setFloating,
|
|
3031
3031
|
style: g,
|
|
3032
|
-
onClick: (
|
|
3033
|
-
|
|
3032
|
+
onClick: (y) => {
|
|
3033
|
+
y.stopPropagation(), y.preventDefault();
|
|
3034
3034
|
},
|
|
3035
|
-
onMouseEnter: (
|
|
3036
|
-
|
|
3035
|
+
onMouseEnter: (y) => {
|
|
3036
|
+
y.stopPropagation(), i(null);
|
|
3037
3037
|
},
|
|
3038
|
-
onKeyDown: (
|
|
3038
|
+
onKeyDown: (y) => y.stopPropagation(),
|
|
3039
3039
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3040
3040
|
children: [
|
|
3041
|
-
|
|
3041
|
+
f && /* @__PURE__ */ jsx(
|
|
3042
3042
|
ArrowUpIcon,
|
|
3043
3043
|
{
|
|
3044
3044
|
className: "hover:scale-105",
|
|
3045
3045
|
onClick: () => {
|
|
3046
|
-
c([]), l([
|
|
3046
|
+
c([]), l([f]);
|
|
3047
3047
|
}
|
|
3048
3048
|
}
|
|
3049
3049
|
),
|
|
3050
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3050
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: x, block: o }),
|
|
3051
3051
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3052
3052
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3053
3053
|
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
|
|
@@ -3205,8 +3205,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3205
3205
|
i
|
|
3206
3206
|
]), useHotkeys(
|
|
3207
3207
|
"del, backspace",
|
|
3208
|
-
(
|
|
3209
|
-
|
|
3208
|
+
(f) => {
|
|
3209
|
+
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
|
|
3210
3210
|
},
|
|
3211
3211
|
m,
|
|
3212
3212
|
[r, l]
|
|
@@ -3499,8 +3499,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3499
3499
|
],
|
|
3500
3500
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3501
3501
|
onBlur: ({ editor: u, event: g }) => {
|
|
3502
|
-
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"),
|
|
3503
|
-
if (!
|
|
3502
|
+
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = m == null ? void 0 : m.contains(h), y = f == null ? void 0 : f.contains(h);
|
|
3503
|
+
if (!x && !y) {
|
|
3504
3504
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3505
3505
|
n(b);
|
|
3506
3506
|
}
|
|
@@ -3555,14 +3555,14 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3555
3555
|
useEffect(() => {
|
|
3556
3556
|
if (a.current) {
|
|
3557
3557
|
a.current.innerText = r, a.current.focus();
|
|
3558
|
-
const m = c.createRange(),
|
|
3559
|
-
m.selectNodeContents(a.current), m.collapse(!1),
|
|
3558
|
+
const m = c.createRange(), f = d.getSelection();
|
|
3559
|
+
m.selectNodeContents(a.current), m.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(m), a.current.focus();
|
|
3560
3560
|
} else
|
|
3561
3561
|
n();
|
|
3562
3562
|
}, [c, d]);
|
|
3563
3563
|
const p = useMemo(() => {
|
|
3564
|
-
var
|
|
3565
|
-
const m = ((
|
|
3564
|
+
var f;
|
|
3565
|
+
const m = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
|
|
3566
3566
|
return m === "button" ? "div" : m;
|
|
3567
3567
|
}, [o]), u = useCallback(
|
|
3568
3568
|
(m) => {
|
|
@@ -3578,12 +3578,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3578
3578
|
contentEditable: !0,
|
|
3579
3579
|
className: `${((m = o == null ? void 0 : o.className) == null ? void 0 : m.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
|
|
3580
3580
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
3581
|
-
onInput: (
|
|
3582
|
-
const
|
|
3583
|
-
|
|
3581
|
+
onInput: (f) => {
|
|
3582
|
+
const x = f.target;
|
|
3583
|
+
x && (x.innerText.trim() === "" ? (x.setAttribute("data-placeholder", "Enter text here"), x.children.length > 0 && x.children[0].remove()) : f.target.removeAttribute("data-placeholder"), l(f.target.innerText));
|
|
3584
3584
|
},
|
|
3585
|
-
onClick: (
|
|
3586
|
-
|
|
3585
|
+
onClick: (f) => {
|
|
3586
|
+
f.stopPropagation(), f.preventDefault();
|
|
3587
3587
|
}
|
|
3588
3588
|
};
|
|
3589
3589
|
}, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
|
|
@@ -3596,47 +3596,47 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3596
3596
|
}
|
|
3597
3597
|
), WithBlockTextEditor = memo(
|
|
3598
3598
|
({ block: o, children: r }) => {
|
|
3599
|
-
const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang:
|
|
3599
|
+
const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: A, blockType: _ } = useMemo(() => {
|
|
3600
3600
|
var j;
|
|
3601
3601
|
const S = o._type;
|
|
3602
|
-
let
|
|
3602
|
+
let E = o[n];
|
|
3603
3603
|
const v = getRegisteredChaiBlock(o._type);
|
|
3604
|
-
return
|
|
3605
|
-
}, [o,
|
|
3604
|
+
return f && ((j = v == null ? void 0 : v.i18nProps) == null ? void 0 : j.includes(n)) && has(o, `${n}-${f}`) && (E = get(o, `${n}-${f}`)), { blockContent: E, blockType: S };
|
|
3605
|
+
}, [o, f]), B = useCallback(
|
|
3606
3606
|
(S) => {
|
|
3607
3607
|
var v;
|
|
3608
|
-
const
|
|
3609
|
-
m([b], { [n]:
|
|
3608
|
+
const E = S || ((v = g.current) == null ? void 0 : v.innerText);
|
|
3609
|
+
m([b], { [n]: E }), u(null), c(null), d(-1), x(b ? [b] : []);
|
|
3610
3610
|
},
|
|
3611
|
-
[b, m, c,
|
|
3611
|
+
[b, m, c, x, f]
|
|
3612
3612
|
), N = useDebouncedCallback(
|
|
3613
3613
|
(S) => {
|
|
3614
3614
|
m([b], { [n]: S });
|
|
3615
3615
|
},
|
|
3616
|
-
[b, o, m,
|
|
3616
|
+
[b, o, m, f],
|
|
3617
3617
|
1e3
|
|
3618
3618
|
), w = useCallback(
|
|
3619
3619
|
(S) => {
|
|
3620
|
-
S.preventDefault(), b && (
|
|
3621
|
-
const
|
|
3622
|
-
|
|
3620
|
+
S.preventDefault(), b && (y.current = b), B(), setTimeout(() => {
|
|
3621
|
+
const E = y.current;
|
|
3622
|
+
y.current = null, x([E]);
|
|
3623
3623
|
}, 100);
|
|
3624
3624
|
},
|
|
3625
|
-
[
|
|
3625
|
+
[x, b, f]
|
|
3626
3626
|
);
|
|
3627
3627
|
useEffect(() => {
|
|
3628
3628
|
var C;
|
|
3629
3629
|
if (!b) return;
|
|
3630
|
-
const S = `[data-block-id="${b}"]`,
|
|
3630
|
+
const S = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", v = a.querySelector(`${S}${E}`);
|
|
3631
3631
|
v && ((C = v == null ? void 0 : v.classList) == null || C.add("sr-only"), u(v));
|
|
3632
|
-
}, [b,
|
|
3633
|
-
const
|
|
3632
|
+
}, [b, _, a, i]);
|
|
3633
|
+
const k = useMemo(() => p ? (h(), _ === "RichText" ? /* @__PURE__ */ jsx(
|
|
3634
3634
|
RichTextEditor,
|
|
3635
3635
|
{
|
|
3636
3636
|
blockContent: A,
|
|
3637
3637
|
editingElement: p,
|
|
3638
3638
|
onChange: N,
|
|
3639
|
-
onClose:
|
|
3639
|
+
onClose: B,
|
|
3640
3640
|
onEscape: w
|
|
3641
3641
|
}
|
|
3642
3642
|
) : /* @__PURE__ */ jsx(
|
|
@@ -3645,13 +3645,13 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3645
3645
|
editorRef: g,
|
|
3646
3646
|
blockContent: A,
|
|
3647
3647
|
editingElement: p,
|
|
3648
|
-
onClose:
|
|
3648
|
+
onClose: B,
|
|
3649
3649
|
onChange: N,
|
|
3650
3650
|
onEscape: w
|
|
3651
3651
|
}
|
|
3652
|
-
)) : null, [p, b,
|
|
3652
|
+
)) : null, [p, b, _, A, B, f]);
|
|
3653
3653
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3654
|
-
|
|
3654
|
+
k,
|
|
3655
3655
|
r
|
|
3656
3656
|
] });
|
|
3657
3657
|
},
|
|
@@ -3684,23 +3684,23 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3684
3684
|
blockAtom: r,
|
|
3685
3685
|
children: n
|
|
3686
3686
|
}) => {
|
|
3687
|
-
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom),
|
|
3687
|
+
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: x, key: y } = useContext(RepeaterContext), b = useMemo(
|
|
3688
3688
|
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
3689
|
-
index:
|
|
3690
|
-
key:
|
|
3689
|
+
index: x,
|
|
3690
|
+
key: y
|
|
3691
3691
|
}) : applyLanguage(i, d, c),
|
|
3692
|
-
[i, d, c, g, m,
|
|
3693
|
-
), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]),
|
|
3692
|
+
[i, d, c, g, m, x, y]
|
|
3693
|
+
), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), _ = useMemo(
|
|
3694
3694
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
3695
3695
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
3696
|
-
),
|
|
3696
|
+
), B = useMemo(
|
|
3697
3697
|
() => ({
|
|
3698
|
-
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index":
|
|
3698
|
+
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": x },
|
|
3699
3699
|
inBuilder: !0,
|
|
3700
3700
|
lang: d || p,
|
|
3701
3701
|
...b,
|
|
3702
3702
|
...A,
|
|
3703
|
-
...
|
|
3703
|
+
..._,
|
|
3704
3704
|
...o
|
|
3705
3705
|
}),
|
|
3706
3706
|
[
|
|
@@ -3710,13 +3710,13 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3710
3710
|
p,
|
|
3711
3711
|
b,
|
|
3712
3712
|
A,
|
|
3713
|
-
|
|
3713
|
+
_,
|
|
3714
3714
|
o
|
|
3715
3715
|
]
|
|
3716
3716
|
), N = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
|
|
3717
|
-
if (isNull(
|
|
3718
|
-
let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(
|
|
3719
|
-
...
|
|
3717
|
+
if (isNull(f) || h.includes(i._id)) return null;
|
|
3718
|
+
let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(f, {
|
|
3719
|
+
...B,
|
|
3720
3720
|
children: n({
|
|
3721
3721
|
_id: i._id,
|
|
3722
3722
|
_type: i._type,
|
|
@@ -3728,8 +3728,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3728
3728
|
...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
|
|
3729
3729
|
})
|
|
3730
3730
|
}) });
|
|
3731
|
-
const
|
|
3732
|
-
return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children:
|
|
3731
|
+
const k = a === i._id && (l === x || x < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
|
|
3732
|
+
return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: k }) : k;
|
|
3733
3733
|
}, PartialWrapper = ({ children: o, partialBlockId: r }) => {
|
|
3734
3734
|
const n = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
3735
3735
|
(d) => {
|
|
@@ -3769,7 +3769,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
|
|
|
3769
3769
|
);
|
|
3770
3770
|
return map(l, (c) => {
|
|
3771
3771
|
const d = a(c._id);
|
|
3772
|
-
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey:
|
|
3772
|
+
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: f }) => g === "Repeater" ? isArray(m) && m.map((x, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
|
|
3773
3773
|
});
|
|
3774
3774
|
}, PageBlocksRenderer = () => {
|
|
3775
3775
|
const [o] = useBlocksStore();
|
|
@@ -3837,14 +3837,14 @@ const CanvasEventsWatcher = () => {
|
|
|
3837
3837
|
}, StaticCanvas = () => {
|
|
3838
3838
|
const [o] = useCanvasDisplayWidth(), [, r] = useHighlightBlockId(), n = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
|
|
3839
3839
|
(m) => {
|
|
3840
|
-
i((
|
|
3840
|
+
i((f) => ({ ...f, width: m }));
|
|
3841
3841
|
},
|
|
3842
3842
|
[i]
|
|
3843
3843
|
);
|
|
3844
3844
|
useEffect(() => {
|
|
3845
3845
|
if (!a.current) return;
|
|
3846
|
-
const { clientWidth: m, clientHeight:
|
|
3847
|
-
i({ width: m, height:
|
|
3846
|
+
const { clientWidth: m, clientHeight: f } = a.current;
|
|
3847
|
+
i({ width: m, height: f });
|
|
3848
3848
|
}, [a, o]);
|
|
3849
3849
|
const h = useMemo(() => {
|
|
3850
3850
|
let m = IframeInitialContent;
|
|
@@ -3959,8 +3959,8 @@ const CanvasEventsWatcher = () => {
|
|
|
3959
3959
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3960
3960
|
] });
|
|
3961
3961
|
}, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
|
|
3962
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (
|
|
3963
|
-
if (!
|
|
3962
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (f) => {
|
|
3963
|
+
if (!f.trim()) {
|
|
3964
3964
|
p(!1), g("Please enter a URL");
|
|
3965
3965
|
return;
|
|
3966
3966
|
}
|
|
@@ -3984,7 +3984,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3984
3984
|
{
|
|
3985
3985
|
placeholder: m(`Enter ${n} URL`),
|
|
3986
3986
|
value: a,
|
|
3987
|
-
onChange: (
|
|
3987
|
+
onChange: (f) => l(f.target.value),
|
|
3988
3988
|
onKeyUp: () => h(a)
|
|
3989
3989
|
}
|
|
3990
3990
|
),
|
|
@@ -4020,47 +4020,45 @@ const CanvasEventsWatcher = () => {
|
|
|
4020
4020
|
] });
|
|
4021
4021
|
};
|
|
4022
4022
|
MediaManagerModal.displayName = "MediaManagerModal";
|
|
4023
|
-
const PLACEHOLDER_IMAGE_URL = "https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/dam-assets/02817647-2581-4c50-a005-f72de13d3da7/banner-placeholder.png
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
...
|
|
4033
|
-
...
|
|
4034
|
-
...x.description && { alt: x.description },
|
|
4035
|
-
...x.id && { assetId: x.id }
|
|
4023
|
+
const PLACEHOLDER_IMAGE_URL = "https://fldwljgzcktqnysdkxnn.supabase.co/storage/v1/object/public/dam-assets/02817647-2581-4c50-a005-f72de13d3da7/banner-placeholder.png", ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
4024
|
+
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = n.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, u, g ? c == null ? void 0 : c.assetId : ""), m = !!h, f = (y) => {
|
|
4025
|
+
const b = isArray(y) ? first(y) : y;
|
|
4026
|
+
if (b) {
|
|
4027
|
+
r(b == null ? void 0 : b.url);
|
|
4028
|
+
const A = b == null ? void 0 : b.width, _ = b == null ? void 0 : b.height;
|
|
4029
|
+
if (c != null && c._id) {
|
|
4030
|
+
const B = {
|
|
4031
|
+
...A && { width: A },
|
|
4032
|
+
..._ && { height: _ },
|
|
4033
|
+
...b.description && { alt: b.description }
|
|
4036
4034
|
};
|
|
4037
|
-
if (
|
|
4038
|
-
|
|
4035
|
+
if (set(B, u, b.id), isEmpty(B)) return;
|
|
4036
|
+
d([c._id], B);
|
|
4039
4037
|
}
|
|
4040
4038
|
}
|
|
4041
|
-
},
|
|
4042
|
-
r(PLACEHOLDER_IMAGE_URL),
|
|
4043
|
-
}, [r,
|
|
4039
|
+
}, x = useCallback(() => {
|
|
4040
|
+
r(PLACEHOLDER_IMAGE_URL), c != null && c._id && d([c._id], { assetId: "" });
|
|
4041
|
+
}, [r, c == null ? void 0 : c._id, d]);
|
|
4044
4042
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
|
|
4045
4043
|
o ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
|
|
4046
4044
|
/* @__PURE__ */ jsx(
|
|
4047
4045
|
"img",
|
|
4048
4046
|
{
|
|
4049
4047
|
src: o,
|
|
4050
|
-
className: "h-20 w-20 overflow-hidden rounded-md border border-border object-cover transition duration-200 " + (
|
|
4048
|
+
className: "h-20 w-20 overflow-hidden rounded-md border border-border object-cover transition duration-200 " + (h && h !== "" ? "cursor-pointer group-hover:blur-sm" : ""),
|
|
4051
4049
|
alt: ""
|
|
4052
4050
|
}
|
|
4053
4051
|
),
|
|
4054
|
-
|
|
4052
|
+
m && /* @__PURE__ */ jsx(
|
|
4055
4053
|
"button",
|
|
4056
4054
|
{
|
|
4057
4055
|
type: "button",
|
|
4058
|
-
onClick:
|
|
4056
|
+
onClick: x,
|
|
4059
4057
|
className: "absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
|
|
4060
4058
|
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
4061
4059
|
}
|
|
4062
4060
|
),
|
|
4063
|
-
|
|
4061
|
+
h && h !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: f, assetId: h, children: /* @__PURE__ */ jsx(
|
|
4064
4062
|
"button",
|
|
4065
4063
|
{
|
|
4066
4064
|
type: "button",
|
|
@@ -4068,10 +4066,10 @@ const PLACEHOLDER_IMAGE_URL = "https://fldwljgzcktqnysdkxnn.supabase.co/storage/
|
|
|
4068
4066
|
children: /* @__PURE__ */ jsx(Edit2Icon, { className: "h-4 w-4 text-white" })
|
|
4069
4067
|
}
|
|
4070
4068
|
) })
|
|
4071
|
-
] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect:
|
|
4069
|
+
] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: f, mode: "image", assetId: h, children: /* @__PURE__ */ jsx("div", { className: "h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
|
|
4072
4070
|
/* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
|
|
4073
4071
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4074
|
-
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect:
|
|
4072
|
+
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect: f, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: o || !isEmpty(o) ? l("Replace image") : l("Choose image") }) }),
|
|
4075
4073
|
/* @__PURE__ */ jsx("small", { className: "-pl-4 pt-2 text-center text-xs text-secondary-foreground", children: "OR" })
|
|
4076
4074
|
] }),
|
|
4077
4075
|
/* @__PURE__ */ jsx(
|
|
@@ -4085,8 +4083,8 @@ const PLACEHOLDER_IMAGE_URL = "https://fldwljgzcktqnysdkxnn.supabase.co/storage/
|
|
|
4085
4083
|
className: "text-xs",
|
|
4086
4084
|
placeholder: l("Enter image URL"),
|
|
4087
4085
|
value: o,
|
|
4088
|
-
onBlur: ({ target: { value:
|
|
4089
|
-
onChange: (
|
|
4086
|
+
onBlur: ({ target: { value: y } }) => a(n, y),
|
|
4087
|
+
onChange: (y) => r(y.target.value)
|
|
4090
4088
|
}
|
|
4091
4089
|
)
|
|
4092
4090
|
] })
|
|
@@ -4094,14 +4092,14 @@ const PLACEHOLDER_IMAGE_URL = "https://fldwljgzcktqnysdkxnn.supabase.co/storage/
|
|
|
4094
4092
|
}, PathDropdown = ({ data: o, onSelect: r, dataType: n }) => {
|
|
4095
4093
|
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", p = React__default.useCallback(
|
|
4096
4094
|
(h) => {
|
|
4097
|
-
const m = (
|
|
4098
|
-
h.type === "object" ? (l((
|
|
4095
|
+
const m = (f) => n === "value" ? f === "value" || f === "object" : n === "array" ? f === "array" : f === n;
|
|
4096
|
+
h.type === "object" ? (l((f) => [...f, h.key]), c(h.value)) : m(h.type) && r([...a, h.key].join("."), n);
|
|
4099
4097
|
},
|
|
4100
4098
|
[a, r, n]
|
|
4101
4099
|
), u = React__default.useCallback(() => {
|
|
4102
4100
|
if (a.length > 0) {
|
|
4103
4101
|
const h = a.slice(0, -1);
|
|
4104
|
-
l(h), c(h.reduce((m,
|
|
4102
|
+
l(h), c(h.reduce((m, f) => m[f], o));
|
|
4105
4103
|
}
|
|
4106
4104
|
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([h, m]) => ({ key: h, value: m, type: d(m) })).filter((h) => !startsWith(h.key, REPEATER_PREFIX) && h.key.includes("/") ? !1 : n === "value" ? h.type === "value" || h.type === "object" : n === "array" ? h.type === "array" || h.type === "object" : n === "object" ? h.type === "object" : !0) : [], [i, n]);
|
|
4107
4105
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
@@ -4194,7 +4192,7 @@ const DataBindingSelector = ({
|
|
|
4194
4192
|
}) => {
|
|
4195
4193
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4196
4194
|
if (i.length === 1) return "";
|
|
4197
|
-
const g = i.find((
|
|
4195
|
+
const g = i.find((f) => f._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4198
4196
|
return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
|
|
4199
4197
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4200
4198
|
(g, h) => {
|
|
@@ -4202,43 +4200,43 @@ const DataBindingSelector = ({
|
|
|
4202
4200
|
r(`{{${g}}}`, {}, n);
|
|
4203
4201
|
return;
|
|
4204
4202
|
}
|
|
4205
|
-
const m = (b) => /[.,!?;:]/.test(b),
|
|
4206
|
-
let
|
|
4207
|
-
const w = A > 0 ? b[A - 1] : "",
|
|
4208
|
-
return A > 0 && (w === "." || !m(w) && w !== " ") && (
|
|
4209
|
-
text:
|
|
4210
|
-
prefixLength:
|
|
4203
|
+
const m = (b) => /[.,!?;:]/.test(b), f = (b, A, _) => {
|
|
4204
|
+
let B = "", N = "";
|
|
4205
|
+
const w = A > 0 ? b[A - 1] : "", k = A < b.length ? b[A] : "";
|
|
4206
|
+
return A > 0 && (w === "." || !m(w) && w !== " ") && (B = " "), A < b.length && !m(k) && k !== " " && (N = " "), {
|
|
4207
|
+
text: B + _ + N,
|
|
4208
|
+
prefixLength: B.length,
|
|
4211
4209
|
suffixLength: N.length
|
|
4212
4210
|
};
|
|
4213
|
-
},
|
|
4214
|
-
if (!
|
|
4215
|
-
const
|
|
4216
|
-
if (
|
|
4217
|
-
const b =
|
|
4211
|
+
}, x = document.getElementById(n);
|
|
4212
|
+
if (!x) return;
|
|
4213
|
+
const y = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
|
|
4214
|
+
if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
|
|
4215
|
+
const b = y.__chaiRTE;
|
|
4218
4216
|
if (b) {
|
|
4219
4217
|
const A = `{{${g}}}`;
|
|
4220
4218
|
b.commands.focus();
|
|
4221
|
-
const { from:
|
|
4222
|
-
if (
|
|
4219
|
+
const { from: _, to: B } = b.state.selection;
|
|
4220
|
+
if (_ !== B)
|
|
4223
4221
|
b.chain().deleteSelection().insertContent(A).run();
|
|
4224
4222
|
else {
|
|
4225
|
-
const { state: w } = b,
|
|
4223
|
+
const { state: w } = b, k = w.selection.from, S = w.doc.textBetween(Math.max(0, k - 1), k), E = w.doc.textBetween(k, Math.min(k + 1, w.doc.content.size));
|
|
4226
4224
|
let v = "";
|
|
4227
|
-
|
|
4225
|
+
k > 0 && S !== " " && !m(S) && (v = " ");
|
|
4228
4226
|
let C = "";
|
|
4229
|
-
|
|
4227
|
+
E && E !== " " && !m(E) && (C = " "), b.chain().insertContent(v + A + C).run();
|
|
4230
4228
|
}
|
|
4231
4229
|
setTimeout(() => r(b.getHTML(), {}, n), 100);
|
|
4232
4230
|
return;
|
|
4233
4231
|
}
|
|
4234
4232
|
} else {
|
|
4235
|
-
const b =
|
|
4236
|
-
if (
|
|
4237
|
-
const
|
|
4233
|
+
const b = x, A = b.selectionStart || 0, _ = b.value || "", B = b.selectionEnd || A;
|
|
4234
|
+
if (B > A) {
|
|
4235
|
+
const E = `{{${g}}}`, { text: v } = f(_, A, E), C = _.slice(0, A) + v + _.slice(B);
|
|
4238
4236
|
r(C, {}, n);
|
|
4239
4237
|
return;
|
|
4240
4238
|
}
|
|
4241
|
-
const w = `{{${g}}}`, { text:
|
|
4239
|
+
const w = `{{${g}}}`, { text: k } = f(_, A, w), S = _.slice(0, A) + k + _.slice(A);
|
|
4242
4240
|
r(S, {}, n);
|
|
4243
4241
|
}
|
|
4244
4242
|
},
|
|
@@ -4260,23 +4258,23 @@ const DataBindingSelector = ({
|
|
|
4260
4258
|
pageTypes: r,
|
|
4261
4259
|
onChange: n
|
|
4262
4260
|
}) => {
|
|
4263
|
-
var
|
|
4264
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [
|
|
4261
|
+
var E;
|
|
4262
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), A = useRef(null), _ = (E = r == null ? void 0 : r.find((v) => v.key === u)) == null ? void 0 : E.name;
|
|
4265
4263
|
useEffect(() => {
|
|
4266
|
-
if (m(""),
|
|
4264
|
+
if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4267
4265
|
const v = split(o, ":"), C = get(v, 1, "page") || "page";
|
|
4268
4266
|
g(C), (async () => {
|
|
4269
4267
|
const j = await l(C, [get(v, 2, "page")]);
|
|
4270
4268
|
j && Array.isArray(j) && m(get(j, [0, "name"], ""));
|
|
4271
4269
|
})();
|
|
4272
4270
|
}, [o]);
|
|
4273
|
-
const
|
|
4271
|
+
const B = useDebouncedCallback(
|
|
4274
4272
|
async (v) => {
|
|
4275
4273
|
if (isEmpty(v))
|
|
4276
|
-
|
|
4274
|
+
x([]);
|
|
4277
4275
|
else {
|
|
4278
4276
|
const C = await l(u, v);
|
|
4279
|
-
|
|
4277
|
+
x(C);
|
|
4280
4278
|
}
|
|
4281
4279
|
c(!1), b(-1);
|
|
4282
4280
|
},
|
|
@@ -4284,34 +4282,34 @@ const DataBindingSelector = ({
|
|
|
4284
4282
|
300
|
|
4285
4283
|
), N = (v) => {
|
|
4286
4284
|
const C = ["pageType", u, v.id];
|
|
4287
|
-
C[1] && (n(C.join(":")), m(v.name), p(!1),
|
|
4285
|
+
C[1] && (n(C.join(":")), m(v.name), p(!1), x([]), b(-1));
|
|
4288
4286
|
}, w = (v) => {
|
|
4289
4287
|
switch (v.key) {
|
|
4290
4288
|
case "ArrowDown":
|
|
4291
|
-
v.preventDefault(), b((C) => C <
|
|
4289
|
+
v.preventDefault(), b((C) => C < f.length - 1 ? C + 1 : C);
|
|
4292
4290
|
break;
|
|
4293
4291
|
case "ArrowUp":
|
|
4294
4292
|
v.preventDefault(), b((C) => C > 0 ? C - 1 : C);
|
|
4295
4293
|
break;
|
|
4296
4294
|
case "Enter":
|
|
4297
|
-
if (v.preventDefault(),
|
|
4298
|
-
|
|
4295
|
+
if (v.preventDefault(), f.length === 0) return;
|
|
4296
|
+
y >= 0 && N(f[y]);
|
|
4299
4297
|
break;
|
|
4300
4298
|
case "Escape":
|
|
4301
|
-
v.preventDefault(),
|
|
4299
|
+
v.preventDefault(), k();
|
|
4302
4300
|
break;
|
|
4303
4301
|
}
|
|
4304
4302
|
};
|
|
4305
4303
|
useEffect(() => {
|
|
4306
|
-
if (
|
|
4307
|
-
const v = A.current.children[
|
|
4304
|
+
if (y >= 0 && A.current) {
|
|
4305
|
+
const v = A.current.children[y];
|
|
4308
4306
|
v == null || v.scrollIntoView({ block: "nearest" });
|
|
4309
4307
|
}
|
|
4310
|
-
}, [
|
|
4311
|
-
const
|
|
4312
|
-
m(""),
|
|
4308
|
+
}, [y]);
|
|
4309
|
+
const k = () => {
|
|
4310
|
+
m(""), x([]), b(-1), p(!1), n("");
|
|
4313
4311
|
}, S = (v) => {
|
|
4314
|
-
m(v), p(!isEmpty(v)), c(!0),
|
|
4312
|
+
m(v), p(!isEmpty(v)), c(!0), B(v);
|
|
4315
4313
|
};
|
|
4316
4314
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4317
4315
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(r, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
|
|
@@ -4323,25 +4321,25 @@ const DataBindingSelector = ({
|
|
|
4323
4321
|
value: h,
|
|
4324
4322
|
onChange: (v) => S(v.target.value),
|
|
4325
4323
|
onKeyDown: w,
|
|
4326
|
-
placeholder: a(`Search ${
|
|
4324
|
+
placeholder: a(`Search ${_ ?? ""}`),
|
|
4327
4325
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4328
4326
|
}
|
|
4329
4327
|
),
|
|
4330
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick:
|
|
4328
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: k, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4331
4329
|
] }),
|
|
4332
|
-
(i || !isEmpty(
|
|
4330
|
+
(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: [
|
|
4333
4331
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4334
4332
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4335
|
-
] }) : d && isEmpty(
|
|
4333
|
+
] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4336
4334
|
a("No results found for"),
|
|
4337
4335
|
' "',
|
|
4338
4336
|
h,
|
|
4339
4337
|
'"'
|
|
4340
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(
|
|
4338
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, C) => /* @__PURE__ */ jsxs(
|
|
4341
4339
|
"li",
|
|
4342
4340
|
{
|
|
4343
4341
|
onClick: () => N(v),
|
|
4344
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : C ===
|
|
4342
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : C === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4345
4343
|
children: [
|
|
4346
4344
|
v.name,
|
|
4347
4345
|
" ",
|
|
@@ -4652,15 +4650,15 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4652
4650
|
if (!u) return;
|
|
4653
4651
|
const m = `{{${h}}}`;
|
|
4654
4652
|
u.commands.focus();
|
|
4655
|
-
const { from:
|
|
4656
|
-
if (
|
|
4653
|
+
const { from: f, to: x } = u.state.selection;
|
|
4654
|
+
if (f !== x)
|
|
4657
4655
|
u.chain().deleteSelection().insertContent(m).run();
|
|
4658
4656
|
else {
|
|
4659
|
-
const { state: b } = u, A = b.selection.from,
|
|
4657
|
+
const { state: b } = u, A = b.selection.from, _ = b.doc.textBetween(Math.max(0, A - 1), A), B = b.doc.textBetween(A, Math.min(A + 1, b.doc.content.size));
|
|
4660
4658
|
let N = "";
|
|
4661
|
-
A > 0 &&
|
|
4659
|
+
A > 0 && _ !== " " && !/[.,!?;:]/.test(_) && (N = " ");
|
|
4662
4660
|
let w = "";
|
|
4663
|
-
|
|
4661
|
+
B && B !== " " && !/[.,!?;:]/.test(B) && (w = " "), u.chain().insertContent(N + m + w).run();
|
|
4664
4662
|
}
|
|
4665
4663
|
};
|
|
4666
4664
|
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
@@ -4699,13 +4697,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4699
4697
|
})
|
|
4700
4698
|
],
|
|
4701
4699
|
content: n || "",
|
|
4702
|
-
onUpdate: ({ editor:
|
|
4703
|
-
const
|
|
4704
|
-
a(
|
|
4700
|
+
onUpdate: ({ editor: f }) => {
|
|
4701
|
+
const x = f.getHTML();
|
|
4702
|
+
a(x), c || u(x);
|
|
4705
4703
|
},
|
|
4706
|
-
onBlur: ({ editor:
|
|
4707
|
-
const
|
|
4708
|
-
l(o,
|
|
4704
|
+
onBlur: ({ editor: f }) => {
|
|
4705
|
+
const x = f.getHTML();
|
|
4706
|
+
l(o, x);
|
|
4709
4707
|
},
|
|
4710
4708
|
editorProps: {
|
|
4711
4709
|
attributes: {
|
|
@@ -4718,8 +4716,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4718
4716
|
}, [g]), useEffect(() => {
|
|
4719
4717
|
u(n || "");
|
|
4720
4718
|
}, [n]);
|
|
4721
|
-
const h = (
|
|
4722
|
-
a(
|
|
4719
|
+
const h = (f) => {
|
|
4720
|
+
a(f);
|
|
4723
4721
|
}, m = () => {
|
|
4724
4722
|
d(!1), g && g.commands.setContent(p);
|
|
4725
4723
|
};
|
|
@@ -4752,25 +4750,25 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4752
4750
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
|
|
4753
4751
|
}, [o, u]);
|
|
4754
4752
|
const h = () => {
|
|
4755
|
-
const
|
|
4756
|
-
if (
|
|
4757
|
-
const
|
|
4753
|
+
const x = findIndex(u, { _id: g });
|
|
4754
|
+
if (x > -1) {
|
|
4755
|
+
const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
|
|
4758
4756
|
if (!b) return;
|
|
4759
4757
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4760
4758
|
}
|
|
4761
4759
|
}, m = () => {
|
|
4762
|
-
const
|
|
4763
|
-
if (
|
|
4764
|
-
const
|
|
4760
|
+
const x = findIndex(u, { _id: g });
|
|
4761
|
+
if (x > -1) {
|
|
4762
|
+
const y = (x - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
|
|
4765
4763
|
if (!b) return;
|
|
4766
4764
|
r({ ...o, currentSlide: b }), c([b]);
|
|
4767
4765
|
}
|
|
4768
|
-
},
|
|
4769
|
-
const
|
|
4766
|
+
}, f = () => {
|
|
4767
|
+
const x = i(
|
|
4770
4768
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4771
4769
|
p == null ? void 0 : p._id
|
|
4772
|
-
),
|
|
4773
|
-
|
|
4770
|
+
), y = x == null ? void 0 : x._id;
|
|
4771
|
+
y && (r({ ...o, currentSlide: y }), c([y]));
|
|
4774
4772
|
};
|
|
4775
4773
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4776
4774
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
@@ -4787,7 +4785,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4787
4785
|
/* @__PURE__ */ jsxs(
|
|
4788
4786
|
"button",
|
|
4789
4787
|
{
|
|
4790
|
-
onClick:
|
|
4788
|
+
onClick: f,
|
|
4791
4789
|
className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
|
|
4792
4790
|
children: [
|
|
4793
4791
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4848,9 +4846,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4848
4846
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4849
4847
|
className: "text-xs",
|
|
4850
4848
|
pattern: "[0-9]*",
|
|
4851
|
-
onChange: (
|
|
4852
|
-
let
|
|
4853
|
-
|
|
4849
|
+
onChange: (x) => {
|
|
4850
|
+
let y = x.target.value;
|
|
4851
|
+
y.length && (y = y.replace("-", "")), r({ ...o, autoplayInterval: y });
|
|
4854
4852
|
}
|
|
4855
4853
|
}
|
|
4856
4854
|
)
|
|
@@ -4957,28 +4955,28 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4957
4955
|
formData: u,
|
|
4958
4956
|
onChange: g
|
|
4959
4957
|
}) => {
|
|
4960
|
-
const { selectedLang: h, fallbackLang: m, languages:
|
|
4961
|
-
() => isEmpty(
|
|
4962
|
-
[
|
|
4963
|
-
),
|
|
4964
|
-
() => get(
|
|
4965
|
-
[
|
|
4958
|
+
const { selectedLang: h, fallbackLang: m, languages: f } = useLanguages(), x = useMemo(
|
|
4959
|
+
() => isEmpty(f) ? "" : isEmpty(h) ? m : h,
|
|
4960
|
+
[f, h, m]
|
|
4961
|
+
), y = useMemo(() => get(LANGUAGES, x, x), [x]), b = usePageExternalData(), A = useSelectedBlock(), _ = useRegisteredChaiBlocks(), B = useMemo(
|
|
4962
|
+
() => get(_, [A == null ? void 0 : A._type, "i18nProps"], []),
|
|
4963
|
+
[_, A == null ? void 0 : A._type]
|
|
4966
4964
|
), [N, w] = useState(null);
|
|
4967
4965
|
if (c)
|
|
4968
4966
|
return null;
|
|
4969
4967
|
if (p.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
|
|
4970
|
-
const S =
|
|
4968
|
+
const S = B == null ? void 0 : B.includes(o.replace("root.", ""));
|
|
4971
4969
|
if (p.type === "array") {
|
|
4972
|
-
const
|
|
4970
|
+
const E = N === o;
|
|
4973
4971
|
return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
|
|
4974
4972
|
p.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
|
|
4975
4973
|
"label",
|
|
4976
4974
|
{
|
|
4977
4975
|
htmlFor: o,
|
|
4978
|
-
onClick: () => w(
|
|
4976
|
+
onClick: () => w(E ? null : o),
|
|
4979
4977
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4980
4978
|
children: [
|
|
4981
|
-
|
|
4979
|
+
E ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
4982
4980
|
/* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
|
|
4983
4981
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
|
|
4984
4982
|
" ",
|
|
@@ -4997,7 +4995,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4997
4995
|
]
|
|
4998
4996
|
}
|
|
4999
4997
|
) }),
|
|
5000
|
-
(u == null ? void 0 : u.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${
|
|
4998
|
+
(u == null ? void 0 : u.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${E ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
5001
4999
|
a,
|
|
5002
5000
|
l,
|
|
5003
5001
|
i
|
|
@@ -5012,7 +5010,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
5012
5010
|
" ",
|
|
5013
5011
|
S && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5014
5012
|
" ",
|
|
5015
|
-
|
|
5013
|
+
y
|
|
5016
5014
|
] }),
|
|
5017
5015
|
d && p.type !== "object" ? " *" : null
|
|
5018
5016
|
] }),
|
|
@@ -5025,8 +5023,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
5025
5023
|
DataBindingSelector,
|
|
5026
5024
|
{
|
|
5027
5025
|
schema: p,
|
|
5028
|
-
onChange: (
|
|
5029
|
-
g(
|
|
5026
|
+
onChange: (E) => {
|
|
5027
|
+
g(E, u, o);
|
|
5030
5028
|
},
|
|
5031
5029
|
id: o,
|
|
5032
5030
|
formData: u
|
|
@@ -5132,36 +5130,36 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
5132
5130
|
}), a;
|
|
5133
5131
|
};
|
|
5134
5132
|
function BlockSettings() {
|
|
5135
|
-
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h),
|
|
5136
|
-
|
|
5137
|
-
},
|
|
5138
|
-
debounce(({ formData: w },
|
|
5139
|
-
|
|
5133
|
+
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: w }, k, S) => {
|
|
5134
|
+
k && (c == null ? void 0 : c._id) === r._id && a([r._id], { [k]: get(w, k) }, S);
|
|
5135
|
+
}, x = useCallback(
|
|
5136
|
+
debounce(({ formData: w }, k, S) => {
|
|
5137
|
+
f({ formData: w }, k, S), d(w);
|
|
5140
5138
|
}, 1500),
|
|
5141
5139
|
[r == null ? void 0 : r._id, o]
|
|
5142
|
-
),
|
|
5143
|
-
|
|
5144
|
-
}, b = ({ formData: w },
|
|
5145
|
-
|
|
5146
|
-
}, { schema: A, uiSchema:
|
|
5140
|
+
), y = ({ formData: w }, k) => {
|
|
5141
|
+
k && (n([r._id], { [k]: get(w, k) }), x({ formData: w }, k, { [k]: get(c, k) }));
|
|
5142
|
+
}, b = ({ formData: w }, k) => {
|
|
5143
|
+
k && (n([g._id], { [k]: get(w, k) }), x({ formData: w }, k, { [k]: get(c, k) }));
|
|
5144
|
+
}, { schema: A, uiSchema: _ } = useMemo(() => {
|
|
5147
5145
|
const w = r == null ? void 0 : r._type;
|
|
5148
5146
|
if (!w)
|
|
5149
5147
|
return { schema: {}, uiSchema: {} };
|
|
5150
5148
|
try {
|
|
5151
|
-
const { schema:
|
|
5149
|
+
const { schema: k, uiSchema: S } = getBlockFormSchemas(w);
|
|
5152
5150
|
if (w === "Repeater") {
|
|
5153
|
-
const
|
|
5154
|
-
startsWith(
|
|
5151
|
+
const E = get(r, "repeaterItems", "");
|
|
5152
|
+
startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(S, "filter", { "ui:widget": "collectionSelect" }), set(S, "sort", { "ui:widget": "collectionSelect" })) : (set(S, "filter", { "ui:widget": "hidden" }), set(S, "sort", { "ui:widget": "hidden" }));
|
|
5155
5153
|
}
|
|
5156
|
-
return { schema:
|
|
5154
|
+
return { schema: k, uiSchema: S };
|
|
5157
5155
|
} catch {
|
|
5158
5156
|
return { schema: {}, uiSchema: {} };
|
|
5159
5157
|
}
|
|
5160
|
-
}, [r]), { wrapperSchema:
|
|
5158
|
+
}, [r]), { wrapperSchema: B, wrapperUiSchema: N } = useMemo(() => {
|
|
5161
5159
|
if (!g || !(g != null && g._type))
|
|
5162
5160
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5163
|
-
const w = g == null ? void 0 : g._type, { schema:
|
|
5164
|
-
return { wrapperSchema:
|
|
5161
|
+
const w = g == null ? void 0 : g._type, { schema: k = {}, uiSchema: S = {} } = getBlockFormSchemas(w);
|
|
5162
|
+
return { wrapperSchema: k, wrapperUiSchema: S };
|
|
5165
5163
|
}, [g]);
|
|
5166
5164
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5167
5165
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
@@ -5189,7 +5187,7 @@ function BlockSettings() {
|
|
|
5189
5187
|
blockId: g == null ? void 0 : g._id,
|
|
5190
5188
|
onChange: b,
|
|
5191
5189
|
formData: m,
|
|
5192
|
-
schema:
|
|
5190
|
+
schema: B,
|
|
5193
5191
|
uiSchema: N
|
|
5194
5192
|
}
|
|
5195
5193
|
) })
|
|
@@ -5198,43 +5196,43 @@ function BlockSettings() {
|
|
|
5198
5196
|
JSONForm,
|
|
5199
5197
|
{
|
|
5200
5198
|
blockId: r == null ? void 0 : r._id,
|
|
5201
|
-
onChange:
|
|
5199
|
+
onChange: y,
|
|
5202
5200
|
formData: i,
|
|
5203
5201
|
schema: A,
|
|
5204
|
-
uiSchema:
|
|
5202
|
+
uiSchema: _
|
|
5205
5203
|
}
|
|
5206
5204
|
)
|
|
5207
5205
|
] });
|
|
5208
5206
|
}
|
|
5209
5207
|
const BlockStylingProps = () => {
|
|
5210
|
-
var
|
|
5208
|
+
var f;
|
|
5211
5209
|
const o = useSelectedBlock(), [r, n] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
|
|
5212
5210
|
if (!o) return null;
|
|
5213
5211
|
const c = Object.keys(o).filter(
|
|
5214
|
-
(
|
|
5215
|
-
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (
|
|
5212
|
+
(x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
|
|
5213
|
+
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = r[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], m = (x) => find(r, (y) => y.prop === x);
|
|
5216
5214
|
return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5217
5215
|
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5218
5216
|
i("Style element"),
|
|
5219
5217
|
":"
|
|
5220
5218
|
] }),
|
|
5221
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (
|
|
5219
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(c, (x) => /* @__PURE__ */ jsxs(
|
|
5222
5220
|
Badge,
|
|
5223
5221
|
{
|
|
5224
5222
|
className: "flex cursor-pointer items-center gap-1 pr-1",
|
|
5225
|
-
variant: m(
|
|
5223
|
+
variant: m(x) ? "default" : "secondary",
|
|
5226
5224
|
onClick: () => {
|
|
5227
|
-
n([{ id: `${
|
|
5225
|
+
n([{ id: `${x}-${o._id}`, blockId: o._id, prop: x }]);
|
|
5228
5226
|
},
|
|
5229
5227
|
children: [
|
|
5230
|
-
startCase(
|
|
5228
|
+
startCase(x),
|
|
5231
5229
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5232
5230
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5233
5231
|
"button",
|
|
5234
5232
|
{
|
|
5235
5233
|
type: "button",
|
|
5236
5234
|
className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
|
|
5237
|
-
onClick: (
|
|
5235
|
+
onClick: (y) => y.stopPropagation(),
|
|
5238
5236
|
children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
|
|
5239
5237
|
}
|
|
5240
5238
|
) }),
|
|
@@ -5244,7 +5242,7 @@ const BlockStylingProps = () => {
|
|
|
5244
5242
|
{
|
|
5245
5243
|
className: "text-xs",
|
|
5246
5244
|
onClick: () => {
|
|
5247
|
-
d(
|
|
5245
|
+
d(x);
|
|
5248
5246
|
},
|
|
5249
5247
|
children: i("Reset style")
|
|
5250
5248
|
}
|
|
@@ -5263,7 +5261,7 @@ const BlockStylingProps = () => {
|
|
|
5263
5261
|
] })
|
|
5264
5262
|
]
|
|
5265
5263
|
},
|
|
5266
|
-
|
|
5264
|
+
x
|
|
5267
5265
|
)) }),
|
|
5268
5266
|
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5269
5267
|
] }) });
|
|
@@ -5412,7 +5410,7 @@ const BlockStylingProps = () => {
|
|
|
5412
5410
|
},
|
|
5413
5411
|
a
|
|
5414
5412
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5415
|
-
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [
|
|
5413
|
+
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [A, _] = useState(!1), [B, N] = useState(!1);
|
|
5416
5414
|
useEffect(() => {
|
|
5417
5415
|
const { value: v, unit: C } = getClassValueAndUnit(i);
|
|
5418
5416
|
if (C === "") {
|
|
@@ -5421,11 +5419,11 @@ const BlockStylingProps = () => {
|
|
|
5421
5419
|
}
|
|
5422
5420
|
m(C), l(C === "class" || isEmpty(v) ? "" : v);
|
|
5423
5421
|
}, [i, p, u]);
|
|
5424
|
-
const w = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME),
|
|
5422
|
+
const w = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), k = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), S = useCallback(
|
|
5425
5423
|
(v = !1) => {
|
|
5426
5424
|
const C = getUserInputValues(`${a}`, u);
|
|
5427
5425
|
if (get(C, "error", !1)) {
|
|
5428
|
-
|
|
5426
|
+
x(!0);
|
|
5429
5427
|
return;
|
|
5430
5428
|
}
|
|
5431
5429
|
const j = get(C, "unit") !== "" ? get(C, "unit") : h;
|
|
@@ -5436,14 +5434,14 @@ const BlockStylingProps = () => {
|
|
|
5436
5434
|
if (get(C, "value") === "")
|
|
5437
5435
|
return;
|
|
5438
5436
|
const L = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5439
|
-
v ?
|
|
5437
|
+
v ? k(L) : w(L);
|
|
5440
5438
|
},
|
|
5441
|
-
[w,
|
|
5442
|
-
),
|
|
5439
|
+
[w, k, a, h, d, u]
|
|
5440
|
+
), E = useCallback(
|
|
5443
5441
|
(v) => {
|
|
5444
5442
|
const C = getUserInputValues(`${a}`, u);
|
|
5445
5443
|
if (get(C, "error", !1)) {
|
|
5446
|
-
|
|
5444
|
+
x(!0);
|
|
5447
5445
|
return;
|
|
5448
5446
|
}
|
|
5449
5447
|
if (v === "auto" || v === "none") {
|
|
@@ -5486,24 +5484,24 @@ const BlockStylingProps = () => {
|
|
|
5486
5484
|
const C = parseInt$1(v.target.value);
|
|
5487
5485
|
let j = isNaN$1(C) ? 0 : C;
|
|
5488
5486
|
v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
|
|
5489
|
-
const
|
|
5490
|
-
|
|
5487
|
+
const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5488
|
+
k(R);
|
|
5491
5489
|
},
|
|
5492
5490
|
onKeyUp: (v) => {
|
|
5493
|
-
|
|
5491
|
+
B && (v.preventDefault(), N(!1));
|
|
5494
5492
|
},
|
|
5495
5493
|
onBlur: () => S(),
|
|
5496
5494
|
onChange: (v) => {
|
|
5497
|
-
|
|
5495
|
+
x(!1), l(v.target.value);
|
|
5498
5496
|
},
|
|
5499
5497
|
onClick: (v) => {
|
|
5500
5498
|
var C;
|
|
5501
5499
|
(C = v == null ? void 0 : v.target) == null || C.select(), n(!1);
|
|
5502
5500
|
},
|
|
5503
|
-
value: A ?
|
|
5501
|
+
value: A ? y : a,
|
|
5504
5502
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5505
5503
|
" ",
|
|
5506
|
-
|
|
5504
|
+
f ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
5507
5505
|
)
|
|
5508
5506
|
}
|
|
5509
5507
|
),
|
|
@@ -5526,7 +5524,7 @@ const BlockStylingProps = () => {
|
|
|
5526
5524
|
units: u,
|
|
5527
5525
|
current: h,
|
|
5528
5526
|
onSelect: (v) => {
|
|
5529
|
-
n(!1), m(v),
|
|
5527
|
+
n(!1), m(v), E(v);
|
|
5530
5528
|
}
|
|
5531
5529
|
}
|
|
5532
5530
|
) })
|
|
@@ -5535,19 +5533,19 @@ const BlockStylingProps = () => {
|
|
|
5535
5533
|
["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
|
|
5536
5534
|
DragStyleButton,
|
|
5537
5535
|
{
|
|
5538
|
-
onDragStart: () =>
|
|
5536
|
+
onDragStart: () => _(!0),
|
|
5539
5537
|
onDragEnd: (v) => {
|
|
5540
|
-
if (b(() => ""),
|
|
5538
|
+
if (b(() => ""), _(!1), isEmpty(v))
|
|
5541
5539
|
return;
|
|
5542
|
-
const C = `${v}`,
|
|
5543
|
-
w(
|
|
5540
|
+
const C = `${v}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5541
|
+
w(I);
|
|
5544
5542
|
},
|
|
5545
5543
|
onDrag: (v) => {
|
|
5546
5544
|
if (isEmpty(v))
|
|
5547
5545
|
return;
|
|
5548
5546
|
b(v);
|
|
5549
|
-
const C = `${v}`,
|
|
5550
|
-
|
|
5547
|
+
const C = `${v}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5548
|
+
k(I);
|
|
5551
5549
|
},
|
|
5552
5550
|
currentValue: a,
|
|
5553
5551
|
unit: h,
|
|
@@ -5612,8 +5610,8 @@ const COLOR_PROP = {
|
|
|
5612
5610
|
}, ColorChoice = ({ property: o, onChange: r }) => {
|
|
5613
5611
|
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
|
|
5614
5612
|
// eslint-disable-next-line no-shadow
|
|
5615
|
-
(
|
|
5616
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
5613
|
+
(y) => {
|
|
5614
|
+
["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" })));
|
|
5617
5615
|
},
|
|
5618
5616
|
[c, p]
|
|
5619
5617
|
);
|
|
@@ -5622,21 +5620,21 @@ const COLOR_PROP = {
|
|
|
5622
5620
|
return c([]);
|
|
5623
5621
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5624
5622
|
}, [g]);
|
|
5625
|
-
const
|
|
5623
|
+
const f = useCallback(
|
|
5626
5624
|
// eslint-disable-next-line no-shadow
|
|
5627
|
-
(
|
|
5628
|
-
p({ color: g, shade:
|
|
5625
|
+
(y) => {
|
|
5626
|
+
p({ color: g, shade: y });
|
|
5629
5627
|
},
|
|
5630
5628
|
[g]
|
|
5631
5629
|
);
|
|
5632
5630
|
useEffect(() => {
|
|
5633
5631
|
p({ color: "", shade: "" });
|
|
5634
5632
|
}, [n]);
|
|
5635
|
-
const { match:
|
|
5633
|
+
const { match: x } = useTailwindClassList();
|
|
5636
5634
|
return useEffect(() => {
|
|
5637
5635
|
const b = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5638
|
-
|
|
5639
|
-
}, [
|
|
5636
|
+
x(o, b) && r(b, o);
|
|
5637
|
+
}, [x, d, r, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5640
5638
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5641
5639
|
DropDown,
|
|
5642
5640
|
{
|
|
@@ -5676,7 +5674,7 @@ const COLOR_PROP = {
|
|
|
5676
5674
|
]
|
|
5677
5675
|
}
|
|
5678
5676
|
) }),
|
|
5679
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange:
|
|
5677
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
|
|
5680
5678
|
] });
|
|
5681
5679
|
}, EDITOR_ICONS = {
|
|
5682
5680
|
"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" }) }),
|
|
@@ -6010,34 +6008,34 @@ const COLOR_PROP = {
|
|
|
6010
6008
|
"2xl": "1536px"
|
|
6011
6009
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6012
6010
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6013
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(),
|
|
6014
|
-
(
|
|
6015
|
-
const
|
|
6016
|
-
(p || u !== "") && (
|
|
6017
|
-
const v = generateFullClsName(
|
|
6018
|
-
m(
|
|
6011
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
|
|
6012
|
+
(k, S = !0) => {
|
|
6013
|
+
const E = { dark: p, mq: g, mod: u, cls: k, property: l, fullCls: "" };
|
|
6014
|
+
(p || u !== "") && (E.mq = "xs");
|
|
6015
|
+
const v = generateFullClsName(E);
|
|
6016
|
+
m(x, [v], S);
|
|
6019
6017
|
},
|
|
6020
|
-
[
|
|
6018
|
+
[x, p, g, u, l, m]
|
|
6021
6019
|
), A = useCallback(() => {
|
|
6022
|
-
x
|
|
6023
|
-
}, [
|
|
6020
|
+
f(x, [y], !0);
|
|
6021
|
+
}, [x, y, f]), _ = useMemo(() => canChangeClass(h, g), [h, g]);
|
|
6024
6022
|
useEffect(() => {
|
|
6025
|
-
i(
|
|
6026
|
-
}, [
|
|
6027
|
-
const [, ,
|
|
6028
|
-
(
|
|
6029
|
-
|
|
6023
|
+
i(_, h);
|
|
6024
|
+
}, [_, i, h]);
|
|
6025
|
+
const [, , B] = useScreenSizeWidth(), N = useCallback(
|
|
6026
|
+
(k) => {
|
|
6027
|
+
B({
|
|
6030
6028
|
xs: 400,
|
|
6031
6029
|
sm: 640,
|
|
6032
6030
|
md: 800,
|
|
6033
6031
|
lg: 1024,
|
|
6034
6032
|
xl: 1420,
|
|
6035
6033
|
"2xl": 1920
|
|
6036
|
-
}[
|
|
6034
|
+
}[k]);
|
|
6037
6035
|
},
|
|
6038
|
-
[
|
|
6036
|
+
[B]
|
|
6039
6037
|
), w = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
|
|
6040
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6038
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: _, canReset: h && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6041
6039
|
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !w ? "text-foreground" : ""}`, children: r(a) }) }),
|
|
6042
6040
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6043
6041
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
@@ -6057,7 +6055,7 @@ const COLOR_PROP = {
|
|
|
6057
6055
|
n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
6058
6056
|
n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
6059
6057
|
] }),
|
|
6060
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
6058
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : _ && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6061
6059
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6062
6060
|
"button",
|
|
6063
6061
|
{
|
|
@@ -6106,23 +6104,23 @@ const COLOR_PROP = {
|
|
|
6106
6104
|
children: [
|
|
6107
6105
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6108
6106
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6109
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key:
|
|
6107
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6110
6108
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6111
6109
|
"button",
|
|
6112
6110
|
{
|
|
6113
6111
|
type: "button",
|
|
6114
|
-
onClick: () => u(
|
|
6115
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6112
|
+
onClick: () => u(f),
|
|
6113
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6116
6114
|
children: [
|
|
6117
6115
|
React__default.createElement("div", {
|
|
6118
|
-
className: h(
|
|
6116
|
+
className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6119
6117
|
}),
|
|
6120
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6118
|
+
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6121
6119
|
]
|
|
6122
6120
|
}
|
|
6123
6121
|
) }),
|
|
6124
6122
|
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
|
|
6125
|
-
] }) }, `option-${
|
|
6123
|
+
] }) }, `option-${x}`)) })
|
|
6126
6124
|
] }),
|
|
6127
6125
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6128
6126
|
BlockStyle,
|
|
@@ -6277,19 +6275,19 @@ const COLOR_PROP = {
|
|
|
6277
6275
|
canvas: r = !1,
|
|
6278
6276
|
tooltip: n = !0
|
|
6279
6277
|
}) => {
|
|
6280
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS),
|
|
6278
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
|
|
6281
6279
|
u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
|
|
6282
|
-
},
|
|
6280
|
+
}, x = (b) => {
|
|
6283
6281
|
r || l(b), c(b);
|
|
6284
|
-
},
|
|
6282
|
+
}, y = getBreakpointValue(r ? i : a).toLowerCase();
|
|
6285
6283
|
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
|
|
6286
6284
|
BreakpointCard,
|
|
6287
6285
|
{
|
|
6288
6286
|
canvas: r,
|
|
6289
6287
|
...b,
|
|
6290
|
-
onClick:
|
|
6288
|
+
onClick: x,
|
|
6291
6289
|
key: b.breakpoint,
|
|
6292
|
-
currentBreakpoint:
|
|
6290
|
+
currentBreakpoint: y
|
|
6293
6291
|
}
|
|
6294
6292
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
6295
6293
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
@@ -6301,9 +6299,9 @@ const COLOR_PROP = {
|
|
|
6301
6299
|
openDelay: o,
|
|
6302
6300
|
tooltip: n,
|
|
6303
6301
|
...b,
|
|
6304
|
-
onClick:
|
|
6302
|
+
onClick: x,
|
|
6305
6303
|
key: b.breakpoint,
|
|
6306
|
-
currentBreakpoint:
|
|
6304
|
+
currentBreakpoint: y
|
|
6307
6305
|
}
|
|
6308
6306
|
)
|
|
6309
6307
|
) }),
|
|
@@ -6316,7 +6314,7 @@ const COLOR_PROP = {
|
|
|
6316
6314
|
DropdownMenuCheckboxItem,
|
|
6317
6315
|
{
|
|
6318
6316
|
disabled: b.breakpoint === "xs",
|
|
6319
|
-
onCheckedChange: () =>
|
|
6317
|
+
onCheckedChange: () => f(toUpper(b.breakpoint)),
|
|
6320
6318
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6321
6319
|
children: h(b.title)
|
|
6322
6320
|
},
|
|
@@ -6401,8 +6399,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6401
6399
|
(m = d.current) == null || m.focus();
|
|
6402
6400
|
}, []);
|
|
6403
6401
|
const h = (m) => {
|
|
6404
|
-
const { usage:
|
|
6405
|
-
!l &&
|
|
6402
|
+
const { usage: f } = m || {};
|
|
6403
|
+
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6406
6404
|
};
|
|
6407
6405
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
6408
6406
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
|
|
@@ -6457,15 +6455,15 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6457
6455
|
] });
|
|
6458
6456
|
};
|
|
6459
6457
|
function ManualClasses() {
|
|
6460
|
-
var
|
|
6461
|
-
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [
|
|
6462
|
-
const L =
|
|
6463
|
-
u(h, L, !0),
|
|
6464
|
-
}, [
|
|
6465
|
-
const R = L.trim().toLowerCase(),
|
|
6458
|
+
var I;
|
|
6459
|
+
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), A = b.split(" ").filter((L) => !isEmpty(L)), _ = () => {
|
|
6460
|
+
const L = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6461
|
+
u(h, L, !0), x("");
|
|
6462
|
+
}, [B, N] = useState([]), w = ({ value: L }) => {
|
|
6463
|
+
const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
|
|
6466
6464
|
let D = [];
|
|
6467
|
-
if (
|
|
6468
|
-
const [O] =
|
|
6465
|
+
if (T && T.length > 0) {
|
|
6466
|
+
const [O] = T, P = R.replace(O, "");
|
|
6469
6467
|
D = i.search(P).map((M) => ({
|
|
6470
6468
|
...M,
|
|
6471
6469
|
item: { ...M.item, name: O + M.item.name }
|
|
@@ -6473,9 +6471,9 @@ function ManualClasses() {
|
|
|
6473
6471
|
} else
|
|
6474
6472
|
D = i.search(R);
|
|
6475
6473
|
return N(map(D, "item"));
|
|
6476
|
-
},
|
|
6474
|
+
}, k = () => {
|
|
6477
6475
|
N([]);
|
|
6478
|
-
}, S = (L) => L.name,
|
|
6476
|
+
}, S = (L) => L.name, E = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), v = useMemo(
|
|
6479
6477
|
() => ({
|
|
6480
6478
|
ref: o,
|
|
6481
6479
|
autoComplete: "off",
|
|
@@ -6483,19 +6481,19 @@ function ManualClasses() {
|
|
|
6483
6481
|
autoCapitalize: "off",
|
|
6484
6482
|
spellCheck: !1,
|
|
6485
6483
|
placeholder: c("Enter classes separated by space"),
|
|
6486
|
-
value:
|
|
6484
|
+
value: f,
|
|
6487
6485
|
onFocus: (L) => {
|
|
6488
6486
|
setTimeout(() => {
|
|
6489
6487
|
L.target && L.target.select();
|
|
6490
6488
|
}, 0);
|
|
6491
6489
|
},
|
|
6492
6490
|
onKeyDown: (L) => {
|
|
6493
|
-
L.key === "Enter" &&
|
|
6491
|
+
L.key === "Enter" && f.trim() !== "" && _();
|
|
6494
6492
|
},
|
|
6495
|
-
onChange: (L, { newValue: R }) =>
|
|
6493
|
+
onChange: (L, { newValue: R }) => x(R),
|
|
6496
6494
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
6497
6495
|
}),
|
|
6498
|
-
[
|
|
6496
|
+
[f, c, o]
|
|
6499
6497
|
), C = (L) => {
|
|
6500
6498
|
debugger;
|
|
6501
6499
|
const R = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
@@ -6528,11 +6526,11 @@ function ManualClasses() {
|
|
|
6528
6526
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
6529
6527
|
Autosuggest,
|
|
6530
6528
|
{
|
|
6531
|
-
suggestions:
|
|
6529
|
+
suggestions: B,
|
|
6532
6530
|
onSuggestionsFetchRequested: w,
|
|
6533
|
-
onSuggestionsClearRequested:
|
|
6531
|
+
onSuggestionsClearRequested: k,
|
|
6534
6532
|
getSuggestionValue: S,
|
|
6535
|
-
renderSuggestion:
|
|
6533
|
+
renderSuggestion: E,
|
|
6536
6534
|
inputProps: v,
|
|
6537
6535
|
containerProps: {
|
|
6538
6536
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
@@ -6549,8 +6547,8 @@ function ManualClasses() {
|
|
|
6549
6547
|
{
|
|
6550
6548
|
variant: "outline",
|
|
6551
6549
|
className: "h-6 border-border",
|
|
6552
|
-
onClick:
|
|
6553
|
-
disabled:
|
|
6550
|
+
onClick: _,
|
|
6551
|
+
disabled: f.trim() === "",
|
|
6554
6552
|
size: "sm",
|
|
6555
6553
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
6556
6554
|
}
|
|
@@ -6562,16 +6560,16 @@ function ManualClasses() {
|
|
|
6562
6560
|
{
|
|
6563
6561
|
ref: o,
|
|
6564
6562
|
value: r,
|
|
6565
|
-
onChange: (
|
|
6563
|
+
onChange: (T) => n(T.target.value),
|
|
6566
6564
|
onBlur: () => {
|
|
6567
6565
|
C(L);
|
|
6568
6566
|
},
|
|
6569
|
-
onKeyDown: (
|
|
6570
|
-
|
|
6567
|
+
onKeyDown: (T) => {
|
|
6568
|
+
T.key === "Enter" && C(L);
|
|
6571
6569
|
},
|
|
6572
|
-
onFocus: (
|
|
6570
|
+
onFocus: (T) => {
|
|
6573
6571
|
setTimeout(() => {
|
|
6574
|
-
|
|
6572
|
+
T.target.select();
|
|
6575
6573
|
}, 0);
|
|
6576
6574
|
},
|
|
6577
6575
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
|
|
@@ -6581,7 +6579,7 @@ function ManualClasses() {
|
|
|
6581
6579
|
"button",
|
|
6582
6580
|
{
|
|
6583
6581
|
onDoubleClick: () => {
|
|
6584
|
-
|
|
6582
|
+
x(L), g(h, [L]), setTimeout(() => {
|
|
6585
6583
|
o.current && o.current.focus();
|
|
6586
6584
|
}, 10);
|
|
6587
6585
|
},
|
|
@@ -6737,10 +6735,10 @@ function BlockStyling() {
|
|
|
6737
6735
|
const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
|
|
6738
6736
|
let m = parseFloat(i.dragStartValue);
|
|
6739
6737
|
m = isNaN(m) ? 0 : m;
|
|
6740
|
-
let
|
|
6741
|
-
(startsWith(h, "scale") || h === "opacity") && (
|
|
6742
|
-
let
|
|
6743
|
-
g &&
|
|
6738
|
+
let f = MAPPER[i.dragUnit];
|
|
6739
|
+
(startsWith(h, "scale") || h === "opacity") && (f = 10);
|
|
6740
|
+
let y = (i.dragStartY - u.pageY) / f + m;
|
|
6741
|
+
g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
|
|
6744
6742
|
},
|
|
6745
6743
|
[i],
|
|
6746
6744
|
50
|
|
@@ -6783,12 +6781,12 @@ const CoreBlock = ({
|
|
|
6783
6781
|
}) => {
|
|
6784
6782
|
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
|
|
6785
6783
|
if (has(o, "blocks")) {
|
|
6786
|
-
const
|
|
6787
|
-
u(syncBlocksWithDefaults(
|
|
6784
|
+
const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
6785
|
+
u(syncBlocksWithDefaults(y), n || null, a);
|
|
6788
6786
|
} else
|
|
6789
6787
|
p(o, n || null, a);
|
|
6790
6788
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6791
|
-
},
|
|
6789
|
+
}, f = useFeature("dnd"), { t: x } = useTranslation();
|
|
6792
6790
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6793
6791
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6794
6792
|
"button",
|
|
@@ -6796,20 +6794,20 @@ const CoreBlock = ({
|
|
|
6796
6794
|
disabled: r,
|
|
6797
6795
|
onClick: m,
|
|
6798
6796
|
type: "button",
|
|
6799
|
-
onDragStart: (
|
|
6800
|
-
|
|
6797
|
+
onDragStart: (y) => {
|
|
6798
|
+
y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6801
6799
|
g([]), h();
|
|
6802
6800
|
}, 200);
|
|
6803
6801
|
},
|
|
6804
|
-
draggable:
|
|
6802
|
+
draggable: f ? "true" : "false",
|
|
6805
6803
|
className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
|
|
6806
6804
|
children: [
|
|
6807
6805
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6808
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6806
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
|
|
6809
6807
|
]
|
|
6810
6808
|
}
|
|
6811
6809
|
) }),
|
|
6812
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6810
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
|
|
6813
6811
|
] }) });
|
|
6814
6812
|
}, DefaultChaiBlocks = ({
|
|
6815
6813
|
parentId: o,
|
|
@@ -7012,7 +7010,7 @@ const CoreBlock = ({
|
|
|
7012
7010
|
}
|
|
7013
7011
|
}
|
|
7014
7012
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
7015
|
-
var h, m,
|
|
7013
|
+
var h, m, f, x, y, b, A, _, B, N;
|
|
7016
7014
|
if (n.type === "comment") return [];
|
|
7017
7015
|
let a = { _id: generateUUID() };
|
|
7018
7016
|
if (r && (a._parent = r.block._id), n.type === "text")
|
|
@@ -7034,7 +7032,7 @@ const CoreBlock = ({
|
|
|
7034
7032
|
...getAttrs(n),
|
|
7035
7033
|
...getStyles(n)
|
|
7036
7034
|
}, n.attributes) {
|
|
7037
|
-
const w = n.attributes.find((
|
|
7035
|
+
const w = n.attributes.find((k) => includes(NAME_ATTRIBUTES, k.key));
|
|
7038
7036
|
w && (a._name = w.value);
|
|
7039
7037
|
}
|
|
7040
7038
|
if (i)
|
|
@@ -7052,30 +7050,30 @@ const CoreBlock = ({
|
|
|
7052
7050
|
];
|
|
7053
7051
|
a = {
|
|
7054
7052
|
...a,
|
|
7055
|
-
href: ((h = l.find((
|
|
7056
|
-
hrefType: ((m = l.find((
|
|
7057
|
-
autoplay: ((
|
|
7058
|
-
maxWidth: ((
|
|
7059
|
-
backdropColor: ((b = l.find((
|
|
7060
|
-
galleryName: ((A = l.find((
|
|
7061
|
-
}, forEach(w, (
|
|
7062
|
-
has(a, `styles_attrs.${
|
|
7053
|
+
href: ((h = l.find((k) => k.key === "href")) == null ? void 0 : h.value) || "",
|
|
7054
|
+
hrefType: ((m = l.find((k) => k.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
|
|
7055
|
+
autoplay: ((f = l.find((k) => k.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
7056
|
+
maxWidth: ((y = (x = l.find((k) => k.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
|
|
7057
|
+
backdropColor: ((b = l.find((k) => k.key === "data-overlay")) == null ? void 0 : b.value) || "",
|
|
7058
|
+
galleryName: ((A = l.find((k) => k.key === "data-gall")) == null ? void 0 : A.value) || ""
|
|
7059
|
+
}, forEach(w, (k) => {
|
|
7060
|
+
has(a, `styles_attrs.${k}`) && delete a.styles_attrs[k];
|
|
7063
7061
|
});
|
|
7064
7062
|
}
|
|
7065
7063
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
7066
7064
|
delete a.styles_attrs;
|
|
7067
7065
|
const w = filter(n.children || [], (S) => (S == null ? void 0 : S.tagName) !== "span");
|
|
7068
7066
|
a.content = getTextContent(w);
|
|
7069
|
-
const
|
|
7067
|
+
const k = find(
|
|
7070
7068
|
n.children || [],
|
|
7071
|
-
(S) => (S == null ? void 0 : S.tagName) === "span" && some(S.children || [], (
|
|
7069
|
+
(S) => (S == null ? void 0 : S.tagName) === "span" && some(S.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg")
|
|
7072
7070
|
);
|
|
7073
|
-
if (
|
|
7074
|
-
const S = find(
|
|
7071
|
+
if (k) {
|
|
7072
|
+
const S = find(k.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg");
|
|
7075
7073
|
if (S) {
|
|
7076
7074
|
a.icon = stringify([S]);
|
|
7077
|
-
const { height:
|
|
7078
|
-
a.iconHeight =
|
|
7075
|
+
const { height: E, width: v } = getSvgDimensions(S, "16px", "16px");
|
|
7076
|
+
a.iconHeight = E, a.iconWidth = v;
|
|
7079
7077
|
}
|
|
7080
7078
|
}
|
|
7081
7079
|
return [a];
|
|
@@ -7087,14 +7085,14 @@ const CoreBlock = ({
|
|
|
7087
7085
|
const w = stringify([n]);
|
|
7088
7086
|
return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
|
|
7089
7087
|
} else if (n.tagName === "svg") {
|
|
7090
|
-
const w = get(find(n.attributes, { key: "class" }), "value", ""), { height:
|
|
7091
|
-
if (
|
|
7092
|
-
a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${
|
|
7088
|
+
const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: k, width: S } = getHeightAndWidthFromClass(w);
|
|
7089
|
+
if (k && S)
|
|
7090
|
+
a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${k}`, w)}`.trim(), a.height = k == null ? void 0 : k.replace("px", ""), a.width = S == null ? void 0 : S.replace("px", "");
|
|
7093
7091
|
else {
|
|
7094
|
-
const
|
|
7095
|
-
|
|
7092
|
+
const E = (_ = find(n.attributes, { key: "height" })) == null ? void 0 : _.value, v = (B = find(n.attributes, { key: "width" })) == null ? void 0 : B.value;
|
|
7093
|
+
E && v ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${v}px] h-[${E}px]`, w)}`.trim(), a.height = E, a.width = v) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
|
|
7096
7094
|
}
|
|
7097
|
-
return n.attributes = filter(n.attributes, (
|
|
7095
|
+
return n.attributes = filter(n.attributes, (E) => !includes(["style", "width", "height", "class"], E.key)), a.icon = stringify([n]), [a];
|
|
7098
7096
|
} else if (n.tagName == "option" && r && ((N = r.block) == null ? void 0 : N._type) === "Select")
|
|
7099
7097
|
return r.block.options.push({
|
|
7100
7098
|
label: getTextContent(n.children),
|
|
@@ -7211,18 +7209,18 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7211
7209
|
parentId: n = void 0,
|
|
7212
7210
|
position: a = -1
|
|
7213
7211
|
}) => {
|
|
7214
|
-
const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""),
|
|
7215
|
-
const
|
|
7216
|
-
return
|
|
7212
|
+
const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (_) => {
|
|
7213
|
+
const B = has(_, "styles_attrs.data-page-section");
|
|
7214
|
+
return _._type === "Box" && B;
|
|
7217
7215
|
}, b = useCallback(
|
|
7218
|
-
async (
|
|
7219
|
-
if (
|
|
7216
|
+
async (_) => {
|
|
7217
|
+
if (_.stopPropagation(), has(o, "component")) {
|
|
7220
7218
|
d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7221
7219
|
return;
|
|
7222
7220
|
}
|
|
7223
7221
|
i(!0);
|
|
7224
|
-
let
|
|
7225
|
-
typeof
|
|
7222
|
+
let B = await c({ library: r, block: o });
|
|
7223
|
+
typeof B == "string" && (B = getBlocksFromHTML(B)), isEmpty(B) || p(syncBlocksWithDefaults(B), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7226
7224
|
},
|
|
7227
7225
|
[d, p, o, c, r, n, a]
|
|
7228
7226
|
);
|
|
@@ -7232,20 +7230,20 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7232
7230
|
{
|
|
7233
7231
|
onClick: l ? () => {
|
|
7234
7232
|
} : b,
|
|
7235
|
-
draggable:
|
|
7236
|
-
onDragStart: async (
|
|
7237
|
-
const
|
|
7233
|
+
draggable: f ? "true" : "false",
|
|
7234
|
+
onDragStart: async (_) => {
|
|
7235
|
+
const B = await c({ library: r, block: o });
|
|
7238
7236
|
let N = n;
|
|
7239
|
-
if (
|
|
7240
|
-
const w = { blocks:
|
|
7241
|
-
if (
|
|
7242
|
-
const
|
|
7243
|
-
|
|
7244
|
-
|
|
7237
|
+
if (y(first(B)) && (N = null), !isEmpty(B)) {
|
|
7238
|
+
const w = { blocks: B, uiLibrary: !0, parent: N };
|
|
7239
|
+
if (_.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
|
|
7240
|
+
const k = new Image();
|
|
7241
|
+
k.src = o.preview, k.onload = () => {
|
|
7242
|
+
_.dataTransfer.setDragImage(k, 0, 0);
|
|
7245
7243
|
};
|
|
7246
7244
|
} else
|
|
7247
|
-
|
|
7248
|
-
|
|
7245
|
+
_.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7246
|
+
x(w), setTimeout(() => {
|
|
7249
7247
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7250
7248
|
}, 200);
|
|
7251
7249
|
}
|
|
@@ -7271,37 +7269,37 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7271
7269
|
] }) })
|
|
7272
7270
|
] });
|
|
7273
7271
|
}, UILibrarySection = ({ parentId: o, position: r }) => {
|
|
7274
|
-
const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((C) => C.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]),
|
|
7272
|
+
const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((C) => C.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
|
|
7275
7273
|
useEffect(() => {
|
|
7276
|
-
c && c.length > 0 && (
|
|
7274
|
+
c && c.length > 0 && (f.current = new Fuse(c, {
|
|
7277
7275
|
keys: ["name", "label", "description", "group"],
|
|
7278
7276
|
threshold: 0.4,
|
|
7279
7277
|
ignoreLocation: !0
|
|
7280
7278
|
}));
|
|
7281
7279
|
}, [c]), useEffect(() => {
|
|
7282
|
-
if (!u.trim() || !
|
|
7280
|
+
if (!u.trim() || !f.current) {
|
|
7283
7281
|
m([]);
|
|
7284
7282
|
return;
|
|
7285
7283
|
}
|
|
7286
|
-
const C =
|
|
7284
|
+
const C = f.current.search(u).map((j) => j.item);
|
|
7287
7285
|
m(C);
|
|
7288
7286
|
}, [u]);
|
|
7289
|
-
const
|
|
7287
|
+
const x = u.trim() && !isEmpty(h) ? h : c, y = groupBy(x, "group"), [b, A] = useState(null);
|
|
7290
7288
|
useEffect(() => {
|
|
7291
|
-
if (isEmpty(keys(
|
|
7289
|
+
if (isEmpty(keys(y))) {
|
|
7292
7290
|
A(null);
|
|
7293
7291
|
return;
|
|
7294
7292
|
}
|
|
7295
|
-
if (!b || !
|
|
7296
|
-
A(first(keys(
|
|
7293
|
+
if (!b || !y[b]) {
|
|
7294
|
+
A(first(keys(y)));
|
|
7297
7295
|
return;
|
|
7298
7296
|
}
|
|
7299
|
-
}, [
|
|
7300
|
-
const
|
|
7301
|
-
|
|
7302
|
-
|
|
7297
|
+
}, [y, b]);
|
|
7298
|
+
const _ = get(y, b, []), B = useRef(null), { t: N } = useTranslation(), w = (C) => {
|
|
7299
|
+
B.current && (clearTimeout(B.current), B.current = null), B.current = setTimeout(() => {
|
|
7300
|
+
B.current && A(C);
|
|
7303
7301
|
}, 400);
|
|
7304
|
-
},
|
|
7302
|
+
}, k = () => {
|
|
7305
7303
|
i != null && i.id && p(i.id);
|
|
7306
7304
|
}, S = () => {
|
|
7307
7305
|
g("");
|
|
@@ -7311,7 +7309,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7311
7309
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7312
7310
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7313
7311
|
] });
|
|
7314
|
-
const
|
|
7312
|
+
const E = filter(_, (C, j) => j % 2 === 0), v = filter(_, (C, j) => j % 2 === 1);
|
|
7315
7313
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7316
7314
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7317
7315
|
/* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
@@ -7339,17 +7337,17 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7339
7337
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7340
7338
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: N("Groups") }),
|
|
7341
7339
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7342
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(
|
|
7340
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7343
7341
|
/* @__PURE__ */ jsx("p", { className: "text-sm", children: N("Failed to load the UI library. Try again") }),
|
|
7344
|
-
/* @__PURE__ */ jsxs(Button, { onClick:
|
|
7342
|
+
/* @__PURE__ */ jsxs(Button, { onClick: k, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7345
7343
|
/* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
|
|
7346
7344
|
N("Retry")
|
|
7347
7345
|
] })
|
|
7348
|
-
] }) }) : map(
|
|
7346
|
+
] }) }) : map(y, (C, j) => /* @__PURE__ */ jsxs(
|
|
7349
7347
|
"div",
|
|
7350
7348
|
{
|
|
7351
7349
|
onMouseEnter: () => w(j),
|
|
7352
|
-
onMouseLeave: () => clearTimeout(
|
|
7350
|
+
onMouseLeave: () => clearTimeout(B.current),
|
|
7353
7351
|
role: "button",
|
|
7354
7352
|
onClick: () => A(j),
|
|
7355
7353
|
className: cn$2(
|
|
@@ -7368,11 +7366,11 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7368
7366
|
/* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
|
|
7369
7367
|
ScrollArea,
|
|
7370
7368
|
{
|
|
7371
|
-
onMouseEnter: () =>
|
|
7369
|
+
onMouseEnter: () => B.current ? clearTimeout(B.current) : null,
|
|
7372
7370
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7373
7371
|
children: [
|
|
7374
|
-
isEmpty(
|
|
7375
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7372
|
+
isEmpty(_) && !isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
|
|
7373
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: E.map((C, j) => /* @__PURE__ */ jsx(
|
|
7376
7374
|
BlockCard,
|
|
7377
7375
|
{
|
|
7378
7376
|
parentId: o,
|
|
@@ -7426,25 +7424,25 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7426
7424
|
error: c
|
|
7427
7425
|
}), g(!0);
|
|
7428
7426
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7429
|
-
const m = Object.entries(a).map(([
|
|
7430
|
-
const b =
|
|
7427
|
+
const m = Object.entries(a).map(([x, y]) => {
|
|
7428
|
+
const b = y, A = b.type || "partial", _ = formatReadableName(A);
|
|
7431
7429
|
return {
|
|
7432
7430
|
type: "PartialBlock",
|
|
7433
7431
|
// Set the type to PartialBlock
|
|
7434
|
-
label: formatReadableName(b.name ||
|
|
7432
|
+
label: formatReadableName(b.name || x),
|
|
7435
7433
|
description: b.description || "",
|
|
7436
7434
|
icon: Globe,
|
|
7437
|
-
group:
|
|
7435
|
+
group: _,
|
|
7438
7436
|
// Use formatted type as group
|
|
7439
7437
|
category: "partial",
|
|
7440
|
-
partialBlockId:
|
|
7438
|
+
partialBlockId: x,
|
|
7441
7439
|
// Store the original ID as partialBlockId
|
|
7442
7440
|
_name: b.name
|
|
7443
7441
|
};
|
|
7444
|
-
}),
|
|
7442
|
+
}), f = uniq(map(m, "group"));
|
|
7445
7443
|
p({
|
|
7446
7444
|
blocks: m,
|
|
7447
|
-
groups:
|
|
7445
|
+
groups: f,
|
|
7448
7446
|
isLoading: !1,
|
|
7449
7447
|
error: null
|
|
7450
7448
|
}), g(!0);
|
|
@@ -7490,7 +7488,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7490
7488
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
|
|
7491
7489
|
}, 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" }) => {
|
|
7492
7490
|
var v;
|
|
7493
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (C) => C._id === n)) == null ? void 0 : v._type, [m,
|
|
7491
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (C) => C._id === n)) == null ? void 0 : v._type, [m, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
|
|
7494
7492
|
useEffect(() => {
|
|
7495
7493
|
const C = setTimeout(() => {
|
|
7496
7494
|
var j;
|
|
@@ -7498,23 +7496,23 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7498
7496
|
}, 0);
|
|
7499
7497
|
return () => clearTimeout(C);
|
|
7500
7498
|
}, [g]), useEffect(() => {
|
|
7501
|
-
d && (
|
|
7499
|
+
d && (f("all"), y(null));
|
|
7502
7500
|
}, [d]), useEffect(() => (b.current = debounce((C) => {
|
|
7503
|
-
|
|
7501
|
+
f(C);
|
|
7504
7502
|
}, 500), () => {
|
|
7505
7503
|
b.current && b.current.cancel();
|
|
7506
7504
|
}), []);
|
|
7507
7505
|
const A = useCallback((C) => {
|
|
7508
|
-
|
|
7509
|
-
}, []),
|
|
7510
|
-
|
|
7511
|
-
}, []),
|
|
7512
|
-
b.current && b.current.cancel(),
|
|
7506
|
+
y(C), b.current && b.current(C);
|
|
7507
|
+
}, []), _ = useCallback(() => {
|
|
7508
|
+
y(null), b.current && b.current.cancel();
|
|
7509
|
+
}, []), B = useCallback((C) => {
|
|
7510
|
+
b.current && b.current.cancel(), f(C), y(null);
|
|
7513
7511
|
}, []), N = useMemo(
|
|
7514
7512
|
() => d ? values(r).filter(
|
|
7515
7513
|
(C) => {
|
|
7516
|
-
var j,
|
|
7517
|
-
return (((j = C.label) == null ? void 0 : j.toLowerCase()) + " " + ((
|
|
7514
|
+
var j, I;
|
|
7515
|
+
return (((j = C.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = C.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
|
|
7518
7516
|
}
|
|
7519
7517
|
) : r,
|
|
7520
7518
|
[r, d]
|
|
@@ -7523,10 +7521,10 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7523
7521
|
(C) => reject(filter(values(N), { group: C }), { hidden: !0 }).length > 0
|
|
7524
7522
|
) : o.filter((C) => reject(filter(values(r), { group: C }), { hidden: !0 }).length > 0),
|
|
7525
7523
|
[r, N, o, d]
|
|
7526
|
-
),
|
|
7524
|
+
), k = useMemo(
|
|
7527
7525
|
() => sortBy(w, (C) => CORE_GROUPS.indexOf(C) === -1 ? 99 : CORE_GROUPS.indexOf(C)),
|
|
7528
7526
|
[w]
|
|
7529
|
-
), S = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]),
|
|
7527
|
+
), S = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), E = useMemo(() => m === "all" ? k : [m], [k, m]);
|
|
7530
7528
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7531
7529
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7532
7530
|
Input$1,
|
|
@@ -7540,25 +7538,25 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7540
7538
|
}
|
|
7541
7539
|
) }),
|
|
7542
7540
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7543
|
-
|
|
7541
|
+
k.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
7544
7542
|
/* @__PURE__ */ jsx(
|
|
7545
7543
|
"button",
|
|
7546
7544
|
{
|
|
7547
|
-
onClick: () =>
|
|
7545
|
+
onClick: () => B("all"),
|
|
7548
7546
|
onMouseEnter: () => A("all"),
|
|
7549
|
-
onMouseLeave:
|
|
7550
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" ||
|
|
7547
|
+
onMouseLeave: _,
|
|
7548
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7551
7549
|
children: i("All")
|
|
7552
7550
|
},
|
|
7553
7551
|
"sidebar-all"
|
|
7554
7552
|
),
|
|
7555
|
-
|
|
7553
|
+
k.map((C) => /* @__PURE__ */ jsx(
|
|
7556
7554
|
"button",
|
|
7557
7555
|
{
|
|
7558
|
-
onClick: () =>
|
|
7556
|
+
onClick: () => B(C),
|
|
7559
7557
|
onMouseEnter: () => A(C),
|
|
7560
|
-
onMouseLeave:
|
|
7561
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === C ||
|
|
7558
|
+
onMouseLeave: _,
|
|
7559
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === C || x === C ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7562
7560
|
children: capitalize(i(C.toLowerCase()))
|
|
7563
7561
|
},
|
|
7564
7562
|
`sidebar-${C}`
|
|
@@ -7569,7 +7567,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7569
7567
|
' "',
|
|
7570
7568
|
d,
|
|
7571
7569
|
'"'
|
|
7572
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children:
|
|
7570
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: E.map((C) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7573
7571
|
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(C.toLowerCase())) }),
|
|
7574
7572
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7575
7573
|
m === "all" ? filter(values(S), { group: C }) : values(S),
|
|
@@ -7599,7 +7597,7 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7599
7597
|
}, [i, g, c]);
|
|
7600
7598
|
const m = useCallback(() => {
|
|
7601
7599
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7602
|
-
}, []),
|
|
7600
|
+
}, []), f = useChaiAddBlockTabs(), x = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
|
|
7603
7601
|
return useEffect(() => {
|
|
7604
7602
|
i === "library" && !b && c("core");
|
|
7605
7603
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7620,14 +7618,14 @@ const registerChaiLibrary = (o, r) => {
|
|
|
7620
7618
|
b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7621
7619
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7622
7620
|
g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7623
|
-
|
|
7624
|
-
map(
|
|
7621
|
+
x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7622
|
+
map(f, (A) => /* @__PURE__ */ jsx(TabsTrigger, { value: A.id, children: React__default.createElement(A.tab) }, `tab-add-block-${A.id}`))
|
|
7625
7623
|
] }),
|
|
7626
7624
|
/* @__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 }) }) }) }),
|
|
7627
7625
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
|
|
7628
7626
|
g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
|
|
7629
|
-
|
|
7630
|
-
map(
|
|
7627
|
+
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,
|
|
7628
|
+
map(f, (A) => /* @__PURE__ */ jsx(TabsContent, { value: A.id, children: React__default.createElement(A.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${A.id}`))
|
|
7631
7629
|
]
|
|
7632
7630
|
}
|
|
7633
7631
|
)
|
|
@@ -7937,35 +7935,35 @@ const Input = ({ node: o }) => {
|
|
|
7937
7935
|
var R;
|
|
7938
7936
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7939
7937
|
let p = null;
|
|
7940
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data:
|
|
7941
|
-
|
|
7942
|
-
}, N = (
|
|
7943
|
-
|
|
7944
|
-
}, w = (
|
|
7945
|
-
|
|
7946
|
-
}, [
|
|
7947
|
-
var
|
|
7948
|
-
v(), o.parent.isSelected || S((
|
|
7938
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: A, handleClick: _ } = o, B = (T) => {
|
|
7939
|
+
T.stopPropagation(), !l.includes(m) && o.toggle();
|
|
7940
|
+
}, N = (T) => {
|
|
7941
|
+
T.isInternal && (p = T.isOpen, T.isOpen && T.close());
|
|
7942
|
+
}, w = (T) => {
|
|
7943
|
+
T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
|
|
7944
|
+
}, [k, S] = useAtom$1(currentAddSelection), E = () => {
|
|
7945
|
+
var T;
|
|
7946
|
+
v(), o.parent.isSelected || S((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
|
|
7949
7947
|
}, v = () => {
|
|
7950
7948
|
S(null);
|
|
7951
|
-
}, C = (
|
|
7952
|
-
v(),
|
|
7949
|
+
}, C = (T) => {
|
|
7950
|
+
v(), T.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), _(T);
|
|
7953
7951
|
};
|
|
7954
7952
|
useEffect(() => {
|
|
7955
|
-
const
|
|
7956
|
-
|
|
7953
|
+
const T = setTimeout(() => {
|
|
7954
|
+
y && !o.isOpen && !b && !l.includes(m) && o.toggle();
|
|
7957
7955
|
}, 500);
|
|
7958
|
-
return () => clearTimeout(
|
|
7959
|
-
}, [
|
|
7960
|
-
const j = (
|
|
7961
|
-
const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${
|
|
7956
|
+
return () => clearTimeout(T);
|
|
7957
|
+
}, [y, o, b]);
|
|
7958
|
+
const j = (T, D) => {
|
|
7959
|
+
const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
|
|
7962
7960
|
P && P.setAttribute("data-drop", D);
|
|
7963
7961
|
const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
|
|
7964
7962
|
$.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
|
|
7965
|
-
},
|
|
7963
|
+
}, I = (T) => {
|
|
7966
7964
|
v();
|
|
7967
7965
|
const D = get(o, "parent.id");
|
|
7968
|
-
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position:
|
|
7966
|
+
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
|
|
7969
7967
|
};
|
|
7970
7968
|
if (m === ROOT_TEMP_KEY)
|
|
7971
7969
|
return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
@@ -7974,7 +7972,7 @@ const Input = ({ node: o }) => {
|
|
|
7974
7972
|
"div",
|
|
7975
7973
|
{
|
|
7976
7974
|
role: "button",
|
|
7977
|
-
onClick: () =>
|
|
7975
|
+
onClick: () => I(-1),
|
|
7978
7976
|
className: "h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",
|
|
7979
7977
|
children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-[9px] leading-tight text-white hover:bg-primary", children: [
|
|
7980
7978
|
/* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7985,7 +7983,7 @@ const Input = ({ node: o }) => {
|
|
|
7985
7983
|
),
|
|
7986
7984
|
/* @__PURE__ */ jsx("br", {})
|
|
7987
7985
|
] });
|
|
7988
|
-
const L = useMemo(() => has(
|
|
7986
|
+
const L = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, d]);
|
|
7989
7987
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7990
7988
|
"div",
|
|
7991
7989
|
{
|
|
@@ -7997,23 +7995,23 @@ const Input = ({ node: o }) => {
|
|
|
7997
7995
|
ref: l.includes(m) ? null : n,
|
|
7998
7996
|
onDragStart: () => N(o),
|
|
7999
7997
|
onDragEnd: () => w(o),
|
|
8000
|
-
onDragOver: (
|
|
8001
|
-
|
|
7998
|
+
onDragOver: (T) => {
|
|
7999
|
+
T.preventDefault(), j(m, "yes");
|
|
8002
8000
|
},
|
|
8003
|
-
onDragLeave: (
|
|
8004
|
-
|
|
8001
|
+
onDragLeave: (T) => {
|
|
8002
|
+
T.preventDefault(), j(m, "no");
|
|
8005
8003
|
},
|
|
8006
|
-
onDrop: (
|
|
8007
|
-
|
|
8004
|
+
onDrop: (T) => {
|
|
8005
|
+
T.preventDefault(), j(m, "no");
|
|
8008
8006
|
},
|
|
8009
8007
|
children: [
|
|
8010
8008
|
d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
8011
8009
|
"div",
|
|
8012
8010
|
{
|
|
8013
|
-
onClick: (
|
|
8014
|
-
|
|
8011
|
+
onClick: (T) => {
|
|
8012
|
+
T.stopPropagation(), I(o.childIndex);
|
|
8015
8013
|
},
|
|
8016
|
-
onMouseEnter:
|
|
8014
|
+
onMouseEnter: E,
|
|
8017
8015
|
onMouseLeave: v,
|
|
8018
8016
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
8019
8017
|
children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
|
|
@@ -8024,12 +8022,12 @@ const Input = ({ node: o }) => {
|
|
|
8024
8022
|
{
|
|
8025
8023
|
className: cn(
|
|
8026
8024
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
(o == null ? void 0 : o.id) ===
|
|
8025
|
+
x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
|
|
8026
|
+
y && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
|
|
8027
|
+
(o == null ? void 0 : o.id) === k ? "bg-primary/10" : "",
|
|
8030
8028
|
b && "opacity-20",
|
|
8031
8029
|
l.includes(m) ? "opacity-50" : "",
|
|
8032
|
-
L &&
|
|
8030
|
+
L && x && "bg-primary/20 text-primary"
|
|
8033
8031
|
),
|
|
8034
8032
|
children: [
|
|
8035
8033
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -8037,7 +8035,7 @@ const Input = ({ node: o }) => {
|
|
|
8037
8035
|
"div",
|
|
8038
8036
|
{
|
|
8039
8037
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
8040
|
-
children: u && /* @__PURE__ */ jsx("button", { onClick:
|
|
8038
|
+
children: u && /* @__PURE__ */ jsx("button", { onClick: B, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-white" : "text-slate-400"}` }) })
|
|
8041
8039
|
}
|
|
8042
8040
|
),
|
|
8043
8041
|
/* @__PURE__ */ jsxs(
|
|
@@ -8046,18 +8044,18 @@ const Input = ({ node: o }) => {
|
|
|
8046
8044
|
className: cn(
|
|
8047
8045
|
"leading-1 flex items-center",
|
|
8048
8046
|
L && "text-primary/60",
|
|
8049
|
-
L &&
|
|
8047
|
+
L && x && "text-primary/80"
|
|
8050
8048
|
),
|
|
8051
8049
|
children: [
|
|
8052
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
8050
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
|
|
8053
8051
|
A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
|
|
8054
8052
|
"div",
|
|
8055
8053
|
{
|
|
8056
8054
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
8057
|
-
onDoubleClick: (
|
|
8058
|
-
|
|
8055
|
+
onDoubleClick: (T) => {
|
|
8056
|
+
T.stopPropagation(), o.edit(), o.deselect();
|
|
8059
8057
|
},
|
|
8060
|
-
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(
|
|
8058
|
+
children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(f) })
|
|
8061
8059
|
}
|
|
8062
8060
|
)
|
|
8063
8061
|
]
|
|
@@ -8065,7 +8063,7 @@ const Input = ({ node: o }) => {
|
|
|
8065
8063
|
)
|
|
8066
8064
|
] }),
|
|
8067
8065
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
8068
|
-
canAddChildBlock(
|
|
8066
|
+
canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8069
8067
|
/* @__PURE__ */ jsx(
|
|
8070
8068
|
TooltipTrigger,
|
|
8071
8069
|
{
|
|
@@ -8081,8 +8079,8 @@ const Input = ({ node: o }) => {
|
|
|
8081
8079
|
/* @__PURE__ */ jsx(
|
|
8082
8080
|
TooltipTrigger,
|
|
8083
8081
|
{
|
|
8084
|
-
onClick: (
|
|
8085
|
-
|
|
8082
|
+
onClick: (T) => {
|
|
8083
|
+
T.stopPropagation(), i(m), o.isOpen && o.toggle();
|
|
8086
8084
|
},
|
|
8087
8085
|
className: "cursor-pointer rounded bg-transparent",
|
|
8088
8086
|
asChild: !0,
|
|
@@ -8370,17 +8368,17 @@ const Input = ({ node: o }) => {
|
|
|
8370
8368
|
console.warn("Failed to clear previous theme from localStorage:", o);
|
|
8371
8369
|
}
|
|
8372
8370
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8373
|
-
const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), [g, h] = useTheme(), m = useThemeOptions(), { t:
|
|
8371
|
+
const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), [g, h] = useTheme(), m = useThemeOptions(), { t: f } = useTranslation(), x = React.useCallback(
|
|
8374
8372
|
(w) => {
|
|
8375
|
-
const
|
|
8376
|
-
setPreviousTheme(
|
|
8373
|
+
const k = { ...g };
|
|
8374
|
+
setPreviousTheme(k), h(w), toast.success("Theme updated", {
|
|
8377
8375
|
action: {
|
|
8378
8376
|
label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8379
8377
|
/* @__PURE__ */ jsx(Undo$1, { className: "h-4 w-4" }),
|
|
8380
8378
|
" Undo"
|
|
8381
8379
|
] }),
|
|
8382
8380
|
onClick: () => {
|
|
8383
|
-
h(
|
|
8381
|
+
h(k), clearPreviousTheme(), toast.dismiss();
|
|
8384
8382
|
}
|
|
8385
8383
|
},
|
|
8386
8384
|
closeButton: !0,
|
|
@@ -8388,28 +8386,28 @@ const Input = ({ node: o }) => {
|
|
|
8388
8386
|
});
|
|
8389
8387
|
},
|
|
8390
8388
|
[g, h]
|
|
8391
|
-
),
|
|
8392
|
-
const w = d.find((
|
|
8389
|
+
), y = () => {
|
|
8390
|
+
const w = d.find((k) => Object.keys(k)[0] === a);
|
|
8393
8391
|
if (w) {
|
|
8394
|
-
const
|
|
8395
|
-
|
|
8392
|
+
const k = Object.values(w)[0];
|
|
8393
|
+
k && typeof k == "object" && "fontFamily" in k && "borderRadius" in k && "colors" in k ? (x(k), l("")) : console.error("Invalid preset structure:", k);
|
|
8396
8394
|
} else
|
|
8397
8395
|
console.error("Preset not found:", a);
|
|
8398
8396
|
}, b = (w) => {
|
|
8399
|
-
|
|
8397
|
+
x(w), l("");
|
|
8400
8398
|
}, A = useDebouncedCallback(
|
|
8401
|
-
(w,
|
|
8399
|
+
(w, k) => {
|
|
8402
8400
|
h(() => ({
|
|
8403
8401
|
...g,
|
|
8404
8402
|
fontFamily: {
|
|
8405
8403
|
...g.fontFamily,
|
|
8406
|
-
[w.replace(/font-/g, "")]:
|
|
8404
|
+
[w.replace(/font-/g, "")]: k
|
|
8407
8405
|
}
|
|
8408
8406
|
}));
|
|
8409
8407
|
},
|
|
8410
8408
|
[g],
|
|
8411
8409
|
200
|
|
8412
|
-
),
|
|
8410
|
+
), _ = React.useCallback(
|
|
8413
8411
|
(w) => {
|
|
8414
8412
|
h(() => ({
|
|
8415
8413
|
...g,
|
|
@@ -8417,11 +8415,11 @@ const Input = ({ node: o }) => {
|
|
|
8417
8415
|
}));
|
|
8418
8416
|
},
|
|
8419
8417
|
[g]
|
|
8420
|
-
),
|
|
8421
|
-
(w,
|
|
8418
|
+
), B = useDebouncedCallback(
|
|
8419
|
+
(w, k) => {
|
|
8422
8420
|
h(() => {
|
|
8423
8421
|
const S = get(g, `colors.${w}`);
|
|
8424
|
-
return r ? set(S, 1,
|
|
8422
|
+
return r ? set(S, 1, k) : set(S, 0, k), {
|
|
8425
8423
|
...g,
|
|
8426
8424
|
colors: {
|
|
8427
8425
|
...g.colors,
|
|
@@ -8432,38 +8430,38 @@ const Input = ({ node: o }) => {
|
|
|
8432
8430
|
},
|
|
8433
8431
|
[g],
|
|
8434
8432
|
200
|
|
8435
|
-
), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([
|
|
8436
|
-
const S = get(g, `colors.${
|
|
8433
|
+
), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([k]) => {
|
|
8434
|
+
const S = get(g, `colors.${k}.${r ? 1 : 0}`);
|
|
8437
8435
|
return S ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8438
8436
|
/* @__PURE__ */ jsx(
|
|
8439
8437
|
ColorPickerInput,
|
|
8440
8438
|
{
|
|
8441
8439
|
value: S,
|
|
8442
|
-
onChange: (
|
|
8440
|
+
onChange: (E) => B(k, E)
|
|
8443
8441
|
}
|
|
8444
8442
|
),
|
|
8445
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children:
|
|
8446
|
-
] },
|
|
8443
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: k.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!k.toLowerCase().includes("foreground") && !k.toLowerCase().includes("border") && !k.toLowerCase().includes("input") && !k.toLowerCase().includes("ring") && !k.toLowerCase().includes("background") ? " Background" : "") })
|
|
8444
|
+
] }, k) : null;
|
|
8447
8445
|
}) });
|
|
8448
8446
|
return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8449
8447
|
/* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8450
8448
|
d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
|
|
8451
8449
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
8452
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm", children:
|
|
8450
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: f("Presets") }),
|
|
8453
8451
|
/* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
|
|
8454
8452
|
/* @__PURE__ */ jsx(ImportIcon, { className: "h-4 w-4" }),
|
|
8455
|
-
|
|
8453
|
+
f("Import theme")
|
|
8456
8454
|
] }) })
|
|
8457
8455
|
] }),
|
|
8458
8456
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
|
|
8459
8457
|
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
|
|
8460
8458
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
|
|
8461
8459
|
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
|
|
8462
|
-
const
|
|
8463
|
-
return /* @__PURE__ */ jsx(SelectItem, { value:
|
|
8460
|
+
const k = Object.keys(w)[0], S = k.replaceAll("_", " ");
|
|
8461
|
+
return /* @__PURE__ */ jsx(SelectItem, { value: k, children: capitalize(S) }, k);
|
|
8464
8462
|
}) })
|
|
8465
8463
|
] }) }),
|
|
8466
|
-
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick:
|
|
8464
|
+
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children: f("Apply") }) })
|
|
8467
8465
|
] })
|
|
8468
8466
|
] }),
|
|
8469
8467
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
@@ -8472,11 +8470,11 @@ const Input = ({ node: o }) => {
|
|
|
8472
8470
|
/* @__PURE__ */ jsx(Type, { className: "h-3 w-3 text-gray-600" }),
|
|
8473
8471
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
|
|
8474
8472
|
] }),
|
|
8475
|
-
(m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w,
|
|
8473
|
+
(m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w, k]) => /* @__PURE__ */ jsx(
|
|
8476
8474
|
FontSelector,
|
|
8477
8475
|
{
|
|
8478
8476
|
label: w,
|
|
8479
|
-
value: g.fontFamily[w.replace(/font-/g, "")] ||
|
|
8477
|
+
value: g.fontFamily[w.replace(/font-/g, "")] || k[Object.keys(k)[0]],
|
|
8480
8478
|
onChange: (S) => A(w, S)
|
|
8481
8479
|
},
|
|
8482
8480
|
w
|
|
@@ -8490,7 +8488,7 @@ const Input = ({ node: o }) => {
|
|
|
8490
8488
|
] }),
|
|
8491
8489
|
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: g.borderRadius })
|
|
8492
8490
|
] }),
|
|
8493
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange:
|
|
8491
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: _ }) })
|
|
8494
8492
|
] }),
|
|
8495
8493
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
8496
8494
|
(m == null ? void 0 : m.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
@@ -9015,12 +9013,12 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9015
9013
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
9016
9014
|
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
|
|
9017
9015
|
useEffect(() => {
|
|
9018
|
-
var
|
|
9019
|
-
(
|
|
9016
|
+
var x;
|
|
9017
|
+
(x = h.current) == null || x.focus();
|
|
9020
9018
|
}, []);
|
|
9021
|
-
const
|
|
9022
|
-
const { usage:
|
|
9023
|
-
!l &&
|
|
9019
|
+
const f = (x) => {
|
|
9020
|
+
const { usage: y } = x || {};
|
|
9021
|
+
!l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
9024
9022
|
};
|
|
9025
9023
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
9026
9024
|
/* @__PURE__ */ jsxs(
|
|
@@ -9040,12 +9038,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9040
9038
|
{
|
|
9041
9039
|
ref: h,
|
|
9042
9040
|
value: i,
|
|
9043
|
-
onChange: (
|
|
9041
|
+
onChange: (x) => c(x.target.value),
|
|
9044
9042
|
placeholder: r("Ask AI to edit content"),
|
|
9045
9043
|
className: "w-full",
|
|
9046
9044
|
rows: 3,
|
|
9047
|
-
onKeyDown: (
|
|
9048
|
-
|
|
9045
|
+
onKeyDown: (x) => {
|
|
9046
|
+
x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f));
|
|
9049
9047
|
}
|
|
9050
9048
|
}
|
|
9051
9049
|
),
|
|
@@ -9055,7 +9053,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9055
9053
|
{
|
|
9056
9054
|
disabled: i.trim().length < 5 || a,
|
|
9057
9055
|
onClick: () => {
|
|
9058
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o, i,
|
|
9056
|
+
m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f);
|
|
9059
9057
|
},
|
|
9060
9058
|
variant: "default",
|
|
9061
9059
|
className: "w-fit",
|
|
@@ -9087,8 +9085,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9087
9085
|
/* @__PURE__ */ jsx(
|
|
9088
9086
|
QuickPrompts,
|
|
9089
9087
|
{
|
|
9090
|
-
onClick: (
|
|
9091
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o,
|
|
9088
|
+
onClick: (x) => {
|
|
9089
|
+
m.current && clearTimeout(m.current), g(void 0), n("content", o, x, f);
|
|
9092
9090
|
}
|
|
9093
9091
|
}
|
|
9094
9092
|
)
|
|
@@ -9105,8 +9103,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9105
9103
|
const m = async () => {
|
|
9106
9104
|
try {
|
|
9107
9105
|
d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
|
|
9108
|
-
} catch (
|
|
9109
|
-
u(
|
|
9106
|
+
} catch (f) {
|
|
9107
|
+
u(f);
|
|
9110
9108
|
} finally {
|
|
9111
9109
|
d(!1);
|
|
9112
9110
|
}
|
|
@@ -9114,8 +9112,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9114
9112
|
return /* @__PURE__ */ jsx(
|
|
9115
9113
|
Accordion,
|
|
9116
9114
|
{
|
|
9117
|
-
onValueChange: (
|
|
9118
|
-
g(
|
|
9115
|
+
onValueChange: (f) => {
|
|
9116
|
+
g(f !== "");
|
|
9119
9117
|
},
|
|
9120
9118
|
type: "single",
|
|
9121
9119
|
collapsible: !0,
|
|
@@ -9127,12 +9125,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9127
9125
|
{
|
|
9128
9126
|
ref: l,
|
|
9129
9127
|
value: n,
|
|
9130
|
-
onChange: (
|
|
9128
|
+
onChange: (f) => a(f.target.value),
|
|
9131
9129
|
placeholder: o("Tell about this page eg this page is about"),
|
|
9132
9130
|
className: "mt-1 w-full",
|
|
9133
9131
|
rows: 10,
|
|
9134
|
-
onKeyDown: (
|
|
9135
|
-
|
|
9132
|
+
onKeyDown: (f) => {
|
|
9133
|
+
f.key === "Enter" && (f.preventDefault(), m());
|
|
9136
9134
|
}
|
|
9137
9135
|
}
|
|
9138
9136
|
),
|
|
@@ -9249,24 +9247,24 @@ function AIChatPanel() {
|
|
|
9249
9247
|
content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
|
|
9250
9248
|
timestamp: /* @__PURE__ */ new Date()
|
|
9251
9249
|
};
|
|
9252
|
-
r((
|
|
9250
|
+
r((_) => [..._, A]), i(!1), d(null);
|
|
9253
9251
|
}, 1500);
|
|
9254
9252
|
}, m = (b) => {
|
|
9255
9253
|
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
|
|
9256
|
-
},
|
|
9257
|
-
var
|
|
9258
|
-
const A = (
|
|
9254
|
+
}, f = (b) => {
|
|
9255
|
+
var _;
|
|
9256
|
+
const A = (_ = b.target.files) == null ? void 0 : _[0];
|
|
9259
9257
|
if (A) {
|
|
9260
|
-
const
|
|
9261
|
-
|
|
9258
|
+
const B = new FileReader();
|
|
9259
|
+
B.onload = (N) => {
|
|
9262
9260
|
var w;
|
|
9263
9261
|
d((w = N.target) == null ? void 0 : w.result);
|
|
9264
|
-
},
|
|
9262
|
+
}, B.readAsDataURL(A);
|
|
9265
9263
|
}
|
|
9266
|
-
},
|
|
9264
|
+
}, x = () => {
|
|
9267
9265
|
var b;
|
|
9268
9266
|
(b = p.current) == null || b.click();
|
|
9269
|
-
},
|
|
9267
|
+
}, y = () => {
|
|
9270
9268
|
d(null), p.current && (p.current.value = "");
|
|
9271
9269
|
};
|
|
9272
9270
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
|
|
@@ -9312,7 +9310,7 @@ function AIChatPanel() {
|
|
|
9312
9310
|
size: "icon",
|
|
9313
9311
|
variant: "destructive",
|
|
9314
9312
|
className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
|
|
9315
|
-
onClick:
|
|
9313
|
+
onClick: y,
|
|
9316
9314
|
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
9317
9315
|
}
|
|
9318
9316
|
)
|
|
@@ -9330,14 +9328,14 @@ function AIChatPanel() {
|
|
|
9330
9328
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9331
9329
|
}
|
|
9332
9330
|
),
|
|
9333
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange:
|
|
9331
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
|
|
9334
9332
|
/* @__PURE__ */ jsx(
|
|
9335
9333
|
Button,
|
|
9336
9334
|
{
|
|
9337
9335
|
size: "icon",
|
|
9338
9336
|
variant: "ghost",
|
|
9339
9337
|
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9340
|
-
onClick:
|
|
9338
|
+
onClick: x,
|
|
9341
9339
|
children: /* @__PURE__ */ jsx(Image$1, { className: "h-4 w-4 text-muted-foreground" })
|
|
9342
9340
|
}
|
|
9343
9341
|
)
|
|
@@ -9455,7 +9453,7 @@ const AiAssistant = () => {
|
|
|
9455
9453
|
preloadedAttributes: r = [],
|
|
9456
9454
|
onAttributesChange: n
|
|
9457
9455
|
}) {
|
|
9458
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""),
|
|
9456
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), y = usePageExternalData();
|
|
9459
9457
|
useEffect(() => {
|
|
9460
9458
|
l(r);
|
|
9461
9459
|
}, [r]);
|
|
@@ -9465,43 +9463,43 @@ const AiAssistant = () => {
|
|
|
9465
9463
|
return;
|
|
9466
9464
|
}
|
|
9467
9465
|
if (i) {
|
|
9468
|
-
const
|
|
9469
|
-
n(
|
|
9466
|
+
const k = [...a, { key: i, value: d }];
|
|
9467
|
+
n(k), l(a), c(""), p(""), m("");
|
|
9470
9468
|
}
|
|
9471
|
-
}, A = (
|
|
9472
|
-
const S = a.filter((
|
|
9469
|
+
}, A = (k) => {
|
|
9470
|
+
const S = a.filter((E, v) => v !== k);
|
|
9473
9471
|
n(S), l(S);
|
|
9474
|
-
},
|
|
9475
|
-
g(
|
|
9476
|
-
},
|
|
9472
|
+
}, _ = (k) => {
|
|
9473
|
+
g(k), c(a[k].key), p(a[k].value);
|
|
9474
|
+
}, B = () => {
|
|
9477
9475
|
if (i.startsWith("@")) {
|
|
9478
9476
|
m("Attribute keys cannot start with '@'");
|
|
9479
9477
|
return;
|
|
9480
9478
|
}
|
|
9481
9479
|
if (u !== null && i) {
|
|
9482
|
-
const
|
|
9483
|
-
|
|
9480
|
+
const k = [...a];
|
|
9481
|
+
k[u] = { key: i, value: d }, n(k), l(k), g(null), c(""), p(""), m("");
|
|
9484
9482
|
}
|
|
9485
|
-
}, N = (
|
|
9486
|
-
|
|
9487
|
-
}, w = useCallback((
|
|
9488
|
-
const S = (C) => /[.,!?;:]/.test(C),
|
|
9483
|
+
}, N = (k) => {
|
|
9484
|
+
k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? B() : b());
|
|
9485
|
+
}, w = useCallback((k) => {
|
|
9486
|
+
const S = (C) => /[.,!?;:]/.test(C), E = (C, j, I) => {
|
|
9489
9487
|
let L = "", R = "";
|
|
9490
|
-
const
|
|
9491
|
-
return j > 0 && (
|
|
9492
|
-
text: L +
|
|
9488
|
+
const T = j > 0 ? C[j - 1] : "", D = j < C.length ? C[j] : "";
|
|
9489
|
+
return j > 0 && (T === "." || !S(T) && T !== " ") && (L = " "), j < C.length && !S(D) && D !== " " && (R = " "), {
|
|
9490
|
+
text: L + I + R,
|
|
9493
9491
|
prefixLength: L.length,
|
|
9494
9492
|
suffixLength: R.length
|
|
9495
9493
|
};
|
|
9496
|
-
}, v =
|
|
9494
|
+
}, v = x.current;
|
|
9497
9495
|
if (v) {
|
|
9498
|
-
const C = v.selectionStart || 0, j = v.value || "",
|
|
9499
|
-
if (
|
|
9500
|
-
const O = `{{${
|
|
9496
|
+
const C = v.selectionStart || 0, j = v.value || "", I = v.selectionEnd || C;
|
|
9497
|
+
if (I > C) {
|
|
9498
|
+
const O = `{{${k}}}`, { text: P } = E(j, C, O), $ = j.slice(0, C) + P + j.slice(I);
|
|
9501
9499
|
p($);
|
|
9502
9500
|
return;
|
|
9503
9501
|
}
|
|
9504
|
-
const R = `{{${
|
|
9502
|
+
const R = `{{${k}}}`, { text: T } = E(j, C, R), D = j.slice(0, C) + T + j.slice(C);
|
|
9505
9503
|
p(D);
|
|
9506
9504
|
}
|
|
9507
9505
|
}, []);
|
|
@@ -9509,8 +9507,8 @@ const AiAssistant = () => {
|
|
|
9509
9507
|
/* @__PURE__ */ jsxs(
|
|
9510
9508
|
"form",
|
|
9511
9509
|
{
|
|
9512
|
-
onSubmit: (
|
|
9513
|
-
|
|
9510
|
+
onSubmit: (k) => {
|
|
9511
|
+
k.preventDefault(), u !== null ? B() : b();
|
|
9514
9512
|
},
|
|
9515
9513
|
className: "space-y-3",
|
|
9516
9514
|
children: [
|
|
@@ -9524,9 +9522,9 @@ const AiAssistant = () => {
|
|
|
9524
9522
|
autoCorrect: "off",
|
|
9525
9523
|
spellCheck: "false",
|
|
9526
9524
|
id: "attrKey",
|
|
9527
|
-
ref:
|
|
9525
|
+
ref: f,
|
|
9528
9526
|
value: i,
|
|
9529
|
-
onChange: (
|
|
9527
|
+
onChange: (k) => c(k.target.value),
|
|
9530
9528
|
placeholder: "Enter Key",
|
|
9531
9529
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9532
9530
|
}
|
|
@@ -9535,7 +9533,7 @@ const AiAssistant = () => {
|
|
|
9535
9533
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9536
9534
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9537
9535
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9538
|
-
!isEmpty(
|
|
9536
|
+
!isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: w })
|
|
9539
9537
|
] }),
|
|
9540
9538
|
/* @__PURE__ */ jsx(
|
|
9541
9539
|
Textarea,
|
|
@@ -9545,9 +9543,9 @@ const AiAssistant = () => {
|
|
|
9545
9543
|
spellCheck: "false",
|
|
9546
9544
|
id: "attrValue",
|
|
9547
9545
|
rows: 2,
|
|
9548
|
-
ref:
|
|
9546
|
+
ref: x,
|
|
9549
9547
|
value: d,
|
|
9550
|
-
onChange: (
|
|
9548
|
+
onChange: (k) => p(k.target.value),
|
|
9551
9549
|
onKeyDown: N,
|
|
9552
9550
|
placeholder: "Enter Value",
|
|
9553
9551
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
@@ -9560,13 +9558,13 @@ const AiAssistant = () => {
|
|
|
9560
9558
|
]
|
|
9561
9559
|
}
|
|
9562
9560
|
),
|
|
9563
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
9561
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((k, S) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9564
9562
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9565
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9566
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children:
|
|
9563
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: k.key }),
|
|
9564
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: k.value.toString() })
|
|
9567
9565
|
] }),
|
|
9568
9566
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9569
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9567
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => _(S), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9570
9568
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(S), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9571
9569
|
] })
|
|
9572
9570
|
] }, S)) })
|
|
@@ -9731,42 +9729,42 @@ const RootLayout = () => {
|
|
|
9731
9729
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9732
9730
|
n("outline");
|
|
9733
9731
|
});
|
|
9734
|
-
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((
|
|
9735
|
-
|
|
9732
|
+
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((k) => {
|
|
9733
|
+
k.preventDefault();
|
|
9736
9734
|
}, []), m = useCallback(
|
|
9737
|
-
(
|
|
9738
|
-
n(r ===
|
|
9735
|
+
(k) => {
|
|
9736
|
+
n(r === k ? null : k);
|
|
9739
9737
|
},
|
|
9740
9738
|
[r]
|
|
9741
|
-
), { t:
|
|
9739
|
+
), { t: f } = useTranslation(), x = useMemo(
|
|
9742
9740
|
() => [...p, ...u, ...g],
|
|
9743
9741
|
[p, u, g]
|
|
9744
|
-
),
|
|
9742
|
+
), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), A = get(b, "width", DEFAULT_PANEL_WIDTH);
|
|
9745
9743
|
useEffect(() => {
|
|
9746
9744
|
if (r !== null) {
|
|
9747
|
-
const
|
|
9748
|
-
|
|
9745
|
+
const k = find(x, { id: r });
|
|
9746
|
+
k && get(k, "view", "standard") === "standard" && (a.current = r, i(get(k, "width", DEFAULT_PANEL_WIDTH)));
|
|
9749
9747
|
}
|
|
9750
|
-
}, [r,
|
|
9751
|
-
const
|
|
9748
|
+
}, [r, x]);
|
|
9749
|
+
const _ = useMemo(() => {
|
|
9752
9750
|
if (r === null) return 0;
|
|
9753
|
-
const
|
|
9754
|
-
return get(
|
|
9755
|
-
}, [r, A, l,
|
|
9751
|
+
const k = find(x, { id: r });
|
|
9752
|
+
return get(k, "view", "standard") === "standard" ? A : l;
|
|
9753
|
+
}, [r, A, l, x]), B = useCallback(() => {
|
|
9756
9754
|
n(a.current);
|
|
9757
9755
|
}, [n]), N = useCallback(() => {
|
|
9758
9756
|
n("outline");
|
|
9759
9757
|
}, [n]);
|
|
9760
9758
|
useEffect(() => {
|
|
9761
|
-
find(
|
|
9762
|
-
}, [r,
|
|
9759
|
+
find(x, { id: r }) || n("outline");
|
|
9760
|
+
}, [r, x]);
|
|
9763
9761
|
const w = useCallback(
|
|
9764
|
-
(
|
|
9765
|
-
m(
|
|
9762
|
+
(k) => {
|
|
9763
|
+
m(k);
|
|
9766
9764
|
},
|
|
9767
9765
|
[m]
|
|
9768
9766
|
);
|
|
9769
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
9767
|
+
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: [
|
|
9770
9768
|
/* @__PURE__ */ jsxs(
|
|
9771
9769
|
"div",
|
|
9772
9770
|
{
|
|
@@ -9776,24 +9774,24 @@ const RootLayout = () => {
|
|
|
9776
9774
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
9777
9775
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9778
9776
|
/* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9779
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((
|
|
9780
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9777
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((k, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9778
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
|
|
9781
9779
|
position: "top",
|
|
9782
|
-
panelId:
|
|
9783
|
-
isActive: r ===
|
|
9784
|
-
show: () => w(
|
|
9780
|
+
panelId: k.id,
|
|
9781
|
+
isActive: r === k.id,
|
|
9782
|
+
show: () => w(k.id)
|
|
9785
9783
|
}) }),
|
|
9786
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9784
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
|
|
9787
9785
|
] }, "button-top-" + S)) }),
|
|
9788
9786
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9789
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((
|
|
9790
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(
|
|
9787
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((k, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9788
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
|
|
9791
9789
|
position: "bottom",
|
|
9792
|
-
panelId:
|
|
9793
|
-
isActive: r ===
|
|
9794
|
-
show: () => w(
|
|
9790
|
+
panelId: k.id,
|
|
9791
|
+
isActive: r === k.id,
|
|
9792
|
+
show: () => w(k.id)
|
|
9795
9793
|
}) }),
|
|
9796
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9794
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
|
|
9797
9795
|
] }, "button-bottom-" + S)) })
|
|
9798
9796
|
] }),
|
|
9799
9797
|
/* @__PURE__ */ jsx(
|
|
@@ -9801,15 +9799,15 @@ const RootLayout = () => {
|
|
|
9801
9799
|
{
|
|
9802
9800
|
id: "left-panel",
|
|
9803
9801
|
className: "h-full max-h-full border-r border-border",
|
|
9804
|
-
initial: { width:
|
|
9805
|
-
animate: { width:
|
|
9802
|
+
initial: { width: _ },
|
|
9803
|
+
animate: { width: _ },
|
|
9806
9804
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
9807
9805
|
children: r !== null && get(b, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
|
|
9808
9806
|
/* @__PURE__ */ jsx(
|
|
9809
9807
|
"div",
|
|
9810
9808
|
{
|
|
9811
9809
|
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
|
|
9812
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9810
|
+
children: /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9813
9811
|
}
|
|
9814
9812
|
),
|
|
9815
9813
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {}) }) })
|
|
@@ -9832,11 +9830,11 @@ const RootLayout = () => {
|
|
|
9832
9830
|
/* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: c === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9833
9831
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9834
9832
|
" ",
|
|
9835
|
-
|
|
9833
|
+
f("AI Assistant")
|
|
9836
9834
|
] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9837
9835
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9838
9836
|
/* @__PURE__ */ jsx(Palette, { className: "w-4 h-4 text-gray-600" }),
|
|
9839
|
-
|
|
9837
|
+
f("Theme Settings")
|
|
9840
9838
|
] }),
|
|
9841
9839
|
/* @__PURE__ */ jsx(
|
|
9842
9840
|
Button,
|
|
@@ -9858,7 +9856,7 @@ const RootLayout = () => {
|
|
|
9858
9856
|
}
|
|
9859
9857
|
),
|
|
9860
9858
|
/* @__PURE__ */ jsx(AddBlocksDialog, {}),
|
|
9861
|
-
r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () =>
|
|
9859
|
+
r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(
|
|
9862
9860
|
SheetContent,
|
|
9863
9861
|
{
|
|
9864
9862
|
side: "left",
|
|
@@ -9867,7 +9865,7 @@ const RootLayout = () => {
|
|
|
9867
9865
|
children: [
|
|
9868
9866
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
9869
9867
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9870
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9868
|
+
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9871
9869
|
] }) }),
|
|
9872
9870
|
/* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
9873
9871
|
close: N
|
|
@@ -9876,10 +9874,10 @@ const RootLayout = () => {
|
|
|
9876
9874
|
}
|
|
9877
9875
|
) }),
|
|
9878
9876
|
" ",
|
|
9879
|
-
r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () =>
|
|
9877
|
+
r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${A}px` }, children: [
|
|
9880
9878
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
9881
9879
|
/* @__PURE__ */ jsx("span", { className: "inline-block", children: get(b, "icon", null) }),
|
|
9882
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9880
|
+
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9883
9881
|
] }) }),
|
|
9884
9882
|
/* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
9885
9883
|
close: N
|
|
@@ -9905,9 +9903,9 @@ const RootLayout = () => {
|
|
|
9905
9903
|
/* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
|
|
9906
9904
|
/* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
|
|
9907
9905
|
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
|
|
9908
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9906
|
+
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
9909
9907
|
] }),
|
|
9910
|
-
/* @__PURE__ */ jsx(Button, { onClick: () =>
|
|
9908
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => B(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
|
|
9911
9909
|
] }),
|
|
9912
9910
|
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
9913
9911
|
close: N
|
|
@@ -9949,36 +9947,36 @@ const RootLayout = () => {
|
|
|
9949
9947
|
}) => {
|
|
9950
9948
|
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
|
|
9951
9949
|
if (!l.trim()) return a;
|
|
9952
|
-
const
|
|
9950
|
+
const x = l.toLowerCase();
|
|
9953
9951
|
return Object.fromEntries(
|
|
9954
|
-
Object.entries(a).filter(([
|
|
9952
|
+
Object.entries(a).filter(([y, b]) => {
|
|
9955
9953
|
var A;
|
|
9956
|
-
return (
|
|
9954
|
+
return (y == null ? void 0 : y.toLowerCase().includes(x)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(x));
|
|
9957
9955
|
})
|
|
9958
9956
|
);
|
|
9959
|
-
}, [a, l]), h = (
|
|
9957
|
+
}, [a, l]), h = (x) => {
|
|
9960
9958
|
d(!0), u({
|
|
9961
|
-
x:
|
|
9962
|
-
y:
|
|
9959
|
+
x: x.clientX - r.x,
|
|
9960
|
+
y: x.clientY - r.y
|
|
9963
9961
|
});
|
|
9964
|
-
}, m = (
|
|
9962
|
+
}, m = (x) => {
|
|
9965
9963
|
if (!c) return;
|
|
9966
|
-
const
|
|
9967
|
-
n(
|
|
9968
|
-
},
|
|
9964
|
+
const y = x.clientX - p.x, b = x.clientY - p.y, A = x.currentTarget, _ = A.offsetWidth, B = A.offsetHeight, N = window.innerWidth - _, w = window.innerHeight - B, k = Math.max(0, Math.min(y, N)), S = Math.max(0, Math.min(b, w));
|
|
9965
|
+
n(k, S);
|
|
9966
|
+
}, f = () => {
|
|
9969
9967
|
d(!1);
|
|
9970
9968
|
};
|
|
9971
9969
|
return useEffect(() => {
|
|
9972
|
-
const
|
|
9970
|
+
const x = () => {
|
|
9973
9971
|
c && d(!1);
|
|
9974
9972
|
};
|
|
9975
|
-
return window.addEventListener("mouseup",
|
|
9973
|
+
return window.addEventListener("mouseup", x), () => window.removeEventListener("mouseup", x);
|
|
9976
9974
|
}, [c]), !r || r.x < 0 || r.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
9977
9975
|
"div",
|
|
9978
9976
|
{
|
|
9979
9977
|
onMouseDown: h,
|
|
9980
9978
|
onMouseMove: m,
|
|
9981
|
-
onMouseUp:
|
|
9979
|
+
onMouseUp: f,
|
|
9982
9980
|
className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
|
|
9983
9981
|
style: {
|
|
9984
9982
|
left: r.x,
|
|
@@ -10020,13 +10018,13 @@ const RootLayout = () => {
|
|
|
10020
10018
|
placeholder: "Search features...",
|
|
10021
10019
|
className: "w-full pl-8",
|
|
10022
10020
|
value: l,
|
|
10023
|
-
onChange: (
|
|
10021
|
+
onChange: (x) => i(x.target.value),
|
|
10024
10022
|
autoFocus: !0
|
|
10025
10023
|
}
|
|
10026
10024
|
)
|
|
10027
10025
|
] })
|
|
10028
10026
|
] }),
|
|
10029
|
-
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([
|
|
10027
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([x, y]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: x, options: y }, x)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
|
|
10030
10028
|
'No features found matching "',
|
|
10031
10029
|
l,
|
|
10032
10030
|
'"'
|
|
@@ -10137,76 +10135,76 @@ const RootLayout = () => {
|
|
|
10137
10135
|
for (const i of r.p)
|
|
10138
10136
|
l.add(i);
|
|
10139
10137
|
return l;
|
|
10140
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...
|
|
10141
|
-
var
|
|
10142
|
-
return (
|
|
10143
|
-
}, g = (m,
|
|
10144
|
-
var
|
|
10145
|
-
return (
|
|
10138
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
|
|
10139
|
+
var x;
|
|
10140
|
+
return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
|
|
10141
|
+
}, g = (m, f) => {
|
|
10142
|
+
var x;
|
|
10143
|
+
return (x = m.onMount) == null ? void 0 : x.call(m, f);
|
|
10146
10144
|
}, ...h) => {
|
|
10147
10145
|
const m = h[0] || ((S) => {
|
|
10148
|
-
let
|
|
10149
|
-
return
|
|
10150
|
-
}),
|
|
10151
|
-
let S,
|
|
10146
|
+
let E = o.get(S);
|
|
10147
|
+
return E || (E = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(S, E), u == null || u(S, k)), E;
|
|
10148
|
+
}), f = h[1] || (() => {
|
|
10149
|
+
let S, E;
|
|
10152
10150
|
const v = (C) => {
|
|
10153
10151
|
try {
|
|
10154
10152
|
C();
|
|
10155
10153
|
} catch (j) {
|
|
10156
|
-
S || (S = !0,
|
|
10154
|
+
S || (S = !0, E = j);
|
|
10157
10155
|
}
|
|
10158
10156
|
};
|
|
10159
10157
|
do {
|
|
10160
10158
|
c.f && v(c.f);
|
|
10161
10159
|
const C = /* @__PURE__ */ new Set(), j = C.add.bind(C);
|
|
10162
|
-
a.forEach((
|
|
10160
|
+
a.forEach((I) => {
|
|
10163
10161
|
var L;
|
|
10164
|
-
return (L = r.get(
|
|
10165
|
-
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), C.forEach(v), a.size &&
|
|
10162
|
+
return (L = r.get(I)) == null ? void 0 : L.l.forEach(j);
|
|
10163
|
+
}), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), C.forEach(v), a.size && x();
|
|
10166
10164
|
} while (a.size || i.size || l.size);
|
|
10167
10165
|
if (S)
|
|
10168
|
-
throw
|
|
10169
|
-
}),
|
|
10170
|
-
const S = [],
|
|
10166
|
+
throw E;
|
|
10167
|
+
}), x = h[2] || (() => {
|
|
10168
|
+
const S = [], E = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), C = Array.from(a);
|
|
10171
10169
|
for (; C.length; ) {
|
|
10172
|
-
const j = C[C.length - 1],
|
|
10170
|
+
const j = C[C.length - 1], I = m(j);
|
|
10173
10171
|
if (v.has(j)) {
|
|
10174
10172
|
C.pop();
|
|
10175
10173
|
continue;
|
|
10176
10174
|
}
|
|
10177
|
-
if (
|
|
10178
|
-
n.get(j) ===
|
|
10175
|
+
if (E.has(j)) {
|
|
10176
|
+
n.get(j) === I.n && S.push([j, I]), v.add(j), C.pop();
|
|
10179
10177
|
continue;
|
|
10180
10178
|
}
|
|
10181
|
-
|
|
10182
|
-
for (const L of getMountedOrPendingDependents(j,
|
|
10183
|
-
|
|
10179
|
+
E.add(j);
|
|
10180
|
+
for (const L of getMountedOrPendingDependents(j, I, r))
|
|
10181
|
+
E.has(L) || C.push(L);
|
|
10184
10182
|
}
|
|
10185
10183
|
for (let j = S.length - 1; j >= 0; --j) {
|
|
10186
|
-
const [
|
|
10184
|
+
const [I, L] = S[j];
|
|
10187
10185
|
let R = !1;
|
|
10188
|
-
for (const
|
|
10189
|
-
if (
|
|
10186
|
+
for (const T of L.d.keys())
|
|
10187
|
+
if (T !== I && a.has(T)) {
|
|
10190
10188
|
R = !0;
|
|
10191
10189
|
break;
|
|
10192
10190
|
}
|
|
10193
|
-
R && (
|
|
10191
|
+
R && (y(I), _(I)), n.delete(I);
|
|
10194
10192
|
}
|
|
10195
|
-
}),
|
|
10196
|
-
var
|
|
10193
|
+
}), y = h[3] || ((S) => {
|
|
10194
|
+
var E, v;
|
|
10197
10195
|
const C = m(S);
|
|
10198
10196
|
if (isAtomStateInitialized(C) && (r.has(S) && n.get(S) !== C.n || Array.from(C.d).every(
|
|
10199
10197
|
([P, $]) => (
|
|
10200
10198
|
// Recursively, read the atom state of the dependency, and
|
|
10201
10199
|
// check if the atom epoch number is unchanged
|
|
10202
|
-
|
|
10200
|
+
y(P).n === $
|
|
10203
10201
|
)
|
|
10204
10202
|
)))
|
|
10205
10203
|
return C;
|
|
10206
10204
|
C.d.clear();
|
|
10207
10205
|
let j = !0;
|
|
10208
|
-
const
|
|
10209
|
-
r.has(S) && (
|
|
10206
|
+
const I = () => {
|
|
10207
|
+
r.has(S) && (_(S), x(), f());
|
|
10210
10208
|
}, L = (P) => {
|
|
10211
10209
|
var $;
|
|
10212
10210
|
if (isSelfAtom(S, P)) {
|
|
@@ -10218,34 +10216,34 @@ const RootLayout = () => {
|
|
|
10218
10216
|
throw new Error("no atom init");
|
|
10219
10217
|
return returnAtomValue(H);
|
|
10220
10218
|
}
|
|
10221
|
-
const M =
|
|
10219
|
+
const M = y(P);
|
|
10222
10220
|
try {
|
|
10223
10221
|
return returnAtomValue(M);
|
|
10224
10222
|
} finally {
|
|
10225
|
-
C.d.set(P, M.n), isPendingPromise(C.v) && addPendingPromiseToDependency(S, C.v, M), ($ = r.get(P)) == null || $.t.add(S), j ||
|
|
10223
|
+
C.d.set(P, M.n), isPendingPromise(C.v) && addPendingPromiseToDependency(S, C.v, M), ($ = r.get(P)) == null || $.t.add(S), j || I();
|
|
10226
10224
|
}
|
|
10227
10225
|
};
|
|
10228
|
-
let R,
|
|
10226
|
+
let R, T;
|
|
10229
10227
|
const D = {
|
|
10230
10228
|
get signal() {
|
|
10231
10229
|
return R || (R = new AbortController()), R.signal;
|
|
10232
10230
|
},
|
|
10233
10231
|
get setSelf() {
|
|
10234
|
-
return !
|
|
10232
|
+
return !T && isActuallyWritableAtom(S) && (T = (...P) => {
|
|
10235
10233
|
if (!j)
|
|
10236
10234
|
try {
|
|
10237
10235
|
return A(S, ...P);
|
|
10238
10236
|
} finally {
|
|
10239
|
-
|
|
10237
|
+
x(), f();
|
|
10240
10238
|
}
|
|
10241
|
-
}),
|
|
10239
|
+
}), T;
|
|
10242
10240
|
}
|
|
10243
10241
|
}, O = C.n;
|
|
10244
10242
|
try {
|
|
10245
10243
|
const P = d(S, L, D);
|
|
10246
|
-
return setAtomStateValueOrPromise(S, P, m), isPromiseLike$1(P) && ((
|
|
10247
|
-
|
|
10248
|
-
|
|
10244
|
+
return setAtomStateValueOrPromise(S, P, m), isPromiseLike$1(P) && ((E = P.onCancel) == null || E.call(P, () => R == null ? void 0 : R.abort()), P.then(
|
|
10245
|
+
I,
|
|
10246
|
+
I
|
|
10249
10247
|
)), C;
|
|
10250
10248
|
} catch (P) {
|
|
10251
10249
|
return delete C.v, C.e = P, ++C.n, C;
|
|
@@ -10253,87 +10251,87 @@ const RootLayout = () => {
|
|
|
10253
10251
|
j = !1, O !== C.n && n.get(S) === O && (n.set(S, C.n), a.add(S), (v = c.c) == null || v.call(c, S));
|
|
10254
10252
|
}
|
|
10255
10253
|
}), b = h[4] || ((S) => {
|
|
10256
|
-
const
|
|
10257
|
-
for (;
|
|
10258
|
-
const v =
|
|
10254
|
+
const E = [S];
|
|
10255
|
+
for (; E.length; ) {
|
|
10256
|
+
const v = E.pop(), C = m(v);
|
|
10259
10257
|
for (const j of getMountedOrPendingDependents(v, C, r)) {
|
|
10260
|
-
const
|
|
10261
|
-
n.set(j,
|
|
10258
|
+
const I = m(j);
|
|
10259
|
+
n.set(j, I.n), E.push(j);
|
|
10262
10260
|
}
|
|
10263
10261
|
}
|
|
10264
|
-
}), A = h[5] || ((S, ...
|
|
10262
|
+
}), A = h[5] || ((S, ...E) => {
|
|
10265
10263
|
let v = !0;
|
|
10266
|
-
const C = (
|
|
10264
|
+
const C = (I) => returnAtomValue(y(I)), j = (I, ...L) => {
|
|
10267
10265
|
var R;
|
|
10268
|
-
const
|
|
10266
|
+
const T = m(I);
|
|
10269
10267
|
try {
|
|
10270
|
-
if (isSelfAtom(S,
|
|
10271
|
-
if (!hasInitialValue(
|
|
10268
|
+
if (isSelfAtom(S, I)) {
|
|
10269
|
+
if (!hasInitialValue(I))
|
|
10272
10270
|
throw new Error("atom not writable");
|
|
10273
|
-
const D =
|
|
10274
|
-
setAtomStateValueOrPromise(
|
|
10271
|
+
const D = T.n, O = L[0];
|
|
10272
|
+
setAtomStateValueOrPromise(I, O, m), _(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
|
|
10275
10273
|
return;
|
|
10276
10274
|
} else
|
|
10277
|
-
return A(
|
|
10275
|
+
return A(I, ...L);
|
|
10278
10276
|
} finally {
|
|
10279
|
-
v || (
|
|
10277
|
+
v || (x(), f());
|
|
10280
10278
|
}
|
|
10281
10279
|
};
|
|
10282
10280
|
try {
|
|
10283
|
-
return p(S, C, j, ...
|
|
10281
|
+
return p(S, C, j, ...E);
|
|
10284
10282
|
} finally {
|
|
10285
10283
|
v = !1;
|
|
10286
10284
|
}
|
|
10287
|
-
}),
|
|
10288
|
-
var
|
|
10285
|
+
}), _ = h[6] || ((S) => {
|
|
10286
|
+
var E;
|
|
10289
10287
|
const v = m(S), C = r.get(S);
|
|
10290
10288
|
if (C && !isPendingPromise(v.v)) {
|
|
10291
|
-
for (const [j,
|
|
10289
|
+
for (const [j, I] of v.d)
|
|
10292
10290
|
if (!C.d.has(j)) {
|
|
10293
10291
|
const L = m(j);
|
|
10294
|
-
|
|
10292
|
+
B(j).t.add(S), C.d.add(j), I !== L.n && (a.add(j), (E = c.c) == null || E.call(c, j), b(j));
|
|
10295
10293
|
}
|
|
10296
10294
|
for (const j of C.d || [])
|
|
10297
10295
|
if (!v.d.has(j)) {
|
|
10298
10296
|
C.d.delete(j);
|
|
10299
|
-
const
|
|
10300
|
-
|
|
10297
|
+
const I = N(j);
|
|
10298
|
+
I == null || I.t.delete(S);
|
|
10301
10299
|
}
|
|
10302
10300
|
}
|
|
10303
|
-
}),
|
|
10304
|
-
var
|
|
10301
|
+
}), B = h[7] || ((S) => {
|
|
10302
|
+
var E;
|
|
10305
10303
|
const v = m(S);
|
|
10306
10304
|
let C = r.get(S);
|
|
10307
10305
|
if (!C) {
|
|
10308
|
-
|
|
10306
|
+
y(S);
|
|
10309
10307
|
for (const j of v.d.keys())
|
|
10310
|
-
|
|
10308
|
+
B(j).t.add(S);
|
|
10311
10309
|
if (C = {
|
|
10312
10310
|
l: /* @__PURE__ */ new Set(),
|
|
10313
10311
|
d: new Set(v.d.keys()),
|
|
10314
10312
|
t: /* @__PURE__ */ new Set()
|
|
10315
|
-
}, r.set(S, C), (
|
|
10313
|
+
}, r.set(S, C), (E = c.m) == null || E.call(c, S), isActuallyWritableAtom(S)) {
|
|
10316
10314
|
const j = () => {
|
|
10317
|
-
let
|
|
10315
|
+
let I = !0;
|
|
10318
10316
|
const L = (...R) => {
|
|
10319
10317
|
try {
|
|
10320
10318
|
return A(S, ...R);
|
|
10321
10319
|
} finally {
|
|
10322
|
-
|
|
10320
|
+
I || (x(), f());
|
|
10323
10321
|
}
|
|
10324
10322
|
};
|
|
10325
10323
|
try {
|
|
10326
10324
|
const R = g(S, L);
|
|
10327
10325
|
R && (C.u = () => {
|
|
10328
|
-
|
|
10326
|
+
I = !0;
|
|
10329
10327
|
try {
|
|
10330
10328
|
R();
|
|
10331
10329
|
} finally {
|
|
10332
|
-
|
|
10330
|
+
I = !1;
|
|
10333
10331
|
}
|
|
10334
10332
|
});
|
|
10335
10333
|
} finally {
|
|
10336
|
-
|
|
10334
|
+
I = !1;
|
|
10337
10335
|
}
|
|
10338
10336
|
};
|
|
10339
10337
|
l.add(j);
|
|
@@ -10341,17 +10339,17 @@ const RootLayout = () => {
|
|
|
10341
10339
|
}
|
|
10342
10340
|
return C;
|
|
10343
10341
|
}), N = h[8] || ((S) => {
|
|
10344
|
-
var
|
|
10342
|
+
var E;
|
|
10345
10343
|
const v = m(S);
|
|
10346
10344
|
let C = r.get(S);
|
|
10347
10345
|
if (C && !C.l.size && !Array.from(C.t).some((j) => {
|
|
10348
|
-
var
|
|
10349
|
-
return (
|
|
10346
|
+
var I;
|
|
10347
|
+
return (I = r.get(j)) == null ? void 0 : I.d.has(S);
|
|
10350
10348
|
})) {
|
|
10351
|
-
C.u && i.add(C.u), C = void 0, r.delete(S), (
|
|
10349
|
+
C.u && i.add(C.u), C = void 0, r.delete(S), (E = c.u) == null || E.call(c, S);
|
|
10352
10350
|
for (const j of v.d.keys()) {
|
|
10353
|
-
const
|
|
10354
|
-
|
|
10351
|
+
const I = N(j);
|
|
10352
|
+
I == null || I.t.delete(S);
|
|
10355
10353
|
}
|
|
10356
10354
|
return;
|
|
10357
10355
|
}
|
|
@@ -10372,31 +10370,31 @@ const RootLayout = () => {
|
|
|
10372
10370
|
g,
|
|
10373
10371
|
// building-block functions
|
|
10374
10372
|
m,
|
|
10375
|
-
x,
|
|
10376
10373
|
f,
|
|
10377
|
-
|
|
10374
|
+
x,
|
|
10375
|
+
y,
|
|
10378
10376
|
b,
|
|
10379
10377
|
A,
|
|
10380
|
-
E,
|
|
10381
10378
|
_,
|
|
10379
|
+
B,
|
|
10382
10380
|
N
|
|
10383
|
-
],
|
|
10384
|
-
get: (S) => returnAtomValue(
|
|
10385
|
-
set: (S, ...
|
|
10381
|
+
], k = {
|
|
10382
|
+
get: (S) => returnAtomValue(y(S)),
|
|
10383
|
+
set: (S, ...E) => {
|
|
10386
10384
|
try {
|
|
10387
|
-
return A(S, ...
|
|
10385
|
+
return A(S, ...E);
|
|
10388
10386
|
} finally {
|
|
10389
|
-
|
|
10387
|
+
x(), f();
|
|
10390
10388
|
}
|
|
10391
10389
|
},
|
|
10392
|
-
sub: (S,
|
|
10393
|
-
const C =
|
|
10394
|
-
return C.add(
|
|
10395
|
-
C.delete(
|
|
10390
|
+
sub: (S, E) => {
|
|
10391
|
+
const C = B(S).l;
|
|
10392
|
+
return C.add(E), f(), () => {
|
|
10393
|
+
C.delete(E), N(S), f();
|
|
10396
10394
|
};
|
|
10397
10395
|
}
|
|
10398
10396
|
};
|
|
10399
|
-
return Object.defineProperty(
|
|
10397
|
+
return Object.defineProperty(k, BUILDING_BLOCKS, { value: w }), k;
|
|
10400
10398
|
}, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
|
|
10401
10399
|
let defaultStore;
|
|
10402
10400
|
const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
|