@chaibuilder/sdk 2.0.0-beta.76 → 2.0.0-beta.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +4 -4
- package/dist/core.js +551 -541
- package/dist/web-blocks.js +1 -3
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -6,7 +6,7 @@ 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
7
|
import { ag as useToast, S as Skeleton, B as Button, L as Label, D as Dialog, s as DialogTrigger, a as DialogContent, h as Badge, T as Textarea, O as Tooltip, P as TooltipTrigger, Q as TooltipContent, V as Popover, W as PopoverTrigger, X as PopoverContent, I as Input$1, U as TooltipPortal, e as AccordionItem, f as AccordionTrigger, g as AccordionContent, $ as DropdownMenu, a0 as DropdownMenuTrigger, a1 as DropdownMenuContent, G as ScrollArea, a5 as DropdownMenuLabel, a6 as DropdownMenuSeparator, a8 as DropdownMenuGroup, a2 as DropdownMenuItem, a7 as DropdownMenuShortcut, A as Accordion, C as Card, x as CardHeader, E as CardDescription, F as CardContent, y as CardFooter, J as Tabs, K as TabsList, M as TabsTrigger, N as TabsContent, aj as ContextMenu, ak as ContextMenuTrigger, al as ContextMenuContent, am as ContextMenuItem, j as AlertDialog, k as AlertDialogTrigger, l as AlertDialogContent, m as AlertDialogHeader, o as AlertDialogTitle, p as AlertDialogDescription, n as AlertDialogFooter, r as AlertDialogCancel, q as AlertDialogAction, a3 as DropdownMenuCheckboxItem, Y as HoverCard, Z as HoverCardTrigger, _ as HoverCardContent, b as Switch, ae as Separator, R as TooltipProvider, ai as Toaster } from "./context-menu-D5ViOi6K.js";
|
|
8
8
|
import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, useSetAtom as useSetAtom$1, getDefaultStore as getDefaultStore$1 } from "jotai";
|
|
9
|
-
import { has, get, find, filter, flatten, map, omit, isString, includes, without, compact, each, set, first, isObject, memoize, isEmpty, noop, keys, range, values, flattenDeep, startsWith, isNull, forEach, unset, chunk, cloneDeep, pick, throttle, reverse, startCase, debounce, capitalize, split, findIndex, take, nth, toLower, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection,
|
|
9
|
+
import { has, get, find, filter, flatten, map, omit, isString, includes, without, compact, each, set, first, isObject, memoize, isEmpty, noop, keys, range, values, flattenDeep, startsWith, isNull, forEach, unset, chunk, cloneDeep, pick, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, findIndex, take, nth, toLower, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, toUpper, round } from "lodash-es";
|
|
10
10
|
import { Provider } from "react-wrap-balancer";
|
|
11
11
|
import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
|
|
12
12
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
@@ -105,7 +105,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
105
105
|
] = o, c = (E) => {
|
|
106
106
|
let j = n(E);
|
|
107
107
|
return j || (j = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, r(E, j), i == null || i(E, I)), j;
|
|
108
|
-
}, p = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(),
|
|
108
|
+
}, p = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), f = () => {
|
|
109
109
|
var E;
|
|
110
110
|
const j = [], N = (L) => {
|
|
111
111
|
try {
|
|
@@ -120,11 +120,11 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
120
120
|
u.forEach((T) => {
|
|
121
121
|
var D;
|
|
122
122
|
return (D = T.m) == null ? void 0 : D.l.forEach(A);
|
|
123
|
-
}), u.clear(), g.forEach(A), g.clear(),
|
|
124
|
-
} while (u.size || g.size ||
|
|
123
|
+
}), u.clear(), g.forEach(A), g.clear(), m.forEach(A), m.clear(), L.forEach(N), u.size && _();
|
|
124
|
+
} while (u.size || g.size || m.size);
|
|
125
125
|
if (j.length)
|
|
126
126
|
throw j[0];
|
|
127
|
-
},
|
|
127
|
+
}, y = (E, j, N) => {
|
|
128
128
|
const L = "v" in j, A = j.v, T = isPendingPromise(j.v) ? j.v : null;
|
|
129
129
|
if (isPromiseLike$2(N)) {
|
|
130
130
|
patchPromiseForCancelability(N);
|
|
@@ -134,40 +134,40 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
134
134
|
} else
|
|
135
135
|
j.v = N;
|
|
136
136
|
delete j.e, (!L || !Object.is(A, j.v)) && (++j.n, T && cancelPromise(T, N));
|
|
137
|
-
},
|
|
137
|
+
}, h = (E) => {
|
|
138
138
|
var j;
|
|
139
139
|
const N = c(E);
|
|
140
140
|
if (isAtomStateInitialized(N) && (N.m && p.get(E) !== N.n || Array.from(N.d).every(
|
|
141
|
-
([M,
|
|
141
|
+
([M, O]) => (
|
|
142
142
|
// Recursively, read the atom state of the dependency, and
|
|
143
143
|
// check if the atom epoch number is unchanged
|
|
144
|
-
|
|
144
|
+
h(M).n === O
|
|
145
145
|
)
|
|
146
146
|
)))
|
|
147
147
|
return N;
|
|
148
148
|
N.d.clear();
|
|
149
149
|
let L = !0;
|
|
150
150
|
const A = () => {
|
|
151
|
-
N.m && (S(E, N), _(),
|
|
151
|
+
N.m && (S(E, N), _(), f());
|
|
152
152
|
}, T = (M) => {
|
|
153
153
|
if (isSelfAtom(E, M)) {
|
|
154
154
|
const U = c(M);
|
|
155
155
|
if (!isAtomStateInitialized(U))
|
|
156
156
|
if (hasInitialValue(M))
|
|
157
|
-
|
|
157
|
+
y(M, U, M.init);
|
|
158
158
|
else
|
|
159
159
|
throw new Error("no atom init");
|
|
160
160
|
return returnAtomValue(U);
|
|
161
161
|
}
|
|
162
|
-
const
|
|
162
|
+
const O = h(M);
|
|
163
163
|
try {
|
|
164
|
-
return returnAtomValue(
|
|
164
|
+
return returnAtomValue(O);
|
|
165
165
|
} finally {
|
|
166
|
-
addDependency(E, N, M,
|
|
166
|
+
addDependency(E, N, M, O), L || A();
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
169
|
let D, $;
|
|
170
|
-
const
|
|
170
|
+
const H = {
|
|
171
171
|
get signal() {
|
|
172
172
|
return D || (D = new AbortController()), D.signal;
|
|
173
173
|
},
|
|
@@ -179,14 +179,14 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
try {
|
|
182
|
-
const M = a(E, T,
|
|
183
|
-
return
|
|
182
|
+
const M = a(E, T, H);
|
|
183
|
+
return y(E, N, M), isPromiseLike$2(M) && ((j = M.onCancel) == null || j.call(M, () => D == null ? void 0 : D.abort()), M.then(A, A)), N;
|
|
184
184
|
} catch (M) {
|
|
185
185
|
return delete N.v, N.e = M, ++N.n, N;
|
|
186
186
|
} finally {
|
|
187
187
|
L = !1;
|
|
188
188
|
}
|
|
189
|
-
}, x = (E) => returnAtomValue(
|
|
189
|
+
}, x = (E) => returnAtomValue(h(E)), b = (E) => {
|
|
190
190
|
var j;
|
|
191
191
|
const N = /* @__PURE__ */ new Map();
|
|
192
192
|
for (const L of ((j = E.m) == null ? void 0 : j.t) || []) {
|
|
@@ -203,7 +203,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
203
203
|
const j = [E];
|
|
204
204
|
for (; j.length; ) {
|
|
205
205
|
const N = j.pop();
|
|
206
|
-
for (const [L, A] of
|
|
206
|
+
for (const [L, A] of b(N))
|
|
207
207
|
p.has(L) || (p.set(L, A.n), j.push(A));
|
|
208
208
|
}
|
|
209
209
|
}, _ = () => {
|
|
@@ -220,35 +220,35 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
220
220
|
continue;
|
|
221
221
|
}
|
|
222
222
|
N.add(T);
|
|
223
|
-
for (const [$,
|
|
224
|
-
N.has($) || A.push([$,
|
|
223
|
+
for (const [$, H] of b(D))
|
|
224
|
+
N.has($) || A.push([$, H]);
|
|
225
225
|
}
|
|
226
226
|
for (let T = j.length - 1; T >= 0; --T) {
|
|
227
|
-
const [D, $,
|
|
227
|
+
const [D, $, H] = j[T];
|
|
228
228
|
let M = !1;
|
|
229
|
-
for (const
|
|
230
|
-
if (
|
|
229
|
+
for (const O of $.d.keys())
|
|
230
|
+
if (O !== D && u.has(O)) {
|
|
231
231
|
M = !0;
|
|
232
232
|
break;
|
|
233
233
|
}
|
|
234
|
-
M && (
|
|
234
|
+
M && (h(D), S(D, $), H !== $.n && (u.set(D, $), (E = $.u) == null || E.call($))), p.delete(D);
|
|
235
235
|
}
|
|
236
236
|
}, v = (E, ...j) => {
|
|
237
237
|
let N = !0;
|
|
238
|
-
const L = (T) => returnAtomValue(
|
|
238
|
+
const L = (T) => returnAtomValue(h(T)), A = (T, ...D) => {
|
|
239
239
|
var $;
|
|
240
|
-
const
|
|
240
|
+
const H = c(T);
|
|
241
241
|
try {
|
|
242
242
|
if (isSelfAtom(E, T)) {
|
|
243
243
|
if (!hasInitialValue(T))
|
|
244
244
|
throw new Error("atom not writable");
|
|
245
|
-
const M =
|
|
246
|
-
|
|
245
|
+
const M = H.n, O = D[0];
|
|
246
|
+
y(T, H, O), S(T, H), M !== H.n && (u.set(T, H), ($ = H.u) == null || $.call(H), w(H));
|
|
247
247
|
return;
|
|
248
248
|
} else
|
|
249
249
|
return v(T, ...D);
|
|
250
250
|
} finally {
|
|
251
|
-
N || (_(),
|
|
251
|
+
N || (_(), f());
|
|
252
252
|
}
|
|
253
253
|
};
|
|
254
254
|
try {
|
|
@@ -260,7 +260,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
260
260
|
try {
|
|
261
261
|
return v(E, ...j);
|
|
262
262
|
} finally {
|
|
263
|
-
_(),
|
|
263
|
+
_(), f();
|
|
264
264
|
}
|
|
265
265
|
}, S = (E, j) => {
|
|
266
266
|
var N;
|
|
@@ -280,7 +280,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
280
280
|
}, B = (E, j) => {
|
|
281
281
|
var N;
|
|
282
282
|
if (!j.m) {
|
|
283
|
-
|
|
283
|
+
h(E);
|
|
284
284
|
for (const L of j.d.keys())
|
|
285
285
|
B(L, c(L)).t.add(E);
|
|
286
286
|
if (j.m = {
|
|
@@ -294,7 +294,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
294
294
|
try {
|
|
295
295
|
return v(E, ...$);
|
|
296
296
|
} finally {
|
|
297
|
-
T || (_(),
|
|
297
|
+
T || (_(), f());
|
|
298
298
|
}
|
|
299
299
|
};
|
|
300
300
|
try {
|
|
@@ -311,7 +311,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
311
311
|
T = !1;
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
|
-
|
|
314
|
+
m.add(A);
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
return j.m;
|
|
@@ -335,8 +335,8 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
335
335
|
set: k,
|
|
336
336
|
sub: (E, j) => {
|
|
337
337
|
const N = c(E), A = B(E, N).l;
|
|
338
|
-
return A.add(j),
|
|
339
|
-
A.delete(j), R(E, N),
|
|
338
|
+
return A.add(j), f(), () => {
|
|
339
|
+
A.delete(j), R(E, N), f();
|
|
340
340
|
};
|
|
341
341
|
},
|
|
342
342
|
unstable_derive: (E) => buildStore(...E(...o))
|
|
@@ -373,26 +373,26 @@ function splitAtom(o, n) {
|
|
|
373
373
|
let p = r.get(d);
|
|
374
374
|
if (p)
|
|
375
375
|
return p;
|
|
376
|
-
const u = c && r.get(c), g = [],
|
|
377
|
-
return d.forEach((
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
const x = u && u.atomList[u.keyList.indexOf(
|
|
376
|
+
const u = c && r.get(c), g = [], m = [];
|
|
377
|
+
return d.forEach((f, y) => {
|
|
378
|
+
const h = n(f);
|
|
379
|
+
m[y] = h;
|
|
380
|
+
const x = u && u.atomList[u.keyList.indexOf(h)];
|
|
381
381
|
if (x) {
|
|
382
|
-
g[
|
|
382
|
+
g[y] = x;
|
|
383
383
|
return;
|
|
384
384
|
}
|
|
385
|
-
const
|
|
386
|
-
const v = _(l), k = _(o), B = a(k, v == null ? void 0 : v.arr).keyList.indexOf(
|
|
385
|
+
const b = (_) => {
|
|
386
|
+
const v = _(l), k = _(o), B = a(k, v == null ? void 0 : v.arr).keyList.indexOf(h);
|
|
387
387
|
if (B < 0 || B >= k.length) {
|
|
388
|
-
const R = d[a(d).keyList.indexOf(
|
|
388
|
+
const R = d[a(d).keyList.indexOf(h)];
|
|
389
389
|
if (R)
|
|
390
390
|
return R;
|
|
391
391
|
throw new Error("splitAtom: index out of bounds for read");
|
|
392
392
|
}
|
|
393
393
|
return k[B];
|
|
394
394
|
}, w = (_, v, k) => {
|
|
395
|
-
const S = _(l), B = _(o), P = a(B, S == null ? void 0 : S.arr).keyList.indexOf(
|
|
395
|
+
const S = _(l), B = _(o), P = a(B, S == null ? void 0 : S.arr).keyList.indexOf(h);
|
|
396
396
|
if (P < 0 || P >= B.length)
|
|
397
397
|
throw new Error("splitAtom: index out of bounds for write");
|
|
398
398
|
const C = isFunction(k) ? k(B[P]) : k;
|
|
@@ -402,8 +402,8 @@ function splitAtom(o, n) {
|
|
|
402
402
|
...B.slice(P + 1)
|
|
403
403
|
]);
|
|
404
404
|
};
|
|
405
|
-
g[
|
|
406
|
-
}), u && u.keyList.length ===
|
|
405
|
+
g[y] = isWritable(o) ? atom(b, w) : atom(b);
|
|
406
|
+
}), u && u.keyList.length === m.length && u.keyList.every((f, y) => f === m[y]) ? p = u : p = { arr: d, atomList: g, keyList: m }, r.set(d, p), p;
|
|
407
407
|
}, l = atom((d) => {
|
|
408
408
|
const c = d(l), p = d(o);
|
|
409
409
|
return a(p, c == null ? void 0 : c.arr);
|
|
@@ -439,17 +439,17 @@ function splitAtom(o, n) {
|
|
|
439
439
|
case "move": {
|
|
440
440
|
const u = d(i).indexOf(p.atom), g = p.before ? d(i).indexOf(p.before) : d(i).length;
|
|
441
441
|
if (u >= 0 && g >= 0) {
|
|
442
|
-
const
|
|
442
|
+
const m = d(o);
|
|
443
443
|
u < g ? c(o, [
|
|
444
|
-
...
|
|
445
|
-
...
|
|
446
|
-
|
|
447
|
-
...
|
|
444
|
+
...m.slice(0, u),
|
|
445
|
+
...m.slice(u + 1, g),
|
|
446
|
+
m[u],
|
|
447
|
+
...m.slice(g)
|
|
448
448
|
]) : c(o, [
|
|
449
|
-
...
|
|
450
|
-
|
|
451
|
-
...
|
|
452
|
-
...
|
|
449
|
+
...m.slice(0, g),
|
|
450
|
+
m[u],
|
|
451
|
+
...m.slice(g, u),
|
|
452
|
+
...m.slice(u + 1)
|
|
453
453
|
]);
|
|
454
454
|
}
|
|
455
455
|
break;
|
|
@@ -475,19 +475,19 @@ function createJSONStorage(o = () => {
|
|
|
475
475
|
let a, l;
|
|
476
476
|
const i = {
|
|
477
477
|
getItem: (p, u) => {
|
|
478
|
-
var g,
|
|
479
|
-
const
|
|
480
|
-
if (
|
|
478
|
+
var g, m;
|
|
479
|
+
const f = (h) => {
|
|
480
|
+
if (h = h || "", a !== h) {
|
|
481
481
|
try {
|
|
482
|
-
l = JSON.parse(
|
|
482
|
+
l = JSON.parse(h, n == null ? void 0 : n.reviver);
|
|
483
483
|
} catch {
|
|
484
484
|
return u;
|
|
485
485
|
}
|
|
486
|
-
a =
|
|
486
|
+
a = h;
|
|
487
487
|
}
|
|
488
488
|
return l;
|
|
489
|
-
},
|
|
490
|
-
return isPromiseLike$1(
|
|
489
|
+
}, y = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
490
|
+
return isPromiseLike$1(y) ? y.then(f) : f(y);
|
|
491
491
|
},
|
|
492
492
|
setItem: (p, u) => {
|
|
493
493
|
var g;
|
|
@@ -500,14 +500,14 @@ function createJSONStorage(o = () => {
|
|
|
500
500
|
var u;
|
|
501
501
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
502
502
|
}
|
|
503
|
-
}, d = (p) => (u, g,
|
|
504
|
-
let
|
|
503
|
+
}, d = (p) => (u, g, m) => p(u, (f) => {
|
|
504
|
+
let y;
|
|
505
505
|
try {
|
|
506
|
-
|
|
506
|
+
y = JSON.parse(f || "");
|
|
507
507
|
} catch {
|
|
508
|
-
|
|
508
|
+
y = m;
|
|
509
509
|
}
|
|
510
|
-
g(
|
|
510
|
+
g(y);
|
|
511
511
|
});
|
|
512
512
|
let c;
|
|
513
513
|
try {
|
|
@@ -518,8 +518,8 @@ function createJSONStorage(o = () => {
|
|
|
518
518
|
if (!(o() instanceof window.Storage))
|
|
519
519
|
return () => {
|
|
520
520
|
};
|
|
521
|
-
const g = (
|
|
522
|
-
|
|
521
|
+
const g = (m) => {
|
|
522
|
+
m.storageArea === o() && m.key === p && u(m.newValue);
|
|
523
523
|
};
|
|
524
524
|
return window.addEventListener("storage", g), () => {
|
|
525
525
|
window.removeEventListener("storage", g);
|
|
@@ -1316,82 +1316,82 @@ const useBlocksStoreManager = () => {
|
|
|
1316
1316
|
updateBlocksProps: d
|
|
1317
1317
|
} = useBlocksStoreManager();
|
|
1318
1318
|
return {
|
|
1319
|
-
moveBlocks: (
|
|
1320
|
-
const w = map(
|
|
1319
|
+
moveBlocks: (h, x, b) => {
|
|
1320
|
+
const w = map(h, (v) => {
|
|
1321
1321
|
const S = n.find((P) => P._id === v)._parent || null, R = n.filter((P) => S ? P._parent === S : !P._parent).map((P) => P._id).indexOf(v);
|
|
1322
1322
|
return { _id: v, oldParent: S, oldPosition: R };
|
|
1323
|
-
}), _ = w.find(({ _id: v }) => v ===
|
|
1324
|
-
_ && _.oldParent === x && _.oldPosition ===
|
|
1323
|
+
}), _ = w.find(({ _id: v }) => v === h[0]);
|
|
1324
|
+
_ && _.oldParent === x && _.oldPosition === b || (i(h, x, b), o({
|
|
1325
1325
|
undo: () => each(w, ({ _id: v, oldParent: k, oldPosition: S }) => {
|
|
1326
1326
|
i([v], k, S);
|
|
1327
1327
|
}),
|
|
1328
|
-
redo: () => i(
|
|
1328
|
+
redo: () => i(h, x, b)
|
|
1329
1329
|
}));
|
|
1330
1330
|
},
|
|
1331
|
-
addBlocks: (
|
|
1332
|
-
a(
|
|
1333
|
-
undo: () => l(map(
|
|
1334
|
-
redo: () => a(
|
|
1331
|
+
addBlocks: (h, x, b) => {
|
|
1332
|
+
a(h, x, b), o({
|
|
1333
|
+
undo: () => l(map(h, "_id")),
|
|
1334
|
+
redo: () => a(h, x, b)
|
|
1335
1335
|
});
|
|
1336
1336
|
},
|
|
1337
|
-
removeBlocks: (
|
|
1337
|
+
removeBlocks: (h) => {
|
|
1338
1338
|
var _;
|
|
1339
|
-
const x = (_ = first(
|
|
1340
|
-
l(map(
|
|
1341
|
-
undo: () => a(
|
|
1342
|
-
redo: () => l(map(
|
|
1339
|
+
const x = (_ = first(h)) == null ? void 0 : _._parent, w = n.filter((v) => x ? v._parent === x : !v._parent).indexOf(first(h));
|
|
1340
|
+
l(map(h, "_id")), o({
|
|
1341
|
+
undo: () => a(h, x, w),
|
|
1342
|
+
redo: () => l(map(h, "_id"))
|
|
1343
1343
|
});
|
|
1344
1344
|
},
|
|
1345
|
-
updateBlocks: (
|
|
1345
|
+
updateBlocks: (h, x, b) => {
|
|
1346
1346
|
let w = [];
|
|
1347
|
-
if (
|
|
1348
|
-
w = map(
|
|
1347
|
+
if (b)
|
|
1348
|
+
w = map(h, (_) => ({ _id: _, ...b }));
|
|
1349
1349
|
else {
|
|
1350
1350
|
const _ = keys(x);
|
|
1351
|
-
w = map(
|
|
1351
|
+
w = map(h, (v) => {
|
|
1352
1352
|
const k = n.find((B) => B._id === v), S = { _id: v };
|
|
1353
1353
|
return each(_, (B) => S[B] = k[B]), S;
|
|
1354
1354
|
});
|
|
1355
1355
|
}
|
|
1356
|
-
d(map(
|
|
1356
|
+
d(map(h, (_) => ({ _id: _, ...x }))), o({
|
|
1357
1357
|
undo: () => d(w),
|
|
1358
|
-
redo: () => d(map(
|
|
1358
|
+
redo: () => d(map(h, (_) => ({ _id: _, ...x })))
|
|
1359
1359
|
});
|
|
1360
1360
|
},
|
|
1361
|
-
updateBlocksRuntime: (
|
|
1362
|
-
d(map(
|
|
1361
|
+
updateBlocksRuntime: (h, x) => {
|
|
1362
|
+
d(map(h, (b) => ({ _id: b, ...x })));
|
|
1363
1363
|
},
|
|
1364
|
-
setNewBlocks: (
|
|
1365
|
-
r(
|
|
1364
|
+
setNewBlocks: (h) => {
|
|
1365
|
+
r(h), o({
|
|
1366
1366
|
undo: () => r(n),
|
|
1367
|
-
redo: () => r(
|
|
1367
|
+
redo: () => r(h)
|
|
1368
1368
|
});
|
|
1369
1369
|
},
|
|
1370
|
-
updateMultipleBlocksProps: (
|
|
1370
|
+
updateMultipleBlocksProps: (h) => {
|
|
1371
1371
|
let x = [];
|
|
1372
|
-
x = map(
|
|
1373
|
-
const w = keys(
|
|
1372
|
+
x = map(h, (b) => {
|
|
1373
|
+
const w = keys(b), _ = n.find((k) => k._id === b._id), v = {};
|
|
1374
1374
|
return each(w, (k) => v[k] = _[k]), v;
|
|
1375
|
-
}), d(
|
|
1375
|
+
}), d(h), o({
|
|
1376
1376
|
undo: () => d(x),
|
|
1377
|
-
redo: () => d(
|
|
1377
|
+
redo: () => d(h)
|
|
1378
1378
|
});
|
|
1379
1379
|
}
|
|
1380
1380
|
};
|
|
1381
1381
|
}, useAddBlock = () => {
|
|
1382
1382
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1383
1383
|
(i, d, c) => {
|
|
1384
|
-
var
|
|
1385
|
-
for (let
|
|
1386
|
-
const { _id:
|
|
1387
|
-
i[
|
|
1388
|
-
const x = filter(i, { _parent:
|
|
1389
|
-
for (let
|
|
1390
|
-
x[
|
|
1384
|
+
var f;
|
|
1385
|
+
for (let y = 0; y < i.length; y++) {
|
|
1386
|
+
const { _id: h } = i[y];
|
|
1387
|
+
i[y]._id = generateUUID();
|
|
1388
|
+
const x = filter(i, { _parent: h });
|
|
1389
|
+
for (let b = 0; b < x.length; b++)
|
|
1390
|
+
x[b]._parent = i[y]._id;
|
|
1391
1391
|
}
|
|
1392
1392
|
const p = first(i);
|
|
1393
1393
|
let u, g;
|
|
1394
|
-
return d && (u = find(o, { _id: d }), i[0]._parent = d, g = d), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, c), n([(
|
|
1394
|
+
return d && (u = find(o, { _id: d }), i[0]._parent = d, g = d), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, c), n([(f = first(i)) == null ? void 0 : f._id]), first(i);
|
|
1395
1395
|
},
|
|
1396
1396
|
[r, o, n]
|
|
1397
1397
|
);
|
|
@@ -1406,8 +1406,8 @@ const useBlocksStoreManager = () => {
|
|
|
1406
1406
|
_id: p,
|
|
1407
1407
|
...u
|
|
1408
1408
|
};
|
|
1409
|
-
let
|
|
1410
|
-
return d && (
|
|
1409
|
+
let m, f;
|
|
1410
|
+
return d && (m = find(o, { _id: d }), g._parent = d, f = d), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, f = m._parent), r([g], f, c), n([g._id]), g;
|
|
1411
1411
|
},
|
|
1412
1412
|
[r, a, o, n]
|
|
1413
1413
|
), addPredefinedBlock: a };
|
|
@@ -2611,13 +2611,13 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
|
|
|
2611
2611
|
(a, l = null) => {
|
|
2612
2612
|
const i = [];
|
|
2613
2613
|
each(a, (d) => {
|
|
2614
|
-
const c = o.find((
|
|
2614
|
+
const c = o.find((f) => f._id === d);
|
|
2615
2615
|
l ? l === "root" && (l = null) : l = c._parent;
|
|
2616
2616
|
const g = filter(
|
|
2617
2617
|
o,
|
|
2618
|
-
(
|
|
2619
|
-
).indexOf(c) + 1,
|
|
2620
|
-
r(
|
|
2618
|
+
(f) => isString(l) ? f._parent === l : !f._parent
|
|
2619
|
+
).indexOf(c) + 1, m = getDuplicatedBlocks(o, d, l);
|
|
2620
|
+
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
2621
2621
|
}), n(i);
|
|
2622
2622
|
},
|
|
2623
2623
|
[o, n]
|
|
@@ -2710,14 +2710,14 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
|
|
|
2710
2710
|
return map(i, (d) => {
|
|
2711
2711
|
const c = o(d), p = a;
|
|
2712
2712
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(c, l.prop, `${STYLES_KEY},`));
|
|
2713
|
-
return each(p, (
|
|
2714
|
-
const
|
|
2715
|
-
u = u.replace(
|
|
2716
|
-
const
|
|
2717
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
2718
|
-
}), each(p, (
|
|
2719
|
-
const
|
|
2720
|
-
g = g.replace(
|
|
2713
|
+
return each(p, (m) => {
|
|
2714
|
+
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), y = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
|
|
2715
|
+
u = u.replace(y, " ").replace(/\s+/g, " ").trim();
|
|
2716
|
+
const h = first(m.split(":"));
|
|
2717
|
+
includes(["2xl", "xl", "lg", "md", "sm"], h) && p.push(m.split(":").pop().trim());
|
|
2718
|
+
}), each(p, (m) => {
|
|
2719
|
+
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), y = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
|
|
2720
|
+
g = g.replace(y, " ").replace(/\s+/g, " ").trim();
|
|
2721
2721
|
}), {
|
|
2722
2722
|
ids: [c._id],
|
|
2723
2723
|
props: {
|
|
@@ -3130,30 +3130,30 @@ const getBlockWithChildren = (o, n) => {
|
|
|
3130
3130
|
return isEmpty(d) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...d });
|
|
3131
3131
|
})
|
|
3132
3132
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
3133
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), d = useUpdateMultipleBlocksProps(), [c] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u,
|
|
3134
|
-
const
|
|
3135
|
-
for (const x in
|
|
3136
|
-
const
|
|
3137
|
-
if (typeof
|
|
3138
|
-
const { baseClasses: w, classes: _ } = getSplitChaiClasses(
|
|
3139
|
-
|
|
3133
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), d = useUpdateMultipleBlocksProps(), [c] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f, y) => {
|
|
3134
|
+
const h = cloneDeep(y.find((x) => x._id === f));
|
|
3135
|
+
for (const x in h) {
|
|
3136
|
+
const b = h[x];
|
|
3137
|
+
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
3138
|
+
const { baseClasses: w, classes: _ } = getSplitChaiClasses(b);
|
|
3139
|
+
h[x] = compact(flattenDeep([w, _])).join(" ");
|
|
3140
3140
|
} else
|
|
3141
|
-
x !== "_id" && delete
|
|
3141
|
+
x !== "_id" && delete h[x];
|
|
3142
3142
|
}
|
|
3143
|
-
return
|
|
3143
|
+
return h;
|
|
3144
3144
|
};
|
|
3145
3145
|
return {
|
|
3146
3146
|
askAi: useCallback(
|
|
3147
|
-
async (
|
|
3147
|
+
async (f, y, h, x) => {
|
|
3148
3148
|
if (l) {
|
|
3149
3149
|
n(!0), a(null);
|
|
3150
3150
|
try {
|
|
3151
|
-
const
|
|
3151
|
+
const b = p === u ? "" : p, w = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(y, c)), p) : [m(y, c)], _ = await l(f, addLangToPrompt(h, g, f), w, b), { blocks: v, error: k } = _;
|
|
3152
3152
|
if (k) {
|
|
3153
3153
|
a(k);
|
|
3154
3154
|
return;
|
|
3155
3155
|
}
|
|
3156
|
-
if (
|
|
3156
|
+
if (f === "styles") {
|
|
3157
3157
|
const S = v.map((B) => {
|
|
3158
3158
|
for (const R in B)
|
|
3159
3159
|
R !== "_id" && (B[R] = `${STYLES_KEY},${B[R]}`);
|
|
@@ -3163,8 +3163,8 @@ const getBlockWithChildren = (o, n) => {
|
|
|
3163
3163
|
} else
|
|
3164
3164
|
i(v);
|
|
3165
3165
|
x && x(_);
|
|
3166
|
-
} catch (
|
|
3167
|
-
a(
|
|
3166
|
+
} catch (b) {
|
|
3167
|
+
a(b);
|
|
3168
3168
|
} finally {
|
|
3169
3169
|
n(!1), x && x();
|
|
3170
3170
|
}
|
|
@@ -3259,7 +3259,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3259
3259
|
}
|
|
3260
3260
|
});
|
|
3261
3261
|
useResizeObserver(o, () => g(), o !== null);
|
|
3262
|
-
const
|
|
3262
|
+
const m = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3263
3263
|
return !o || !n || c ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
3264
3264
|
"div",
|
|
3265
3265
|
{
|
|
@@ -3267,25 +3267,25 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3267
3267
|
tabIndex: 0,
|
|
3268
3268
|
ref: u.setFloating,
|
|
3269
3269
|
style: p,
|
|
3270
|
-
onClick: (
|
|
3271
|
-
|
|
3270
|
+
onClick: (y) => {
|
|
3271
|
+
y.stopPropagation(), y.preventDefault();
|
|
3272
3272
|
},
|
|
3273
|
-
onMouseEnter: (
|
|
3274
|
-
|
|
3273
|
+
onMouseEnter: (y) => {
|
|
3274
|
+
y.stopPropagation(), i(null);
|
|
3275
3275
|
},
|
|
3276
|
-
onKeyDown: (
|
|
3276
|
+
onKeyDown: (y) => y.stopPropagation(),
|
|
3277
3277
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3278
3278
|
children: [
|
|
3279
|
-
|
|
3279
|
+
m && /* @__PURE__ */ jsx(
|
|
3280
3280
|
ArrowUpIcon,
|
|
3281
3281
|
{
|
|
3282
3282
|
className: "hover:scale-105",
|
|
3283
3283
|
onClick: () => {
|
|
3284
|
-
d([]), l([
|
|
3284
|
+
d([]), l([m]);
|
|
3285
3285
|
}
|
|
3286
3286
|
}
|
|
3287
3287
|
),
|
|
3288
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3288
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: n }),
|
|
3289
3289
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-2 px-1", children: [
|
|
3290
3290
|
canAddChildBlock(get(n, "_type", "")) && /* @__PURE__ */ jsx(
|
|
3291
3291
|
PlusIcon,
|
|
@@ -3357,23 +3357,23 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3357
3357
|
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
|
|
3358
3358
|
</body>
|
|
3359
3359
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3360
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: d, redo: c } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks:
|
|
3360
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: d, redo: c } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), f = o ? { document: o } : {};
|
|
3361
3361
|
useHotkeys("ctrl+z,command+z", () => d(), {}, [d]), useHotkeys("ctrl+y,command+y", () => c(), {}, [c]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
|
|
3362
3362
|
"ctrl+v,command+v",
|
|
3363
3363
|
() => {
|
|
3364
|
-
g(n[0]) &&
|
|
3364
|
+
g(n[0]) && m(n);
|
|
3365
3365
|
},
|
|
3366
|
-
{ ...
|
|
3367
|
-
[n, g,
|
|
3368
|
-
), useHotkeys("esc", () => r([]),
|
|
3366
|
+
{ ...f, preventDefault: !0 },
|
|
3367
|
+
[n, g, m]
|
|
3368
|
+
), useHotkeys("esc", () => r([]), f, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...f, preventDefault: !0 }, [
|
|
3369
3369
|
n,
|
|
3370
3370
|
i
|
|
3371
3371
|
]), useHotkeys(
|
|
3372
3372
|
"del, backspace",
|
|
3373
|
-
(
|
|
3374
|
-
|
|
3373
|
+
(y) => {
|
|
3374
|
+
y.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3375
3375
|
},
|
|
3376
|
-
|
|
3376
|
+
f,
|
|
3377
3377
|
[n, l]
|
|
3378
3378
|
);
|
|
3379
3379
|
}, KeyboardHandler = () => {
|
|
@@ -3459,38 +3459,38 @@ function removeDataDrop() {
|
|
|
3459
3459
|
const useDnd = () => {
|
|
3460
3460
|
const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: d } = useBlocksStoreUndoableActions(), [c, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
|
|
3461
3461
|
if (!useFeature("dnd")) return {};
|
|
3462
|
-
const
|
|
3462
|
+
const m = () => {
|
|
3463
3463
|
removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
|
|
3464
3464
|
};
|
|
3465
3465
|
return iframeDocument = o, {
|
|
3466
3466
|
isDragging: n,
|
|
3467
|
-
onDragOver: (
|
|
3468
|
-
|
|
3467
|
+
onDragOver: (f) => {
|
|
3468
|
+
f.preventDefault(), f.stopPropagation(), throttledDragOver(f);
|
|
3469
3469
|
},
|
|
3470
|
-
onDrop: (
|
|
3470
|
+
onDrop: (f) => {
|
|
3471
3471
|
var k;
|
|
3472
|
-
const
|
|
3472
|
+
const y = dropTarget, x = getOrientation(y) === "vertical" ? f.clientY + ((k = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : k.scrollY) : f.clientX;
|
|
3473
3473
|
dropIndex = calculateDropIndex(x, possiblePositions);
|
|
3474
|
-
const
|
|
3475
|
-
if ((
|
|
3476
|
-
|
|
3474
|
+
const b = c, w = y.getAttribute("data-block-id"), _ = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3475
|
+
if ((b == null ? void 0 : b._id) === w || !_) {
|
|
3476
|
+
m();
|
|
3477
3477
|
return;
|
|
3478
3478
|
}
|
|
3479
|
-
if (!has(
|
|
3480
|
-
a(
|
|
3479
|
+
if (!has(b, "_id")) {
|
|
3480
|
+
a(b, w === "canvas" ? null : w, dropIndex), setTimeout(m, 300);
|
|
3481
3481
|
return;
|
|
3482
3482
|
}
|
|
3483
|
-
let v =
|
|
3484
|
-
v === null && (v =
|
|
3483
|
+
let v = y.getAttribute("data-block-id");
|
|
3484
|
+
v === null && (v = f.target.parentElement.getAttribute("data-block-id")), d([b._id], v === "canvas" ? null : v, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3485
3485
|
},
|
|
3486
|
-
onDragEnter: (
|
|
3487
|
-
const
|
|
3488
|
-
dropTarget =
|
|
3489
|
-
const x =
|
|
3490
|
-
u(x),
|
|
3486
|
+
onDragEnter: (f) => {
|
|
3487
|
+
const y = f, h = y.target;
|
|
3488
|
+
dropTarget = h;
|
|
3489
|
+
const x = h.getAttribute("data-block-id"), b = h.getAttribute("data-dnd-dragged") !== "yes";
|
|
3490
|
+
u(x), y.stopPropagation(), y.preventDefault(), possiblePositions = [], b && calculatePossiblePositions(h), r(!0), l(""), i([]);
|
|
3491
3491
|
},
|
|
3492
|
-
onDragLeave: (
|
|
3493
|
-
|
|
3492
|
+
onDragLeave: (f) => {
|
|
3493
|
+
f.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3494
3494
|
}
|
|
3495
3495
|
};
|
|
3496
3496
|
};
|
|
@@ -3508,28 +3508,31 @@ function destroyQuill(o) {
|
|
|
3508
3508
|
n && n.parentNode.removeChild(n), o = null;
|
|
3509
3509
|
}
|
|
3510
3510
|
const useHandleCanvasDblClick = () => {
|
|
3511
|
-
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight();
|
|
3512
|
-
return (
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
m.
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
m.
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3511
|
+
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight(), [i] = useBlocksStore();
|
|
3512
|
+
return useCallback(
|
|
3513
|
+
(d) => {
|
|
3514
|
+
var h, x;
|
|
3515
|
+
if (r) return;
|
|
3516
|
+
const c = getTargetedBlock(d.target), p = c.getAttribute("data-block-type");
|
|
3517
|
+
if (!p || !o.includes(p))
|
|
3518
|
+
return;
|
|
3519
|
+
const u = c.getAttribute("data-block-id"), g = (h = find(i, { _id: u })) == null ? void 0 : h.content, m = c.cloneNode(!0);
|
|
3520
|
+
m.innerHTML = g, c.style.display = "none", Array.from(m.attributes).forEach((b) => {
|
|
3521
|
+
b.name !== "class" && m.removeAttribute(b.name);
|
|
3522
|
+
}), p === "Text" && (m.style.display = "inline-block"), c.parentNode.insertBefore(m, c.nextSibling);
|
|
3523
|
+
const f = new Quill(m, { placeholder: "Type here..." });
|
|
3524
|
+
function y() {
|
|
3525
|
+
const b = f.getText(0, f.getLength());
|
|
3526
|
+
n([u], { content: b }), c.removeAttribute("style"), m.removeEventListener("blur", y, !0), destroyQuill(f), a(""), l(), m.remove();
|
|
3527
|
+
}
|
|
3528
|
+
m.addEventListener("blur", y, !0), m.addEventListener("click", (b) => {
|
|
3529
|
+
b.stopPropagation();
|
|
3530
|
+
}), m.addEventListener("keydown", (b) => {
|
|
3531
|
+
(b.key === "Enter" || b.key === "Escape") && y();
|
|
3532
|
+
}), f.focus(), (x = m.querySelector(".ql-clipboard")) == null || x.remove(), a(c.getAttribute("data-block-id"));
|
|
3533
|
+
},
|
|
3534
|
+
[r, i, a, n, l]
|
|
3535
|
+
);
|
|
3533
3536
|
}, useHandleCanvasClick = () => {
|
|
3534
3537
|
const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
|
|
3535
3538
|
return (d) => {
|
|
@@ -3565,12 +3568,12 @@ const useHandleCanvasDblClick = () => {
|
|
|
3565
3568
|
setTimeout(() => {
|
|
3566
3569
|
if (!isEmpty(a))
|
|
3567
3570
|
return;
|
|
3568
|
-
const
|
|
3569
|
-
if (
|
|
3570
|
-
const
|
|
3571
|
-
if (
|
|
3572
|
-
const
|
|
3573
|
-
l([{ id:
|
|
3571
|
+
const m = getElementByDataBlockId(n, first(r));
|
|
3572
|
+
if (m) {
|
|
3573
|
+
const f = m.getAttribute("data-style-prop");
|
|
3574
|
+
if (f) {
|
|
3575
|
+
const y = m.getAttribute("data-style-id"), h = m.getAttribute("data-block-parent");
|
|
3576
|
+
l([{ id: y, prop: f, blockId: h }]);
|
|
3574
3577
|
}
|
|
3575
3578
|
}
|
|
3576
3579
|
}, 100);
|
|
@@ -3593,9 +3596,9 @@ const useHandleCanvasDblClick = () => {
|
|
|
3593
3596
|
}, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
|
|
3594
3597
|
const [o] = useTheme(), n = useThemeOptions(), [r] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [d] = useAtom$1(dropTargetBlockIdAtom), { document: c, window: p } = useFrame(), [u] = useState(c == null ? void 0 : c.getElementById("highlighted-block")), [g] = useState(
|
|
3595
3598
|
c == null ? void 0 : c.getElementById("selected-block")
|
|
3596
|
-
), [h] = useState(
|
|
3597
|
-
c == null ? void 0 : c.getElementById("selected-styling-block")
|
|
3598
3599
|
), [m] = useState(
|
|
3600
|
+
c == null ? void 0 : c.getElementById("selected-styling-block")
|
|
3601
|
+
), [f] = useState(
|
|
3599
3602
|
c == null ? void 0 : c.getElementById("dragged-block")
|
|
3600
3603
|
);
|
|
3601
3604
|
useEffect(() => {
|
|
@@ -3620,15 +3623,15 @@ const useHandleCanvasDblClick = () => {
|
|
|
3620
3623
|
forms,
|
|
3621
3624
|
aspectRatio,
|
|
3622
3625
|
containerQueries,
|
|
3623
|
-
plugin(function({ addBase: x, theme:
|
|
3626
|
+
plugin(function({ addBase: x, theme: b }) {
|
|
3624
3627
|
x({
|
|
3625
3628
|
"h1,h2,h3,h4,h5,h6": {
|
|
3626
|
-
fontFamily:
|
|
3629
|
+
fontFamily: b("fontFamily.heading")
|
|
3627
3630
|
},
|
|
3628
3631
|
body: {
|
|
3629
|
-
fontFamily:
|
|
3630
|
-
color:
|
|
3631
|
-
backgroundColor:
|
|
3632
|
+
fontFamily: b("fontFamily.body"),
|
|
3633
|
+
color: b("colors.foreground"),
|
|
3634
|
+
backgroundColor: b("colors.background")
|
|
3632
3635
|
}
|
|
3633
3636
|
});
|
|
3634
3637
|
})
|
|
@@ -3639,23 +3642,23 @@ const useHandleCanvasDblClick = () => {
|
|
|
3639
3642
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3640
3643
|
}`);
|
|
3641
3644
|
}, [r, g]), useEffect(() => {
|
|
3642
|
-
|
|
3643
|
-
}, [i,
|
|
3645
|
+
f.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3646
|
+
}, [i, f]), useEffect(() => {
|
|
3644
3647
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3645
3648
|
}, [u]), useEffect(() => {
|
|
3646
|
-
|
|
3649
|
+
m && (m.textContent = `${map(l, ({ id: x }) => `[data-style-id="${x}"]`).join(",")}{
|
|
3647
3650
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3648
3651
|
}`);
|
|
3649
|
-
}, [l,
|
|
3652
|
+
}, [l, m]), useEffect(() => {
|
|
3650
3653
|
c.querySelector("#drop-target-block").innerHTML = d ? `[data-block-id="${d}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3651
3654
|
}, [d, c]);
|
|
3652
|
-
const
|
|
3655
|
+
const y = useMemo(
|
|
3653
3656
|
() => getChaiThemeCssVariables(o),
|
|
3654
3657
|
[o]
|
|
3655
|
-
),
|
|
3658
|
+
), h = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3656
3659
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3657
|
-
/* @__PURE__ */ jsx("style", { id: "chai-theme", children:
|
|
3658
|
-
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html:
|
|
3660
|
+
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: y }),
|
|
3661
|
+
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: h } })
|
|
3659
3662
|
] });
|
|
3660
3663
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
3661
3664
|
const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), d = useDebouncedCallback(
|
|
@@ -3684,7 +3687,7 @@ function applyLanguage(o, n, r) {
|
|
|
3684
3687
|
const applyBinding = (o, n) => {
|
|
3685
3688
|
const r = cloneDeep(o);
|
|
3686
3689
|
return forEach(keys(r), (a) => {
|
|
3687
|
-
if (isString(r[a])) {
|
|
3690
|
+
if (isString(r[a]) && !startsWith(a, "_")) {
|
|
3688
3691
|
let l = r[a];
|
|
3689
3692
|
const i = /\{\{(.*?)\}\}/g, d = l.match(i);
|
|
3690
3693
|
d && d.forEach((c) => {
|
|
@@ -3731,30 +3734,37 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3731
3734
|
}, {}),
|
|
3732
3735
|
[o]
|
|
3733
3736
|
);
|
|
3734
|
-
},
|
|
3735
|
-
const r = useMemo(() => getRegisteredChaiBlock(o._type), [o._type]), { selectedLang: a, fallbackLang: l } = useLanguages(), i = useBlockRuntimeProps(), d = usePageExternalData(), [c] = useAtom$1(dataBindingActiveAtom),
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
[o, a, r, d, c]
|
|
3740
|
-
), g = useMemo(() => getBlockTagAttributes(o), [o]), h = useMemo(() => i(o._id, getBlockRuntimeProps(o._type)), [o]), m = useMemo(
|
|
3737
|
+
}, BlockRenderer = ({ block: o, children: n }) => {
|
|
3738
|
+
const r = useMemo(() => getRegisteredChaiBlock(o._type), [o._type]), { selectedLang: a, fallbackLang: l } = useLanguages(), i = useBlockRuntimeProps(), d = usePageExternalData(), [c] = useHiddenBlockIds(), [p] = useAtom$1(inlineEditingActiveAtom), [u] = useAtom$1(dataBindingActiveAtom), g = get(r, "component", null), m = useMemo(
|
|
3739
|
+
() => u ? applyBinding(applyLanguage(o, a, r), d) : applyLanguage(o, a, r),
|
|
3740
|
+
[o, a, r, d, u]
|
|
3741
|
+
), f = useMemo(() => getBlockTagAttributes(o), [o]), y = useMemo(() => i(o._id, getBlockRuntimeProps(o._type)), [o]), h = useMemo(() => !has(r, "dataProvider") || !isFunction$1(r.dataProvider) ? {} : r.dataProvider(o, a), [o, a, r]), x = useMemo(
|
|
3741
3742
|
() => ({
|
|
3742
|
-
|
|
3743
|
-
|
|
3743
|
+
blockProps: {
|
|
3744
|
+
"data-block-id": o._id,
|
|
3745
|
+
"data-block-type": o._type
|
|
3746
|
+
},
|
|
3744
3747
|
inBuilder: !0,
|
|
3745
3748
|
lang: a || l,
|
|
3746
|
-
...
|
|
3747
|
-
...
|
|
3749
|
+
...m,
|
|
3750
|
+
...f,
|
|
3751
|
+
...y,
|
|
3748
3752
|
...h
|
|
3749
3753
|
}),
|
|
3750
|
-
[o, a, l,
|
|
3754
|
+
[o, a, l, m, f, y, h]
|
|
3751
3755
|
);
|
|
3752
|
-
return /* @__PURE__ */ jsx(Suspense, { children: createElement(
|
|
3753
|
-
},
|
|
3754
|
-
const
|
|
3755
|
-
return
|
|
3756
|
-
},
|
|
3757
|
-
const
|
|
3756
|
+
return isNull(g) || c.includes(o._id) || p === o._id ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...x, children: n }) });
|
|
3757
|
+
}, GlobalBlocksRenderer = ({ block: o }) => {
|
|
3758
|
+
const { getGlobalBlocks: n } = useGlobalBlocksStore(), r = n(o);
|
|
3759
|
+
return /* @__PURE__ */ jsx(BlocksRenderer, { blocks: r, filterFn: (a) => isEmpty(a._parent) });
|
|
3760
|
+
}, BlocksRenderer = ({ blocks: o, filterFn: n }) => {
|
|
3761
|
+
const r = useMemo(() => filter(o, n), [o, n]), a = (l) => filter(o, (i) => i._parent === l).length > 0;
|
|
3762
|
+
return map(r, (l) => /* @__PURE__ */ jsx(BlockRenderer, { block: l, children: l._type === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlocksRenderer, { block: l }) : a(l._id) ? /* @__PURE__ */ jsx(BlocksRenderer, { blocks: o, filterFn: (i) => i._parent === l._id }) : null }, l._id));
|
|
3763
|
+
}, PageBlocksRenderer = () => {
|
|
3764
|
+
const [o] = useBlocksStore();
|
|
3765
|
+
return /* @__PURE__ */ jsx(BlocksRenderer, { blocks: o, filterFn: (n) => isEmpty(n._parent) });
|
|
3766
|
+
}, StaticBlocksRenderer = () => {
|
|
3767
|
+
const [o] = useBlocksStore(), n = isEmpty(o) ? null : /* @__PURE__ */ jsx(PageBlocksRenderer, {});
|
|
3758
3768
|
return /* @__PURE__ */ jsx(Fragment, { children: n });
|
|
3759
3769
|
}, useCanvasScale = (o) => {
|
|
3760
3770
|
const [n] = useCanvasWidth(), [, r] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), d = useCallback(() => {
|
|
@@ -3762,11 +3772,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3762
3772
|
if (c < n) {
|
|
3763
3773
|
const u = parseFloat((c / n).toFixed(2).toString());
|
|
3764
3774
|
let g = {};
|
|
3765
|
-
const
|
|
3775
|
+
const m = p * u, f = c * u;
|
|
3766
3776
|
p && (g = {
|
|
3767
3777
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3768
|
-
height: 100 + (p -
|
|
3769
|
-
width: 100 + (c -
|
|
3778
|
+
height: 100 + (p - m) / m * 100 + "%",
|
|
3779
|
+
width: 100 + (c - f) / f * 100 + "%"
|
|
3770
3780
|
}), i({
|
|
3771
3781
|
position: "relative",
|
|
3772
3782
|
top: 0,
|
|
@@ -3783,7 +3793,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3783
3793
|
d();
|
|
3784
3794
|
}, [n, o, r, d]), l;
|
|
3785
3795
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3786
|
-
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), d = useRef(null), [c, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(c), [g,
|
|
3796
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), d = useRef(null), [c, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(c), [g, m] = useState([]), [, f] = useState([]), [, y] = useAtom$1(canvasIframeAtom), [h, x] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), w = useBuilderProp("htmlDir", "ltr"), _ = (S) => {
|
|
3787
3797
|
p((B) => ({ ...B, width: S }));
|
|
3788
3798
|
};
|
|
3789
3799
|
useEffect(() => {
|
|
@@ -3799,18 +3809,18 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3799
3809
|
var S, B;
|
|
3800
3810
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3801
3811
|
const R = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3802
|
-
R && (v(R) || (B = (S = i.current) == null ? void 0 : S.contentWindow) == null || B.scrollTo({ top: R.offsetTop, behavior: "smooth" }),
|
|
3812
|
+
R && (v(R) || (B = (S = i.current) == null ? void 0 : S.contentWindow) == null || B.scrollTo({ top: R.offsetTop, behavior: "smooth" }), m([R]));
|
|
3803
3813
|
}
|
|
3804
3814
|
}, [a]), useEffect(() => {
|
|
3805
|
-
if (!isEmpty(
|
|
3815
|
+
if (!isEmpty(h) && i.current) {
|
|
3806
3816
|
const S = getElementByStyleId(
|
|
3807
3817
|
i.current.contentDocument,
|
|
3808
|
-
first(
|
|
3818
|
+
first(h).id
|
|
3809
3819
|
);
|
|
3810
|
-
|
|
3820
|
+
f(S ? [S] : [null]);
|
|
3811
3821
|
} else
|
|
3812
|
-
|
|
3813
|
-
}, [
|
|
3822
|
+
f([null]);
|
|
3823
|
+
}, [h]);
|
|
3814
3824
|
const k = useMemo(() => {
|
|
3815
3825
|
let S = IframeInitialContent;
|
|
3816
3826
|
return S = S.replace("__HTML_DIR__", w), o === "offline" && (S = S.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), S;
|
|
@@ -3827,7 +3837,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3827
3837
|
children: /* @__PURE__ */ jsxs(
|
|
3828
3838
|
ChaiFrame,
|
|
3829
3839
|
{
|
|
3830
|
-
contentDidMount: () =>
|
|
3840
|
+
contentDidMount: () => y(i.current),
|
|
3831
3841
|
ref: i,
|
|
3832
3842
|
id: "canvas-iframe",
|
|
3833
3843
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
@@ -3844,7 +3854,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3844
3854
|
),
|
|
3845
3855
|
/* @__PURE__ */ jsx(HeadTags, {}),
|
|
3846
3856
|
/* @__PURE__ */ jsx(Provider, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
|
|
3847
|
-
|
|
3857
|
+
b ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
|
|
3848
3858
|
/* @__PURE__ */ jsx(AddBlockAtBottom, {}),
|
|
3849
3859
|
/* @__PURE__ */ jsx("br", {}),
|
|
3850
3860
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4083,59 +4093,59 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4083
4093
|
}
|
|
4084
4094
|
);
|
|
4085
4095
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
4086
|
-
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [d, c] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (
|
|
4087
|
-
a(
|
|
4088
|
-
},
|
|
4089
|
-
const
|
|
4090
|
-
if (
|
|
4091
|
-
const w = Object.values(
|
|
4096
|
+
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [d, c] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (b) => {
|
|
4097
|
+
a(b);
|
|
4098
|
+
}, m = () => {
|
|
4099
|
+
const b = l.find((w) => Object.keys(w)[0] === r);
|
|
4100
|
+
if (b) {
|
|
4101
|
+
const w = Object.values(b)[0];
|
|
4092
4102
|
w && typeof w == "object" && "fontFamily" in w && "borderRadius" in w && "colors" in w ? c(w) : console.error("Invalid preset structure:", w);
|
|
4093
4103
|
} else
|
|
4094
4104
|
console.error("Preset not found:", r);
|
|
4095
|
-
},
|
|
4096
|
-
(
|
|
4105
|
+
}, f = useDebouncedCallback(
|
|
4106
|
+
(b, w) => {
|
|
4097
4107
|
c(() => ({
|
|
4098
4108
|
...d,
|
|
4099
4109
|
fontFamily: {
|
|
4100
4110
|
...d.fontFamily,
|
|
4101
|
-
[
|
|
4111
|
+
[b.replace(/font-/g, "")]: w
|
|
4102
4112
|
}
|
|
4103
4113
|
}));
|
|
4104
4114
|
},
|
|
4105
4115
|
[d],
|
|
4106
4116
|
200
|
|
4107
|
-
),
|
|
4108
|
-
(
|
|
4117
|
+
), y = useDebouncedCallback(
|
|
4118
|
+
(b) => {
|
|
4109
4119
|
c(() => ({
|
|
4110
4120
|
...d,
|
|
4111
|
-
borderRadius: `${
|
|
4121
|
+
borderRadius: `${b}px`
|
|
4112
4122
|
}));
|
|
4113
4123
|
},
|
|
4114
4124
|
[d],
|
|
4115
4125
|
200
|
|
4116
|
-
),
|
|
4117
|
-
(
|
|
4126
|
+
), h = useDebouncedCallback(
|
|
4127
|
+
(b, w) => {
|
|
4118
4128
|
c(() => {
|
|
4119
|
-
const _ = get(d, `colors.${
|
|
4129
|
+
const _ = get(d, `colors.${b}`);
|
|
4120
4130
|
return n ? set(_, 1, w) : set(_, 0, w), {
|
|
4121
4131
|
...d,
|
|
4122
4132
|
colors: {
|
|
4123
4133
|
...d.colors,
|
|
4124
|
-
[
|
|
4134
|
+
[b]: _
|
|
4125
4135
|
}
|
|
4126
4136
|
};
|
|
4127
4137
|
});
|
|
4128
4138
|
},
|
|
4129
4139
|
[d],
|
|
4130
4140
|
200
|
|
4131
|
-
), x = (
|
|
4141
|
+
), x = (b) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(b.items).map(([w]) => {
|
|
4132
4142
|
const _ = get(d, `colors.${w}.${n ? 1 : 0}`);
|
|
4133
4143
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4134
4144
|
/* @__PURE__ */ jsx(
|
|
4135
4145
|
ColorPickerInput,
|
|
4136
4146
|
{
|
|
4137
4147
|
value: _,
|
|
4138
|
-
onChange: (v) =>
|
|
4148
|
+
onChange: (v) => h(w, v)
|
|
4139
4149
|
}
|
|
4140
4150
|
),
|
|
4141
4151
|
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: w.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((v) => v.charAt(0).toUpperCase() + v.slice(1)).join(" ") + (!w.toLowerCase().includes("foreground") && !w.toLowerCase().includes("border") && !w.toLowerCase().includes("input") && !w.toLowerCase().includes("ring") && !w.toLowerCase().includes("background") ? " Background" : "") })
|
|
@@ -4150,11 +4160,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4150
4160
|
"select",
|
|
4151
4161
|
{
|
|
4152
4162
|
value: r,
|
|
4153
|
-
onChange: (
|
|
4163
|
+
onChange: (b) => g(b.target.value),
|
|
4154
4164
|
className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
4155
4165
|
children: [
|
|
4156
4166
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
4157
|
-
Array.isArray(l) && l.map((
|
|
4167
|
+
Array.isArray(l) && l.map((b) => /* @__PURE__ */ jsx("option", { value: Object.keys(b)[0], children: capitalize(Object.keys(b)[0]) }, Object.keys(b)[0]))
|
|
4158
4168
|
]
|
|
4159
4169
|
}
|
|
4160
4170
|
)
|
|
@@ -4165,31 +4175,31 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4165
4175
|
className: "w-full text-sm",
|
|
4166
4176
|
disabled: r === "",
|
|
4167
4177
|
variant: "default",
|
|
4168
|
-
onClick:
|
|
4178
|
+
onClick: m,
|
|
4169
4179
|
children: u("Apply")
|
|
4170
4180
|
}
|
|
4171
4181
|
) })
|
|
4172
4182
|
] }),
|
|
4173
4183
|
/* @__PURE__ */ jsxs("div", { className: cn("space-y-2", o), children: [
|
|
4174
|
-
(p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([
|
|
4184
|
+
(p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([b, w]) => /* @__PURE__ */ jsx(
|
|
4175
4185
|
FontSelector,
|
|
4176
4186
|
{
|
|
4177
|
-
label:
|
|
4178
|
-
value: d.fontFamily[
|
|
4179
|
-
onChange: (_) =>
|
|
4187
|
+
label: b,
|
|
4188
|
+
value: d.fontFamily[b.replace(/font-/g, "")] || w[Object.keys(w)[0]],
|
|
4189
|
+
onChange: (_) => f(b, _)
|
|
4180
4190
|
},
|
|
4181
|
-
|
|
4191
|
+
b
|
|
4182
4192
|
)) }),
|
|
4183
4193
|
(p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4184
4194
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
|
|
4185
4195
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4186
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange:
|
|
4196
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: y }),
|
|
4187
4197
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
|
|
4188
4198
|
] })
|
|
4189
4199
|
] }),
|
|
4190
4200
|
(p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4191
4201
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
|
|
4192
|
-
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((
|
|
4202
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((b) => x(b)) }, n ? "dark" : "light")
|
|
4193
4203
|
] })
|
|
4194
4204
|
] }),
|
|
4195
4205
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4395,41 +4405,41 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4395
4405
|
onChange: r
|
|
4396
4406
|
}) => {
|
|
4397
4407
|
var P;
|
|
4398
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, I) => []), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState("page"), [
|
|
4408
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, I) => []), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [y, h] = useState([]), [x, b] = useState(-1), w = useRef(null), _ = (P = n == null ? void 0 : n.find((C) => C.key === u)) == null ? void 0 : P.name;
|
|
4399
4409
|
useEffect(() => {
|
|
4400
|
-
if (
|
|
4410
|
+
if (f(""), h([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4401
4411
|
const C = split(o, ":"), I = get(C, 1, "page") || "page";
|
|
4402
4412
|
g(I), (async () => {
|
|
4403
4413
|
const E = await l(I, [get(C, 2, "page")]);
|
|
4404
|
-
E && Array.isArray(E) &&
|
|
4414
|
+
E && Array.isArray(E) && f(get(E, [0, "name"], ""));
|
|
4405
4415
|
})();
|
|
4406
4416
|
}, [o]);
|
|
4407
4417
|
const v = useDebouncedCallback(
|
|
4408
4418
|
async (C) => {
|
|
4409
4419
|
if (isEmpty(C))
|
|
4410
|
-
|
|
4420
|
+
h([]);
|
|
4411
4421
|
else {
|
|
4412
4422
|
const I = await l(u, C);
|
|
4413
|
-
|
|
4423
|
+
h(I);
|
|
4414
4424
|
}
|
|
4415
|
-
d(!1),
|
|
4425
|
+
d(!1), b(-1);
|
|
4416
4426
|
},
|
|
4417
4427
|
[u],
|
|
4418
4428
|
300
|
|
4419
4429
|
), k = (C) => {
|
|
4420
4430
|
const I = ["pageType", u, C.id];
|
|
4421
|
-
I[1] && (r(I.join(":")),
|
|
4431
|
+
I[1] && (r(I.join(":")), f(C.name), p(!1), h([]), b(-1));
|
|
4422
4432
|
}, S = (C) => {
|
|
4423
4433
|
switch (C.key) {
|
|
4424
4434
|
case "ArrowDown":
|
|
4425
|
-
C.preventDefault(),
|
|
4435
|
+
C.preventDefault(), b((I) => I < y.length - 1 ? I + 1 : I);
|
|
4426
4436
|
break;
|
|
4427
4437
|
case "ArrowUp":
|
|
4428
|
-
C.preventDefault(),
|
|
4438
|
+
C.preventDefault(), b((I) => I > 0 ? I - 1 : I);
|
|
4429
4439
|
break;
|
|
4430
4440
|
case "Enter":
|
|
4431
|
-
if (C.preventDefault(),
|
|
4432
|
-
x >= 0 && k(
|
|
4441
|
+
if (C.preventDefault(), y.length === 0) return;
|
|
4442
|
+
x >= 0 && k(y[x]);
|
|
4433
4443
|
break;
|
|
4434
4444
|
case "Escape":
|
|
4435
4445
|
C.preventDefault(), B();
|
|
@@ -4443,9 +4453,9 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4443
4453
|
}
|
|
4444
4454
|
}, [x]);
|
|
4445
4455
|
const B = () => {
|
|
4446
|
-
|
|
4456
|
+
f(""), h([]), b(-1), p(!1), r("");
|
|
4447
4457
|
}, R = (C) => {
|
|
4448
|
-
|
|
4458
|
+
f(C), p(!isEmpty(C)), d(!0), v(C);
|
|
4449
4459
|
};
|
|
4450
4460
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4451
4461
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(n, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
|
|
@@ -4454,24 +4464,24 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4454
4464
|
"input",
|
|
4455
4465
|
{
|
|
4456
4466
|
type: "text",
|
|
4457
|
-
value:
|
|
4467
|
+
value: m,
|
|
4458
4468
|
onChange: (C) => R(C.target.value),
|
|
4459
4469
|
onKeyDown: S,
|
|
4460
4470
|
placeholder: a(`Search ${_ ?? ""}`),
|
|
4461
4471
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4462
4472
|
}
|
|
4463
4473
|
),
|
|
4464
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
4474
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: B, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4465
4475
|
] }),
|
|
4466
|
-
(i || !isEmpty(
|
|
4476
|
+
(i || !isEmpty(y) || c && isEmpty(y)) && /* @__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: [
|
|
4467
4477
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4468
4478
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4469
|
-
] }) : c && isEmpty(
|
|
4479
|
+
] }) : c && isEmpty(y) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4470
4480
|
a("No results found for"),
|
|
4471
4481
|
' "',
|
|
4472
|
-
|
|
4482
|
+
m,
|
|
4473
4483
|
'"'
|
|
4474
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: w, children: map(
|
|
4484
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: w, children: map(y == null ? void 0 : y.slice(0, 20), (C, I) => /* @__PURE__ */ jsxs(
|
|
4475
4485
|
"li",
|
|
4476
4486
|
{
|
|
4477
4487
|
onClick: () => k(C),
|
|
@@ -4568,30 +4578,30 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4568
4578
|
}, [a]), useEffect(() => {
|
|
4569
4579
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4570
4580
|
}, [o, u]);
|
|
4571
|
-
const
|
|
4572
|
-
const
|
|
4573
|
-
if (
|
|
4574
|
-
const x = (
|
|
4575
|
-
if (!
|
|
4576
|
-
n({ ...o, currentSlide:
|
|
4581
|
+
const m = () => {
|
|
4582
|
+
const h = findIndex(u, { _id: g });
|
|
4583
|
+
if (h > -1) {
|
|
4584
|
+
const x = (h + 1) % u.length, b = get(u, [x, "_id"]);
|
|
4585
|
+
if (!b) return;
|
|
4586
|
+
n({ ...o, currentSlide: b }), d([b]);
|
|
4577
4587
|
}
|
|
4578
|
-
},
|
|
4579
|
-
const
|
|
4580
|
-
if (
|
|
4581
|
-
const x = (
|
|
4582
|
-
if (!
|
|
4583
|
-
n({ ...o, currentSlide:
|
|
4588
|
+
}, f = () => {
|
|
4589
|
+
const h = findIndex(u, { _id: g });
|
|
4590
|
+
if (h > -1) {
|
|
4591
|
+
const x = (h - 1 + u.length) % u.length, b = get(u, [x, "_id"]);
|
|
4592
|
+
if (!b) return;
|
|
4593
|
+
n({ ...o, currentSlide: b }), d([b]);
|
|
4584
4594
|
}
|
|
4585
|
-
},
|
|
4586
|
-
const
|
|
4595
|
+
}, y = () => {
|
|
4596
|
+
const h = i(
|
|
4587
4597
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4588
4598
|
p == null ? void 0 : p._id
|
|
4589
|
-
), x =
|
|
4599
|
+
), x = h == null ? void 0 : h._id;
|
|
4590
4600
|
x && (n({ ...o, currentSlide: x }), d([x]));
|
|
4591
4601
|
};
|
|
4592
4602
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4593
4603
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4594
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4604
|
+
/* @__PURE__ */ jsx("button", { onClick: f, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4595
4605
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4596
4606
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4597
4607
|
" ",
|
|
@@ -4600,11 +4610,11 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4600
4610
|
"/",
|
|
4601
4611
|
u.length
|
|
4602
4612
|
] }) : "-" }),
|
|
4603
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4613
|
+
/* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4604
4614
|
/* @__PURE__ */ jsxs(
|
|
4605
4615
|
"button",
|
|
4606
4616
|
{
|
|
4607
|
-
onClick:
|
|
4617
|
+
onClick: y,
|
|
4608
4618
|
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",
|
|
4609
4619
|
children: [
|
|
4610
4620
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4665,8 +4675,8 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4665
4675
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4666
4676
|
className: "text-xs",
|
|
4667
4677
|
pattern: "[0-9]*",
|
|
4668
|
-
onChange: (
|
|
4669
|
-
let x =
|
|
4678
|
+
onChange: (h) => {
|
|
4679
|
+
let x = h.target.value;
|
|
4670
4680
|
x.length && (x = x.replace("-", "")), n({ ...o, autoplayInterval: x });
|
|
4671
4681
|
}
|
|
4672
4682
|
}
|
|
@@ -4705,7 +4715,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4705
4715
|
schema: u,
|
|
4706
4716
|
formData: g
|
|
4707
4717
|
}) => {
|
|
4708
|
-
const { selectedLang:
|
|
4718
|
+
const { selectedLang: m, fallbackLang: f, languages: y } = useLanguages(), h = isEmpty(y) ? "" : isEmpty(m) ? f : m, x = get(LANGUAGES, h, h), b = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get(w, [b == null ? void 0 : b._type, "i18nProps"], []) || [], [v, k] = useState(null);
|
|
4709
4719
|
if (c)
|
|
4710
4720
|
return null;
|
|
4711
4721
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
@@ -4757,8 +4767,8 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4757
4767
|
/* @__PURE__ */ jsx("span", { children: "Add" })
|
|
4758
4768
|
] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
|
|
4759
4769
|
const { selectedLang: i } = useLanguages(), [d] = useAtom$1(chaiRjsfWidgetsAtom), [c] = useAtom$1(chaiRjsfFieldsAtom), [p] = useAtom$1(chaiRjsfTemplatesAtom), u = useThrottledCallback(
|
|
4760
|
-
async ({ formData: g },
|
|
4761
|
-
l({ formData: g },
|
|
4770
|
+
async ({ formData: g }, m) => {
|
|
4771
|
+
l({ formData: g }, m);
|
|
4762
4772
|
},
|
|
4763
4773
|
[l, i],
|
|
4764
4774
|
1e3
|
|
@@ -4797,10 +4807,10 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4797
4807
|
uiSchema: r,
|
|
4798
4808
|
schema: n,
|
|
4799
4809
|
formData: a,
|
|
4800
|
-
onChange: ({ formData: g },
|
|
4801
|
-
if (!
|
|
4802
|
-
const
|
|
4803
|
-
u({ formData: g },
|
|
4810
|
+
onChange: ({ formData: g }, m) => {
|
|
4811
|
+
if (!m || o !== (g == null ? void 0 : g._id)) return;
|
|
4812
|
+
const f = take(m.split("."), 2).join(".").replace("root.", "");
|
|
4813
|
+
u({ formData: g }, f);
|
|
4804
4814
|
}
|
|
4805
4815
|
},
|
|
4806
4816
|
i
|
|
@@ -4812,17 +4822,17 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4812
4822
|
}), a;
|
|
4813
4823
|
};
|
|
4814
4824
|
function BlockSettings() {
|
|
4815
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [d, c] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(),
|
|
4825
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [d, c] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m), y = ({ formData: S }, B, R) => {
|
|
4816
4826
|
B && (d == null ? void 0 : d._id) === n._id && a([n._id], { [B]: get(S, B) }, R);
|
|
4817
|
-
},
|
|
4827
|
+
}, h = useCallback(
|
|
4818
4828
|
debounce(({ formData: S }, B, R) => {
|
|
4819
|
-
|
|
4829
|
+
y({ formData: S }, B, R), c(S);
|
|
4820
4830
|
}, 1500),
|
|
4821
4831
|
[n == null ? void 0 : n._id, o]
|
|
4822
4832
|
), x = ({ formData: S }, B) => {
|
|
4823
|
-
B && (r([n._id], { [B]: get(S, B) }),
|
|
4824
|
-
},
|
|
4825
|
-
B && (r([g._id], { [B]: get(S, B) }),
|
|
4833
|
+
B && (r([n._id], { [B]: get(S, B) }), h({ formData: S }, B, { [B]: get(d, B) }));
|
|
4834
|
+
}, b = ({ formData: S }, B) => {
|
|
4835
|
+
B && (r([g._id], { [B]: get(S, B) }), h({ formData: S }, B, { [B]: get(d, B) }));
|
|
4826
4836
|
};
|
|
4827
4837
|
keys(get(i, "_bindings", {}));
|
|
4828
4838
|
const { schema: w, uiSchema: _ } = useMemo(() => {
|
|
@@ -4859,8 +4869,8 @@ function BlockSettings() {
|
|
|
4859
4869
|
JSONForm,
|
|
4860
4870
|
{
|
|
4861
4871
|
blockId: g == null ? void 0 : g._id,
|
|
4862
|
-
onChange:
|
|
4863
|
-
formData:
|
|
4872
|
+
onChange: b,
|
|
4873
|
+
formData: f,
|
|
4864
4874
|
schema: v,
|
|
4865
4875
|
uiSchema: k
|
|
4866
4876
|
}
|
|
@@ -4945,12 +4955,12 @@ function Countdown() {
|
|
|
4945
4955
|
const AskAIStyles = ({ blockId: o }) => {
|
|
4946
4956
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, d] = useState(""), c = useRef(null), p = useRef(null), [u, g] = useState();
|
|
4947
4957
|
useEffect(() => {
|
|
4948
|
-
var
|
|
4949
|
-
(
|
|
4958
|
+
var f;
|
|
4959
|
+
(f = c.current) == null || f.focus();
|
|
4950
4960
|
}, []);
|
|
4951
|
-
const
|
|
4952
|
-
const { usage:
|
|
4953
|
-
!l &&
|
|
4961
|
+
const m = (f) => {
|
|
4962
|
+
const { usage: y } = f || {};
|
|
4963
|
+
!l && y && g(y), p.current = setTimeout(() => g(void 0), 1e4), l || d("");
|
|
4954
4964
|
};
|
|
4955
4965
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
4956
4966
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -4959,12 +4969,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
4959
4969
|
{
|
|
4960
4970
|
ref: c,
|
|
4961
4971
|
value: i,
|
|
4962
|
-
onChange: (
|
|
4972
|
+
onChange: (f) => d(f.target.value),
|
|
4963
4973
|
placeholder: n("Ask AI to edit styles"),
|
|
4964
4974
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
4965
4975
|
rows: 4,
|
|
4966
|
-
onKeyDown: (
|
|
4967
|
-
|
|
4976
|
+
onKeyDown: (f) => {
|
|
4977
|
+
f.key === "Enter" && (f.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
|
|
4968
4978
|
}
|
|
4969
4979
|
}
|
|
4970
4980
|
),
|
|
@@ -4974,7 +4984,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
4974
4984
|
{
|
|
4975
4985
|
disabled: i.trim().length < 5 || a,
|
|
4976
4986
|
onClick: () => {
|
|
4977
|
-
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i,
|
|
4987
|
+
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
|
|
4978
4988
|
},
|
|
4979
4989
|
variant: "default",
|
|
4980
4990
|
className: "w-fit",
|
|
@@ -5006,10 +5016,10 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5006
5016
|
};
|
|
5007
5017
|
function ManualClasses() {
|
|
5008
5018
|
var R;
|
|
5009
|
-
const o = useFuseSearch(), { t: n } = useTranslation(), [r] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [d] = useSelectedBlockIds(), c = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: g } = useToast(),
|
|
5019
|
+
const o = useFuseSearch(), { t: n } = useTranslation(), [r] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [d] = useSelectedBlockIds(), c = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: g } = useToast(), m = (R = first(r)) == null ? void 0 : R.prop, { classes: f } = getSplitChaiClasses(get(a, m, "")), y = f.split(" ").filter((P) => !isEmpty(P)), h = () => {
|
|
5010
5020
|
const P = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5011
5021
|
l(d, P, !0), u("");
|
|
5012
|
-
}, [x,
|
|
5022
|
+
}, [x, b] = useState([]), w = ({ value: P }) => {
|
|
5013
5023
|
const C = P.trim().toLowerCase(), I = C.match(/.+:/g);
|
|
5014
5024
|
let E = [];
|
|
5015
5025
|
if (I && I.length > 0) {
|
|
@@ -5020,9 +5030,9 @@ function ManualClasses() {
|
|
|
5020
5030
|
}));
|
|
5021
5031
|
} else
|
|
5022
5032
|
E = o.search(C);
|
|
5023
|
-
return
|
|
5033
|
+
return b(map(E, "item"));
|
|
5024
5034
|
}, _ = () => {
|
|
5025
|
-
|
|
5035
|
+
b([]);
|
|
5026
5036
|
}, v = (P) => P.name, k = (P) => /* @__PURE__ */ jsx("div", { className: "p-1 rounded-md", children: P.name }), S = {
|
|
5027
5037
|
autoComplete: "off",
|
|
5028
5038
|
autoCorrect: "off",
|
|
@@ -5031,7 +5041,7 @@ function ManualClasses() {
|
|
|
5031
5041
|
placeholder: n("Enter classes separated by space"),
|
|
5032
5042
|
value: p,
|
|
5033
5043
|
onKeyDown: (P) => {
|
|
5034
|
-
P.key === "Enter" && p.trim() !== "" &&
|
|
5044
|
+
P.key === "Enter" && p.trim() !== "" && h();
|
|
5035
5045
|
},
|
|
5036
5046
|
onChange: (P, { newValue: C }) => u(C),
|
|
5037
5047
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
@@ -5044,7 +5054,7 @@ function ManualClasses() {
|
|
|
5044
5054
|
});
|
|
5045
5055
|
return;
|
|
5046
5056
|
}
|
|
5047
|
-
navigator.clipboard.writeText(
|
|
5057
|
+
navigator.clipboard.writeText(y.join(" ")), g({
|
|
5048
5058
|
title: n("Copied"),
|
|
5049
5059
|
description: n("Classes copied to clipboard")
|
|
5050
5060
|
});
|
|
@@ -5091,14 +5101,14 @@ function ManualClasses() {
|
|
|
5091
5101
|
{
|
|
5092
5102
|
variant: "outline",
|
|
5093
5103
|
className: "h-6 border-border",
|
|
5094
|
-
onClick:
|
|
5104
|
+
onClick: h,
|
|
5095
5105
|
disabled: p.trim() === "",
|
|
5096
5106
|
size: "sm",
|
|
5097
5107
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5098
5108
|
}
|
|
5099
5109
|
)
|
|
5100
5110
|
] }),
|
|
5101
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap w-full gap-2 overflow-x-hidden", children:
|
|
5111
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap w-full gap-2 overflow-x-hidden", children: y.map((P) => /* @__PURE__ */ jsxs(
|
|
5102
5112
|
"div",
|
|
5103
5113
|
{
|
|
5104
5114
|
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 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
|
|
@@ -5501,10 +5511,10 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5501
5511
|
ringColor: "ring",
|
|
5502
5512
|
ringOffsetColor: "ring-offset"
|
|
5503
5513
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5504
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, d] = useState([]), [c, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""),
|
|
5514
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, d] = useState([]), [c, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), f = useCallback(
|
|
5505
5515
|
// eslint-disable-next-line no-shadow
|
|
5506
5516
|
(x) => {
|
|
5507
|
-
["current", "inherit", "transparent", "black", "white"].includes(x) ? (d([]), p({ color: x })) : (d(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((
|
|
5517
|
+
["current", "inherit", "transparent", "black", "white"].includes(x) ? (d([]), p({ color: x })) : (d(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: x, shade: b.shade ? b.shade : "500" })));
|
|
5508
5518
|
},
|
|
5509
5519
|
[d, p]
|
|
5510
5520
|
);
|
|
@@ -5513,7 +5523,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5513
5523
|
return d([]);
|
|
5514
5524
|
d(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5515
5525
|
}, [g]);
|
|
5516
|
-
const
|
|
5526
|
+
const y = useCallback(
|
|
5517
5527
|
// eslint-disable-next-line no-shadow
|
|
5518
5528
|
(x) => {
|
|
5519
5529
|
p({ color: g, shade: x });
|
|
@@ -5523,18 +5533,18 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5523
5533
|
useEffect(() => {
|
|
5524
5534
|
p({ color: "", shade: "" });
|
|
5525
5535
|
}, [r]);
|
|
5526
|
-
const { match:
|
|
5536
|
+
const { match: h } = useTailwindClassList();
|
|
5527
5537
|
return useEffect(() => {
|
|
5528
|
-
const
|
|
5529
|
-
|
|
5530
|
-
}, [
|
|
5538
|
+
const b = `${get(COLOR_PROP, o, "")}-${c.color}${c.shade ? `-${c.shade}` : ""}`;
|
|
5539
|
+
h(o, b) && n(b, o);
|
|
5540
|
+
}, [h, c, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5531
5541
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5532
5542
|
DropDown,
|
|
5533
5543
|
{
|
|
5534
5544
|
disabled: !l,
|
|
5535
5545
|
rounded: !0,
|
|
5536
5546
|
selected: g,
|
|
5537
|
-
onChange:
|
|
5547
|
+
onChange: f,
|
|
5538
5548
|
options: [
|
|
5539
5549
|
"current",
|
|
5540
5550
|
"transparent",
|
|
@@ -5567,7 +5577,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5567
5577
|
]
|
|
5568
5578
|
}
|
|
5569
5579
|
) }),
|
|
5570
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected:
|
|
5580
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: y, options: i }) })
|
|
5571
5581
|
] });
|
|
5572
5582
|
}, getUserInputValues = (o, n) => {
|
|
5573
5583
|
o = o.toLowerCase();
|
|
@@ -5714,23 +5724,23 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5714
5724
|
},
|
|
5715
5725
|
a
|
|
5716
5726
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5717
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: d, classPrefix: c, cssProperty: p, units: u, negative: g } = o, [
|
|
5727
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: d, classPrefix: c, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [y, h] = useState(!1), [x, b] = useState(""), [w, _] = useState(!1), [v, k] = useState(!1);
|
|
5718
5728
|
useEffect(() => {
|
|
5719
5729
|
const { value: C, unit: I } = getClassValueAndUnit(i);
|
|
5720
5730
|
if (I === "") {
|
|
5721
|
-
l(C),
|
|
5731
|
+
l(C), f(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5722
5732
|
return;
|
|
5723
5733
|
}
|
|
5724
|
-
|
|
5734
|
+
f(I), l(I === "class" || isEmpty(C) ? "" : C);
|
|
5725
5735
|
}, [i, p, u]);
|
|
5726
5736
|
const S = useThrottledCallback((C) => d(C), [d], THROTTLE_TIME), B = useThrottledCallback((C) => d(C, !1), [d], THROTTLE_TIME), R = useCallback(
|
|
5727
5737
|
(C = !1) => {
|
|
5728
5738
|
const I = getUserInputValues(`${a}`, u);
|
|
5729
5739
|
if (get(I, "error", !1)) {
|
|
5730
|
-
|
|
5740
|
+
h(!0);
|
|
5731
5741
|
return;
|
|
5732
5742
|
}
|
|
5733
|
-
const E = get(I, "unit") !== "" ? get(I, "unit") :
|
|
5743
|
+
const E = get(I, "unit") !== "" ? get(I, "unit") : m;
|
|
5734
5744
|
if (E === "auto" || E === "none") {
|
|
5735
5745
|
S(`${c}${E}`);
|
|
5736
5746
|
return;
|
|
@@ -5740,12 +5750,12 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5740
5750
|
const N = `${get(I, "value", "").startsWith("-") ? "-" : ""}${c}[${get(I, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
|
|
5741
5751
|
C ? B(N) : S(N);
|
|
5742
5752
|
},
|
|
5743
|
-
[S, B, a,
|
|
5753
|
+
[S, B, a, m, c, u]
|
|
5744
5754
|
), P = useCallback(
|
|
5745
5755
|
(C) => {
|
|
5746
5756
|
const I = getUserInputValues(`${a}`, u);
|
|
5747
5757
|
if (get(I, "error", !1)) {
|
|
5748
|
-
|
|
5758
|
+
h(!0);
|
|
5749
5759
|
return;
|
|
5750
5760
|
}
|
|
5751
5761
|
if (C === "auto" || C === "none") {
|
|
@@ -5759,7 +5769,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5759
5769
|
},
|
|
5760
5770
|
[S, a, c, u]
|
|
5761
5771
|
);
|
|
5762
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children:
|
|
5772
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5763
5773
|
/* @__PURE__ */ jsx(
|
|
5764
5774
|
"input",
|
|
5765
5775
|
{
|
|
@@ -5774,10 +5784,10 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5774
5784
|
] })
|
|
5775
5785
|
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${w ? "z-auto" : ""}`, children: [
|
|
5776
5786
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
5777
|
-
["none", "auto"].indexOf(
|
|
5787
|
+
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
5778
5788
|
"input",
|
|
5779
5789
|
{
|
|
5780
|
-
readOnly:
|
|
5790
|
+
readOnly: m === "class",
|
|
5781
5791
|
onKeyPress: (C) => {
|
|
5782
5792
|
C.key === "Enter" && R();
|
|
5783
5793
|
},
|
|
@@ -5788,7 +5798,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5788
5798
|
const I = parseInt$1(C.target.value);
|
|
5789
5799
|
let E = isNaN$1(I) ? 0 : I;
|
|
5790
5800
|
C.keyCode === 38 && (E += 1), C.keyCode === 40 && (E -= 1);
|
|
5791
|
-
const j = `${E}`, L = `${j.startsWith("-") ? "-" : ""}${c}[${j.replace("-", "")}${
|
|
5801
|
+
const j = `${E}`, L = `${j.startsWith("-") ? "-" : ""}${c}[${j.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5792
5802
|
B(L);
|
|
5793
5803
|
},
|
|
5794
5804
|
onKeyUp: (C) => {
|
|
@@ -5796,7 +5806,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5796
5806
|
},
|
|
5797
5807
|
onBlur: () => R(),
|
|
5798
5808
|
onChange: (C) => {
|
|
5799
|
-
|
|
5809
|
+
h(!1), l(C.target.value);
|
|
5800
5810
|
},
|
|
5801
5811
|
onClick: (C) => {
|
|
5802
5812
|
var I;
|
|
@@ -5805,7 +5815,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5805
5815
|
value: w ? x : a,
|
|
5806
5816
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
5807
5817
|
" ",
|
|
5808
|
-
|
|
5818
|
+
y ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
5809
5819
|
)
|
|
5810
5820
|
}
|
|
5811
5821
|
),
|
|
@@ -5817,7 +5827,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5817
5827
|
onClick: () => r(!n),
|
|
5818
5828
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
5819
5829
|
children: [
|
|
5820
|
-
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
5830
|
+
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
|
|
5821
5831
|
u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
|
|
5822
5832
|
]
|
|
5823
5833
|
}
|
|
@@ -5826,33 +5836,33 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5826
5836
|
UnitSelection,
|
|
5827
5837
|
{
|
|
5828
5838
|
units: u,
|
|
5829
|
-
current:
|
|
5839
|
+
current: m,
|
|
5830
5840
|
onSelect: (C) => {
|
|
5831
|
-
r(!1),
|
|
5841
|
+
r(!1), f(C), P(C);
|
|
5832
5842
|
}
|
|
5833
5843
|
}
|
|
5834
5844
|
) }) })
|
|
5835
5845
|
] })
|
|
5836
5846
|
] }),
|
|
5837
|
-
["none", "auto"].indexOf(
|
|
5847
|
+
["none", "auto"].indexOf(m) !== -1 || w ? null : /* @__PURE__ */ jsx(
|
|
5838
5848
|
DragStyleButton,
|
|
5839
5849
|
{
|
|
5840
5850
|
onDragStart: () => _(!0),
|
|
5841
5851
|
onDragEnd: (C) => {
|
|
5842
|
-
if (
|
|
5852
|
+
if (b(() => ""), _(!1), isEmpty(C))
|
|
5843
5853
|
return;
|
|
5844
|
-
const I = `${C}`, j = `${I.startsWith("-") ? "-" : ""}${c}[${I.replace("-", "")}${
|
|
5854
|
+
const I = `${C}`, j = `${I.startsWith("-") ? "-" : ""}${c}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5845
5855
|
S(j);
|
|
5846
5856
|
},
|
|
5847
5857
|
onDrag: (C) => {
|
|
5848
5858
|
if (isEmpty(C))
|
|
5849
5859
|
return;
|
|
5850
|
-
|
|
5851
|
-
const I = `${C}`, j = `${I.startsWith("-") ? "-" : ""}${c}[${I.replace("-", "")}${
|
|
5860
|
+
b(C);
|
|
5861
|
+
const I = `${C}`, j = `${I.startsWith("-") ? "-" : ""}${c}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5852
5862
|
B(j);
|
|
5853
5863
|
},
|
|
5854
5864
|
currentValue: a,
|
|
5855
|
-
unit:
|
|
5865
|
+
unit: m,
|
|
5856
5866
|
negative: g,
|
|
5857
5867
|
cssProperty: p
|
|
5858
5868
|
}
|
|
@@ -5946,20 +5956,20 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5946
5956
|
"2xl": "1536px"
|
|
5947
5957
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
5948
5958
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
5949
|
-
}, units: d, negative: c = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useCanvasWidth(),
|
|
5959
|
+
}, units: d, negative: c = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useCanvasWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(), y = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), x = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
|
|
5950
5960
|
(B, R = !0) => {
|
|
5951
5961
|
const P = { dark: p, mq: g, mod: u, cls: B, property: l, fullCls: "" };
|
|
5952
5962
|
(p || u !== "") && (P.mq = "xs");
|
|
5953
5963
|
const C = generateFullClsName(P);
|
|
5954
|
-
|
|
5964
|
+
f(h, [C], R);
|
|
5955
5965
|
},
|
|
5956
|
-
[
|
|
5966
|
+
[h, p, g, u, l, f]
|
|
5957
5967
|
), w = useCallback(() => {
|
|
5958
|
-
|
|
5959
|
-
}, [
|
|
5968
|
+
y(h, [x]);
|
|
5969
|
+
}, [h, x, y]), _ = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
5960
5970
|
useEffect(() => {
|
|
5961
|
-
i(_,
|
|
5962
|
-
}, [_, i,
|
|
5971
|
+
i(_, m);
|
|
5972
|
+
}, [_, i, m]);
|
|
5963
5973
|
const [, , v] = useCanvasWidth(), k = useCallback(
|
|
5964
5974
|
(B) => {
|
|
5965
5975
|
v({
|
|
@@ -5972,28 +5982,28 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5972
5982
|
}[B]);
|
|
5973
5983
|
},
|
|
5974
5984
|
[v]
|
|
5975
|
-
), S = get(
|
|
5976
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: _, canReset:
|
|
5977
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${
|
|
5985
|
+
), S = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
5986
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: _, canReset: m && S, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
5987
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !S ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
5978
5988
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
5979
5989
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
5980
5990
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
5981
5991
|
AdvanceChoices,
|
|
5982
5992
|
{
|
|
5983
|
-
currentClass: get(
|
|
5993
|
+
currentClass: get(m, "cls", ""),
|
|
5984
5994
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
5985
5995
|
units: d || [],
|
|
5986
|
-
onChange:
|
|
5996
|
+
onChange: b,
|
|
5987
5997
|
negative: c,
|
|
5988
5998
|
cssProperty: l
|
|
5989
5999
|
}
|
|
5990
6000
|
) : null,
|
|
5991
|
-
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange:
|
|
5992
|
-
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange:
|
|
5993
|
-
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange:
|
|
5994
|
-
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange:
|
|
6001
|
+
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: b }),
|
|
6002
|
+
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: b }),
|
|
6003
|
+
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
6004
|
+
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
5995
6005
|
] }),
|
|
5996
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${x ? "visible" : "invisible"}`, children: S ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => w(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : _ &&
|
|
6006
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${x ? "visible" : "invisible"}`, children: S ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => w(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : _ && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
5997
6007
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5998
6008
|
"button",
|
|
5999
6009
|
{
|
|
@@ -6005,19 +6015,19 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6005
6015
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
6006
6016
|
"Current style is set at ",
|
|
6007
6017
|
/* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
|
|
6008
|
-
getBreakpoint(get(
|
|
6009
|
-
p && !
|
|
6018
|
+
getBreakpoint(get(m, "mq")),
|
|
6019
|
+
p && !m.dark ? "(Light mode)" : ""
|
|
6010
6020
|
] }),
|
|
6011
6021
|
/* @__PURE__ */ jsx("br", {}),
|
|
6012
6022
|
/* @__PURE__ */ jsxs(
|
|
6013
6023
|
"button",
|
|
6014
6024
|
{
|
|
6015
6025
|
type: "button",
|
|
6016
|
-
onClick: () => k(get(
|
|
6026
|
+
onClick: () => k(get(m, "mq")),
|
|
6017
6027
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6018
6028
|
children: [
|
|
6019
6029
|
"Switch to ",
|
|
6020
|
-
get(
|
|
6030
|
+
get(m, "mq").toUpperCase()
|
|
6021
6031
|
]
|
|
6022
6032
|
}
|
|
6023
6033
|
)
|
|
@@ -6034,7 +6044,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6034
6044
|
units: i = basicUnits,
|
|
6035
6045
|
negative: d = !1
|
|
6036
6046
|
}) => {
|
|
6037
|
-
const { t: c } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(),
|
|
6047
|
+
const { t: c } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((f) => map(g, "property").includes(f), [g]);
|
|
6038
6048
|
return /* @__PURE__ */ jsxs(
|
|
6039
6049
|
"div",
|
|
6040
6050
|
{
|
|
@@ -6043,22 +6053,22 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6043
6053
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6044
6054
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: c(o) }),
|
|
6045
6055
|
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6046
|
-
n.map(({ label:
|
|
6056
|
+
n.map(({ label: f, key: y }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6047
6057
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6048
6058
|
"button",
|
|
6049
6059
|
{
|
|
6050
6060
|
type: "button",
|
|
6051
|
-
onClick: () => u(
|
|
6052
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6061
|
+
onClick: () => u(y),
|
|
6062
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${y === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6053
6063
|
children: [
|
|
6054
6064
|
React__default.createElement("div", {
|
|
6055
|
-
className:
|
|
6065
|
+
className: m(y) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6056
6066
|
}),
|
|
6057
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6067
|
+
React__default.createElement(get(EDITOR_ICONS, y, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6058
6068
|
]
|
|
6059
6069
|
}
|
|
6060
6070
|
) }),
|
|
6061
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
6071
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(f)) })
|
|
6062
6072
|
] }) }))
|
|
6063
6073
|
) })
|
|
6064
6074
|
] }),
|
|
@@ -6197,13 +6207,13 @@ function BlockStyling() {
|
|
|
6197
6207
|
cssProperty: ""
|
|
6198
6208
|
}), c = useThrottledCallback(
|
|
6199
6209
|
(u) => {
|
|
6200
|
-
const g = !get(i, "negative", !1),
|
|
6201
|
-
let
|
|
6202
|
-
|
|
6203
|
-
let
|
|
6204
|
-
(startsWith(
|
|
6205
|
-
let x = (i.dragStartY - u.pageY) /
|
|
6206
|
-
g && x < 0 && (x = 0),
|
|
6210
|
+
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6211
|
+
let f = parseFloat(i.dragStartValue);
|
|
6212
|
+
f = isNaN(f) ? 0 : f;
|
|
6213
|
+
let y = MAPPER[i.dragUnit];
|
|
6214
|
+
(startsWith(m, "scale") || m === "opacity") && (y = 10);
|
|
6215
|
+
let x = (i.dragStartY - u.pageY) / y + f;
|
|
6216
|
+
g && x < 0 && (x = 0), m === "opacity" && x > 1 && (x = 1), i.onDrag(`${x}`), l(`${x}`);
|
|
6207
6217
|
},
|
|
6208
6218
|
[i],
|
|
6209
6219
|
50
|
|
@@ -6245,35 +6255,35 @@ const CoreBlock = ({
|
|
|
6245
6255
|
parentId: r,
|
|
6246
6256
|
position: a
|
|
6247
6257
|
}) => {
|
|
6248
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: d, label: c } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight:
|
|
6258
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: d, label: c } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), f = () => {
|
|
6249
6259
|
if (has(o, "blocks")) {
|
|
6250
6260
|
const x = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6251
6261
|
u(syncBlocksWithDefaults(x), r || null, a);
|
|
6252
6262
|
} else
|
|
6253
6263
|
p(o, r || null, a);
|
|
6254
6264
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6255
|
-
},
|
|
6265
|
+
}, y = useFeature("dnd"), { t: h } = useTranslation();
|
|
6256
6266
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6257
6267
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6258
6268
|
"button",
|
|
6259
6269
|
{
|
|
6260
6270
|
disabled: n,
|
|
6261
|
-
onClick:
|
|
6271
|
+
onClick: f,
|
|
6262
6272
|
type: "button",
|
|
6263
6273
|
onDragStart: (x) => {
|
|
6264
6274
|
x.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), x.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6265
|
-
g([]),
|
|
6275
|
+
g([]), m();
|
|
6266
6276
|
}, 200);
|
|
6267
6277
|
},
|
|
6268
|
-
draggable:
|
|
6278
|
+
draggable: y ? "true" : "false",
|
|
6269
6279
|
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",
|
|
6270
6280
|
children: [
|
|
6271
6281
|
createElement(d || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6272
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6282
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(h(c || i)) })
|
|
6273
6283
|
]
|
|
6274
6284
|
}
|
|
6275
6285
|
) }),
|
|
6276
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6286
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h(c || i) }) })
|
|
6277
6287
|
] }) });
|
|
6278
6288
|
}, DefaultChaiBlocks = ({
|
|
6279
6289
|
parentId: o,
|
|
@@ -6458,7 +6468,7 @@ const CoreBlock = ({
|
|
|
6458
6468
|
}
|
|
6459
6469
|
}
|
|
6460
6470
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6461
|
-
var
|
|
6471
|
+
var m, f, y, h, x, b, w, _;
|
|
6462
6472
|
if (r.type === "comment") return [];
|
|
6463
6473
|
console.log("node ===>", r);
|
|
6464
6474
|
let a = { _id: generateUUID() };
|
|
@@ -6499,11 +6509,11 @@ const CoreBlock = ({
|
|
|
6499
6509
|
];
|
|
6500
6510
|
a = {
|
|
6501
6511
|
...a,
|
|
6502
|
-
href: ((
|
|
6503
|
-
hrefType: ((
|
|
6504
|
-
autoplay: ((
|
|
6505
|
-
maxWidth: ((x = (
|
|
6506
|
-
backdropColor: ((
|
|
6512
|
+
href: ((m = l.find((k) => k.key === "href")) == null ? void 0 : m.value) || "",
|
|
6513
|
+
hrefType: ((f = l.find((k) => k.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
|
|
6514
|
+
autoplay: ((y = l.find((k) => k.key === "data-autoplay")) == null ? void 0 : y.value) === "true" ? "true" : "false",
|
|
6515
|
+
maxWidth: ((x = (h = l.find((k) => k.key === "data-maxwidth")) == null ? void 0 : h.value) == null ? void 0 : x.replace("px", "")) || "",
|
|
6516
|
+
backdropColor: ((b = l.find((k) => k.key === "data-overlay")) == null ? void 0 : b.value) || "",
|
|
6507
6517
|
galleryName: ((w = l.find((k) => k.key === "data-gall")) == null ? void 0 : w.value) || ""
|
|
6508
6518
|
}, forEach(v, (k) => {
|
|
6509
6519
|
has(a, `styles_attrs.${k}`) && delete a.styles_attrs[k];
|
|
@@ -6585,21 +6595,21 @@ const CoreBlock = ({
|
|
|
6585
6595
|
/* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: a.trim() === "", onClick: () => d(), size: "sm", className: "w-fit", children: r("Import HTML") }) })
|
|
6586
6596
|
] });
|
|
6587
6597
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
6588
|
-
var
|
|
6589
|
-
const { t: i } = useTranslation(), [d] = useBlocksStore(), [c, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom),
|
|
6598
|
+
var h;
|
|
6599
|
+
const { t: i } = useTranslation(), [d] = useBlocksStore(), [c, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (h = find(d, (x) => x._id === r)) == null ? void 0 : h._type;
|
|
6590
6600
|
useEffect(() => {
|
|
6591
6601
|
const x = setTimeout(() => {
|
|
6592
|
-
var
|
|
6593
|
-
(
|
|
6602
|
+
var b;
|
|
6603
|
+
(b = u.current) == null || b.focus();
|
|
6594
6604
|
}, 0);
|
|
6595
6605
|
return () => clearTimeout(x);
|
|
6596
6606
|
}, [g]);
|
|
6597
|
-
const
|
|
6607
|
+
const f = c ? values(n).filter(
|
|
6598
6608
|
(x) => {
|
|
6599
|
-
var
|
|
6600
|
-
return (((
|
|
6609
|
+
var b, w;
|
|
6610
|
+
return (((b = x.label) == null ? void 0 : b.toLowerCase()) + " " + ((w = x.type) == null ? void 0 : w.toLowerCase())).includes(c.toLowerCase());
|
|
6601
6611
|
}
|
|
6602
|
-
) : n,
|
|
6612
|
+
) : n, y = c ? o.filter((x) => reject(filter(values(f), { group: x }), { hidden: !0 }).length > 0) : o.filter((x) => reject(filter(values(n), { group: x }), { hidden: !0 }).length > 0);
|
|
6603
6613
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-2xl flex-col", children: [
|
|
6604
6614
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
6605
6615
|
Input$1,
|
|
@@ -6611,24 +6621,24 @@ const CoreBlock = ({
|
|
|
6611
6621
|
onChange: (x) => p(x.target.value)
|
|
6612
6622
|
}
|
|
6613
6623
|
) }),
|
|
6614
|
-
/* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children:
|
|
6624
|
+
/* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: y.length === 0 && c ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
6615
6625
|
i("No blocks found matching"),
|
|
6616
6626
|
' "',
|
|
6617
6627
|
c,
|
|
6618
6628
|
'"'
|
|
6619
6629
|
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: sortBy(
|
|
6620
|
-
|
|
6630
|
+
y,
|
|
6621
6631
|
(x) => CORE_GROUPS.indexOf(x) === -1 ? 99 : CORE_GROUPS.indexOf(x)
|
|
6622
6632
|
).map((x) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
6623
6633
|
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(x.toLowerCase())) }),
|
|
6624
6634
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
|
|
6625
|
-
reject(filter(values(
|
|
6635
|
+
reject(filter(values(f), { group: x }), { hidden: !0 }).map((b) => /* @__PURE__ */ jsx(
|
|
6626
6636
|
CoreBlock,
|
|
6627
6637
|
{
|
|
6628
6638
|
parentId: r,
|
|
6629
6639
|
position: a,
|
|
6630
|
-
block:
|
|
6631
|
-
disabled: !canAcceptChildBlock(
|
|
6640
|
+
block: b,
|
|
6641
|
+
disabled: !canAcceptChildBlock(m, b.type) || !canBeNestedInside(m, b.type)
|
|
6632
6642
|
}
|
|
6633
6643
|
))
|
|
6634
6644
|
) })
|
|
@@ -6651,8 +6661,8 @@ const CoreBlock = ({
|
|
|
6651
6661
|
/* @__PURE__ */ jsxs(
|
|
6652
6662
|
Tabs,
|
|
6653
6663
|
{
|
|
6654
|
-
onValueChange: (
|
|
6655
|
-
c(""), d(
|
|
6664
|
+
onValueChange: (m) => {
|
|
6665
|
+
c(""), d(m);
|
|
6656
6666
|
},
|
|
6657
6667
|
value: i,
|
|
6658
6668
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -6661,12 +6671,12 @@ const CoreBlock = ({
|
|
|
6661
6671
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
6662
6672
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
6663
6673
|
p ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
6664
|
-
map(u, (
|
|
6674
|
+
map(u, (m) => /* @__PURE__ */ jsx(TabsTrigger, { value: m.key, children: React__default.createElement(m.tab) }))
|
|
6665
6675
|
] }),
|
|
6666
6676
|
/* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ScrollArea, { className: "-mx-1.5 h-full max-h-full overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
6667
6677
|
/* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
6668
6678
|
p ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
6669
|
-
map(u, (
|
|
6679
|
+
map(u, (m) => /* @__PURE__ */ jsx(TabsContent, { value: m.key, children: React__default.createElement(m.tabContent, { close: g, parentId: r, position: a }) }))
|
|
6670
6680
|
]
|
|
6671
6681
|
}
|
|
6672
6682
|
)
|
|
@@ -6723,7 +6733,7 @@ const BlockCard = ({
|
|
|
6723
6733
|
parentId: r = void 0,
|
|
6724
6734
|
position: a = -1
|
|
6725
6735
|
}) => {
|
|
6726
|
-
const [l, i] = useState(!1), d = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(),
|
|
6736
|
+
const [l, i] = useState(!1), d = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), f = useFeature("dnd"), [, y] = useAtom$1(draggedBlockAtom), h = (w) => {
|
|
6727
6737
|
const _ = has(w, "styles_attrs.data-page-section");
|
|
6728
6738
|
return w._type === "Box" && _;
|
|
6729
6739
|
}, x = useCallback(
|
|
@@ -6744,11 +6754,11 @@ const BlockCard = ({
|
|
|
6744
6754
|
{
|
|
6745
6755
|
onClick: l ? () => {
|
|
6746
6756
|
} : x,
|
|
6747
|
-
draggable:
|
|
6757
|
+
draggable: f ? "true" : "false",
|
|
6748
6758
|
onDragStart: async (w) => {
|
|
6749
6759
|
const _ = await d(n, o);
|
|
6750
6760
|
let v = r;
|
|
6751
|
-
if (
|
|
6761
|
+
if (h(first(_)) && (v = null), !isEmpty(_)) {
|
|
6752
6762
|
const k = { blocks: _, uiLibrary: !0, parent: v };
|
|
6753
6763
|
if (w.dataTransfer.setData("text/plain", JSON.stringify(k)), o.preview) {
|
|
6754
6764
|
const S = new Image();
|
|
@@ -6757,7 +6767,7 @@ const BlockCard = ({
|
|
|
6757
6767
|
};
|
|
6758
6768
|
} else
|
|
6759
6769
|
w.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
6760
|
-
|
|
6770
|
+
y(k), setTimeout(() => {
|
|
6761
6771
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6762
6772
|
}, 200);
|
|
6763
6773
|
}
|
|
@@ -6770,11 +6780,11 @@ const BlockCard = ({
|
|
|
6770
6780
|
/* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
|
|
6771
6781
|
/* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
6772
6782
|
] }),
|
|
6773
|
-
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
6783
|
+
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: m }) })
|
|
6774
6784
|
]
|
|
6775
6785
|
}
|
|
6776
6786
|
) }),
|
|
6777
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6787
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
|
|
6778
6788
|
] });
|
|
6779
6789
|
}, libraryBlocksAtom = atom$1(
|
|
6780
6790
|
{}
|
|
@@ -6789,9 +6799,9 @@ const BlockCard = ({
|
|
|
6789
6799
|
})();
|
|
6790
6800
|
}, [o, l, i, d, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
6791
6801
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
6792
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), d = values(i).filter((v) => v.category === "custom"), c = l.find((v) => v.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(c), g = groupBy([...p, ...d], "group"), [
|
|
6793
|
-
|
|
6794
|
-
|
|
6802
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), d = values(i).filter((v) => v.category === "custom"), c = l.find((v) => v.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(c), g = groupBy([...p, ...d], "group"), [m, f] = useState("Hero"), y = get(g, m, []), h = useRef(null), { t: x } = useTranslation(), b = (v) => {
|
|
6803
|
+
h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
|
|
6804
|
+
h.current && f(v);
|
|
6795
6805
|
}, 300);
|
|
6796
6806
|
};
|
|
6797
6807
|
if (u)
|
|
@@ -6799,7 +6809,7 @@ const BlockCard = ({
|
|
|
6799
6809
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
6800
6810
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
6801
6811
|
] });
|
|
6802
|
-
const w = filter(
|
|
6812
|
+
const w = filter(y, (v, k) => k % 2 === 0), _ = filter(y, (v, k) => k % 2 === 1);
|
|
6803
6813
|
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: [
|
|
6804
6814
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
6805
6815
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: c == null ? void 0 : c.uuid, setLibrary: a, uiLibraries: l }),
|
|
@@ -6810,12 +6820,12 @@ const BlockCard = ({
|
|
|
6810
6820
|
map(g, (v, k) => /* @__PURE__ */ jsxs(
|
|
6811
6821
|
"div",
|
|
6812
6822
|
{
|
|
6813
|
-
onMouseEnter: () =>
|
|
6814
|
-
onMouseLeave: () => clearTimeout(
|
|
6815
|
-
onClick: () =>
|
|
6823
|
+
onMouseEnter: () => b(k),
|
|
6824
|
+
onMouseLeave: () => clearTimeout(h.current),
|
|
6825
|
+
onClick: () => f(k),
|
|
6816
6826
|
className: cn(
|
|
6817
6827
|
"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",
|
|
6818
|
-
k ===
|
|
6828
|
+
k === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
6819
6829
|
),
|
|
6820
6830
|
children: [
|
|
6821
6831
|
/* @__PURE__ */ jsx("span", { children: capitalize(x(k.toLowerCase())) }),
|
|
@@ -6830,7 +6840,7 @@ const BlockCard = ({
|
|
|
6830
6840
|
/* @__PURE__ */ jsxs(
|
|
6831
6841
|
ScrollArea,
|
|
6832
6842
|
{
|
|
6833
|
-
onMouseEnter: () =>
|
|
6843
|
+
onMouseEnter: () => h.current ? clearTimeout(h.current) : null,
|
|
6834
6844
|
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",
|
|
6835
6845
|
children: [
|
|
6836
6846
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
@@ -7061,8 +7071,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7061
7071
|
var L;
|
|
7062
7072
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , d] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom);
|
|
7063
7073
|
let p = null;
|
|
7064
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight:
|
|
7065
|
-
A.stopPropagation(), !i.includes(
|
|
7074
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data: y, isSelected: h, willReceiveDrop: x, isDragging: b, isEditing: w, handleClick: _ } = o, v = (A) => {
|
|
7075
|
+
A.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7066
7076
|
}, k = (A) => {
|
|
7067
7077
|
A.isInternal && (p = A.isOpen, A.isOpen && A.close());
|
|
7068
7078
|
}, S = (A) => {
|
|
@@ -7073,33 +7083,33 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7073
7083
|
}, C = () => {
|
|
7074
7084
|
R(null);
|
|
7075
7085
|
}, I = (A) => {
|
|
7076
|
-
C(), A.stopPropagation(), !o.isOpen && !i.includes(
|
|
7086
|
+
C(), A.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), _(A);
|
|
7077
7087
|
};
|
|
7078
7088
|
useEffect(() => {
|
|
7079
7089
|
const A = setTimeout(() => {
|
|
7080
|
-
x && !o.isOpen && !
|
|
7090
|
+
x && !o.isOpen && !b && !i.includes(f) && o.toggle();
|
|
7081
7091
|
}, 500);
|
|
7082
7092
|
return () => clearTimeout(A);
|
|
7083
|
-
}, [x, o,
|
|
7093
|
+
}, [x, o, b]);
|
|
7084
7094
|
const E = useMemo(() => {
|
|
7085
|
-
const A = Object.keys(
|
|
7095
|
+
const A = Object.keys(y), T = [];
|
|
7086
7096
|
for (let D = 0; D < A.length; D++)
|
|
7087
7097
|
if (A[D].endsWith("_attrs")) {
|
|
7088
|
-
const $ =
|
|
7089
|
-
|
|
7098
|
+
const $ = y[A[D]], H = Object.keys($).join("|");
|
|
7099
|
+
H.match(/x-data/) && T.push("data"), H.match(/x-on/) && T.push("event"), H.match(/x-show|x-if/) && T.push("show");
|
|
7090
7100
|
}
|
|
7091
7101
|
return T;
|
|
7092
|
-
}, [
|
|
7102
|
+
}, [y]), j = (A, T) => {
|
|
7093
7103
|
const D = c.contentDocument || c.contentWindow.document, $ = D.querySelector(`[data-block-id=${A}]`);
|
|
7094
7104
|
$ && $.setAttribute("data-drop", T);
|
|
7095
|
-
const
|
|
7096
|
-
|
|
7105
|
+
const H = $.getBoundingClientRect(), M = c.getBoundingClientRect();
|
|
7106
|
+
H.top >= M.top && H.left >= M.left && H.bottom <= M.bottom && H.right <= M.right || (D.documentElement.scrollTop = $.offsetTop - M.top);
|
|
7097
7107
|
}, N = (A) => {
|
|
7098
7108
|
C();
|
|
7099
7109
|
const T = get(o, "parent.id");
|
|
7100
7110
|
T !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: T, position: A }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: A });
|
|
7101
7111
|
};
|
|
7102
|
-
return
|
|
7112
|
+
return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7103
7113
|
/* @__PURE__ */ jsx("br", {}),
|
|
7104
7114
|
/* @__PURE__ */ jsx(
|
|
7105
7115
|
"div",
|
|
@@ -7114,25 +7124,25 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7114
7124
|
}
|
|
7115
7125
|
),
|
|
7116
7126
|
/* @__PURE__ */ jsx("br", {})
|
|
7117
|
-
] }) : /* @__PURE__ */ jsx(BlockContextMenu, { id:
|
|
7127
|
+
] }) : /* @__PURE__ */ jsx(BlockContextMenu, { id: f, children: /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7118
7128
|
"div",
|
|
7119
7129
|
{
|
|
7120
|
-
onMouseEnter: () => g(
|
|
7121
|
-
onMouseLeave: () =>
|
|
7130
|
+
onMouseEnter: () => g(f),
|
|
7131
|
+
onMouseLeave: () => m(),
|
|
7122
7132
|
onClick: I,
|
|
7123
7133
|
style: n,
|
|
7124
|
-
"data-node-id":
|
|
7125
|
-
ref: i.includes(
|
|
7134
|
+
"data-node-id": f,
|
|
7135
|
+
ref: i.includes(f) ? null : r,
|
|
7126
7136
|
onDragStart: () => k(o),
|
|
7127
7137
|
onDragEnd: () => S(o),
|
|
7128
7138
|
onDragOver: (A) => {
|
|
7129
|
-
A.preventDefault(), j(
|
|
7139
|
+
A.preventDefault(), j(f, "yes");
|
|
7130
7140
|
},
|
|
7131
7141
|
onDragLeave: (A) => {
|
|
7132
|
-
A.preventDefault(), j(
|
|
7142
|
+
A.preventDefault(), j(f, "no");
|
|
7133
7143
|
},
|
|
7134
7144
|
onDrop: (A) => {
|
|
7135
|
-
A.preventDefault(), j(
|
|
7145
|
+
A.preventDefault(), j(f, "no");
|
|
7136
7146
|
},
|
|
7137
7147
|
children: [
|
|
7138
7148
|
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
@@ -7152,11 +7162,11 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7152
7162
|
{
|
|
7153
7163
|
className: cn(
|
|
7154
7164
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7155
|
-
|
|
7156
|
-
x && canAcceptChildBlock(
|
|
7165
|
+
h ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7166
|
+
x && canAcceptChildBlock(y._type, "Icon") ? "bg-green-200" : "",
|
|
7157
7167
|
(o == null ? void 0 : o.id) === B ? "bg-purple-100" : "",
|
|
7158
|
-
|
|
7159
|
-
i.includes(
|
|
7168
|
+
b && "opacity-20",
|
|
7169
|
+
i.includes(f) ? "opacity-50" : ""
|
|
7160
7170
|
),
|
|
7161
7171
|
children: [
|
|
7162
7172
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7167,13 +7177,13 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7167
7177
|
children: u && /* @__PURE__ */ jsx("button", { onClick: v, type: "button", children: /* @__PURE__ */ jsx(
|
|
7168
7178
|
ChevronRight,
|
|
7169
7179
|
{
|
|
7170
|
-
className: `h-3 w-3 stroke-[3] ${
|
|
7180
|
+
className: `h-3 w-3 stroke-[3] ${h ? "text-slate-200" : "text-slate-400"}`
|
|
7171
7181
|
}
|
|
7172
7182
|
) })
|
|
7173
7183
|
}
|
|
7174
7184
|
),
|
|
7175
7185
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7176
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7186
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: y == null ? void 0 : y._type }),
|
|
7177
7187
|
w ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7178
7188
|
"div",
|
|
7179
7189
|
{
|
|
@@ -7182,7 +7192,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7182
7192
|
A.stopPropagation(), o.edit(), o.deselect();
|
|
7183
7193
|
},
|
|
7184
7194
|
children: [
|
|
7185
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7195
|
+
/* @__PURE__ */ jsx("span", { children: (y == null ? void 0 : y._name) || (y == null ? void 0 : y._type.split("/").pop()) }),
|
|
7186
7196
|
E.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7187
7197
|
E.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
|
|
7188
7198
|
E.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
|
|
@@ -7192,22 +7202,22 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7192
7202
|
] })
|
|
7193
7203
|
] }),
|
|
7194
7204
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7195
|
-
!i.includes(
|
|
7205
|
+
!i.includes(f) && a.map((A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7196
7206
|
/* @__PURE__ */ jsx(
|
|
7197
7207
|
TooltipTrigger,
|
|
7198
7208
|
{
|
|
7199
7209
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
7200
7210
|
asChild: !0,
|
|
7201
|
-
children: React__default.createElement(A.item, { blockId:
|
|
7211
|
+
children: React__default.createElement(A.item, { blockId: f })
|
|
7202
7212
|
}
|
|
7203
7213
|
),
|
|
7204
7214
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: A.tooltip })
|
|
7205
7215
|
] })),
|
|
7206
|
-
canAddChildBlock(
|
|
7216
|
+
canAddChildBlock(y == null ? void 0 : y._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7207
7217
|
/* @__PURE__ */ jsx(
|
|
7208
7218
|
TooltipTrigger,
|
|
7209
7219
|
{
|
|
7210
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
7220
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: f }),
|
|
7211
7221
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7212
7222
|
asChild: !0,
|
|
7213
7223
|
children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
|
|
@@ -7220,7 +7230,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7220
7230
|
TooltipTrigger,
|
|
7221
7231
|
{
|
|
7222
7232
|
onClick: (A) => {
|
|
7223
|
-
A.stopPropagation(), d(
|
|
7233
|
+
A.stopPropagation(), d(f), o.isOpen && o.toggle();
|
|
7224
7234
|
},
|
|
7225
7235
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7226
7236
|
asChild: !0,
|
|
@@ -7880,14 +7890,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
7880
7890
|
) }) });
|
|
7881
7891
|
}
|
|
7882
7892
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
7883
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, d] = useState(""), [c, p] = useState(!0), [u, g] = useState(),
|
|
7893
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, d] = useState(""), [c, p] = useState(!0), [u, g] = useState(), m = useRef(null), f = useRef(null);
|
|
7884
7894
|
useEffect(() => {
|
|
7885
|
-
var
|
|
7886
|
-
(
|
|
7895
|
+
var h;
|
|
7896
|
+
(h = m.current) == null || h.focus();
|
|
7887
7897
|
}, []);
|
|
7888
|
-
const
|
|
7889
|
-
const { usage: x } =
|
|
7890
|
-
!l && x && g(x),
|
|
7898
|
+
const y = (h) => {
|
|
7899
|
+
const { usage: x } = h || {};
|
|
7900
|
+
!l && x && g(x), f.current = setTimeout(() => g(void 0), 1e4), l || d("");
|
|
7891
7901
|
};
|
|
7892
7902
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
7893
7903
|
/* @__PURE__ */ jsxs(
|
|
@@ -7905,14 +7915,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7905
7915
|
/* @__PURE__ */ jsx(
|
|
7906
7916
|
Textarea,
|
|
7907
7917
|
{
|
|
7908
|
-
ref:
|
|
7918
|
+
ref: m,
|
|
7909
7919
|
value: i,
|
|
7910
|
-
onChange: (
|
|
7920
|
+
onChange: (h) => d(h.target.value),
|
|
7911
7921
|
placeholder: n("Ask AI to edit content"),
|
|
7912
7922
|
className: "w-full",
|
|
7913
7923
|
rows: 3,
|
|
7914
|
-
onKeyDown: (
|
|
7915
|
-
|
|
7924
|
+
onKeyDown: (h) => {
|
|
7925
|
+
h.key === "Enter" && (h.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, y));
|
|
7916
7926
|
}
|
|
7917
7927
|
}
|
|
7918
7928
|
),
|
|
@@ -7922,7 +7932,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7922
7932
|
{
|
|
7923
7933
|
disabled: i.trim().length < 5 || a,
|
|
7924
7934
|
onClick: () => {
|
|
7925
|
-
|
|
7935
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, i, y);
|
|
7926
7936
|
},
|
|
7927
7937
|
variant: "default",
|
|
7928
7938
|
className: "w-fit",
|
|
@@ -7954,8 +7964,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7954
7964
|
/* @__PURE__ */ jsx(
|
|
7955
7965
|
QuickPrompts,
|
|
7956
7966
|
{
|
|
7957
|
-
onClick: (
|
|
7958
|
-
|
|
7967
|
+
onClick: (h) => {
|
|
7968
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, h, y);
|
|
7959
7969
|
}
|
|
7960
7970
|
}
|
|
7961
7971
|
)
|
|
@@ -7965,19 +7975,19 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7965
7975
|
] }) }) : null
|
|
7966
7976
|
] });
|
|
7967
7977
|
}, AISetContext = () => {
|
|
7968
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [d, c] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), { toast:
|
|
7978
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [d, c] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), { toast: m } = useToast(), f = useRef(null);
|
|
7969
7979
|
useEffect(() => {
|
|
7970
7980
|
n && a(n);
|
|
7971
7981
|
}, [n]);
|
|
7972
|
-
const
|
|
7982
|
+
const y = async () => {
|
|
7973
7983
|
try {
|
|
7974
|
-
c(!0), u(null), await i(r),
|
|
7984
|
+
c(!0), u(null), await i(r), m({
|
|
7975
7985
|
title: o("Updated AI Context"),
|
|
7976
7986
|
description: o("You can now Ask AI to edit your content"),
|
|
7977
7987
|
variant: "default"
|
|
7978
|
-
}),
|
|
7979
|
-
} catch (
|
|
7980
|
-
u(
|
|
7988
|
+
}), f.current.click();
|
|
7989
|
+
} catch (h) {
|
|
7990
|
+
u(h);
|
|
7981
7991
|
} finally {
|
|
7982
7992
|
c(!1);
|
|
7983
7993
|
}
|
|
@@ -7985,25 +7995,25 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7985
7995
|
return /* @__PURE__ */ jsx(
|
|
7986
7996
|
Accordion,
|
|
7987
7997
|
{
|
|
7988
|
-
onValueChange: (
|
|
7989
|
-
g(
|
|
7998
|
+
onValueChange: (h) => {
|
|
7999
|
+
g(h !== "");
|
|
7990
8000
|
},
|
|
7991
8001
|
type: "single",
|
|
7992
8002
|
collapsible: !0,
|
|
7993
8003
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
7994
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8004
|
+
/* @__PURE__ */ jsx(AccordionTrigger, { ref: f, 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") }) }) }),
|
|
7995
8005
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
7996
8006
|
/* @__PURE__ */ jsx(
|
|
7997
8007
|
Textarea,
|
|
7998
8008
|
{
|
|
7999
8009
|
ref: l,
|
|
8000
8010
|
value: r,
|
|
8001
|
-
onChange: (
|
|
8011
|
+
onChange: (h) => a(h.target.value),
|
|
8002
8012
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8003
8013
|
className: "mt-1 w-full",
|
|
8004
8014
|
rows: 10,
|
|
8005
|
-
onKeyDown: (
|
|
8006
|
-
|
|
8015
|
+
onKeyDown: (h) => {
|
|
8016
|
+
h.key === "Enter" && (h.preventDefault(), y());
|
|
8007
8017
|
}
|
|
8008
8018
|
}
|
|
8009
8019
|
),
|
|
@@ -8015,7 +8025,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8015
8025
|
Button,
|
|
8016
8026
|
{
|
|
8017
8027
|
disabled: r.trim().length < 5,
|
|
8018
|
-
onClick: () =>
|
|
8028
|
+
onClick: () => y(),
|
|
8019
8029
|
variant: "default",
|
|
8020
8030
|
className: "w-fit",
|
|
8021
8031
|
size: "sm",
|
|
@@ -8044,7 +8054,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8044
8054
|
AlertDialogAction,
|
|
8045
8055
|
{
|
|
8046
8056
|
onClick: () => {
|
|
8047
|
-
a(""),
|
|
8057
|
+
a(""), y();
|
|
8048
8058
|
},
|
|
8049
8059
|
children: o("Yes, Delete")
|
|
8050
8060
|
}
|
|
@@ -8306,32 +8316,32 @@ const AiAssistant = () => {
|
|
|
8306
8316
|
] })
|
|
8307
8317
|
] });
|
|
8308
8318
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
|
|
8309
|
-
const [a, l] = useState([]), [i, d] = useState(""), [c, p] = useState(""), [u, g] = useState(null), [
|
|
8319
|
+
const [a, l] = useState([]), [i, d] = useState(""), [c, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), y = useRef(null), h = useRef(null);
|
|
8310
8320
|
useEffect(() => {
|
|
8311
8321
|
l(n);
|
|
8312
8322
|
}, [n]);
|
|
8313
8323
|
const x = () => {
|
|
8314
8324
|
if (i.startsWith("@")) {
|
|
8315
|
-
|
|
8325
|
+
f("Attribute keys cannot start with '@'");
|
|
8316
8326
|
return;
|
|
8317
8327
|
}
|
|
8318
8328
|
if (i) {
|
|
8319
8329
|
const k = [...a, { key: i, value: c }];
|
|
8320
|
-
r(k), l(a), d(""), p(""),
|
|
8330
|
+
r(k), l(a), d(""), p(""), f("");
|
|
8321
8331
|
}
|
|
8322
|
-
},
|
|
8332
|
+
}, b = (k) => {
|
|
8323
8333
|
const S = a.filter((B, R) => R !== k);
|
|
8324
8334
|
r(S), l(S);
|
|
8325
8335
|
}, w = (k) => {
|
|
8326
8336
|
g(k), d(a[k].key), p(a[k].value);
|
|
8327
8337
|
}, _ = () => {
|
|
8328
8338
|
if (i.startsWith("@")) {
|
|
8329
|
-
|
|
8339
|
+
f("Attribute keys cannot start with '@'");
|
|
8330
8340
|
return;
|
|
8331
8341
|
}
|
|
8332
8342
|
if (u !== null && i) {
|
|
8333
8343
|
const k = [...a];
|
|
8334
|
-
k[u] = { key: i, value: c }, r(k), l(k), g(null), d(""), p(""),
|
|
8344
|
+
k[u] = { key: i, value: c }, r(k), l(k), g(null), d(""), p(""), f("");
|
|
8335
8345
|
}
|
|
8336
8346
|
};
|
|
8337
8347
|
return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
|
|
@@ -8353,7 +8363,7 @@ const AiAssistant = () => {
|
|
|
8353
8363
|
autoCorrect: "off",
|
|
8354
8364
|
spellCheck: "false",
|
|
8355
8365
|
id: "attrKey",
|
|
8356
|
-
ref:
|
|
8366
|
+
ref: y,
|
|
8357
8367
|
value: i,
|
|
8358
8368
|
onChange: (k) => d(k.target.value),
|
|
8359
8369
|
placeholder: "Enter Key",
|
|
@@ -8371,7 +8381,7 @@ const AiAssistant = () => {
|
|
|
8371
8381
|
spellCheck: "false",
|
|
8372
8382
|
id: "attrValue",
|
|
8373
8383
|
rows: 2,
|
|
8374
|
-
ref:
|
|
8384
|
+
ref: h,
|
|
8375
8385
|
value: c,
|
|
8376
8386
|
onChange: (k) => p(k.target.value),
|
|
8377
8387
|
onKeyDown: (k) => {
|
|
@@ -8384,7 +8394,7 @@ const AiAssistant = () => {
|
|
|
8384
8394
|
] })
|
|
8385
8395
|
] }),
|
|
8386
8396
|
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
|
|
8387
|
-
|
|
8397
|
+
m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
|
|
8388
8398
|
]
|
|
8389
8399
|
}
|
|
8390
8400
|
),
|
|
@@ -8395,7 +8405,7 @@ const AiAssistant = () => {
|
|
|
8395
8405
|
] }),
|
|
8396
8406
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
8397
8407
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => w(S), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
8398
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
8408
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => b(S), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
8399
8409
|
] })
|
|
8400
8410
|
] }, S)) })
|
|
8401
8411
|
] });
|
|
@@ -8591,12 +8601,12 @@ const RootLayout = () => {
|
|
|
8591
8601
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
8592
8602
|
n(1);
|
|
8593
8603
|
});
|
|
8594
|
-
const d = useBuilderProp("sideBarComponents.top", []), c = useBuilderProp("sideBarComponents.bottom", []), p = (
|
|
8595
|
-
|
|
8596
|
-
}, u = (
|
|
8597
|
-
n(o ===
|
|
8598
|
-
}, g = useSidebarMenuItems(), { t:
|
|
8599
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
8604
|
+
const d = useBuilderProp("sideBarComponents.top", []), c = useBuilderProp("sideBarComponents.bottom", []), p = (h) => {
|
|
8605
|
+
h.preventDefault();
|
|
8606
|
+
}, u = (h) => {
|
|
8607
|
+
n(o === h ? null : h);
|
|
8608
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...d], y = useBuilderProp("htmlDir", "ltr");
|
|
8609
|
+
return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
8600
8610
|
/* @__PURE__ */ jsxs(
|
|
8601
8611
|
"div",
|
|
8602
8612
|
{
|
|
@@ -8606,21 +8616,21 @@ const RootLayout = () => {
|
|
|
8606
8616
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
8607
8617
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8608
8618
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
8609
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children:
|
|
8619
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((h, x) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8610
8620
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
8611
8621
|
Button,
|
|
8612
8622
|
{
|
|
8613
8623
|
variant: o === x ? "default" : "ghost",
|
|
8614
8624
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
8615
8625
|
onClick: () => u(x),
|
|
8616
|
-
children: get(
|
|
8626
|
+
children: get(h, "icon", null)
|
|
8617
8627
|
},
|
|
8618
8628
|
x
|
|
8619
8629
|
) }),
|
|
8620
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h
|
|
8630
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(h.label) }) })
|
|
8621
8631
|
] }, "button" + x)) }),
|
|
8622
8632
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
8623
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: c == null ? void 0 : c.map((
|
|
8633
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: c == null ? void 0 : c.map((h, x) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(h, {}) }, `sidebar-component-${x}`)) })
|
|
8624
8634
|
] }),
|
|
8625
8635
|
/* @__PURE__ */ jsx(
|
|
8626
8636
|
motion.div,
|
|
@@ -8633,14 +8643,14 @@ const RootLayout = () => {
|
|
|
8633
8643
|
/* @__PURE__ */ jsxs(
|
|
8634
8644
|
"div",
|
|
8635
8645
|
{
|
|
8636
|
-
className: `absolute top-2 z-50 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(
|
|
8646
|
+
className: `absolute top-2 z-50 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(f, `${o}.isInternal`, !1) ? "" : "w-64"}`,
|
|
8637
8647
|
children: [
|
|
8638
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
8639
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
8648
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(f, `${o}.icon`, null) }),
|
|
8649
|
+
/* @__PURE__ */ jsx("span", { children: m(f[o].label) })
|
|
8640
8650
|
]
|
|
8641
8651
|
}
|
|
8642
8652
|
),
|
|
8643
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(
|
|
8653
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(f, `${o}.component`, null), {}) }) })
|
|
8644
8654
|
] })
|
|
8645
8655
|
}
|
|
8646
8656
|
),
|
|
@@ -8659,11 +8669,11 @@ const RootLayout = () => {
|
|
|
8659
8669
|
/* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8660
8670
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
8661
8671
|
" ",
|
|
8662
|
-
|
|
8672
|
+
m("AI Assistant")
|
|
8663
8673
|
] }) }) : l === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
8664
8674
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8665
8675
|
/* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
|
|
8666
|
-
|
|
8676
|
+
m("Theme Settings")
|
|
8667
8677
|
] }),
|
|
8668
8678
|
/* @__PURE__ */ jsx(
|
|
8669
8679
|
Button,
|