@chaibuilder/sdk 2.0.0-beta.103 → 2.0.0-beta.105
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/{CodeEditor-DyWk02_x.js → CodeEditor-Bv7cAp6l.js} +1 -1
- package/dist/CodeEditor-ol63c03C.cjs +1 -0
- package/dist/{Topbar-BuWEmzZG.js → Topbar-DutZ_viX.js} +1 -1
- package/dist/Topbar-lIu26u9Y.cjs +1 -0
- package/dist/core.cjs +4 -4
- package/dist/core.js +395 -405
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +5 -2
- package/dist/render.js +128 -122
- package/dist/tooltip-CuxBhGWF.js +763 -0
- package/dist/tooltip-DHlrjqh8.cjs +1 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +7 -65
- package/dist/ui.js +76 -79
- package/package.json +3 -1
- package/dist/CodeEditor-BQTYQosF.cjs +0 -1
- package/dist/Topbar-BhwvnJJc.cjs +0 -1
- package/dist/context-menu-CeqJxblw.cjs +0 -1
- package/dist/context-menu-iqXuo9Yt.js +0 -907
package/dist/core.js
CHANGED
|
@@ -4,12 +4,12 @@ var U = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
|
|
|
4
4
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, Suspense, createElement, memo, lazy } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { S as Skeleton, B as Button, al as Label, X as Dialog, Y as DialogTrigger, Z as DialogContent, am as Popover, az as Tooltip, aA as TooltipTrigger, an as PopoverTrigger, aB as TooltipContent, ao as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, n as Badge, a2 as DropdownMenu, a3 as DropdownMenuTrigger, a4 as DropdownMenuContent, a8 as DropdownMenuLabel, a9 as DropdownMenuSeparator, a6 as DropdownMenuCheckboxItem, ah as HoverCard, ai as HoverCardTrigger, aj as HoverCardContent, ay as Textarea, ak as Input$1, aD as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, ap as ScrollArea, ab as DropdownMenuGroup, a5 as DropdownMenuItem, aa as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, au as Tabs, av as TabsList, aw as TabsTrigger, ax as TabsContent, H as ContextMenu, I as ContextMenuTrigger, J as ContextMenuContent, K as ContextMenuItem, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, at as Switch, ar as Separator, aC as TooltipProvider, as as Toaster } from "./tooltip-CuxBhGWF.js";
|
|
8
8
|
import { atom as atom$1, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
9
9
|
import { find, filter, flatten, map, omit, isString, has, each, set, first, get, isObject, memoize, compact, isEmpty, noop, includes, without, keys, range, values, flattenDeep, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, findIndex, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
|
|
10
10
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
11
11
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
12
|
-
import { useTranslation as
|
|
12
|
+
import { useTranslation as Me } from "react-i18next";
|
|
13
13
|
import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
|
|
14
14
|
import { flip } from "@floating-ui/dom";
|
|
15
15
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
@@ -17,10 +17,11 @@ import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxMod
|
|
|
17
17
|
import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
|
|
18
18
|
import { useFeature, FlagsProvider } from "flagged";
|
|
19
19
|
import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
20
|
-
import { registerChaiBlock as
|
|
20
|
+
import { registerChaiBlock as Oe } from "@chaibuilder/runtime";
|
|
21
21
|
import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, a as getChaiThemeCssVariables, c as getThemeFontsLinkMarkup } from "./ChaiThemeFn-Cort9tch.js";
|
|
22
22
|
import TreeModel from "tree-model";
|
|
23
23
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
24
|
+
import { toast } from "sonner";
|
|
24
25
|
import { PlusIcon as PlusIcon$1, PanelRightClose, PanelRightOpen, AppWindowIcon, AlignHorizontalJustifyStart, UnfoldHorizontal, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, X, Plus, ChevronLeft, PlusCircle, ChevronDown, List, Loader, SparklesIcon, EyeOff, Eye, SmileIcon, ShuffleIcon, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
|
|
25
26
|
import ReactQuill, { Quill } from "react-quill";
|
|
26
27
|
import typography from "@tailwindcss/typography";
|
|
@@ -41,7 +42,7 @@ import { parse, stringify } from "himalaya";
|
|
|
41
42
|
import clsx from "clsx";
|
|
42
43
|
import { Tree } from "react-arborist";
|
|
43
44
|
import i18n from "i18next";
|
|
44
|
-
import { default as
|
|
45
|
+
import { default as Ve } from "i18next";
|
|
45
46
|
import { motion } from "framer-motion";
|
|
46
47
|
const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
|
|
47
48
|
if ("e" in o)
|
|
@@ -89,17 +90,17 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
89
90
|
for (const i of n.p)
|
|
90
91
|
l.add(i);
|
|
91
92
|
return l;
|
|
92
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (f, ...
|
|
93
|
-
var
|
|
94
|
-
return (
|
|
95
|
-
}, g = (f,
|
|
96
|
-
var
|
|
97
|
-
return (
|
|
93
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (f, ...x) => f.read(...x), p = (f, ...x) => f.write(...x), u = (f, x) => {
|
|
94
|
+
var b;
|
|
95
|
+
return (b = f.unstable_onInit) == null ? void 0 : b.call(f, x);
|
|
96
|
+
}, g = (f, x) => {
|
|
97
|
+
var b;
|
|
98
|
+
return (b = f.onMount) == null ? void 0 : b.call(f, x);
|
|
98
99
|
}, ...m) => {
|
|
99
100
|
const f = m[0] || ((C) => {
|
|
100
101
|
let T = o.get(C);
|
|
101
102
|
return T || (T = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, T), u == null || u(C, _)), T;
|
|
102
|
-
}),
|
|
103
|
+
}), x = m[1] || (() => {
|
|
103
104
|
let C, T;
|
|
104
105
|
const k = (v) => {
|
|
105
106
|
try {
|
|
@@ -112,13 +113,13 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
112
113
|
c.f && k(c.f);
|
|
113
114
|
const v = /* @__PURE__ */ new Set(), N = v.add.bind(v);
|
|
114
115
|
a.forEach((I) => {
|
|
115
|
-
var
|
|
116
|
-
return (
|
|
117
|
-
}), a.clear(), i.forEach(N), i.clear(), l.forEach(N), l.clear(), v.forEach(k), a.size &&
|
|
116
|
+
var P;
|
|
117
|
+
return (P = n.get(I)) == null ? void 0 : P.l.forEach(N);
|
|
118
|
+
}), a.clear(), i.forEach(N), i.clear(), l.forEach(N), l.clear(), v.forEach(k), a.size && b();
|
|
118
119
|
} while (a.size || i.size || l.size);
|
|
119
120
|
if (C)
|
|
120
121
|
throw T;
|
|
121
|
-
}),
|
|
122
|
+
}), b = m[2] || (() => {
|
|
122
123
|
const C = [], T = /* @__PURE__ */ new WeakSet(), k = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
|
|
123
124
|
for (; v.length; ) {
|
|
124
125
|
const N = v[v.length - 1], I = f(N);
|
|
@@ -131,18 +132,18 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
131
132
|
continue;
|
|
132
133
|
}
|
|
133
134
|
T.add(N);
|
|
134
|
-
for (const
|
|
135
|
-
T.has(
|
|
135
|
+
for (const P of getMountedOrPendingDependents(N, I, n))
|
|
136
|
+
T.has(P) || v.push(P);
|
|
136
137
|
}
|
|
137
138
|
for (let N = C.length - 1; N >= 0; --N) {
|
|
138
|
-
const [I,
|
|
139
|
-
let
|
|
140
|
-
for (const j of
|
|
139
|
+
const [I, P] = C[N];
|
|
140
|
+
let D = !1;
|
|
141
|
+
for (const j of P.d.keys())
|
|
141
142
|
if (j !== I && a.has(j)) {
|
|
142
|
-
|
|
143
|
+
D = !0;
|
|
143
144
|
break;
|
|
144
145
|
}
|
|
145
|
-
|
|
146
|
+
D && (h(I), E(I)), r.delete(I);
|
|
146
147
|
}
|
|
147
148
|
}), h = m[3] || ((C) => {
|
|
148
149
|
var T, k;
|
|
@@ -158,8 +159,8 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
158
159
|
v.d.clear();
|
|
159
160
|
let N = !0;
|
|
160
161
|
const I = () => {
|
|
161
|
-
n.has(C) && (E(C),
|
|
162
|
-
},
|
|
162
|
+
n.has(C) && (E(C), b(), x());
|
|
163
|
+
}, P = (L) => {
|
|
163
164
|
var $;
|
|
164
165
|
if (isSelfAtom(C, L)) {
|
|
165
166
|
const H = f(L);
|
|
@@ -177,10 +178,10 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
177
178
|
v.d.set(L, O.n), isPendingPromise(v.v) && addPendingPromiseToDependency(C, v.v, O), ($ = n.get(L)) == null || $.t.add(C), N || I();
|
|
178
179
|
}
|
|
179
180
|
};
|
|
180
|
-
let
|
|
181
|
+
let D, j;
|
|
181
182
|
const R = {
|
|
182
183
|
get signal() {
|
|
183
|
-
return
|
|
184
|
+
return D || (D = new AbortController()), D.signal;
|
|
184
185
|
},
|
|
185
186
|
get setSelf() {
|
|
186
187
|
return !j && isActuallyWritableAtom(C) && (j = (...L) => {
|
|
@@ -188,21 +189,21 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
188
189
|
try {
|
|
189
190
|
return B(C, ...L);
|
|
190
191
|
} finally {
|
|
191
|
-
|
|
192
|
+
b(), x();
|
|
192
193
|
}
|
|
193
194
|
}), j;
|
|
194
195
|
}
|
|
195
|
-
},
|
|
196
|
+
}, M = v.n;
|
|
196
197
|
try {
|
|
197
|
-
const L = d(C,
|
|
198
|
-
return setAtomStateValueOrPromise(C, L, f), isPromiseLike$2(L) && ((T = L.onCancel) == null || T.call(L, () =>
|
|
198
|
+
const L = d(C, P, R);
|
|
199
|
+
return setAtomStateValueOrPromise(C, L, f), isPromiseLike$2(L) && ((T = L.onCancel) == null || T.call(L, () => D == null ? void 0 : D.abort()), L.then(
|
|
199
200
|
I,
|
|
200
201
|
I
|
|
201
202
|
)), v;
|
|
202
203
|
} catch (L) {
|
|
203
204
|
return delete v.v, v.e = L, ++v.n, v;
|
|
204
205
|
} finally {
|
|
205
|
-
N = !1,
|
|
206
|
+
N = !1, M !== v.n && r.get(C) === M && (r.set(C, v.n), a.add(C), (k = c.c) == null || k.call(c, C));
|
|
206
207
|
}
|
|
207
208
|
}), y = m[4] || ((C) => {
|
|
208
209
|
const T = [C];
|
|
@@ -215,20 +216,20 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
215
216
|
}
|
|
216
217
|
}), B = m[5] || ((C, ...T) => {
|
|
217
218
|
let k = !0;
|
|
218
|
-
const v = (I) => returnAtomValue(h(I)), N = (I, ...
|
|
219
|
-
var
|
|
219
|
+
const v = (I) => returnAtomValue(h(I)), N = (I, ...P) => {
|
|
220
|
+
var D;
|
|
220
221
|
const j = f(I);
|
|
221
222
|
try {
|
|
222
223
|
if (isSelfAtom(C, I)) {
|
|
223
224
|
if (!hasInitialValue(I))
|
|
224
225
|
throw new Error("atom not writable");
|
|
225
|
-
const R = j.n,
|
|
226
|
-
setAtomStateValueOrPromise(I,
|
|
226
|
+
const R = j.n, M = P[0];
|
|
227
|
+
setAtomStateValueOrPromise(I, M, f), E(I), R !== j.n && (a.add(I), (D = c.c) == null || D.call(c, I), y(I));
|
|
227
228
|
return;
|
|
228
229
|
} else
|
|
229
|
-
return B(I, ...
|
|
230
|
+
return B(I, ...P);
|
|
230
231
|
} finally {
|
|
231
|
-
k || (
|
|
232
|
+
k || (b(), x());
|
|
232
233
|
}
|
|
233
234
|
};
|
|
234
235
|
try {
|
|
@@ -242,8 +243,8 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
242
243
|
if (v && !isPendingPromise(k.v)) {
|
|
243
244
|
for (const [N, I] of k.d)
|
|
244
245
|
if (!v.d.has(N)) {
|
|
245
|
-
const
|
|
246
|
-
w(N).t.add(C), v.d.add(N), I !==
|
|
246
|
+
const P = f(N);
|
|
247
|
+
w(N).t.add(C), v.d.add(N), I !== P.n && (a.add(N), (T = c.c) == null || T.call(c, N), y(N));
|
|
247
248
|
}
|
|
248
249
|
for (const N of v.d || [])
|
|
249
250
|
if (!k.d.has(N)) {
|
|
@@ -267,19 +268,19 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
267
268
|
}, n.set(C, v), (T = c.m) == null || T.call(c, C), isActuallyWritableAtom(C)) {
|
|
268
269
|
const N = () => {
|
|
269
270
|
let I = !0;
|
|
270
|
-
const
|
|
271
|
+
const P = (...D) => {
|
|
271
272
|
try {
|
|
272
|
-
return B(C, ...
|
|
273
|
+
return B(C, ...D);
|
|
273
274
|
} finally {
|
|
274
|
-
I || (
|
|
275
|
+
I || (b(), x());
|
|
275
276
|
}
|
|
276
277
|
};
|
|
277
278
|
try {
|
|
278
|
-
const
|
|
279
|
-
|
|
279
|
+
const D = g(C, P);
|
|
280
|
+
D && (v.u = () => {
|
|
280
281
|
I = !0;
|
|
281
282
|
try {
|
|
282
|
-
|
|
283
|
+
D();
|
|
283
284
|
} finally {
|
|
284
285
|
I = !1;
|
|
285
286
|
}
|
|
@@ -324,8 +325,8 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
324
325
|
g,
|
|
325
326
|
// building-block functions
|
|
326
327
|
f,
|
|
327
|
-
b,
|
|
328
328
|
x,
|
|
329
|
+
b,
|
|
329
330
|
h,
|
|
330
331
|
y,
|
|
331
332
|
B,
|
|
@@ -338,13 +339,13 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
338
339
|
try {
|
|
339
340
|
return B(C, ...T);
|
|
340
341
|
} finally {
|
|
341
|
-
|
|
342
|
+
b(), x();
|
|
342
343
|
}
|
|
343
344
|
},
|
|
344
345
|
sub: (C, T) => {
|
|
345
346
|
const v = w(C).l;
|
|
346
|
-
return v.add(T),
|
|
347
|
-
v.delete(T), S(C),
|
|
347
|
+
return v.add(T), x(), () => {
|
|
348
|
+
v.delete(T), S(C), x();
|
|
348
349
|
};
|
|
349
350
|
}
|
|
350
351
|
};
|
|
@@ -384,25 +385,25 @@ function splitAtom(o, n) {
|
|
|
384
385
|
if (p)
|
|
385
386
|
return p;
|
|
386
387
|
const u = d && r.get(d), g = [], m = [];
|
|
387
|
-
return c.forEach((f,
|
|
388
|
-
const
|
|
389
|
-
m[
|
|
390
|
-
const h = u && u.atomList[u.keyList.indexOf(
|
|
388
|
+
return c.forEach((f, x) => {
|
|
389
|
+
const b = x;
|
|
390
|
+
m[x] = b;
|
|
391
|
+
const h = u && u.atomList[u.keyList.indexOf(b)];
|
|
391
392
|
if (h) {
|
|
392
|
-
g[
|
|
393
|
+
g[x] = h;
|
|
393
394
|
return;
|
|
394
395
|
}
|
|
395
396
|
const y = (E) => {
|
|
396
|
-
const w = E(l), S = E(o), _ = a(S, w == null ? void 0 : w.arr).keyList.indexOf(
|
|
397
|
+
const w = E(l), S = E(o), _ = a(S, w == null ? void 0 : w.arr).keyList.indexOf(b);
|
|
397
398
|
if (_ < 0 || _ >= S.length) {
|
|
398
|
-
const C = c[a(c).keyList.indexOf(
|
|
399
|
+
const C = c[a(c).keyList.indexOf(b)];
|
|
399
400
|
if (C)
|
|
400
401
|
return C;
|
|
401
402
|
throw new Error("splitAtom: index out of bounds for read");
|
|
402
403
|
}
|
|
403
404
|
return S[_];
|
|
404
405
|
}, B = (E, w, S) => {
|
|
405
|
-
const A = E(l), _ = E(o), T = a(_, A == null ? void 0 : A.arr).keyList.indexOf(
|
|
406
|
+
const A = E(l), _ = E(o), T = a(_, A == null ? void 0 : A.arr).keyList.indexOf(b);
|
|
406
407
|
if (T < 0 || T >= _.length)
|
|
407
408
|
throw new Error("splitAtom: index out of bounds for write");
|
|
408
409
|
const k = isFunction(S) ? S(_[T]) : S;
|
|
@@ -412,8 +413,8 @@ function splitAtom(o, n) {
|
|
|
412
413
|
..._.slice(T + 1)
|
|
413
414
|
]);
|
|
414
415
|
};
|
|
415
|
-
g[
|
|
416
|
-
}), u && u.keyList.length === m.length && u.keyList.every((f,
|
|
416
|
+
g[x] = isWritable(o) ? atom(y, B) : atom(y);
|
|
417
|
+
}), u && u.keyList.length === m.length && u.keyList.every((f, x) => f === m[x]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
|
|
417
418
|
}, l = atom((c) => {
|
|
418
419
|
const d = c(l), p = c(o);
|
|
419
420
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -486,18 +487,18 @@ function createJSONStorage(o = () => {
|
|
|
486
487
|
const i = {
|
|
487
488
|
getItem: (p, u) => {
|
|
488
489
|
var g, m;
|
|
489
|
-
const f = (
|
|
490
|
-
if (
|
|
490
|
+
const f = (b) => {
|
|
491
|
+
if (b = b || "", a !== b) {
|
|
491
492
|
try {
|
|
492
|
-
l = JSON.parse(
|
|
493
|
+
l = JSON.parse(b, n == null ? void 0 : n.reviver);
|
|
493
494
|
} catch {
|
|
494
495
|
return u;
|
|
495
496
|
}
|
|
496
|
-
a =
|
|
497
|
+
a = b;
|
|
497
498
|
}
|
|
498
499
|
return l;
|
|
499
|
-
},
|
|
500
|
-
return isPromiseLike$1(
|
|
500
|
+
}, x = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
501
|
+
return isPromiseLike$1(x) ? x.then(f) : f(x);
|
|
501
502
|
},
|
|
502
503
|
setItem: (p, u) => {
|
|
503
504
|
var g;
|
|
@@ -511,13 +512,13 @@ function createJSONStorage(o = () => {
|
|
|
511
512
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
512
513
|
}
|
|
513
514
|
}, c = (p) => (u, g, m) => p(u, (f) => {
|
|
514
|
-
let
|
|
515
|
+
let x;
|
|
515
516
|
try {
|
|
516
|
-
|
|
517
|
+
x = JSON.parse(f || "");
|
|
517
518
|
} catch {
|
|
518
|
-
|
|
519
|
+
x = m;
|
|
519
520
|
}
|
|
520
|
-
g(
|
|
521
|
+
g(x);
|
|
521
522
|
});
|
|
522
523
|
let d;
|
|
523
524
|
try {
|
|
@@ -1339,65 +1340,65 @@ const useBlocksStoreManager = () => {
|
|
|
1339
1340
|
updateBlocksProps: c
|
|
1340
1341
|
} = useBlocksStoreManager();
|
|
1341
1342
|
return {
|
|
1342
|
-
moveBlocks: (
|
|
1343
|
-
const B = map(
|
|
1343
|
+
moveBlocks: (b, h, y) => {
|
|
1344
|
+
const B = map(b, (w) => {
|
|
1344
1345
|
const A = n.find((T) => T._id === w)._parent || null, C = n.filter((T) => A ? T._parent === A : !T._parent).map((T) => T._id).indexOf(w);
|
|
1345
1346
|
return { _id: w, oldParent: A, oldPosition: C };
|
|
1346
|
-
}), E = B.find(({ _id: w }) => w ===
|
|
1347
|
-
E && E.oldParent === h && E.oldPosition === y || (i(
|
|
1347
|
+
}), E = B.find(({ _id: w }) => w === b[0]);
|
|
1348
|
+
E && E.oldParent === h && E.oldPosition === y || (i(b, h, y), o({
|
|
1348
1349
|
undo: () => each(B, ({ _id: w, oldParent: S, oldPosition: A }) => {
|
|
1349
1350
|
i([w], S, A);
|
|
1350
1351
|
}),
|
|
1351
|
-
redo: () => i(
|
|
1352
|
+
redo: () => i(b, h, y)
|
|
1352
1353
|
}));
|
|
1353
1354
|
},
|
|
1354
|
-
addBlocks: (
|
|
1355
|
-
a(
|
|
1356
|
-
undo: () => l(map(
|
|
1357
|
-
redo: () => a(
|
|
1355
|
+
addBlocks: (b, h, y) => {
|
|
1356
|
+
a(b, h, y), o({
|
|
1357
|
+
undo: () => l(map(b, "_id")),
|
|
1358
|
+
redo: () => a(b, h, y)
|
|
1358
1359
|
});
|
|
1359
1360
|
},
|
|
1360
|
-
removeBlocks: (
|
|
1361
|
+
removeBlocks: (b) => {
|
|
1361
1362
|
var E;
|
|
1362
|
-
const h = (E = first(
|
|
1363
|
-
l(map(
|
|
1364
|
-
undo: () => a(
|
|
1365
|
-
redo: () => l(map(
|
|
1363
|
+
const h = (E = first(b)) == null ? void 0 : E._parent, B = n.filter((w) => h ? w._parent === h : !w._parent).indexOf(first(b));
|
|
1364
|
+
l(map(b, "_id")), o({
|
|
1365
|
+
undo: () => a(b, h, B),
|
|
1366
|
+
redo: () => l(map(b, "_id"))
|
|
1366
1367
|
});
|
|
1367
1368
|
},
|
|
1368
|
-
updateBlocks: (
|
|
1369
|
+
updateBlocks: (b, h, y) => {
|
|
1369
1370
|
let B = [];
|
|
1370
1371
|
if (y)
|
|
1371
|
-
B = map(
|
|
1372
|
+
B = map(b, (E) => ({ _id: E, ...y }));
|
|
1372
1373
|
else {
|
|
1373
1374
|
const E = keys(h);
|
|
1374
|
-
B = map(
|
|
1375
|
+
B = map(b, (w) => {
|
|
1375
1376
|
const S = n.find((_) => _._id === w), A = { _id: w };
|
|
1376
1377
|
return each(E, (_) => A[_] = S[_]), A;
|
|
1377
1378
|
});
|
|
1378
1379
|
}
|
|
1379
|
-
c(map(
|
|
1380
|
+
c(map(b, (E) => ({ _id: E, ...h }))), o({
|
|
1380
1381
|
undo: () => c(B),
|
|
1381
|
-
redo: () => c(map(
|
|
1382
|
+
redo: () => c(map(b, (E) => ({ _id: E, ...h })))
|
|
1382
1383
|
});
|
|
1383
1384
|
},
|
|
1384
|
-
updateBlocksRuntime: (
|
|
1385
|
-
c(map(
|
|
1385
|
+
updateBlocksRuntime: (b, h) => {
|
|
1386
|
+
c(map(b, (y) => ({ _id: y, ...h })));
|
|
1386
1387
|
},
|
|
1387
|
-
setNewBlocks: (
|
|
1388
|
-
r(
|
|
1388
|
+
setNewBlocks: (b) => {
|
|
1389
|
+
r(b), o({
|
|
1389
1390
|
undo: () => r(n),
|
|
1390
|
-
redo: () => r(
|
|
1391
|
+
redo: () => r(b)
|
|
1391
1392
|
});
|
|
1392
1393
|
},
|
|
1393
|
-
updateMultipleBlocksProps: (
|
|
1394
|
+
updateMultipleBlocksProps: (b) => {
|
|
1394
1395
|
let h = [];
|
|
1395
|
-
h = map(
|
|
1396
|
+
h = map(b, (y) => {
|
|
1396
1397
|
const B = keys(y), E = n.find((S) => S._id === y._id), w = {};
|
|
1397
1398
|
return each(B, (S) => w[S] = E[S]), w;
|
|
1398
|
-
}), c(
|
|
1399
|
+
}), c(b), o({
|
|
1399
1400
|
undo: () => c(h),
|
|
1400
|
-
redo: () => c(
|
|
1401
|
+
redo: () => c(b)
|
|
1401
1402
|
});
|
|
1402
1403
|
}
|
|
1403
1404
|
};
|
|
@@ -1434,12 +1435,12 @@ const useAddBlock = () => {
|
|
|
1434
1435
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1435
1436
|
(i, c, d) => {
|
|
1436
1437
|
var f;
|
|
1437
|
-
for (let
|
|
1438
|
-
const { _id:
|
|
1439
|
-
i[
|
|
1440
|
-
const h = filter(i, { _parent:
|
|
1438
|
+
for (let x = 0; x < i.length; x++) {
|
|
1439
|
+
const { _id: b } = i[x];
|
|
1440
|
+
i[x]._id = generateUUID();
|
|
1441
|
+
const h = filter(i, { _parent: b });
|
|
1441
1442
|
for (let y = 0; y < h.length; y++)
|
|
1442
|
-
h[y]._parent = i[
|
|
1443
|
+
h[y]._parent = i[x]._id;
|
|
1443
1444
|
}
|
|
1444
1445
|
const p = first(i);
|
|
1445
1446
|
let u, g;
|
|
@@ -2905,25 +2906,25 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2905
2906
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2906
2907
|
})
|
|
2907
2908
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2908
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f,
|
|
2909
|
-
const
|
|
2910
|
-
for (const h in
|
|
2911
|
-
const y =
|
|
2909
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f, x) => {
|
|
2910
|
+
const b = cloneDeep(x.find((h) => h._id === f));
|
|
2911
|
+
for (const h in b) {
|
|
2912
|
+
const y = b[h];
|
|
2912
2913
|
if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
|
|
2913
2914
|
const { baseClasses: B, classes: E } = getSplitChaiClasses(y);
|
|
2914
|
-
|
|
2915
|
+
b[h] = compact(flattenDeep([B, E])).join(" ");
|
|
2915
2916
|
} else
|
|
2916
|
-
h !== "_id" && delete
|
|
2917
|
+
h !== "_id" && delete b[h];
|
|
2917
2918
|
}
|
|
2918
|
-
return
|
|
2919
|
+
return b;
|
|
2919
2920
|
};
|
|
2920
2921
|
return {
|
|
2921
2922
|
askAi: useCallback(
|
|
2922
|
-
async (f,
|
|
2923
|
+
async (f, x, b, h) => {
|
|
2923
2924
|
if (l) {
|
|
2924
2925
|
n(!0), a(null);
|
|
2925
2926
|
try {
|
|
2926
|
-
const y = p === u ? "" : p, B = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(
|
|
2927
|
+
const y = p === u ? "" : p, B = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p) : [m(x, d)], E = await l(f, addLangToPrompt(b, g, f), B, y), { blocks: w, error: S } = E;
|
|
2927
2928
|
if (S) {
|
|
2928
2929
|
a(S);
|
|
2929
2930
|
return;
|
|
@@ -3119,17 +3120,17 @@ const useBlockHighlight = () => {
|
|
|
3119
3120
|
[n, o]
|
|
3120
3121
|
);
|
|
3121
3122
|
}, usePasteBlocks = () => {
|
|
3122
|
-
const [o, n] = useCutBlockIds(), r = useMoveCutBlocks(), a = useCanPaste(), {
|
|
3123
|
+
const [o, n] = useCutBlockIds(), r = useMoveCutBlocks(), a = useCanPaste(), { addPredefinedBlock: l } = useAddBlock();
|
|
3123
3124
|
return {
|
|
3124
3125
|
canPaste: useCallback(
|
|
3125
|
-
async (
|
|
3126
|
+
async (c) => {
|
|
3126
3127
|
if (o.length > 0)
|
|
3127
|
-
return a(o,
|
|
3128
|
+
return a(o, c);
|
|
3128
3129
|
try {
|
|
3129
|
-
const
|
|
3130
|
-
if (
|
|
3131
|
-
const
|
|
3132
|
-
return has(
|
|
3130
|
+
const d = await navigator.clipboard.readText();
|
|
3131
|
+
if (d) {
|
|
3132
|
+
const p = JSON.parse(d);
|
|
3133
|
+
return has(p, "_chai_copied_blocks");
|
|
3133
3134
|
}
|
|
3134
3135
|
} catch {
|
|
3135
3136
|
return !1;
|
|
@@ -3139,24 +3140,24 @@ const useBlockHighlight = () => {
|
|
|
3139
3140
|
[a, o]
|
|
3140
3141
|
),
|
|
3141
3142
|
pasteBlocks: useCallback(
|
|
3142
|
-
async (
|
|
3143
|
-
const
|
|
3143
|
+
async (c) => {
|
|
3144
|
+
const d = Array.isArray(c) ? c[0] : c;
|
|
3144
3145
|
if (!isEmpty(o)) {
|
|
3145
|
-
r(o,
|
|
3146
|
+
r(o, c), n([]), await navigator.clipboard.writeText("");
|
|
3146
3147
|
return;
|
|
3147
3148
|
}
|
|
3148
3149
|
try {
|
|
3149
|
-
const
|
|
3150
|
-
if (
|
|
3151
|
-
const
|
|
3152
|
-
has(
|
|
3150
|
+
const p = await navigator.clipboard.readText();
|
|
3151
|
+
if (p) {
|
|
3152
|
+
const u = JSON.parse(p);
|
|
3153
|
+
has(u, "_chai_copied_blocks") ? l(u._chai_copied_blocks, d === "root" ? null : d) : toast.error("Nothing to paste");
|
|
3153
3154
|
} else
|
|
3154
|
-
|
|
3155
|
+
toast.error("Nothing to paste");
|
|
3155
3156
|
} catch {
|
|
3156
|
-
|
|
3157
|
+
toast.error("Failed to paste blocks from clipboard");
|
|
3157
3158
|
}
|
|
3158
3159
|
},
|
|
3159
|
-
[o,
|
|
3160
|
+
[o, l, r, n]
|
|
3160
3161
|
)
|
|
3161
3162
|
};
|
|
3162
3163
|
}, previewModeAtom = atom$1(!1), usePreviewMode = () => {
|
|
@@ -3174,13 +3175,13 @@ const useBlockHighlight = () => {
|
|
|
3174
3175
|
const d = o(c), p = a;
|
|
3175
3176
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3176
3177
|
return each(p, (m) => {
|
|
3177
|
-
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
3178
|
-
u = u.replace(
|
|
3179
|
-
const
|
|
3180
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
3178
|
+
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
|
|
3179
|
+
u = u.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
3180
|
+
const b = first(m.split(":"));
|
|
3181
|
+
includes(["2xl", "xl", "lg", "md", "sm"], b) && p.push(m.split(":").pop().trim());
|
|
3181
3182
|
}), each(p, (m) => {
|
|
3182
|
-
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
3183
|
-
g = g.replace(
|
|
3183
|
+
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
|
|
3184
|
+
g = g.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
3184
3185
|
}), {
|
|
3185
3186
|
ids: [d._id],
|
|
3186
3187
|
props: {
|
|
@@ -3212,7 +3213,7 @@ const useBlockHighlight = () => {
|
|
|
3212
3213
|
const n = first(o(selectedStylingBlocksAtom)), r = o(selectedBlockAtom);
|
|
3213
3214
|
if (!n || n.blockId !== get(r, "_id", null)) return [];
|
|
3214
3215
|
const a = get(r, n.prop, `${STYLES_KEY},`), { classes: l } = getSplitChaiClasses(a);
|
|
3215
|
-
return
|
|
3216
|
+
return filter(map(l.trim().split(" "), constructClassObject), (i) => !isNull(i));
|
|
3216
3217
|
}), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom$1((o) => {
|
|
3217
3218
|
const n = o(canvasBreakpointAtom), r = o(styleStateAtom), a = o(darkModeAtom), l = getQueries(n);
|
|
3218
3219
|
let i = filter(o(selectedBlockAllClassesAtom), { mod: r });
|
|
@@ -3321,13 +3322,13 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3321
3322
|
tabIndex: 0,
|
|
3322
3323
|
ref: u.setFloating,
|
|
3323
3324
|
style: p,
|
|
3324
|
-
onClick: (
|
|
3325
|
-
|
|
3325
|
+
onClick: (x) => {
|
|
3326
|
+
x.stopPropagation(), x.preventDefault();
|
|
3326
3327
|
},
|
|
3327
|
-
onMouseEnter: (
|
|
3328
|
-
|
|
3328
|
+
onMouseEnter: (x) => {
|
|
3329
|
+
x.stopPropagation(), i(null);
|
|
3329
3330
|
},
|
|
3330
|
-
onKeyDown: (
|
|
3331
|
+
onKeyDown: (x) => x.stopPropagation(),
|
|
3331
3332
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3332
3333
|
children: [
|
|
3333
3334
|
m && /* @__PURE__ */ jsx(
|
|
@@ -3424,8 +3425,8 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3424
3425
|
i
|
|
3425
3426
|
]), useHotkeys(
|
|
3426
3427
|
"del, backspace",
|
|
3427
|
-
(
|
|
3428
|
-
|
|
3428
|
+
(x) => {
|
|
3429
|
+
x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3429
3430
|
},
|
|
3430
3431
|
f,
|
|
3431
3432
|
[n, l]
|
|
@@ -3523,9 +3524,9 @@ const useDnd = () => {
|
|
|
3523
3524
|
},
|
|
3524
3525
|
onDrop: (f) => {
|
|
3525
3526
|
var S;
|
|
3526
|
-
const
|
|
3527
|
+
const x = dropTarget, h = getOrientation(x) === "vertical" ? f.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : f.clientX;
|
|
3527
3528
|
dropIndex = calculateDropIndex(h, possiblePositions);
|
|
3528
|
-
const y = d, B =
|
|
3529
|
+
const y = d, B = x.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3529
3530
|
if ((y == null ? void 0 : y._id) === B || !E) {
|
|
3530
3531
|
m();
|
|
3531
3532
|
return;
|
|
@@ -3534,14 +3535,14 @@ const useDnd = () => {
|
|
|
3534
3535
|
a(y, B === "canvas" ? null : B, dropIndex), setTimeout(m, 300);
|
|
3535
3536
|
return;
|
|
3536
3537
|
}
|
|
3537
|
-
let w =
|
|
3538
|
+
let w = x.getAttribute("data-block-id");
|
|
3538
3539
|
w === null && (w = f.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3539
3540
|
},
|
|
3540
3541
|
onDragEnter: (f) => {
|
|
3541
|
-
const
|
|
3542
|
-
dropTarget =
|
|
3543
|
-
const h =
|
|
3544
|
-
u(h),
|
|
3542
|
+
const x = f, b = x.target;
|
|
3543
|
+
dropTarget = b;
|
|
3544
|
+
const h = b.getAttribute("data-block-id"), y = b.getAttribute("data-dnd-dragged") !== "yes";
|
|
3545
|
+
u(h), x.stopPropagation(), x.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(b), r(!0), l(""), i([]);
|
|
3545
3546
|
},
|
|
3546
3547
|
onDragLeave: (f) => {
|
|
3547
3548
|
f.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
@@ -3565,7 +3566,7 @@ const useHandleCanvasDblClick = () => {
|
|
|
3565
3566
|
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight(), i = useGetBlockAtomValue(pageBlocksAtomsAtom);
|
|
3566
3567
|
return useCallback(
|
|
3567
3568
|
(c) => {
|
|
3568
|
-
var
|
|
3569
|
+
var b;
|
|
3569
3570
|
if (r) return;
|
|
3570
3571
|
const d = getTargetedBlock(c.target), p = d.getAttribute("data-block-type");
|
|
3571
3572
|
if (!p || !o.includes(p))
|
|
@@ -3575,15 +3576,15 @@ const useHandleCanvasDblClick = () => {
|
|
|
3575
3576
|
h.name !== "class" && m.removeAttribute(h.name);
|
|
3576
3577
|
}), p === "Text" && (m.style.display = "inline-block"), d.parentNode.insertBefore(m, d.nextSibling);
|
|
3577
3578
|
const f = new Quill(m, { placeholder: "Type here..." });
|
|
3578
|
-
function
|
|
3579
|
+
function x() {
|
|
3579
3580
|
const h = f.getText(0, f.getLength());
|
|
3580
|
-
n([u], { content: h }), d.removeAttribute("style"), m.removeEventListener("blur",
|
|
3581
|
+
n([u], { content: h }), d.removeAttribute("style"), m.removeEventListener("blur", x, !0), destroyQuill(f), a(""), l(), m.remove();
|
|
3581
3582
|
}
|
|
3582
|
-
m.addEventListener("blur",
|
|
3583
|
+
m.addEventListener("blur", x, !0), m.addEventListener("click", (h) => {
|
|
3583
3584
|
h.stopPropagation();
|
|
3584
3585
|
}), m.addEventListener("keydown", (h) => {
|
|
3585
|
-
(h.key === "Enter" || h.key === "Escape") &&
|
|
3586
|
-
}), f.focus(), (
|
|
3586
|
+
(h.key === "Enter" || h.key === "Escape") && x();
|
|
3587
|
+
}), f.focus(), (b = m.querySelector(".ql-clipboard")) == null || b.remove(), a(d.getAttribute("data-block-id"));
|
|
3587
3588
|
},
|
|
3588
3589
|
[r, a, n, l]
|
|
3589
3590
|
);
|
|
@@ -3626,8 +3627,8 @@ const useHandleCanvasDblClick = () => {
|
|
|
3626
3627
|
if (m) {
|
|
3627
3628
|
const f = m.getAttribute("data-style-prop");
|
|
3628
3629
|
if (f) {
|
|
3629
|
-
const
|
|
3630
|
-
l([{ id:
|
|
3630
|
+
const x = m.getAttribute("data-style-id"), b = m.getAttribute("data-block-parent");
|
|
3631
|
+
l([{ id: x, prop: f, blockId: b }]);
|
|
3631
3632
|
}
|
|
3632
3633
|
}
|
|
3633
3634
|
}, 100);
|
|
@@ -3706,13 +3707,13 @@ const useHandleCanvasDblClick = () => {
|
|
|
3706
3707
|
}, [l, m]), useEffect(() => {
|
|
3707
3708
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3708
3709
|
}, [c, d]);
|
|
3709
|
-
const
|
|
3710
|
+
const x = useMemo(
|
|
3710
3711
|
() => getChaiThemeCssVariables(o),
|
|
3711
3712
|
[o]
|
|
3712
|
-
),
|
|
3713
|
+
), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3713
3714
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3714
|
-
/* @__PURE__ */ jsx("style", { id: "chai-theme", children:
|
|
3715
|
-
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html:
|
|
3715
|
+
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: x }),
|
|
3716
|
+
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
|
|
3716
3717
|
] });
|
|
3717
3718
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
3718
3719
|
const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
|
|
@@ -3792,7 +3793,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3792
3793
|
const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(inlineEditingActiveAtom), [g] = useAtom$1(dataBindingActiveAtom), m = get(a, "component", null), f = useMemo(
|
|
3793
3794
|
() => g ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3794
3795
|
[r, l, a, d, g]
|
|
3795
|
-
),
|
|
3796
|
+
), x = useMemo(() => getBlockTagAttributes(r), [r]), b = useMemo(() => c(r._id, getBlockRuntimeProps(r._type)), [r]), h = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), y = useMemo(
|
|
3796
3797
|
() => ({
|
|
3797
3798
|
blockProps: {
|
|
3798
3799
|
"data-block-id": r._id,
|
|
@@ -3801,11 +3802,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3801
3802
|
inBuilder: !0,
|
|
3802
3803
|
lang: l || i,
|
|
3803
3804
|
...f,
|
|
3804
|
-
...b,
|
|
3805
3805
|
...x,
|
|
3806
|
+
...b,
|
|
3806
3807
|
...h
|
|
3807
3808
|
}),
|
|
3808
|
-
[r, l, i, f,
|
|
3809
|
+
[r, l, i, f, x, b, h]
|
|
3809
3810
|
);
|
|
3810
3811
|
return isNull(m) || p.includes(r._id) || u === r._id ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(m, { ...y, children: n }) });
|
|
3811
3812
|
}, GlobalBlocksRenderer = ({ globalBlockId: o }) => {
|
|
@@ -3857,10 +3858,10 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3857
3858
|
c();
|
|
3858
3859
|
}, [n, o, r, c]), l;
|
|
3859
3860
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3860
|
-
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, f] = useState([]), [,
|
|
3861
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, f] = useState([]), [, x] = useAtom$1(canvasIframeAtom), [b, h] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), E = (A) => {
|
|
3861
3862
|
p((_) => ({ ..._, width: A }));
|
|
3862
3863
|
};
|
|
3863
|
-
|
|
3864
|
+
useEffect(() => {
|
|
3864
3865
|
if (!c.current) return;
|
|
3865
3866
|
const { clientWidth: A, clientHeight: _ } = c.current;
|
|
3866
3867
|
p({ width: A, height: _ });
|
|
@@ -3876,15 +3877,15 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3876
3877
|
C && (w(C) || (_ = (A = i.current) == null ? void 0 : A.contentWindow) == null || _.scrollTo({ top: C.offsetTop, behavior: "smooth" }), m([C]));
|
|
3877
3878
|
}
|
|
3878
3879
|
}, [a]), useEffect(() => {
|
|
3879
|
-
if (!isEmpty(
|
|
3880
|
+
if (!isEmpty(b) && i.current) {
|
|
3880
3881
|
const A = getElementByStyleId(
|
|
3881
3882
|
i.current.contentDocument,
|
|
3882
|
-
first(
|
|
3883
|
+
first(b).id
|
|
3883
3884
|
);
|
|
3884
3885
|
f(A ? [A] : [null]);
|
|
3885
3886
|
} else
|
|
3886
3887
|
f([null]);
|
|
3887
|
-
}, [
|
|
3888
|
+
}, [b]);
|
|
3888
3889
|
const S = useMemo(() => {
|
|
3889
3890
|
let A = IframeInitialContent;
|
|
3890
3891
|
return A = A.replace("__HTML_DIR__", B), o === "offline" && (A = A.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), A;
|
|
@@ -3901,7 +3902,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3901
3902
|
children: /* @__PURE__ */ jsxs(
|
|
3902
3903
|
ChaiFrame,
|
|
3903
3904
|
{
|
|
3904
|
-
contentDidMount: () =>
|
|
3905
|
+
contentDidMount: () => x(i.current),
|
|
3905
3906
|
ref: i,
|
|
3906
3907
|
id: "canvas-iframe",
|
|
3907
3908
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
@@ -4046,7 +4047,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4046
4047
|
l !== o.length - 1 && /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
|
|
4047
4048
|
] }, l))
|
|
4048
4049
|
] }) });
|
|
4049
|
-
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-
|
|
4050
|
+
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-Bv7cAp6l.js")), CanvasArea = () => {
|
|
4050
4051
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
4051
4052
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
|
|
4052
4053
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -4178,7 +4179,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4178
4179
|
},
|
|
4179
4180
|
[c],
|
|
4180
4181
|
200
|
|
4181
|
-
),
|
|
4182
|
+
), x = useDebouncedCallback(
|
|
4182
4183
|
(y) => {
|
|
4183
4184
|
d(() => ({
|
|
4184
4185
|
...c,
|
|
@@ -4187,7 +4188,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4187
4188
|
},
|
|
4188
4189
|
[c],
|
|
4189
4190
|
200
|
|
4190
|
-
),
|
|
4191
|
+
), b = useDebouncedCallback(
|
|
4191
4192
|
(y, B) => {
|
|
4192
4193
|
d(() => {
|
|
4193
4194
|
const E = get(c, `colors.${y}`);
|
|
@@ -4209,7 +4210,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4209
4210
|
ColorPickerInput,
|
|
4210
4211
|
{
|
|
4211
4212
|
value: E,
|
|
4212
|
-
onChange: (w) =>
|
|
4213
|
+
onChange: (w) => b(B, w)
|
|
4213
4214
|
}
|
|
4214
4215
|
),
|
|
4215
4216
|
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
|
|
@@ -4257,7 +4258,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4257
4258
|
(p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4258
4259
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
|
|
4259
4260
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4260
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange:
|
|
4261
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: x }),
|
|
4261
4262
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
|
|
4262
4263
|
] })
|
|
4263
4264
|
] }),
|
|
@@ -4477,9 +4478,9 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4477
4478
|
onChange: r
|
|
4478
4479
|
}) => {
|
|
4479
4480
|
var T;
|
|
4480
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (k, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [
|
|
4481
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (k, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [x, b] = useState([]), [h, y] = useState(-1), B = useRef(null), E = (T = n == null ? void 0 : n.find((k) => k.key === u)) == null ? void 0 : T.name;
|
|
4481
4482
|
useEffect(() => {
|
|
4482
|
-
if (f(""),
|
|
4483
|
+
if (f(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4483
4484
|
const k = split(o, ":"), v = get(k, 1, "page") || "page";
|
|
4484
4485
|
g(v), (async () => {
|
|
4485
4486
|
const N = await l(v, [get(k, 2, "page")]);
|
|
@@ -4489,10 +4490,10 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4489
4490
|
const w = useDebouncedCallback(
|
|
4490
4491
|
async (k) => {
|
|
4491
4492
|
if (isEmpty(k))
|
|
4492
|
-
|
|
4493
|
+
b([]);
|
|
4493
4494
|
else {
|
|
4494
4495
|
const v = await l(u, k);
|
|
4495
|
-
|
|
4496
|
+
b(v);
|
|
4496
4497
|
}
|
|
4497
4498
|
c(!1), y(-1);
|
|
4498
4499
|
},
|
|
@@ -4500,18 +4501,18 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4500
4501
|
300
|
|
4501
4502
|
), S = (k) => {
|
|
4502
4503
|
const v = ["pageType", u, k.id];
|
|
4503
|
-
v[1] && (r(v.join(":")), f(k.name), p(!1),
|
|
4504
|
+
v[1] && (r(v.join(":")), f(k.name), p(!1), b([]), y(-1));
|
|
4504
4505
|
}, A = (k) => {
|
|
4505
4506
|
switch (k.key) {
|
|
4506
4507
|
case "ArrowDown":
|
|
4507
|
-
k.preventDefault(), y((v) => v <
|
|
4508
|
+
k.preventDefault(), y((v) => v < x.length - 1 ? v + 1 : v);
|
|
4508
4509
|
break;
|
|
4509
4510
|
case "ArrowUp":
|
|
4510
4511
|
k.preventDefault(), y((v) => v > 0 ? v - 1 : v);
|
|
4511
4512
|
break;
|
|
4512
4513
|
case "Enter":
|
|
4513
|
-
if (k.preventDefault(),
|
|
4514
|
-
h >= 0 && S(
|
|
4514
|
+
if (k.preventDefault(), x.length === 0) return;
|
|
4515
|
+
h >= 0 && S(x[h]);
|
|
4515
4516
|
break;
|
|
4516
4517
|
case "Escape":
|
|
4517
4518
|
k.preventDefault(), _();
|
|
@@ -4525,7 +4526,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4525
4526
|
}
|
|
4526
4527
|
}, [h]);
|
|
4527
4528
|
const _ = () => {
|
|
4528
|
-
f(""),
|
|
4529
|
+
f(""), b([]), y(-1), p(!1), r("");
|
|
4529
4530
|
}, C = (k) => {
|
|
4530
4531
|
f(k), p(!isEmpty(k)), c(!0), w(k);
|
|
4531
4532
|
};
|
|
@@ -4545,15 +4546,15 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4545
4546
|
),
|
|
4546
4547
|
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4547
4548
|
] }),
|
|
4548
|
-
(i || !isEmpty(
|
|
4549
|
+
(i || !isEmpty(x) || d && isEmpty(x)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4549
4550
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4550
4551
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4551
|
-
] }) : d && isEmpty(
|
|
4552
|
+
] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4552
4553
|
a("No results found for"),
|
|
4553
4554
|
' "',
|
|
4554
4555
|
m,
|
|
4555
4556
|
'"'
|
|
4556
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(
|
|
4557
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(x == null ? void 0 : x.slice(0, 20), (k, v) => /* @__PURE__ */ jsxs(
|
|
4557
4558
|
"li",
|
|
4558
4559
|
{
|
|
4559
4560
|
onClick: () => S(k),
|
|
@@ -4651,24 +4652,24 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4651
4652
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4652
4653
|
}, [o, u]);
|
|
4653
4654
|
const m = () => {
|
|
4654
|
-
const
|
|
4655
|
-
if (
|
|
4656
|
-
const h = (
|
|
4655
|
+
const b = findIndex(u, { _id: g });
|
|
4656
|
+
if (b > -1) {
|
|
4657
|
+
const h = (b + 1) % u.length, y = get(u, [h, "_id"]);
|
|
4657
4658
|
if (!y) return;
|
|
4658
4659
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4659
4660
|
}
|
|
4660
4661
|
}, f = () => {
|
|
4661
|
-
const
|
|
4662
|
-
if (
|
|
4663
|
-
const h = (
|
|
4662
|
+
const b = findIndex(u, { _id: g });
|
|
4663
|
+
if (b > -1) {
|
|
4664
|
+
const h = (b - 1 + u.length) % u.length, y = get(u, [h, "_id"]);
|
|
4664
4665
|
if (!y) return;
|
|
4665
4666
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4666
4667
|
}
|
|
4667
|
-
},
|
|
4668
|
-
const
|
|
4668
|
+
}, x = () => {
|
|
4669
|
+
const b = i(
|
|
4669
4670
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4670
4671
|
p == null ? void 0 : p._id
|
|
4671
|
-
), h =
|
|
4672
|
+
), h = b == null ? void 0 : b._id;
|
|
4672
4673
|
h && (n({ ...o, currentSlide: h }), c([h]));
|
|
4673
4674
|
};
|
|
4674
4675
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
@@ -4686,7 +4687,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4686
4687
|
/* @__PURE__ */ jsxs(
|
|
4687
4688
|
"button",
|
|
4688
4689
|
{
|
|
4689
|
-
onClick:
|
|
4690
|
+
onClick: x,
|
|
4690
4691
|
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",
|
|
4691
4692
|
children: [
|
|
4692
4693
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4747,8 +4748,8 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4747
4748
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4748
4749
|
className: "text-xs",
|
|
4749
4750
|
pattern: "[0-9]*",
|
|
4750
|
-
onChange: (
|
|
4751
|
-
let h =
|
|
4751
|
+
onChange: (b) => {
|
|
4752
|
+
let h = b.target.value;
|
|
4752
4753
|
h.length && (h = h.replace("-", "")), n({ ...o, autoplayInterval: h });
|
|
4753
4754
|
}
|
|
4754
4755
|
}
|
|
@@ -4780,22 +4781,22 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4780
4781
|
useEffect(() => {
|
|
4781
4782
|
a || c([]), p(o);
|
|
4782
4783
|
}, [a, o]);
|
|
4783
|
-
const u = (
|
|
4784
|
-
(
|
|
4785
|
-
const
|
|
4786
|
-
|
|
4784
|
+
const u = (x) => Array.isArray(x) ? "array" : typeof x == "object" && x !== null ? "object" : "value", g = React.useCallback(
|
|
4785
|
+
(x) => {
|
|
4786
|
+
const b = (h) => r === "value" ? h === "value" || h === "object" : r === "array" ? h === "array" : h === r;
|
|
4787
|
+
x.type === "object" ? (c((h) => [...h, x.key]), p(x.value)) : b(x.type) && (n([...i, x.key].join(".")), l(!1));
|
|
4787
4788
|
},
|
|
4788
4789
|
[i, n, r]
|
|
4789
4790
|
), m = React.useCallback(() => {
|
|
4790
4791
|
if (i.length > 0) {
|
|
4791
|
-
const
|
|
4792
|
-
c(
|
|
4792
|
+
const x = i.slice(0, -1);
|
|
4793
|
+
c(x), p(x.reduce((b, h) => b[h], o));
|
|
4793
4794
|
}
|
|
4794
|
-
}, [i, o]), f = React.useMemo(() => Object.entries(d).map(([
|
|
4795
|
-
key:
|
|
4796
|
-
value:
|
|
4797
|
-
type: u(
|
|
4798
|
-
})).filter((
|
|
4795
|
+
}, [i, o]), f = React.useMemo(() => Object.entries(d).map(([x, b]) => ({
|
|
4796
|
+
key: x,
|
|
4797
|
+
value: b,
|
|
4798
|
+
type: u(b)
|
|
4799
|
+
})).filter((x) => r === "value" ? x.type === "value" || x.type === "object" : r === "array" ? x.type === "array" || x.type === "object" : r === "object" ? x.type === "object" : !0), [d, r]);
|
|
4799
4800
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4800
4801
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4801
4802
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
@@ -4820,33 +4821,33 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4820
4821
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4821
4822
|
"Back"
|
|
4822
4823
|
] }),
|
|
4823
|
-
f.map((
|
|
4824
|
+
f.map((x) => /* @__PURE__ */ jsxs(
|
|
4824
4825
|
CommandItem,
|
|
4825
4826
|
{
|
|
4826
|
-
value:
|
|
4827
|
+
value: x.key,
|
|
4827
4828
|
disabled: !1,
|
|
4828
|
-
onSelect: () => g(
|
|
4829
|
+
onSelect: () => g(x),
|
|
4829
4830
|
className: "flex items-center justify-between",
|
|
4830
4831
|
children: [
|
|
4831
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
4832
|
+
/* @__PURE__ */ jsx("span", { children: x.key }),
|
|
4832
4833
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4833
|
-
r === "object" &&
|
|
4834
|
+
r === "object" && x.type === "object" && /* @__PURE__ */ jsx(
|
|
4834
4835
|
Button,
|
|
4835
4836
|
{
|
|
4836
4837
|
size: "sm",
|
|
4837
4838
|
variant: "ghost",
|
|
4838
4839
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4839
|
-
onClick: (
|
|
4840
|
-
|
|
4840
|
+
onClick: (b) => {
|
|
4841
|
+
b.stopPropagation(), n([...i, x.key].join(".")), l(!1);
|
|
4841
4842
|
},
|
|
4842
4843
|
children: "Select"
|
|
4843
4844
|
}
|
|
4844
4845
|
),
|
|
4845
|
-
(
|
|
4846
|
+
(x.type === "object" || x.type === "array") && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
|
|
4846
4847
|
] })
|
|
4847
4848
|
]
|
|
4848
4849
|
},
|
|
4849
|
-
|
|
4850
|
+
x.key
|
|
4850
4851
|
))
|
|
4851
4852
|
] })
|
|
4852
4853
|
] })
|
|
@@ -4867,29 +4868,29 @@ const CustomFieldTemplate = ({
|
|
|
4867
4868
|
formData: g,
|
|
4868
4869
|
onChange: m
|
|
4869
4870
|
}) => {
|
|
4870
|
-
const { selectedLang: f, fallbackLang:
|
|
4871
|
+
const { selectedLang: f, fallbackLang: x, languages: b } = useLanguages(), h = isEmpty(b) ? "" : isEmpty(f) ? x : f, y = get(LANGUAGES, h, h), B = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), S = get(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [A, _] = useState(null), C = useCallback(
|
|
4871
4872
|
(v) => {
|
|
4872
|
-
const N = (j) => /[.,!?;:]/.test(j), I = (j, R,
|
|
4873
|
+
const N = (j) => /[.,!?;:]/.test(j), I = (j, R, M) => {
|
|
4873
4874
|
let L = "", $ = "";
|
|
4874
4875
|
const O = R > 0 ? j[R - 1] : "", H = R < j.length ? j[R] : "";
|
|
4875
4876
|
return R > 0 && (O === "." || !N(O) && O !== " ") && (L = " "), R < j.length && !N(H) && H !== " " && ($ = " "), {
|
|
4876
|
-
text: L +
|
|
4877
|
+
text: L + M + $,
|
|
4877
4878
|
prefixLength: L.length,
|
|
4878
4879
|
suffixLength: $.length
|
|
4879
4880
|
};
|
|
4880
|
-
},
|
|
4881
|
-
if (!
|
|
4882
|
-
const
|
|
4883
|
-
if (
|
|
4884
|
-
const j =
|
|
4881
|
+
}, P = document.getElementById(o);
|
|
4882
|
+
if (!P) return;
|
|
4883
|
+
const D = document.getElementById(`quill.${o}`);
|
|
4884
|
+
if (D && "__quill" in D) {
|
|
4885
|
+
const j = D.__quill;
|
|
4885
4886
|
if (j) {
|
|
4886
4887
|
const R = `{{${v}}}`;
|
|
4887
4888
|
j.focus();
|
|
4888
|
-
let
|
|
4889
|
-
if (
|
|
4890
|
-
if (
|
|
4891
|
-
const L =
|
|
4892
|
-
j.deleteText(
|
|
4889
|
+
let M = j.getSelection();
|
|
4890
|
+
if (M || (M = j.getSelection(!0)), M)
|
|
4891
|
+
if (M.length > 0) {
|
|
4892
|
+
const L = M.index;
|
|
4893
|
+
j.deleteText(M.index, M.length), j.setSelection(L, 0);
|
|
4893
4894
|
const $ = j.getText(), {
|
|
4894
4895
|
text: O,
|
|
4895
4896
|
prefixLength: H,
|
|
@@ -4897,7 +4898,7 @@ const CustomFieldTemplate = ({
|
|
|
4897
4898
|
} = I($, L, R);
|
|
4898
4899
|
j.insertText(L, O), j.setSelection(L + H + R.length + V, 0);
|
|
4899
4900
|
} else {
|
|
4900
|
-
const L =
|
|
4901
|
+
const L = M.index;
|
|
4901
4902
|
j.setSelection(L, 0);
|
|
4902
4903
|
const $ = j.getText(), {
|
|
4903
4904
|
text: O,
|
|
@@ -4920,13 +4921,13 @@ const CustomFieldTemplate = ({
|
|
|
4920
4921
|
return;
|
|
4921
4922
|
}
|
|
4922
4923
|
} else {
|
|
4923
|
-
const j =
|
|
4924
|
+
const j = P, R = j.selectionStart || 0, M = j.value || "", L = j.selectionEnd || R;
|
|
4924
4925
|
if (L > R) {
|
|
4925
|
-
const F = `{{${v}}}`, { text: z } = I(
|
|
4926
|
+
const F = `{{${v}}}`, { text: z } = I(M, R, F), W = M.slice(0, R) + z + M.slice(L);
|
|
4926
4927
|
m(W, {}, o);
|
|
4927
4928
|
return;
|
|
4928
4929
|
}
|
|
4929
|
-
const O = `{{${v}}}`, { text: H } = I(
|
|
4930
|
+
const O = `{{${v}}}`, { text: H } = I(M, R, O), V = M.slice(0, R) + H + M.slice(R);
|
|
4930
4931
|
m(V, {}, o);
|
|
4931
4932
|
}
|
|
4932
4933
|
},
|
|
@@ -5041,17 +5042,17 @@ const CustomFieldTemplate = ({
|
|
|
5041
5042
|
}), a;
|
|
5042
5043
|
};
|
|
5043
5044
|
function BlockSettings() {
|
|
5044
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m),
|
|
5045
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m), x = ({ formData: A }, _, C) => {
|
|
5045
5046
|
_ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(A, _) }, C);
|
|
5046
|
-
},
|
|
5047
|
+
}, b = useCallback(
|
|
5047
5048
|
debounce(({ formData: A }, _, C) => {
|
|
5048
|
-
|
|
5049
|
+
x({ formData: A }, _, C), d(A);
|
|
5049
5050
|
}, 1500),
|
|
5050
5051
|
[n == null ? void 0 : n._id, o]
|
|
5051
5052
|
), h = ({ formData: A }, _) => {
|
|
5052
|
-
_ && (r([n._id], { [_]: get(A, _) }),
|
|
5053
|
+
_ && (r([n._id], { [_]: get(A, _) }), b({ formData: A }, _, { [_]: get(c, _) }));
|
|
5053
5054
|
}, y = ({ formData: A }, _) => {
|
|
5054
|
-
_ && (r([g._id], { [_]: get(A, _) }),
|
|
5055
|
+
_ && (r([g._id], { [_]: get(A, _) }), b({ formData: A }, _, { [_]: get(c, _) }));
|
|
5055
5056
|
};
|
|
5056
5057
|
keys(get(i, "_bindings", {}));
|
|
5057
5058
|
const { schema: B, uiSchema: E } = useMemo(() => {
|
|
@@ -5195,17 +5196,17 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5195
5196
|
}, Breakpoints$1 = ({ openDelay: o = 400, canvas: n = !1 }) => {
|
|
5196
5197
|
const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (h) => {
|
|
5197
5198
|
p.includes(h) ? p.length > 2 && u(p.filter((y) => y !== h)) : u((y) => [...y, h]);
|
|
5198
|
-
},
|
|
5199
|
+
}, x = (h) => {
|
|
5199
5200
|
n || a(h), i(h);
|
|
5200
|
-
},
|
|
5201
|
+
}, b = getBreakpointValue(n ? l : r).toLowerCase();
|
|
5201
5202
|
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (h) => /* @__PURE__ */ createElement(
|
|
5202
5203
|
BreakpointCard,
|
|
5203
5204
|
{
|
|
5204
5205
|
canvas: n,
|
|
5205
5206
|
...h,
|
|
5206
|
-
onClick:
|
|
5207
|
+
onClick: x,
|
|
5207
5208
|
key: h.breakpoint,
|
|
5208
|
-
currentBreakpoint:
|
|
5209
|
+
currentBreakpoint: b
|
|
5209
5210
|
}
|
|
5210
5211
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5211
5212
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
@@ -5216,9 +5217,9 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5216
5217
|
canvas: n,
|
|
5217
5218
|
openDelay: o,
|
|
5218
5219
|
...h,
|
|
5219
|
-
onClick:
|
|
5220
|
+
onClick: x,
|
|
5220
5221
|
key: h.breakpoint,
|
|
5221
|
-
currentBreakpoint:
|
|
5222
|
+
currentBreakpoint: b
|
|
5222
5223
|
}
|
|
5223
5224
|
)
|
|
5224
5225
|
) }),
|
|
@@ -5324,8 +5325,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5324
5325
|
(f = d.current) == null || f.focus();
|
|
5325
5326
|
}, []);
|
|
5326
5327
|
const m = (f) => {
|
|
5327
|
-
const { usage:
|
|
5328
|
-
!l &&
|
|
5328
|
+
const { usage: x } = f || {};
|
|
5329
|
+
!l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5329
5330
|
};
|
|
5330
5331
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
5331
5332
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -5380,25 +5381,25 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5380
5381
|
] });
|
|
5381
5382
|
};
|
|
5382
5383
|
function ManualClasses() {
|
|
5383
|
-
var
|
|
5384
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), f = useBuilderProp("askAiCallBack", null), [
|
|
5385
|
-
const P =
|
|
5386
|
-
u(m, P, !0),
|
|
5387
|
-
}, [
|
|
5388
|
-
const
|
|
5389
|
-
let
|
|
5390
|
-
if (
|
|
5391
|
-
const [
|
|
5392
|
-
|
|
5393
|
-
...
|
|
5394
|
-
item: { ...
|
|
5384
|
+
var I;
|
|
5385
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), f = useBuilderProp("askAiCallBack", null), [x, b] = useState(""), h = (I = first(d)) == null ? void 0 : I.prop, { classes: y } = getSplitChaiClasses(get(p, h, "")), B = y.split(" ").filter((P) => !isEmpty(P)), E = () => {
|
|
5386
|
+
const P = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5387
|
+
u(m, P, !0), b("");
|
|
5388
|
+
}, [w, S] = useState([]), A = ({ value: P }) => {
|
|
5389
|
+
const D = P.trim().toLowerCase(), j = D.match(/.+:/g);
|
|
5390
|
+
let R = [];
|
|
5391
|
+
if (j && j.length > 0) {
|
|
5392
|
+
const [M] = j, L = D.replace(M, "");
|
|
5393
|
+
R = i.search(L).map((O) => ({
|
|
5394
|
+
...O,
|
|
5395
|
+
item: { ...O.item, name: M + O.item.name }
|
|
5395
5396
|
}));
|
|
5396
5397
|
} else
|
|
5397
|
-
|
|
5398
|
-
return
|
|
5399
|
-
},
|
|
5400
|
-
|
|
5401
|
-
},
|
|
5398
|
+
R = i.search(D);
|
|
5399
|
+
return S(map(R, "item"));
|
|
5400
|
+
}, _ = () => {
|
|
5401
|
+
S([]);
|
|
5402
|
+
}, C = (P) => P.name, T = (P) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: P.name }), k = useMemo(
|
|
5402
5403
|
() => ({
|
|
5403
5404
|
ref: o,
|
|
5404
5405
|
autoComplete: "off",
|
|
@@ -5406,38 +5407,31 @@ function ManualClasses() {
|
|
|
5406
5407
|
autoCapitalize: "off",
|
|
5407
5408
|
spellCheck: !1,
|
|
5408
5409
|
placeholder: c("Enter classes separated by space"),
|
|
5409
|
-
value:
|
|
5410
|
+
value: x,
|
|
5410
5411
|
onKeyDown: (P) => {
|
|
5411
|
-
P.key === "Enter" &&
|
|
5412
|
+
P.key === "Enter" && x.trim() !== "" && E();
|
|
5412
5413
|
},
|
|
5413
|
-
onChange: (P, { newValue:
|
|
5414
|
+
onChange: (P, { newValue: D }) => b(D),
|
|
5414
5415
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5415
5416
|
}),
|
|
5416
|
-
[
|
|
5417
|
-
),
|
|
5417
|
+
[x, c, o]
|
|
5418
|
+
), v = (P) => {
|
|
5418
5419
|
debugger;
|
|
5419
|
-
const
|
|
5420
|
-
g(m, [P]), u(m,
|
|
5421
|
-
},
|
|
5420
|
+
const D = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5421
|
+
g(m, [P]), u(m, D, !0), r(""), l(-1);
|
|
5422
|
+
}, N = () => {
|
|
5422
5423
|
if (navigator.clipboard === void 0) {
|
|
5423
|
-
|
|
5424
|
-
title: c("Clipboard not supported"),
|
|
5425
|
-
description: c("Please use Chrome, Firefox or Safari"),
|
|
5426
|
-
variant: "destructive"
|
|
5427
|
-
});
|
|
5424
|
+
toast.error(c("Clipboard not supported"));
|
|
5428
5425
|
return;
|
|
5429
5426
|
}
|
|
5430
|
-
navigator.clipboard.writeText(
|
|
5431
|
-
title: c("Copied"),
|
|
5432
|
-
description: c("Classes copied to clipboard")
|
|
5433
|
-
});
|
|
5427
|
+
navigator.clipboard.writeText(B.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
5434
5428
|
};
|
|
5435
5429
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5436
5430
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
5437
5431
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5438
5432
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
5439
5433
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5440
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
5434
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: N, className: "cursor-pointer" }) }),
|
|
5441
5435
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
5442
5436
|
] })
|
|
5443
5437
|
] }),
|
|
@@ -5453,12 +5447,12 @@ function ManualClasses() {
|
|
|
5453
5447
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5454
5448
|
Autosuggest,
|
|
5455
5449
|
{
|
|
5456
|
-
suggestions:
|
|
5457
|
-
onSuggestionsFetchRequested:
|
|
5458
|
-
onSuggestionsClearRequested:
|
|
5459
|
-
getSuggestionValue:
|
|
5460
|
-
renderSuggestion:
|
|
5461
|
-
inputProps:
|
|
5450
|
+
suggestions: w,
|
|
5451
|
+
onSuggestionsFetchRequested: A,
|
|
5452
|
+
onSuggestionsClearRequested: _,
|
|
5453
|
+
getSuggestionValue: C,
|
|
5454
|
+
renderSuggestion: T,
|
|
5455
|
+
inputProps: k,
|
|
5462
5456
|
containerProps: {
|
|
5463
5457
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
5464
5458
|
},
|
|
@@ -5474,25 +5468,25 @@ function ManualClasses() {
|
|
|
5474
5468
|
{
|
|
5475
5469
|
variant: "outline",
|
|
5476
5470
|
className: "h-6 border-border",
|
|
5477
|
-
onClick:
|
|
5478
|
-
disabled:
|
|
5471
|
+
onClick: E,
|
|
5472
|
+
disabled: x.trim() === "",
|
|
5479
5473
|
size: "sm",
|
|
5480
5474
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5481
5475
|
}
|
|
5482
5476
|
)
|
|
5483
5477
|
] }),
|
|
5484
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5485
|
-
(P,
|
|
5478
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: B.map(
|
|
5479
|
+
(P, D) => a === D ? /* @__PURE__ */ jsx(
|
|
5486
5480
|
"input",
|
|
5487
5481
|
{
|
|
5488
5482
|
ref: o,
|
|
5489
5483
|
value: n,
|
|
5490
|
-
onChange: (
|
|
5484
|
+
onChange: (j) => r(j.target.value),
|
|
5491
5485
|
onBlur: () => {
|
|
5492
|
-
|
|
5486
|
+
v(P);
|
|
5493
5487
|
},
|
|
5494
|
-
onKeyDown: (
|
|
5495
|
-
|
|
5488
|
+
onKeyDown: (j) => {
|
|
5489
|
+
j.key === "Enter" && v(P);
|
|
5496
5490
|
},
|
|
5497
5491
|
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"
|
|
5498
5492
|
},
|
|
@@ -5864,7 +5858,7 @@ const COLOR_PROP = {
|
|
|
5864
5858
|
return c([]);
|
|
5865
5859
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5866
5860
|
}, [g]);
|
|
5867
|
-
const
|
|
5861
|
+
const x = useCallback(
|
|
5868
5862
|
// eslint-disable-next-line no-shadow
|
|
5869
5863
|
(h) => {
|
|
5870
5864
|
p({ color: g, shade: h });
|
|
@@ -5874,11 +5868,11 @@ const COLOR_PROP = {
|
|
|
5874
5868
|
useEffect(() => {
|
|
5875
5869
|
p({ color: "", shade: "" });
|
|
5876
5870
|
}, [r]);
|
|
5877
|
-
const { match:
|
|
5871
|
+
const { match: b } = useTailwindClassList();
|
|
5878
5872
|
return useEffect(() => {
|
|
5879
5873
|
const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5880
|
-
|
|
5881
|
-
}, [
|
|
5874
|
+
b(o, y) && n(y, o);
|
|
5875
|
+
}, [b, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5882
5876
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5883
5877
|
DropDown,
|
|
5884
5878
|
{
|
|
@@ -5918,7 +5912,7 @@ const COLOR_PROP = {
|
|
|
5918
5912
|
]
|
|
5919
5913
|
}
|
|
5920
5914
|
) }),
|
|
5921
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange:
|
|
5915
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: x, options: i }) })
|
|
5922
5916
|
] });
|
|
5923
5917
|
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
5924
5918
|
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
@@ -6115,7 +6109,7 @@ const COLOR_PROP = {
|
|
|
6115
6109
|
},
|
|
6116
6110
|
a
|
|
6117
6111
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6118
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [
|
|
6112
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, b] = useState(!1), [h, y] = useState(""), [B, E] = useState(!1), [w, S] = useState(!1);
|
|
6119
6113
|
useEffect(() => {
|
|
6120
6114
|
const { value: k, unit: v } = getClassValueAndUnit(i);
|
|
6121
6115
|
if (v === "") {
|
|
@@ -6128,7 +6122,7 @@ const COLOR_PROP = {
|
|
|
6128
6122
|
(k = !1) => {
|
|
6129
6123
|
const v = getUserInputValues(`${a}`, u);
|
|
6130
6124
|
if (get(v, "error", !1)) {
|
|
6131
|
-
|
|
6125
|
+
b(!0);
|
|
6132
6126
|
return;
|
|
6133
6127
|
}
|
|
6134
6128
|
const N = get(v, "unit") !== "" ? get(v, "unit") : m;
|
|
@@ -6138,15 +6132,15 @@ const COLOR_PROP = {
|
|
|
6138
6132
|
}
|
|
6139
6133
|
if (get(v, "value") === "")
|
|
6140
6134
|
return;
|
|
6141
|
-
const
|
|
6142
|
-
k ? _(
|
|
6135
|
+
const P = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
|
|
6136
|
+
k ? _(P) : A(P);
|
|
6143
6137
|
},
|
|
6144
6138
|
[A, _, a, m, d, u]
|
|
6145
6139
|
), T = useCallback(
|
|
6146
6140
|
(k) => {
|
|
6147
6141
|
const v = getUserInputValues(`${a}`, u);
|
|
6148
6142
|
if (get(v, "error", !1)) {
|
|
6149
|
-
|
|
6143
|
+
b(!0);
|
|
6150
6144
|
return;
|
|
6151
6145
|
}
|
|
6152
6146
|
if (k === "auto" || k === "none") {
|
|
@@ -6155,8 +6149,8 @@ const COLOR_PROP = {
|
|
|
6155
6149
|
}
|
|
6156
6150
|
if (get(v, "value") === "")
|
|
6157
6151
|
return;
|
|
6158
|
-
const N = get(v, "unit") !== "" ? get(v, "unit") : k,
|
|
6159
|
-
A(
|
|
6152
|
+
const N = get(v, "unit") !== "" ? get(v, "unit") : k, P = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
|
|
6153
|
+
A(P);
|
|
6160
6154
|
},
|
|
6161
6155
|
[A, a, d, u]
|
|
6162
6156
|
);
|
|
@@ -6189,15 +6183,15 @@ const COLOR_PROP = {
|
|
|
6189
6183
|
const v = parseInt$1(k.target.value);
|
|
6190
6184
|
let N = isNaN$1(v) ? 0 : v;
|
|
6191
6185
|
k.keyCode === 38 && (N += 1), k.keyCode === 40 && (N -= 1);
|
|
6192
|
-
const I = `${N}`,
|
|
6193
|
-
_(
|
|
6186
|
+
const I = `${N}`, D = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6187
|
+
_(D);
|
|
6194
6188
|
},
|
|
6195
6189
|
onKeyUp: (k) => {
|
|
6196
6190
|
w && (k.preventDefault(), S(!1));
|
|
6197
6191
|
},
|
|
6198
6192
|
onBlur: () => C(),
|
|
6199
6193
|
onChange: (k) => {
|
|
6200
|
-
|
|
6194
|
+
b(!1), l(k.target.value);
|
|
6201
6195
|
},
|
|
6202
6196
|
onClick: (k) => {
|
|
6203
6197
|
var v;
|
|
@@ -6206,7 +6200,7 @@ const COLOR_PROP = {
|
|
|
6206
6200
|
value: B ? h : a,
|
|
6207
6201
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6208
6202
|
" ",
|
|
6209
|
-
|
|
6203
|
+
x ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
6210
6204
|
)
|
|
6211
6205
|
}
|
|
6212
6206
|
),
|
|
@@ -6347,17 +6341,17 @@ const COLOR_PROP = {
|
|
|
6347
6341
|
"2xl": "1536px"
|
|
6348
6342
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6349
6343
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6350
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(),
|
|
6344
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), h = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
|
|
6351
6345
|
(_, C = !0) => {
|
|
6352
6346
|
const T = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
|
|
6353
6347
|
(p || u !== "") && (T.mq = "xs");
|
|
6354
6348
|
const k = generateFullClsName(T);
|
|
6355
|
-
f(
|
|
6349
|
+
f(b, [k], C);
|
|
6356
6350
|
},
|
|
6357
|
-
[
|
|
6351
|
+
[b, p, g, u, l, f]
|
|
6358
6352
|
), B = useCallback(() => {
|
|
6359
|
-
b
|
|
6360
|
-
}, [
|
|
6353
|
+
x(b, [h], !0);
|
|
6354
|
+
}, [b, h, x]), E = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6361
6355
|
useEffect(() => {
|
|
6362
6356
|
i(E, m);
|
|
6363
6357
|
}, [E, i, m]);
|
|
@@ -6444,18 +6438,18 @@ const COLOR_PROP = {
|
|
|
6444
6438
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6445
6439
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6446
6440
|
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6447
|
-
n.map(({ label: f, key:
|
|
6441
|
+
n.map(({ label: f, key: x }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6448
6442
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6449
6443
|
"button",
|
|
6450
6444
|
{
|
|
6451
6445
|
type: "button",
|
|
6452
|
-
onClick: () => u(
|
|
6453
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6446
|
+
onClick: () => u(x),
|
|
6447
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6454
6448
|
children: [
|
|
6455
6449
|
React__default.createElement("div", {
|
|
6456
|
-
className: m(
|
|
6450
|
+
className: m(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6457
6451
|
}),
|
|
6458
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6452
|
+
React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6459
6453
|
]
|
|
6460
6454
|
}
|
|
6461
6455
|
) }),
|
|
@@ -6601,9 +6595,9 @@ function BlockStyling() {
|
|
|
6601
6595
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6602
6596
|
let f = parseFloat(i.dragStartValue);
|
|
6603
6597
|
f = isNaN(f) ? 0 : f;
|
|
6604
|
-
let
|
|
6605
|
-
(startsWith(m, "scale") || m === "opacity") && (
|
|
6606
|
-
let h = (i.dragStartY - u.pageY) /
|
|
6598
|
+
let x = MAPPER[i.dragUnit];
|
|
6599
|
+
(startsWith(m, "scale") || m === "opacity") && (x = 10);
|
|
6600
|
+
let h = (i.dragStartY - u.pageY) / x + f;
|
|
6607
6601
|
g && h < 0 && (h = 0), m === "opacity" && h > 1 && (h = 1), i.onDrag(`${h}`), l(`${h}`);
|
|
6608
6602
|
},
|
|
6609
6603
|
[i],
|
|
@@ -6653,7 +6647,7 @@ const CoreBlock = ({
|
|
|
6653
6647
|
} else
|
|
6654
6648
|
p(o, r || null, a);
|
|
6655
6649
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6656
|
-
},
|
|
6650
|
+
}, x = useFeature("dnd"), { t: b } = useTranslation();
|
|
6657
6651
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6658
6652
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6659
6653
|
"button",
|
|
@@ -6666,15 +6660,15 @@ const CoreBlock = ({
|
|
|
6666
6660
|
g([]), m();
|
|
6667
6661
|
}, 200);
|
|
6668
6662
|
},
|
|
6669
|
-
draggable:
|
|
6663
|
+
draggable: x ? "true" : "false",
|
|
6670
6664
|
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",
|
|
6671
6665
|
children: [
|
|
6672
6666
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6673
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6667
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(b(d || i)) })
|
|
6674
6668
|
]
|
|
6675
6669
|
}
|
|
6676
6670
|
) }),
|
|
6677
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6671
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: b(d || i) }) })
|
|
6678
6672
|
] }) });
|
|
6679
6673
|
}, DefaultChaiBlocks = ({
|
|
6680
6674
|
parentId: o,
|
|
@@ -6859,7 +6853,7 @@ const CoreBlock = ({
|
|
|
6859
6853
|
}
|
|
6860
6854
|
}
|
|
6861
6855
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6862
|
-
var m, f,
|
|
6856
|
+
var m, f, x, b, h, y, B, E;
|
|
6863
6857
|
if (r.type === "comment") return [];
|
|
6864
6858
|
console.log("node ===>", r);
|
|
6865
6859
|
let a = { _id: generateUUID() };
|
|
@@ -6902,8 +6896,8 @@ const CoreBlock = ({
|
|
|
6902
6896
|
...a,
|
|
6903
6897
|
href: ((m = l.find((S) => S.key === "href")) == null ? void 0 : m.value) || "",
|
|
6904
6898
|
hrefType: ((f = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
|
|
6905
|
-
autoplay: ((
|
|
6906
|
-
maxWidth: ((h = (
|
|
6899
|
+
autoplay: ((x = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
|
|
6900
|
+
maxWidth: ((h = (b = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : b.value) == null ? void 0 : h.replace("px", "")) || "",
|
|
6907
6901
|
backdropColor: ((y = l.find((S) => S.key === "data-overlay")) == null ? void 0 : y.value) || "",
|
|
6908
6902
|
galleryName: ((B = l.find((S) => S.key === "data-gall")) == null ? void 0 : B.value) || ""
|
|
6909
6903
|
}, forEach(w, (S) => {
|
|
@@ -6986,8 +6980,8 @@ const CoreBlock = ({
|
|
|
6986
6980
|
/* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: a.trim() === "", onClick: () => c(), size: "sm", className: "w-fit", children: r("Import HTML") }) })
|
|
6987
6981
|
] });
|
|
6988
6982
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
6989
|
-
var
|
|
6990
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (
|
|
6983
|
+
var b;
|
|
6984
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (b = find(c, (h) => h._id === r)) == null ? void 0 : b._type;
|
|
6991
6985
|
useEffect(() => {
|
|
6992
6986
|
const h = setTimeout(() => {
|
|
6993
6987
|
var y;
|
|
@@ -7000,7 +6994,7 @@ const CoreBlock = ({
|
|
|
7000
6994
|
var y, B;
|
|
7001
6995
|
return (((y = h.label) == null ? void 0 : y.toLowerCase()) + " " + ((B = h.type) == null ? void 0 : B.toLowerCase())).includes(d.toLowerCase());
|
|
7002
6996
|
}
|
|
7003
|
-
) : n,
|
|
6997
|
+
) : n, x = d ? o.filter((h) => reject(filter(values(f), { group: h }), { hidden: !0 }).length > 0) : o.filter((h) => reject(filter(values(n), { group: h }), { hidden: !0 }).length > 0);
|
|
7004
6998
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-2xl flex-col", children: [
|
|
7005
6999
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7006
7000
|
Input$1,
|
|
@@ -7012,13 +7006,13 @@ const CoreBlock = ({
|
|
|
7012
7006
|
onChange: (h) => p(h.target.value)
|
|
7013
7007
|
}
|
|
7014
7008
|
) }),
|
|
7015
|
-
/* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children:
|
|
7009
|
+
/* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: x.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
7016
7010
|
i("No blocks found matching"),
|
|
7017
7011
|
' "',
|
|
7018
7012
|
d,
|
|
7019
7013
|
'"'
|
|
7020
7014
|
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: sortBy(
|
|
7021
|
-
|
|
7015
|
+
x,
|
|
7022
7016
|
(h) => CORE_GROUPS.indexOf(h) === -1 ? 99 : CORE_GROUPS.indexOf(h)
|
|
7023
7017
|
).map((h) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7024
7018
|
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(h.toLowerCase())) }),
|
|
@@ -7125,7 +7119,7 @@ const BlockCard = ({
|
|
|
7125
7119
|
parentId: r = void 0,
|
|
7126
7120
|
position: a = -1
|
|
7127
7121
|
}) => {
|
|
7128
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), f = useFeature("dnd"), [,
|
|
7122
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), b = (B) => {
|
|
7129
7123
|
const E = has(B, "styles_attrs.data-page-section");
|
|
7130
7124
|
return B._type === "Box" && E;
|
|
7131
7125
|
}, h = useCallback(
|
|
@@ -7150,7 +7144,7 @@ const BlockCard = ({
|
|
|
7150
7144
|
onDragStart: async (B) => {
|
|
7151
7145
|
const E = await c(n, o);
|
|
7152
7146
|
let w = r;
|
|
7153
|
-
if (
|
|
7147
|
+
if (b(first(E)) && (w = null), !isEmpty(E)) {
|
|
7154
7148
|
const S = { blocks: E, uiLibrary: !0, parent: w };
|
|
7155
7149
|
if (B.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
|
|
7156
7150
|
const A = new Image();
|
|
@@ -7159,7 +7153,7 @@ const BlockCard = ({
|
|
|
7159
7153
|
};
|
|
7160
7154
|
} else
|
|
7161
7155
|
B.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7162
|
-
|
|
7156
|
+
x(S), setTimeout(() => {
|
|
7163
7157
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7164
7158
|
}, 200);
|
|
7165
7159
|
}
|
|
@@ -7191,9 +7185,9 @@ const BlockCard = ({
|
|
|
7191
7185
|
})();
|
|
7192
7186
|
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
7193
7187
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7194
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, f] = useState("Hero"),
|
|
7195
|
-
|
|
7196
|
-
|
|
7188
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, f] = useState("Hero"), x = get(g, m, []), b = useRef(null), { t: h } = useTranslation(), y = (w) => {
|
|
7189
|
+
b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
|
|
7190
|
+
b.current && f(w);
|
|
7197
7191
|
}, 300);
|
|
7198
7192
|
};
|
|
7199
7193
|
if (u)
|
|
@@ -7201,7 +7195,7 @@ const BlockCard = ({
|
|
|
7201
7195
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7202
7196
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7203
7197
|
] });
|
|
7204
|
-
const B = filter(
|
|
7198
|
+
const B = filter(x, (w, S) => S % 2 === 0), E = filter(x, (w, S) => S % 2 === 1);
|
|
7205
7199
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
|
|
7206
7200
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7207
7201
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
@@ -7213,7 +7207,7 @@ const BlockCard = ({
|
|
|
7213
7207
|
"div",
|
|
7214
7208
|
{
|
|
7215
7209
|
onMouseEnter: () => y(S),
|
|
7216
|
-
onMouseLeave: () => clearTimeout(
|
|
7210
|
+
onMouseLeave: () => clearTimeout(b.current),
|
|
7217
7211
|
onClick: () => f(S),
|
|
7218
7212
|
className: cn(
|
|
7219
7213
|
"flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
@@ -7232,7 +7226,7 @@ const BlockCard = ({
|
|
|
7232
7226
|
/* @__PURE__ */ jsxs(
|
|
7233
7227
|
ScrollArea,
|
|
7234
7228
|
{
|
|
7235
|
-
onMouseEnter: () =>
|
|
7229
|
+
onMouseEnter: () => b.current ? clearTimeout(b.current) : null,
|
|
7236
7230
|
className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
|
|
7237
7231
|
children: [
|
|
7238
7232
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
@@ -7460,10 +7454,10 @@ function BiExpandVertical(o) {
|
|
|
7460
7454
|
return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z" }, child: [] }] })(o);
|
|
7461
7455
|
}
|
|
7462
7456
|
const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
7463
|
-
var
|
|
7457
|
+
var D;
|
|
7464
7458
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7465
7459
|
let p = null;
|
|
7466
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data:
|
|
7460
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data: x, isSelected: b, willReceiveDrop: h, isDragging: y, isEditing: B, handleClick: E } = o, w = (j) => {
|
|
7467
7461
|
j.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7468
7462
|
}, S = (j) => {
|
|
7469
7463
|
j.isInternal && (p = j.isOpen, j.isOpen && j.close());
|
|
@@ -7484,19 +7478,19 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7484
7478
|
return () => clearTimeout(j);
|
|
7485
7479
|
}, [h, o, y]);
|
|
7486
7480
|
const N = useMemo(() => {
|
|
7487
|
-
const j = Object.keys(
|
|
7488
|
-
for (let
|
|
7489
|
-
if (j[
|
|
7490
|
-
const L =
|
|
7481
|
+
const j = Object.keys(x), R = [];
|
|
7482
|
+
for (let M = 0; M < j.length; M++)
|
|
7483
|
+
if (j[M].endsWith("_attrs")) {
|
|
7484
|
+
const L = x[j[M]], $ = Object.keys(L).join("|");
|
|
7491
7485
|
$.match(/x-data/) && R.push("data"), $.match(/x-on/) && R.push("event"), $.match(/x-show|x-if/) && R.push("show");
|
|
7492
7486
|
}
|
|
7493
7487
|
return R;
|
|
7494
|
-
}, [
|
|
7495
|
-
const
|
|
7488
|
+
}, [x]), I = (j, R) => {
|
|
7489
|
+
const M = d.contentDocument || d.contentWindow.document, L = M.querySelector(`[data-block-id=${j}]`);
|
|
7496
7490
|
L && L.setAttribute("data-drop", R);
|
|
7497
7491
|
const $ = L.getBoundingClientRect(), O = d.getBoundingClientRect();
|
|
7498
|
-
$.top >= O.top && $.left >= O.left && $.bottom <= O.bottom && $.right <= O.right || (
|
|
7499
|
-
},
|
|
7492
|
+
$.top >= O.top && $.left >= O.left && $.bottom <= O.bottom && $.right <= O.right || (M.documentElement.scrollTop = L.offsetTop - O.top);
|
|
7493
|
+
}, P = (j) => {
|
|
7500
7494
|
k();
|
|
7501
7495
|
const R = get(o, "parent.id");
|
|
7502
7496
|
R !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: R, position: j }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: j });
|
|
@@ -7506,7 +7500,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7506
7500
|
/* @__PURE__ */ jsx(
|
|
7507
7501
|
"div",
|
|
7508
7502
|
{
|
|
7509
|
-
onClick: () =>
|
|
7503
|
+
onClick: () => P(-1),
|
|
7510
7504
|
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
7511
7505
|
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-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
|
|
7512
7506
|
/* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7537,11 +7531,11 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7537
7531
|
j.preventDefault(), I(f, "no");
|
|
7538
7532
|
},
|
|
7539
7533
|
children: [
|
|
7540
|
-
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((
|
|
7534
|
+
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((D = o == null ? void 0 : o.parent) == null ? void 0 : D.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
7541
7535
|
"div",
|
|
7542
7536
|
{
|
|
7543
7537
|
onClick: (j) => {
|
|
7544
|
-
j.stopPropagation(),
|
|
7538
|
+
j.stopPropagation(), P(o.childIndex);
|
|
7545
7539
|
},
|
|
7546
7540
|
onMouseEnter: T,
|
|
7547
7541
|
onMouseLeave: k,
|
|
@@ -7554,8 +7548,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7554
7548
|
{
|
|
7555
7549
|
className: cn(
|
|
7556
7550
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7557
|
-
|
|
7558
|
-
h && canAcceptChildBlock(
|
|
7551
|
+
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7552
|
+
h && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
|
|
7559
7553
|
(o == null ? void 0 : o.id) === _ ? "bg-purple-100" : "",
|
|
7560
7554
|
y && "opacity-20",
|
|
7561
7555
|
i.includes(f) ? "opacity-50" : ""
|
|
@@ -7569,13 +7563,13 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7569
7563
|
children: u && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(
|
|
7570
7564
|
ChevronRight,
|
|
7571
7565
|
{
|
|
7572
|
-
className: `h-3 w-3 stroke-[3] ${
|
|
7566
|
+
className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
|
|
7573
7567
|
}
|
|
7574
7568
|
) })
|
|
7575
7569
|
}
|
|
7576
7570
|
),
|
|
7577
7571
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7578
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7572
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
|
|
7579
7573
|
B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7580
7574
|
"div",
|
|
7581
7575
|
{
|
|
@@ -7584,7 +7578,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7584
7578
|
j.stopPropagation(), o.edit(), o.deselect();
|
|
7585
7579
|
},
|
|
7586
7580
|
children: [
|
|
7587
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7581
|
+
/* @__PURE__ */ jsx("span", { children: (x == null ? void 0 : x._name) || (x == null ? void 0 : x._type.split("/").pop()) }),
|
|
7588
7582
|
N.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7589
7583
|
N.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
|
|
7590
7584
|
N.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
|
|
@@ -7605,7 +7599,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7605
7599
|
),
|
|
7606
7600
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: j.tooltip })
|
|
7607
7601
|
] })),
|
|
7608
|
-
canAddChildBlock(
|
|
7602
|
+
canAddChildBlock(x == null ? void 0 : x._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7609
7603
|
/* @__PURE__ */ jsx(
|
|
7610
7604
|
TooltipTrigger,
|
|
7611
7605
|
{
|
|
@@ -8284,11 +8278,11 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8284
8278
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8285
8279
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), f = useRef(null);
|
|
8286
8280
|
useEffect(() => {
|
|
8287
|
-
var
|
|
8288
|
-
(
|
|
8281
|
+
var b;
|
|
8282
|
+
(b = m.current) == null || b.focus();
|
|
8289
8283
|
}, []);
|
|
8290
|
-
const
|
|
8291
|
-
const { usage: h } =
|
|
8284
|
+
const x = (b) => {
|
|
8285
|
+
const { usage: h } = b || {};
|
|
8292
8286
|
!l && h && g(h), f.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8293
8287
|
};
|
|
8294
8288
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -8309,12 +8303,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8309
8303
|
{
|
|
8310
8304
|
ref: m,
|
|
8311
8305
|
value: i,
|
|
8312
|
-
onChange: (
|
|
8306
|
+
onChange: (b) => c(b.target.value),
|
|
8313
8307
|
placeholder: n("Ask AI to edit content"),
|
|
8314
8308
|
className: "w-full",
|
|
8315
8309
|
rows: 3,
|
|
8316
|
-
onKeyDown: (
|
|
8317
|
-
|
|
8310
|
+
onKeyDown: (b) => {
|
|
8311
|
+
b.key === "Enter" && (b.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, x));
|
|
8318
8312
|
}
|
|
8319
8313
|
}
|
|
8320
8314
|
),
|
|
@@ -8324,7 +8318,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8324
8318
|
{
|
|
8325
8319
|
disabled: i.trim().length < 5 || a,
|
|
8326
8320
|
onClick: () => {
|
|
8327
|
-
f.current && clearTimeout(f.current), g(void 0), r("content", o, i,
|
|
8321
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, i, x);
|
|
8328
8322
|
},
|
|
8329
8323
|
variant: "default",
|
|
8330
8324
|
className: "w-fit",
|
|
@@ -8356,8 +8350,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8356
8350
|
/* @__PURE__ */ jsx(
|
|
8357
8351
|
QuickPrompts,
|
|
8358
8352
|
{
|
|
8359
|
-
onClick: (
|
|
8360
|
-
f.current && clearTimeout(f.current), g(void 0), r("content", o,
|
|
8353
|
+
onClick: (b) => {
|
|
8354
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, b, x);
|
|
8361
8355
|
}
|
|
8362
8356
|
}
|
|
8363
8357
|
)
|
|
@@ -8367,17 +8361,13 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8367
8361
|
] }) }) : null
|
|
8368
8362
|
] });
|
|
8369
8363
|
}, AISetContext = () => {
|
|
8370
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1),
|
|
8364
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), m = useRef(null);
|
|
8371
8365
|
useEffect(() => {
|
|
8372
8366
|
n && a(n);
|
|
8373
8367
|
}, [n]);
|
|
8374
|
-
const
|
|
8368
|
+
const f = async () => {
|
|
8375
8369
|
try {
|
|
8376
|
-
d(!0), u(null), await i(r), m(
|
|
8377
|
-
title: o("Updated AI Context"),
|
|
8378
|
-
description: o("You can now Ask AI to edit your content"),
|
|
8379
|
-
variant: "default"
|
|
8380
|
-
}), f.current.click();
|
|
8370
|
+
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8381
8371
|
} catch (x) {
|
|
8382
8372
|
u(x);
|
|
8383
8373
|
} finally {
|
|
@@ -8393,7 +8383,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8393
8383
|
type: "single",
|
|
8394
8384
|
collapsible: !0,
|
|
8395
8385
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8396
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8386
|
+
/* @__PURE__ */ jsx(AccordionTrigger, { ref: m, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
8397
8387
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
8398
8388
|
/* @__PURE__ */ jsx(
|
|
8399
8389
|
Textarea,
|
|
@@ -8405,7 +8395,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8405
8395
|
className: "mt-1 w-full",
|
|
8406
8396
|
rows: 10,
|
|
8407
8397
|
onKeyDown: (x) => {
|
|
8408
|
-
x.key === "Enter" && (x.preventDefault(),
|
|
8398
|
+
x.key === "Enter" && (x.preventDefault(), f());
|
|
8409
8399
|
}
|
|
8410
8400
|
}
|
|
8411
8401
|
),
|
|
@@ -8417,7 +8407,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8417
8407
|
Button,
|
|
8418
8408
|
{
|
|
8419
8409
|
disabled: r.trim().length < 5,
|
|
8420
|
-
onClick: () =>
|
|
8410
|
+
onClick: () => f(),
|
|
8421
8411
|
variant: "default",
|
|
8422
8412
|
className: "w-fit",
|
|
8423
8413
|
size: "sm",
|
|
@@ -8446,7 +8436,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8446
8436
|
AlertDialogAction,
|
|
8447
8437
|
{
|
|
8448
8438
|
onClick: () => {
|
|
8449
|
-
a(""),
|
|
8439
|
+
a(""), f();
|
|
8450
8440
|
},
|
|
8451
8441
|
children: o("Yes, Delete")
|
|
8452
8442
|
}
|
|
@@ -8600,7 +8590,7 @@ const AiAssistant = () => {
|
|
|
8600
8590
|
] })
|
|
8601
8591
|
] });
|
|
8602
8592
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
|
|
8603
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""),
|
|
8593
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), x = useRef(null), b = useRef(null);
|
|
8604
8594
|
useEffect(() => {
|
|
8605
8595
|
l(n);
|
|
8606
8596
|
}, [n]);
|
|
@@ -8647,7 +8637,7 @@ const AiAssistant = () => {
|
|
|
8647
8637
|
autoCorrect: "off",
|
|
8648
8638
|
spellCheck: "false",
|
|
8649
8639
|
id: "attrKey",
|
|
8650
|
-
ref:
|
|
8640
|
+
ref: x,
|
|
8651
8641
|
value: i,
|
|
8652
8642
|
onChange: (S) => c(S.target.value),
|
|
8653
8643
|
placeholder: "Enter Key",
|
|
@@ -8665,7 +8655,7 @@ const AiAssistant = () => {
|
|
|
8665
8655
|
spellCheck: "false",
|
|
8666
8656
|
id: "attrValue",
|
|
8667
8657
|
rows: 2,
|
|
8668
|
-
ref:
|
|
8658
|
+
ref: b,
|
|
8669
8659
|
value: d,
|
|
8670
8660
|
onChange: (S) => p(S.target.value),
|
|
8671
8661
|
onKeyDown: (S) => {
|
|
@@ -8869,7 +8859,7 @@ const ChooseLayout = ({ open: o, close: n }) => {
|
|
|
8869
8859
|
)
|
|
8870
8860
|
] }) })
|
|
8871
8861
|
] }) });
|
|
8872
|
-
}, TopBar = lazy(() => import("./Topbar-
|
|
8862
|
+
}, TopBar = lazy(() => import("./Topbar-DutZ_viX.js"));
|
|
8873
8863
|
function useSidebarMenuItems() {
|
|
8874
8864
|
return useMemo(() => compact([
|
|
8875
8865
|
{
|
|
@@ -8885,12 +8875,12 @@ const RootLayout = () => {
|
|
|
8885
8875
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
8886
8876
|
n(1);
|
|
8887
8877
|
});
|
|
8888
|
-
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (
|
|
8889
|
-
|
|
8890
|
-
}, u = (
|
|
8891
|
-
n(o ===
|
|
8892
|
-
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c],
|
|
8893
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
8878
|
+
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (b) => {
|
|
8879
|
+
b.preventDefault();
|
|
8880
|
+
}, u = (b) => {
|
|
8881
|
+
n(o === b ? null : b);
|
|
8882
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c], x = useBuilderProp("htmlDir", "ltr");
|
|
8883
|
+
return /* @__PURE__ */ jsx("div", { dir: x, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
8894
8884
|
/* @__PURE__ */ jsxs(
|
|
8895
8885
|
"div",
|
|
8896
8886
|
{
|
|
@@ -8900,21 +8890,21 @@ const RootLayout = () => {
|
|
|
8900
8890
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
8901
8891
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8902
8892
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
8903
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((
|
|
8893
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((b, h) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8904
8894
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
8905
8895
|
Button,
|
|
8906
8896
|
{
|
|
8907
8897
|
variant: o === h ? "default" : "ghost",
|
|
8908
8898
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
8909
8899
|
onClick: () => u(h),
|
|
8910
|
-
children: get(
|
|
8900
|
+
children: get(b, "icon", null)
|
|
8911
8901
|
},
|
|
8912
8902
|
h
|
|
8913
8903
|
) }),
|
|
8914
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(
|
|
8904
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(b.label) }) })
|
|
8915
8905
|
] }, "button" + h)) }),
|
|
8916
8906
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
8917
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((
|
|
8907
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((b, h) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(b, {}) }, `sidebar-component-${h}`)) })
|
|
8918
8908
|
] }),
|
|
8919
8909
|
/* @__PURE__ */ jsx(
|
|
8920
8910
|
motion.div,
|
|
@@ -9079,9 +9069,9 @@ export {
|
|
|
9079
9069
|
generateUUID as generateBlockId,
|
|
9080
9070
|
getBlocksFromHTML,
|
|
9081
9071
|
getClassValueAndUnit,
|
|
9082
|
-
|
|
9072
|
+
Ve as i18n,
|
|
9083
9073
|
cn as mergeClasses,
|
|
9084
|
-
|
|
9074
|
+
Oe as registerChaiBlock,
|
|
9085
9075
|
useAddBlock,
|
|
9086
9076
|
useAddClassesToBlocks,
|
|
9087
9077
|
useAskAi,
|
|
@@ -9124,7 +9114,7 @@ export {
|
|
|
9124
9114
|
useStylingState,
|
|
9125
9115
|
useTheme,
|
|
9126
9116
|
useThemeOptions,
|
|
9127
|
-
|
|
9117
|
+
Me as useTranslation,
|
|
9128
9118
|
useUILibraryBlocks,
|
|
9129
9119
|
useUndoManager,
|
|
9130
9120
|
useUpdateBlocksProps,
|