@chaibuilder/sdk 2.0.0-beta.37 → 2.0.0-beta.39
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/README.md +0 -4
- package/dist/core.cjs +4 -4
- package/dist/core.js +598 -654
- package/dist/web-blocks.cjs +2 -2
- package/dist/web-blocks.js +218 -186
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ var O = (o, r, n) => U(o, typeof r != "symbol" ? r + "" : r, n);
|
|
|
4
4
|
import { j as jsxRuntimeExports } from "./jsx-runtime-DGlMoOmv.js";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, useState, Component, Children, Suspense, useRef, memo, createElement, lazy } from "react";
|
|
7
|
-
import { ag as useToast, S as Skeleton, B as Button, L as Label, aj as ContextMenu, ak as ContextMenuTrigger, al as ContextMenuContent, am as ContextMenuItem, O as Tooltip, P as TooltipTrigger, Q as TooltipContent, C as Card, x as CardHeader, E as CardDescription, F as CardContent, T as Textarea, y as CardFooter, D as Dialog, s as DialogTrigger, a as DialogContent, h as Badge,
|
|
7
|
+
import { ag as useToast, S as Skeleton, B as Button, L as Label, aj as ContextMenu, ak as ContextMenuTrigger, al as ContextMenuContent, am as ContextMenuItem, O as Tooltip, P as TooltipTrigger, Q as TooltipContent, C as Card, x as CardHeader, E as CardDescription, F as CardContent, T as Textarea, y as CardFooter, D as Dialog, s as DialogTrigger, a as DialogContent, h as Badge, 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, J as Tabs, K as TabsList, M as TabsTrigger, N as TabsContent, j as AlertDialog, l as AlertDialogContent, m as AlertDialogHeader, o as AlertDialogTitle, k as AlertDialogTrigger, p as AlertDialogDescription, n as AlertDialogFooter, r as AlertDialogCancel, q as AlertDialogAction, b as Switch, a3 as DropdownMenuCheckboxItem, Y as HoverCard, Z as HoverCardTrigger, _ as HoverCardContent, ae as Separator, R as TooltipProvider, ai as Toaster } from "./context-menu-CxioWiWD.js";
|
|
8
8
|
import { has, find, filter, flatten, map, omit, isString, includes, without, get, compact, isObject, each, set, first, isEmpty, noop, keys, range, values, flattenDeep, startsWith, isNull, pick, sortBy, memoize, forEach, unset, chunk, cloneDeep, throttle, reverse, startCase, debounce, capitalize, flatMapDeep, some, split, reject, nth, toLower, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, isFunction as isFunction$1, uniq, toUpper, round } from "lodash-es";
|
|
9
9
|
import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, useSetAtom as useSetAtom$1, getDefaultStore as getDefaultStore$1 } from "jotai";
|
|
10
10
|
import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
|
|
@@ -86,32 +86,32 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
86
86
|
throw o.e;
|
|
87
87
|
return o.v;
|
|
88
88
|
}, createStore = () => {
|
|
89
|
-
const o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map(), a = (
|
|
90
|
-
const w = o.get(
|
|
91
|
-
if (o.set(
|
|
92
|
-
const
|
|
93
|
-
cancelPromise(w.v,
|
|
89
|
+
const o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map(), a = (h) => o.get(h), l = (h, j) => {
|
|
90
|
+
const w = o.get(h);
|
|
91
|
+
if (o.set(h, j), n.has(h) || n.set(h, w), w && hasPromiseAtomValue(w)) {
|
|
92
|
+
const f = "v" in j ? j.v instanceof Promise ? j.v : Promise.resolve(j.v) : Promise.reject(j.e);
|
|
93
|
+
cancelPromise(w.v, f);
|
|
94
94
|
}
|
|
95
|
-
}, i = (
|
|
96
|
-
const
|
|
95
|
+
}, i = (h, j, w) => {
|
|
96
|
+
const f = /* @__PURE__ */ new Map();
|
|
97
97
|
let C = !1;
|
|
98
98
|
w.forEach((B, N) => {
|
|
99
|
-
!B && N ===
|
|
100
|
-
}), (C || j.d.size !==
|
|
101
|
-
}, c = (
|
|
102
|
-
const
|
|
103
|
-
d: (
|
|
99
|
+
!B && N === h && (B = j), B && (f.set(N, B), j.d.get(N) !== B && (C = !0));
|
|
100
|
+
}), (C || j.d.size !== f.size) && (j.d = f);
|
|
101
|
+
}, c = (h, j, w) => {
|
|
102
|
+
const f = a(h), C = {
|
|
103
|
+
d: (f == null ? void 0 : f.d) || /* @__PURE__ */ new Map(),
|
|
104
104
|
v: j
|
|
105
105
|
};
|
|
106
|
-
if (w && i(
|
|
107
|
-
return
|
|
108
|
-
if (
|
|
109
|
-
if (
|
|
110
|
-
return
|
|
111
|
-
C.v =
|
|
106
|
+
if (w && i(h, C, w), f && isEqualAtomValue(f, C) && f.d === C.d)
|
|
107
|
+
return f;
|
|
108
|
+
if (f && hasPromiseAtomValue(f) && hasPromiseAtomValue(C) && isEqualPromiseAtomValue(f, C)) {
|
|
109
|
+
if (f.d === C.d)
|
|
110
|
+
return f;
|
|
111
|
+
C.v = f.v;
|
|
112
112
|
}
|
|
113
|
-
return l(
|
|
114
|
-
}, d = (
|
|
113
|
+
return l(h, C), C;
|
|
114
|
+
}, d = (h, j, w, f) => {
|
|
115
115
|
if (isPromiseLike$2(j)) {
|
|
116
116
|
let C;
|
|
117
117
|
const B = new Promise((N, D) => {
|
|
@@ -120,23 +120,23 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
120
120
|
(T) => {
|
|
121
121
|
if (!I) {
|
|
122
122
|
I = !0;
|
|
123
|
-
const L = a(
|
|
124
|
-
|
|
123
|
+
const L = a(h), P = c(
|
|
124
|
+
h,
|
|
125
125
|
B,
|
|
126
126
|
w
|
|
127
127
|
);
|
|
128
|
-
resolvePromise(B, T), N(T), (L == null ? void 0 : L.d) !== P.d && S(
|
|
128
|
+
resolvePromise(B, T), N(T), (L == null ? void 0 : L.d) !== P.d && S(h, P, L == null ? void 0 : L.d);
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
131
|
(T) => {
|
|
132
132
|
if (!I) {
|
|
133
133
|
I = !0;
|
|
134
|
-
const L = a(
|
|
135
|
-
|
|
134
|
+
const L = a(h), P = c(
|
|
135
|
+
h,
|
|
136
136
|
B,
|
|
137
137
|
w
|
|
138
138
|
);
|
|
139
|
-
rejectPromise(B, T), D(T), (L == null ? void 0 : L.d) !== P.d && S(
|
|
139
|
+
rejectPromise(B, T), D(T), (L == null ? void 0 : L.d) !== P.d && S(h, P, L == null ? void 0 : L.d);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
), C = (T) => {
|
|
@@ -147,30 +147,30 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
147
147
|
};
|
|
148
148
|
});
|
|
149
149
|
return B.orig = j, B.status = "pending", registerCancelPromise(B, (N) => {
|
|
150
|
-
N && C(N),
|
|
151
|
-
}), c(
|
|
150
|
+
N && C(N), f == null || f();
|
|
151
|
+
}), c(h, B, w);
|
|
152
152
|
}
|
|
153
|
-
return c(
|
|
154
|
-
}, p = (
|
|
155
|
-
const
|
|
156
|
-
d: (
|
|
153
|
+
return c(h, j, w);
|
|
154
|
+
}, p = (h, j, w) => {
|
|
155
|
+
const f = a(h), C = {
|
|
156
|
+
d: (f == null ? void 0 : f.d) || /* @__PURE__ */ new Map(),
|
|
157
157
|
e: j
|
|
158
158
|
};
|
|
159
|
-
return w && i(
|
|
160
|
-
}, u = (
|
|
161
|
-
const j = a(
|
|
159
|
+
return w && i(h, C, w), f && isEqualAtomError(f, C) && f.d === C.d ? f : (l(h, C), C);
|
|
160
|
+
}, u = (h) => {
|
|
161
|
+
const j = a(h);
|
|
162
162
|
if (j && (j.d.forEach((I, T) => {
|
|
163
|
-
T !==
|
|
163
|
+
T !== h && !r.has(T) && u(T);
|
|
164
164
|
}), Array.from(j.d).every(([I, T]) => {
|
|
165
165
|
const L = a(I);
|
|
166
|
-
return I ===
|
|
166
|
+
return I === h || L === T || // TODO This is a hack, we should find a better solution.
|
|
167
167
|
L && !hasPromiseAtomValue(L) && isEqualAtomValue(L, T);
|
|
168
168
|
})))
|
|
169
169
|
return j;
|
|
170
170
|
const w = /* @__PURE__ */ new Map();
|
|
171
|
-
let
|
|
171
|
+
let f = !0;
|
|
172
172
|
const C = (I) => {
|
|
173
|
-
if (I ===
|
|
173
|
+
if (I === h) {
|
|
174
174
|
const L = a(I);
|
|
175
175
|
if (L)
|
|
176
176
|
return w.set(I, L), returnAtomValue(L);
|
|
@@ -187,42 +187,42 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
187
187
|
return B || (B = new AbortController()), B.signal;
|
|
188
188
|
},
|
|
189
189
|
get setSelf() {
|
|
190
|
-
return !N && isActuallyWritableAtom(
|
|
191
|
-
if (!
|
|
192
|
-
return k(
|
|
190
|
+
return !N && isActuallyWritableAtom(h) && (N = (...I) => {
|
|
191
|
+
if (!f)
|
|
192
|
+
return k(h, ...I);
|
|
193
193
|
}), N;
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
196
|
try {
|
|
197
|
-
const I =
|
|
197
|
+
const I = h.read(C, D);
|
|
198
198
|
return d(
|
|
199
|
-
|
|
199
|
+
h,
|
|
200
200
|
I,
|
|
201
201
|
w,
|
|
202
202
|
() => B == null ? void 0 : B.abort()
|
|
203
203
|
);
|
|
204
204
|
} catch (I) {
|
|
205
|
-
return p(
|
|
205
|
+
return p(h, I, w);
|
|
206
206
|
} finally {
|
|
207
|
-
|
|
207
|
+
f = !1;
|
|
208
208
|
}
|
|
209
|
-
}, x = (
|
|
210
|
-
let j = r.get(
|
|
211
|
-
return j || (j = _(
|
|
212
|
-
},
|
|
213
|
-
const j = r.get(
|
|
214
|
-
j &&
|
|
215
|
-
}, y = (
|
|
216
|
-
const j = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new WeakMap(),
|
|
209
|
+
}, x = (h) => returnAtomValue(u(h)), m = (h) => {
|
|
210
|
+
let j = r.get(h);
|
|
211
|
+
return j || (j = _(h)), j;
|
|
212
|
+
}, g = (h, j) => !j.l.size && (!j.t.size || j.t.size === 1 && j.t.has(h)), E = (h) => {
|
|
213
|
+
const j = r.get(h);
|
|
214
|
+
j && g(h, j) && A(h);
|
|
215
|
+
}, y = (h) => {
|
|
216
|
+
const j = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new WeakMap(), f = (B) => {
|
|
217
217
|
const N = r.get(B);
|
|
218
218
|
N == null || N.t.forEach((D) => {
|
|
219
219
|
D !== B && (j.set(
|
|
220
220
|
D,
|
|
221
221
|
(j.get(D) || /* @__PURE__ */ new Set()).add(B)
|
|
222
|
-
), w.set(D, (w.get(D) || 0) + 1),
|
|
222
|
+
), w.set(D, (w.get(D) || 0) + 1), f(D));
|
|
223
223
|
});
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
f(h);
|
|
226
226
|
const C = (B) => {
|
|
227
227
|
const N = r.get(B);
|
|
228
228
|
N == null || N.t.forEach((D) => {
|
|
@@ -241,72 +241,72 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
241
241
|
}
|
|
242
242
|
});
|
|
243
243
|
};
|
|
244
|
-
C(
|
|
245
|
-
},
|
|
244
|
+
C(h);
|
|
245
|
+
}, b = (h, ...j) => {
|
|
246
246
|
let w = !0;
|
|
247
|
-
const
|
|
247
|
+
const f = (N) => returnAtomValue(u(N)), C = (N, ...D) => {
|
|
248
248
|
let I;
|
|
249
|
-
if (N ===
|
|
249
|
+
if (N === h) {
|
|
250
250
|
if (!hasInitialValue(N))
|
|
251
251
|
throw new Error("atom not writable");
|
|
252
252
|
const T = a(N), L = d(N, D[0]);
|
|
253
253
|
(!T || !isEqualAtomValue(T, L)) && y(N);
|
|
254
254
|
} else
|
|
255
|
-
I =
|
|
255
|
+
I = b(N, ...D);
|
|
256
256
|
return w || v(), I;
|
|
257
|
-
}, B =
|
|
257
|
+
}, B = h.write(f, C, ...j);
|
|
258
258
|
return w = !1, B;
|
|
259
|
-
}, k = (
|
|
260
|
-
const w =
|
|
259
|
+
}, k = (h, ...j) => {
|
|
260
|
+
const w = b(h, ...j);
|
|
261
261
|
return v(), w;
|
|
262
|
-
}, _ = (
|
|
262
|
+
}, _ = (h, j) => {
|
|
263
263
|
const w = {
|
|
264
264
|
t: new Set(j && [j]),
|
|
265
265
|
l: /* @__PURE__ */ new Set()
|
|
266
266
|
};
|
|
267
|
-
if (r.set(
|
|
267
|
+
if (r.set(h, w), u(h).d.forEach((f, C) => {
|
|
268
268
|
const B = r.get(C);
|
|
269
|
-
B ? B.t.add(
|
|
270
|
-
}), u(
|
|
271
|
-
const
|
|
272
|
-
|
|
269
|
+
B ? B.t.add(h) : C !== h && _(C, h);
|
|
270
|
+
}), u(h), isActuallyWritableAtom(h) && h.onMount) {
|
|
271
|
+
const f = h.onMount((...C) => k(h, ...C));
|
|
272
|
+
f && (w.u = f);
|
|
273
273
|
}
|
|
274
274
|
return w;
|
|
275
|
-
}, A = (
|
|
275
|
+
}, A = (h) => {
|
|
276
276
|
var j;
|
|
277
|
-
const w = (j = r.get(
|
|
278
|
-
w && w(), r.delete(
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
if (B !==
|
|
277
|
+
const w = (j = r.get(h)) == null ? void 0 : j.u;
|
|
278
|
+
w && w(), r.delete(h);
|
|
279
|
+
const f = a(h);
|
|
280
|
+
f && (hasPromiseAtomValue(f) && cancelPromise(f.v), f.d.forEach((C, B) => {
|
|
281
|
+
if (B !== h) {
|
|
282
282
|
const N = r.get(B);
|
|
283
|
-
N && (N.t.delete(
|
|
283
|
+
N && (N.t.delete(h), g(B, N) && A(B));
|
|
284
284
|
}
|
|
285
285
|
}));
|
|
286
|
-
}, S = (
|
|
287
|
-
const
|
|
286
|
+
}, S = (h, j, w) => {
|
|
287
|
+
const f = new Set(j.d.keys());
|
|
288
288
|
w == null || w.forEach((C, B) => {
|
|
289
|
-
if (
|
|
290
|
-
|
|
289
|
+
if (f.has(B)) {
|
|
290
|
+
f.delete(B);
|
|
291
291
|
return;
|
|
292
292
|
}
|
|
293
293
|
const N = r.get(B);
|
|
294
|
-
N && (N.t.delete(
|
|
295
|
-
}),
|
|
294
|
+
N && (N.t.delete(h), g(B, N) && A(B));
|
|
295
|
+
}), f.forEach((C) => {
|
|
296
296
|
const B = r.get(C);
|
|
297
|
-
B ? B.t.add(
|
|
297
|
+
B ? B.t.add(h) : r.has(h) && _(C, h);
|
|
298
298
|
});
|
|
299
299
|
}, v = () => {
|
|
300
300
|
for (; n.size; ) {
|
|
301
|
-
const
|
|
302
|
-
n.clear(),
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
|
|
301
|
+
const h = Array.from(n);
|
|
302
|
+
n.clear(), h.forEach(([j, w]) => {
|
|
303
|
+
const f = a(j);
|
|
304
|
+
if (f) {
|
|
305
|
+
f.d !== (w == null ? void 0 : w.d) && S(j, f, w == null ? void 0 : w.d);
|
|
306
306
|
const C = r.get(j);
|
|
307
307
|
C && !// TODO This seems pretty hacky. Hope to fix it.
|
|
308
308
|
// Maybe we could `mountDependencies` in `setAtomState`?
|
|
309
|
-
(w && !hasPromiseAtomValue(w) && (isEqualAtomValue(w,
|
|
309
|
+
(w && !hasPromiseAtomValue(w) && (isEqualAtomValue(w, f) || isEqualAtomError(w, f))) && C.l.forEach((B) => B());
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
312
|
}
|
|
@@ -314,12 +314,12 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
|
|
|
314
314
|
return {
|
|
315
315
|
get: x,
|
|
316
316
|
set: k,
|
|
317
|
-
sub: (
|
|
318
|
-
const w = h
|
|
317
|
+
sub: (h, j) => {
|
|
318
|
+
const w = m(h);
|
|
319
319
|
v();
|
|
320
|
-
const
|
|
321
|
-
return
|
|
322
|
-
|
|
320
|
+
const f = w.l;
|
|
321
|
+
return f.add(j), () => {
|
|
322
|
+
f.delete(j), E(h);
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
325
|
};
|
|
@@ -336,37 +336,37 @@ function splitAtom(o, r) {
|
|
|
336
336
|
let p = n.get(c);
|
|
337
337
|
if (p)
|
|
338
338
|
return p;
|
|
339
|
-
const u = d && n.get(d), x = [],
|
|
340
|
-
return c.forEach((
|
|
339
|
+
const u = d && n.get(d), x = [], m = [];
|
|
340
|
+
return c.forEach((g, E) => {
|
|
341
341
|
const y = E;
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
x[E] =
|
|
342
|
+
m[E] = y;
|
|
343
|
+
const b = u && u.atomList[u.keyList.indexOf(y)];
|
|
344
|
+
if (b) {
|
|
345
|
+
x[E] = b;
|
|
346
346
|
return;
|
|
347
347
|
}
|
|
348
348
|
const k = (A) => {
|
|
349
|
-
const S = A(l), v = A(o),
|
|
350
|
-
if (
|
|
349
|
+
const S = A(l), v = A(o), h = a(v, S == null ? void 0 : S.arr).keyList.indexOf(y);
|
|
350
|
+
if (h < 0 || h >= v.length) {
|
|
351
351
|
const j = c[a(c).keyList.indexOf(y)];
|
|
352
352
|
if (j)
|
|
353
353
|
return j;
|
|
354
354
|
throw new Error("splitAtom: index out of bounds for read");
|
|
355
355
|
}
|
|
356
|
-
return v[
|
|
356
|
+
return v[h];
|
|
357
357
|
}, _ = (A, S, v) => {
|
|
358
|
-
const R = A(l),
|
|
359
|
-
if (w < 0 || w >=
|
|
358
|
+
const R = A(l), h = A(o), w = a(h, R == null ? void 0 : R.arr).keyList.indexOf(y);
|
|
359
|
+
if (w < 0 || w >= h.length)
|
|
360
360
|
throw new Error("splitAtom: index out of bounds for write");
|
|
361
|
-
const
|
|
361
|
+
const f = isFunction(v) ? v(h[w]) : v;
|
|
362
362
|
S(o, [
|
|
363
|
-
...
|
|
364
|
-
|
|
365
|
-
...
|
|
363
|
+
...h.slice(0, w),
|
|
364
|
+
f,
|
|
365
|
+
...h.slice(w + 1)
|
|
366
366
|
]);
|
|
367
367
|
};
|
|
368
368
|
x[E] = isWritable(o) ? atom(k, _) : atom(k);
|
|
369
|
-
}), u && u.keyList.length ===
|
|
369
|
+
}), u && u.keyList.length === m.length && u.keyList.every((g, E) => g === m[E]) ? p = u : p = { arr: c, atomList: x, keyList: m }, n.set(c, p), p;
|
|
370
370
|
}, l = atom((c) => {
|
|
371
371
|
const d = c(l), p = c(o);
|
|
372
372
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -402,17 +402,17 @@ function splitAtom(o, r) {
|
|
|
402
402
|
case "move": {
|
|
403
403
|
const u = c(i).indexOf(p.atom), x = p.before ? c(i).indexOf(p.before) : c(i).length;
|
|
404
404
|
if (u >= 0 && x >= 0) {
|
|
405
|
-
const
|
|
405
|
+
const m = c(o);
|
|
406
406
|
u < x ? d(o, [
|
|
407
|
-
...
|
|
408
|
-
...
|
|
409
|
-
|
|
410
|
-
...
|
|
407
|
+
...m.slice(0, u),
|
|
408
|
+
...m.slice(u + 1, x),
|
|
409
|
+
m[u],
|
|
410
|
+
...m.slice(x)
|
|
411
411
|
]) : d(o, [
|
|
412
|
-
...
|
|
413
|
-
|
|
414
|
-
...
|
|
415
|
-
...
|
|
412
|
+
...m.slice(0, x),
|
|
413
|
+
m[u],
|
|
414
|
+
...m.slice(x, u),
|
|
415
|
+
...m.slice(u + 1)
|
|
416
416
|
]);
|
|
417
417
|
}
|
|
418
418
|
break;
|
|
@@ -1082,50 +1082,50 @@ const useBlocksStoreManager = () => {
|
|
|
1082
1082
|
updateBlocksProps: c
|
|
1083
1083
|
} = useBlocksStoreManager();
|
|
1084
1084
|
return {
|
|
1085
|
-
moveBlocks: (y,
|
|
1085
|
+
moveBlocks: (y, b, k) => {
|
|
1086
1086
|
const _ = map(y, (S) => {
|
|
1087
1087
|
const R = r.find((w) => w._id === S)._parent || null, j = r.filter((w) => R ? w._parent === R : !w._parent).map((w) => w._id).indexOf(S);
|
|
1088
1088
|
return { _id: S, oldParent: R, oldPosition: j };
|
|
1089
1089
|
}), A = _.find(({ _id: S }) => S === y[0]);
|
|
1090
|
-
A && A.oldParent ===
|
|
1090
|
+
A && A.oldParent === b && A.oldPosition === k || (i(y, b, k), o({
|
|
1091
1091
|
undo: () => each(_, ({ _id: S, oldParent: v, oldPosition: R }) => {
|
|
1092
1092
|
i([S], v, R);
|
|
1093
1093
|
}),
|
|
1094
|
-
redo: () => i(y,
|
|
1094
|
+
redo: () => i(y, b, k)
|
|
1095
1095
|
}));
|
|
1096
1096
|
},
|
|
1097
|
-
addBlocks: (y,
|
|
1098
|
-
a(y,
|
|
1097
|
+
addBlocks: (y, b, k) => {
|
|
1098
|
+
a(y, b, k), o({
|
|
1099
1099
|
undo: () => l(map(y, "_id")),
|
|
1100
|
-
redo: () => a(y,
|
|
1100
|
+
redo: () => a(y, b, k)
|
|
1101
1101
|
});
|
|
1102
1102
|
},
|
|
1103
1103
|
removeBlocks: (y) => {
|
|
1104
1104
|
var A;
|
|
1105
|
-
const
|
|
1105
|
+
const b = (A = first(y)) == null ? void 0 : A._parent, _ = r.filter((S) => b ? S._parent === b : !S._parent).indexOf(first(y));
|
|
1106
1106
|
l(map(y, "_id")), o({
|
|
1107
|
-
undo: () => a(y,
|
|
1107
|
+
undo: () => a(y, b, _),
|
|
1108
1108
|
redo: () => l(map(y, "_id"))
|
|
1109
1109
|
});
|
|
1110
1110
|
},
|
|
1111
|
-
updateBlocks: (y,
|
|
1111
|
+
updateBlocks: (y, b, k) => {
|
|
1112
1112
|
let _ = [];
|
|
1113
1113
|
if (k)
|
|
1114
1114
|
_ = map(y, (A) => ({ _id: A, ...k }));
|
|
1115
1115
|
else {
|
|
1116
|
-
const A = keys(
|
|
1116
|
+
const A = keys(b);
|
|
1117
1117
|
_ = map(y, (S) => {
|
|
1118
|
-
const v = r.find((
|
|
1119
|
-
return each(A, (
|
|
1118
|
+
const v = r.find((h) => h._id === S), R = { _id: S };
|
|
1119
|
+
return each(A, (h) => R[h] = v[h]), R;
|
|
1120
1120
|
});
|
|
1121
1121
|
}
|
|
1122
|
-
c(map(y, (A) => ({ _id: A, ...
|
|
1122
|
+
c(map(y, (A) => ({ _id: A, ...b }))), o({
|
|
1123
1123
|
undo: () => c(_),
|
|
1124
|
-
redo: () => c(map(y, (A) => ({ _id: A, ...
|
|
1124
|
+
redo: () => c(map(y, (A) => ({ _id: A, ...b })))
|
|
1125
1125
|
});
|
|
1126
1126
|
},
|
|
1127
|
-
updateBlocksRuntime: (y,
|
|
1128
|
-
c(map(y, (k) => ({ _id: k, ...
|
|
1127
|
+
updateBlocksRuntime: (y, b) => {
|
|
1128
|
+
c(map(y, (k) => ({ _id: k, ...b })));
|
|
1129
1129
|
},
|
|
1130
1130
|
setNewBlocks: (y) => {
|
|
1131
1131
|
n(y), o({
|
|
@@ -1134,12 +1134,12 @@ const useBlocksStoreManager = () => {
|
|
|
1134
1134
|
});
|
|
1135
1135
|
},
|
|
1136
1136
|
updateMultipleBlocksProps: (y) => {
|
|
1137
|
-
let
|
|
1138
|
-
|
|
1137
|
+
let b = [];
|
|
1138
|
+
b = map(y, (k) => {
|
|
1139
1139
|
const _ = keys(k), A = r.find((v) => v._id === k._id), S = {};
|
|
1140
1140
|
return each(_, (v) => S[v] = A[v]), S;
|
|
1141
1141
|
}), c(y), o({
|
|
1142
|
-
undo: () => c(
|
|
1142
|
+
undo: () => c(b),
|
|
1143
1143
|
redo: () => c(y)
|
|
1144
1144
|
});
|
|
1145
1145
|
}
|
|
@@ -1147,33 +1147,33 @@ const useBlocksStoreManager = () => {
|
|
|
1147
1147
|
}, useAddBlock = () => {
|
|
1148
1148
|
const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1149
1149
|
(i, c, d) => {
|
|
1150
|
-
var
|
|
1150
|
+
var g;
|
|
1151
1151
|
for (let E = 0; E < i.length; E++) {
|
|
1152
1152
|
const { _id: y } = i[E];
|
|
1153
1153
|
i[E]._id = generateUUID();
|
|
1154
|
-
const
|
|
1155
|
-
for (let k = 0; k <
|
|
1156
|
-
|
|
1154
|
+
const b = filter(i, { _parent: y });
|
|
1155
|
+
for (let k = 0; k < b.length; k++)
|
|
1156
|
+
b[k]._parent = i[E]._id;
|
|
1157
1157
|
}
|
|
1158
1158
|
const p = first(i);
|
|
1159
1159
|
let u, x;
|
|
1160
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c, x = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, x = u._parent), n(i, x, d), r([(
|
|
1160
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, x = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, x = u._parent), n(i, x, d), r([(g = first(i)) == null ? void 0 : g._id]), first(i);
|
|
1161
1161
|
},
|
|
1162
1162
|
[n, o, r]
|
|
1163
1163
|
);
|
|
1164
1164
|
return { addCoreBlock: useCallback(
|
|
1165
1165
|
(i, c, d) => {
|
|
1166
1166
|
if (has(i, "blocks")) {
|
|
1167
|
-
const
|
|
1168
|
-
return a(
|
|
1167
|
+
const b = i.blocks;
|
|
1168
|
+
return a(b, c, d);
|
|
1169
1169
|
}
|
|
1170
1170
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), x = {
|
|
1171
1171
|
_type: i.type,
|
|
1172
1172
|
_id: p,
|
|
1173
1173
|
...u
|
|
1174
1174
|
};
|
|
1175
|
-
let
|
|
1176
|
-
return c && (
|
|
1175
|
+
let m, g;
|
|
1176
|
+
return c && (m = find(o, { _id: c }), x._parent = c, g = c), !canAcceptChildBlock(m == null ? void 0 : m._type, x._type) && m && (x._parent = m._parent, g = m._parent), n([x], g, d), r([x._id]), x;
|
|
1177
1177
|
},
|
|
1178
1178
|
[n, a, o, r]
|
|
1179
1179
|
), addPredefinedBlock: a };
|
|
@@ -2313,15 +2313,15 @@ function getNewClasses(o = "", r = "", n = []) {
|
|
|
2313
2313
|
);
|
|
2314
2314
|
const i = [], c = [];
|
|
2315
2315
|
each(n, (u) => {
|
|
2316
|
-
const x = constructClassObject(u),
|
|
2317
|
-
if (
|
|
2316
|
+
const x = constructClassObject(u), m = find(a, pick(x, ["dark", "mq", "mod", "property"]));
|
|
2317
|
+
if (m && (a = filter(
|
|
2318
2318
|
a,
|
|
2319
|
-
(
|
|
2320
|
-
)), i.push(x), x.mq === "xs" && !x.dark && x.mod === "" && (l = filter(l, (
|
|
2321
|
-
const
|
|
2322
|
-
|
|
2319
|
+
(g) => g.fullCls !== (m == null ? void 0 : m.fullCls)
|
|
2320
|
+
)), i.push(x), x.mq === "xs" && !x.dark && x.mod === "" && (l = filter(l, (g) => g.property !== x.property)), getBelongsToForClass(a, x) === "baseClasses" && !includes(IGNORED_BASES_CLASSES_PROPERTIES, x.property)) {
|
|
2321
|
+
const g = find(l, pick(x, ["property"]));
|
|
2322
|
+
m && (l = filter(
|
|
2323
2323
|
l,
|
|
2324
|
-
(E) => E.fullCls !== (
|
|
2324
|
+
(E) => E.fullCls !== (g == null ? void 0 : g.fullCls)
|
|
2325
2325
|
)), c.push({
|
|
2326
2326
|
...x,
|
|
2327
2327
|
fullCls: x.cls,
|
|
@@ -2412,13 +2412,13 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
|
|
|
2412
2412
|
(a, l = null) => {
|
|
2413
2413
|
const i = [];
|
|
2414
2414
|
each(a, (c) => {
|
|
2415
|
-
const d = o.find((
|
|
2415
|
+
const d = o.find((g) => g._id === c);
|
|
2416
2416
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
2417
2417
|
const x = filter(
|
|
2418
2418
|
o,
|
|
2419
|
-
(
|
|
2420
|
-
).indexOf(d) + 1,
|
|
2421
|
-
n(
|
|
2419
|
+
(g) => isString(l) ? g._parent === l : !g._parent
|
|
2420
|
+
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
2421
|
+
n(m, l, x), i.push(get(m, "0._id", ""));
|
|
2422
2422
|
}), r(i);
|
|
2423
2423
|
},
|
|
2424
2424
|
[o, r]
|
|
@@ -2514,14 +2514,14 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
|
|
|
2514
2514
|
return map(i, (c) => {
|
|
2515
2515
|
const d = o(c), p = a;
|
|
2516
2516
|
let { classes: u, baseClasses: x } = getSplitClasses(get(d, l.prop, "styles:,"));
|
|
2517
|
-
return each(p, (
|
|
2518
|
-
const
|
|
2517
|
+
return each(p, (m) => {
|
|
2518
|
+
const g = m.replace(/[\[\]\/\\{}()*+?.^$|]/g, "\\$&"), E = new RegExp(`(^| )${g}($| )`, "g");
|
|
2519
2519
|
u = u.replace(E, " ").replace(/ +/g, " ").trim();
|
|
2520
|
-
const y = first(
|
|
2521
|
-
includes(["2xl", "xl", "lg", "md", "sm"], y) && p.push(
|
|
2522
|
-
}), each(p, (
|
|
2523
|
-
const
|
|
2524
|
-
x = x.replace(
|
|
2520
|
+
const y = first(m.split(":"));
|
|
2521
|
+
includes(["2xl", "xl", "lg", "md", "sm"], y) && p.push(m.split(":").pop().trim());
|
|
2522
|
+
}), each(p, (m) => {
|
|
2523
|
+
const g = new RegExp(`(^| )${m.replace("[", "\\[").replace("]", "\\]")}($| )`, "g");
|
|
2524
|
+
x = x.replace(g, " ").replace(/ +/g, " ").trim();
|
|
2525
2525
|
}), {
|
|
2526
2526
|
ids: [d._id],
|
|
2527
2527
|
props: {
|
|
@@ -2970,39 +2970,39 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2970
2970
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2971
2971
|
})
|
|
2972
2972
|
), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2973
|
-
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), x = p.length ? p : u,
|
|
2974
|
-
const y = cloneDeep(E.find((
|
|
2975
|
-
for (const
|
|
2976
|
-
const k = y[
|
|
2977
|
-
typeof k == "string" && startsWith(k, STYLES_KEY) ? y[
|
|
2973
|
+
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), x = p.length ? p : u, m = (g, E) => {
|
|
2974
|
+
const y = cloneDeep(E.find((b) => b._id === g));
|
|
2975
|
+
for (const b in y) {
|
|
2976
|
+
const k = y[b];
|
|
2977
|
+
typeof k == "string" && startsWith(k, STYLES_KEY) ? y[b] = compact(flattenDeep(k.replace(STYLES_KEY, "").split(","))).join(" ") : b !== "_id" && delete y[b];
|
|
2978
2978
|
}
|
|
2979
2979
|
return y;
|
|
2980
2980
|
};
|
|
2981
2981
|
return {
|
|
2982
2982
|
askAi: useCallback(
|
|
2983
|
-
async (
|
|
2983
|
+
async (g, E, y, b) => {
|
|
2984
2984
|
if (l) {
|
|
2985
2985
|
r(!0), a(null);
|
|
2986
2986
|
try {
|
|
2987
|
-
const k = p === u ? "" : p, _ =
|
|
2987
|
+
const k = p === u ? "" : p, _ = g === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(E, d)), p) : [m(E, d)], A = await l(g, addLangToPrompt(y, x, g), _, k), { blocks: S, error: v } = A;
|
|
2988
2988
|
if (v) {
|
|
2989
2989
|
a(v);
|
|
2990
2990
|
return;
|
|
2991
2991
|
}
|
|
2992
|
-
if (
|
|
2993
|
-
const R = S.map((
|
|
2994
|
-
for (const j in
|
|
2995
|
-
j !== "_id" && (
|
|
2996
|
-
return
|
|
2992
|
+
if (g === "styles") {
|
|
2993
|
+
const R = S.map((h) => {
|
|
2994
|
+
for (const j in h)
|
|
2995
|
+
j !== "_id" && (h[j] = `${STYLES_KEY},${h[j]}`);
|
|
2996
|
+
return h;
|
|
2997
2997
|
});
|
|
2998
2998
|
c(R);
|
|
2999
2999
|
} else
|
|
3000
3000
|
i(S);
|
|
3001
|
-
|
|
3001
|
+
b && b(A);
|
|
3002
3002
|
} catch (k) {
|
|
3003
3003
|
a(k);
|
|
3004
3004
|
} finally {
|
|
3005
|
-
r(!1),
|
|
3005
|
+
r(!1), b && b();
|
|
3006
3006
|
}
|
|
3007
3007
|
}
|
|
3008
3008
|
},
|
|
@@ -3110,11 +3110,11 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAto
|
|
|
3110
3110
|
if (d < r) {
|
|
3111
3111
|
const u = parseFloat((d / r).toFixed(2).toString());
|
|
3112
3112
|
let x = {};
|
|
3113
|
-
const
|
|
3113
|
+
const m = p * u, g = d * u;
|
|
3114
3114
|
p && (x = {
|
|
3115
3115
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3116
|
-
height: 100 + (p -
|
|
3117
|
-
width: 100 + (d -
|
|
3116
|
+
height: 100 + (p - m) / m * 100 + "%",
|
|
3117
|
+
width: 100 + (d - g) / g * 100 + "%"
|
|
3118
3118
|
}), i({
|
|
3119
3119
|
position: "relative",
|
|
3120
3120
|
top: 0,
|
|
@@ -3289,38 +3289,38 @@ function removeDataDrop() {
|
|
|
3289
3289
|
const useDnd = () => {
|
|
3290
3290
|
const { document: o } = useFrame(), [r, n] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
|
|
3291
3291
|
if (!useFeature("dnd")) return {};
|
|
3292
|
-
const
|
|
3292
|
+
const m = () => {
|
|
3293
3293
|
removePlaceholder(), n(!1), p(null), u(null), possiblePositions = [];
|
|
3294
3294
|
};
|
|
3295
3295
|
return iframeDocument = o, {
|
|
3296
3296
|
isDragging: r,
|
|
3297
|
-
onDragOver: (
|
|
3298
|
-
|
|
3297
|
+
onDragOver: (g) => {
|
|
3298
|
+
g.preventDefault(), g.stopPropagation(), throttledDragOver(g);
|
|
3299
3299
|
},
|
|
3300
|
-
onDrop: (
|
|
3300
|
+
onDrop: (g) => {
|
|
3301
3301
|
var v;
|
|
3302
|
-
const E = dropTarget,
|
|
3303
|
-
dropIndex = calculateDropIndex(
|
|
3302
|
+
const E = dropTarget, b = getOrientation(E) === "vertical" ? g.clientY + ((v = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : v.scrollY) : g.clientX;
|
|
3303
|
+
dropIndex = calculateDropIndex(b, possiblePositions);
|
|
3304
3304
|
const k = d, _ = E.getAttribute("data-block-id"), A = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3305
3305
|
if ((k == null ? void 0 : k._id) === _ || !A) {
|
|
3306
|
-
|
|
3306
|
+
m();
|
|
3307
3307
|
return;
|
|
3308
3308
|
}
|
|
3309
3309
|
if (!has(k, "_id")) {
|
|
3310
|
-
a(k, _ === "canvas" ? null : _, dropIndex), setTimeout(
|
|
3310
|
+
a(k, _ === "canvas" ? null : _, dropIndex), setTimeout(m, 300);
|
|
3311
3311
|
return;
|
|
3312
3312
|
}
|
|
3313
3313
|
let S = E.getAttribute("data-block-id");
|
|
3314
|
-
S === null && (S =
|
|
3314
|
+
S === null && (S = g.target.parentElement.getAttribute("data-block-id")), c([k._id], S === "canvas" ? null : S, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3315
3315
|
},
|
|
3316
|
-
onDragEnter: (
|
|
3317
|
-
const E =
|
|
3316
|
+
onDragEnter: (g) => {
|
|
3317
|
+
const E = g, y = E.target;
|
|
3318
3318
|
dropTarget = y;
|
|
3319
|
-
const
|
|
3320
|
-
u(
|
|
3319
|
+
const b = y.getAttribute("data-block-id"), k = y.getAttribute("data-dnd-dragged") !== "yes";
|
|
3320
|
+
u(b), E.stopPropagation(), E.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(y), n(!0), l(""), i([]);
|
|
3321
3321
|
},
|
|
3322
|
-
onDragLeave: (
|
|
3323
|
-
|
|
3322
|
+
onDragLeave: (g) => {
|
|
3323
|
+
g.target.getAttribute("data-block-id") === "canvas" && (u(null), n(!1), removePlaceholder(), possiblePositions = []);
|
|
3324
3324
|
}
|
|
3325
3325
|
};
|
|
3326
3326
|
};
|
|
@@ -3340,25 +3340,25 @@ function destroyQuill(o) {
|
|
|
3340
3340
|
const useHandleCanvasDblClick = () => {
|
|
3341
3341
|
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], r = useUpdateBlocksProps(), [n, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight();
|
|
3342
3342
|
return (i) => {
|
|
3343
|
-
var
|
|
3343
|
+
var m;
|
|
3344
3344
|
if (n) return;
|
|
3345
3345
|
const c = getTargetedBlock(i.target), d = c.getAttribute("data-block-type");
|
|
3346
3346
|
if (!d || !o.includes(d))
|
|
3347
3347
|
return;
|
|
3348
3348
|
const p = c.cloneNode(!0);
|
|
3349
|
-
c.style.display = "none", Array.from(p.attributes).forEach((
|
|
3350
|
-
|
|
3349
|
+
c.style.display = "none", Array.from(p.attributes).forEach((g) => {
|
|
3350
|
+
g.name !== "class" && p.removeAttribute(g.name);
|
|
3351
3351
|
}), d === "Text" && (p.style.display = "inline-block"), c.parentNode.insertBefore(p, c.nextSibling);
|
|
3352
3352
|
const u = new Quill(p, { placeholder: "Type here..." });
|
|
3353
3353
|
function x() {
|
|
3354
|
-
const
|
|
3355
|
-
r([c.getAttribute("data-block-id")], { content:
|
|
3354
|
+
const g = u.getText(0, u.getLength());
|
|
3355
|
+
r([c.getAttribute("data-block-id")], { content: g }), c.removeAttribute("style"), p.removeEventListener("blur", x, !0), destroyQuill(u), a(""), l(), p.remove();
|
|
3356
3356
|
}
|
|
3357
|
-
p.addEventListener("blur", x, !0), p.addEventListener("click", (
|
|
3358
|
-
|
|
3359
|
-
}), p.addEventListener("keydown", (
|
|
3360
|
-
(
|
|
3361
|
-
}), u.focus(), (
|
|
3357
|
+
p.addEventListener("blur", x, !0), p.addEventListener("click", (g) => {
|
|
3358
|
+
g.stopPropagation();
|
|
3359
|
+
}), p.addEventListener("keydown", (g) => {
|
|
3360
|
+
(g.key === "Enter" || g.key === "Escape") && x();
|
|
3361
|
+
}), u.focus(), (m = p.querySelector(".ql-clipboard")) == null || m.remove(), a(c.getAttribute("data-block-id"));
|
|
3362
3362
|
};
|
|
3363
3363
|
}, useHandleCanvasClick = () => {
|
|
3364
3364
|
const [, o] = useSelectedStylingBlocks(), [r, n] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
|
|
@@ -3395,12 +3395,12 @@ const useHandleCanvasDblClick = () => {
|
|
|
3395
3395
|
setTimeout(() => {
|
|
3396
3396
|
if (!isEmpty(a))
|
|
3397
3397
|
return;
|
|
3398
|
-
const
|
|
3399
|
-
if (
|
|
3400
|
-
const
|
|
3401
|
-
if (
|
|
3402
|
-
const E =
|
|
3403
|
-
l([{ id: E, prop:
|
|
3398
|
+
const m = getElementByDataBlockId(r, first(n));
|
|
3399
|
+
if (m) {
|
|
3400
|
+
const g = m.getAttribute("data-style-prop");
|
|
3401
|
+
if (g) {
|
|
3402
|
+
const E = m.getAttribute("data-style-id"), y = m.getAttribute("data-block-parent");
|
|
3403
|
+
l([{ id: E, prop: g, blockId: y }]);
|
|
3404
3404
|
}
|
|
3405
3405
|
}
|
|
3406
3406
|
}, 100);
|
|
@@ -3421,15 +3421,15 @@ const useHandleCanvasDblClick = () => {
|
|
|
3421
3421
|
}
|
|
3422
3422
|
);
|
|
3423
3423
|
}, getElementByDataBlockId = (o, r) => o.querySelector(`[data-block-id="${r}"]`), useKeyEventWatcher = (o) => {
|
|
3424
|
-
const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: x, pasteBlocks:
|
|
3424
|
+
const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: x, pasteBlocks: m } = usePasteBlocks(), g = o ? { document: o } : {};
|
|
3425
3425
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(r), {}, [r, p]), useHotkeys("ctrl+c,command+c", () => u(r), {}, [r, u]), useHotkeys(
|
|
3426
3426
|
"ctrl+v,command+v",
|
|
3427
3427
|
() => {
|
|
3428
|
-
x(r[0]) &&
|
|
3428
|
+
x(r[0]) && m(r);
|
|
3429
3429
|
},
|
|
3430
|
-
{ ...
|
|
3431
|
-
[r, x,
|
|
3432
|
-
), useHotkeys("esc", () => n([]),
|
|
3430
|
+
{ ...g, preventDefault: !0 },
|
|
3431
|
+
[r, x, m]
|
|
3432
|
+
), useHotkeys("esc", () => n([]), g, [n]), useHotkeys("ctrl+d,command+d", () => i(r), { ...g, preventDefault: !0 }, [
|
|
3433
3433
|
r,
|
|
3434
3434
|
i
|
|
3435
3435
|
]), useHotkeys(
|
|
@@ -3437,7 +3437,7 @@ const useHandleCanvasDblClick = () => {
|
|
|
3437
3437
|
(E) => {
|
|
3438
3438
|
E.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
|
|
3439
3439
|
},
|
|
3440
|
-
|
|
3440
|
+
g,
|
|
3441
3441
|
[r, l]
|
|
3442
3442
|
);
|
|
3443
3443
|
}, KeyboardHandler = () => {
|
|
@@ -3490,7 +3490,7 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
|
|
|
3490
3490
|
}
|
|
3491
3491
|
});
|
|
3492
3492
|
useResizeObserver(o, () => x(), o !== null);
|
|
3493
|
-
const
|
|
3493
|
+
const m = get(r, "_parent", null), g = isEmpty(get(r, "_name", "")) ? get(r, "_type", "") : get(r, "_name", "");
|
|
3494
3494
|
return !o || !r || d ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3495
3495
|
"div",
|
|
3496
3496
|
{
|
|
@@ -3507,16 +3507,16 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
|
|
|
3507
3507
|
onKeyDown: (E) => E.stopPropagation(),
|
|
3508
3508
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3509
3509
|
children: [
|
|
3510
|
-
|
|
3510
|
+
m && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3511
3511
|
ArrowUpIcon,
|
|
3512
3512
|
{
|
|
3513
3513
|
className: "hover:scale-105",
|
|
3514
3514
|
onClick: () => {
|
|
3515
|
-
c([]), l([
|
|
3515
|
+
c([]), l([m]);
|
|
3516
3516
|
}
|
|
3517
3517
|
}
|
|
3518
3518
|
),
|
|
3519
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(BlockActionLabel, { label:
|
|
3519
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(BlockActionLabel, { label: g, block: r }),
|
|
3520
3520
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 px-1", children: [
|
|
3521
3521
|
canAddChildBlock(get(r, "_type", "")) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3522
3522
|
PlusIcon,
|
|
@@ -3534,9 +3534,9 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
|
|
|
3534
3534
|
}, HeadTags = () => {
|
|
3535
3535
|
const [o] = useTheme(), r = useThemeOptions(), [n] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [x] = useState(
|
|
3536
3536
|
d == null ? void 0 : d.getElementById("selected-block")
|
|
3537
|
-
), [h] = useState(
|
|
3538
|
-
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3539
3537
|
), [m] = useState(
|
|
3538
|
+
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3539
|
+
), [g] = useState(
|
|
3540
3540
|
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3541
3541
|
);
|
|
3542
3542
|
useEffect(() => {
|
|
@@ -3561,8 +3561,8 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
|
|
|
3561
3561
|
forms,
|
|
3562
3562
|
aspectRatio,
|
|
3563
3563
|
containerQueries,
|
|
3564
|
-
plugin(function({ addBase:
|
|
3565
|
-
|
|
3564
|
+
plugin(function({ addBase: b, theme: k }) {
|
|
3565
|
+
b({
|
|
3566
3566
|
"h1,h2,h3,h4,h5,h6": {
|
|
3567
3567
|
fontFamily: k("fontFamily.heading")
|
|
3568
3568
|
},
|
|
@@ -3576,18 +3576,18 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
|
|
|
3576
3576
|
]
|
|
3577
3577
|
});
|
|
3578
3578
|
}, [o, r, p]), useEffect(() => {
|
|
3579
|
-
x && (x.textContent = `${map(n, (
|
|
3579
|
+
x && (x.textContent = `${map(n, (b) => `[data-block-id="${b}"]`).join(",")}{
|
|
3580
3580
|
outline: 1px solid ${n.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3581
3581
|
}`);
|
|
3582
3582
|
}, [n, x]), useEffect(() => {
|
|
3583
|
-
|
|
3584
|
-
}, [i,
|
|
3583
|
+
g.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3584
|
+
}, [i, g]), useEffect(() => {
|
|
3585
3585
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3586
3586
|
}, [u]), useEffect(() => {
|
|
3587
|
-
|
|
3587
|
+
m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
|
|
3588
3588
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3589
3589
|
}`);
|
|
3590
|
-
}, [l,
|
|
3590
|
+
}, [l, m]), useEffect(() => {
|
|
3591
3591
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3592
3592
|
}, [c, d]);
|
|
3593
3593
|
const E = useMemo(
|
|
@@ -3598,24 +3598,6 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
|
|
|
3598
3598
|
/* @__PURE__ */ jsxRuntimeExports.jsx("style", { id: "chai-theme", children: E }),
|
|
3599
3599
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: y } })
|
|
3600
3600
|
] });
|
|
3601
|
-
}, useChaiExternalData = () => useAtom$1(chaiExternalDataAtom), useCanvasSettings = () => useAtom$1(canvasSettingsAtom), isVisibleAtBreakpoint = (o, r) => {
|
|
3602
|
-
const n = ["xs", "sm", "md", "lg", "xl", "2xl"], a = n.indexOf(r), l = o.split(" ");
|
|
3603
|
-
let i = new Array(n.length).fill(!1);
|
|
3604
|
-
for (const c of l) {
|
|
3605
|
-
let [d, p] = c.split(":");
|
|
3606
|
-
p || (p = d, d = "xs");
|
|
3607
|
-
const u = n.indexOf(d);
|
|
3608
|
-
if (u <= a) {
|
|
3609
|
-
const x = ["block", "flex", "inline", "inline-block", "inline-flex", "grid", "table"], h = ["hidden"];
|
|
3610
|
-
if (x.includes(p))
|
|
3611
|
-
for (let m = u; m < n.length; m++)
|
|
3612
|
-
i[m] = !0;
|
|
3613
|
-
else if (h.includes(p))
|
|
3614
|
-
for (let m = u; m < n.length; m++)
|
|
3615
|
-
i[m] = !1;
|
|
3616
|
-
}
|
|
3617
|
-
}
|
|
3618
|
-
return i[a];
|
|
3619
3601
|
};
|
|
3620
3602
|
function AsyncPropsBlock(o) {
|
|
3621
3603
|
const { dataProvider: r, block: n } = o, a = useMemo(() => r ? r(n, o.lang) : {}, [n, r, o.lang]);
|
|
@@ -3628,29 +3610,27 @@ function RuntimePropsBlock(o) {
|
|
|
3628
3610
|
}, {});
|
|
3629
3611
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(o.component, { ...o.props, ...n }) });
|
|
3630
3612
|
}
|
|
3631
|
-
const generateClassNames = memoize((o) => {
|
|
3613
|
+
const useChaiExternalData = () => useAtom$1(chaiExternalDataAtom), generateClassNames = memoize((o) => {
|
|
3632
3614
|
const r = o.replace(STYLES_KEY, "").split(",");
|
|
3633
3615
|
return twMerge(r[0], r[1]);
|
|
3634
3616
|
});
|
|
3635
3617
|
function getElementAttrs(o, r) {
|
|
3636
3618
|
return get(o, `${r}_attrs`, {});
|
|
3637
3619
|
}
|
|
3638
|
-
function getStyleAttrs(o
|
|
3639
|
-
const
|
|
3640
|
-
return Object.keys(o).forEach((
|
|
3641
|
-
if (isString(o[
|
|
3642
|
-
const
|
|
3643
|
-
n
|
|
3644
|
-
className:
|
|
3645
|
-
"data-style-prop":
|
|
3620
|
+
function getStyleAttrs(o) {
|
|
3621
|
+
const r = {};
|
|
3622
|
+
return Object.keys(o).forEach((n) => {
|
|
3623
|
+
if (isString(o[n]) && o[n].startsWith(STYLES_KEY)) {
|
|
3624
|
+
const a = generateClassNames(o[n]), l = getElementAttrs(o, n);
|
|
3625
|
+
r[n] = {
|
|
3626
|
+
className: a,
|
|
3627
|
+
"data-style-prop": n,
|
|
3646
3628
|
"data-block-parent": o._id,
|
|
3647
|
-
"data-style-id": `${
|
|
3648
|
-
...
|
|
3629
|
+
"data-style-id": `${n}-${o._id}`,
|
|
3630
|
+
...l
|
|
3649
3631
|
};
|
|
3650
|
-
const c = has(i, "x-show") || has(i, "x-if");
|
|
3651
|
-
c && (n.__isHidden = c && !isVisibleAtBreakpoint(l, r));
|
|
3652
3632
|
}
|
|
3653
|
-
}),
|
|
3633
|
+
}), r;
|
|
3654
3634
|
}
|
|
3655
3635
|
function applyBindings(o, r) {
|
|
3656
3636
|
const n = get(o, "_bindings", {});
|
|
@@ -3676,62 +3656,51 @@ function applyLanguage(o, r, n) {
|
|
|
3676
3656
|
}), a;
|
|
3677
3657
|
}
|
|
3678
3658
|
function BlocksRendererStatic({ blocks: o, allBlocks: r }) {
|
|
3679
|
-
const { selectedLang: n } = useLanguages(), [a] =
|
|
3680
|
-
(g) => g.reduce((k, _) => {
|
|
3681
|
-
const A = get(p, _, {});
|
|
3682
|
-
return { ...k, ...A };
|
|
3683
|
-
}, {}),
|
|
3684
|
-
[p]
|
|
3685
|
-
);
|
|
3659
|
+
const { selectedLang: n } = useLanguages(), [a] = useCutBlockIds(), [l] = useAtom$1(draggedBlockAtom), [i] = useAtom$1(dropTargetBlockIdAtom), [c] = useHiddenBlockIds(), { getGlobalBlocks: d } = useGlobalBlocksStore(), p = useCallback((m) => getStyleAttrs(m), []), [u] = useChaiExternalData(), [x] = useAtom$1(inlineEditingActiveAtom);
|
|
3686
3660
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.toArray(
|
|
3687
|
-
o.map((
|
|
3688
|
-
if (
|
|
3689
|
-
const
|
|
3690
|
-
if (
|
|
3691
|
-
const
|
|
3692
|
-
|
|
3661
|
+
o.map((m, g) => {
|
|
3662
|
+
if (x === m._id || c.includes(m._id)) return null;
|
|
3663
|
+
const E = {}, y = filter(r, { _parent: m._id });
|
|
3664
|
+
if (E.children = y.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: r, blocks: y }) : null, m._type === "GlobalBlock") {
|
|
3665
|
+
const h = d(m);
|
|
3666
|
+
E.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(h, (j) => !j._parent), allBlocks: h });
|
|
3693
3667
|
}
|
|
3694
|
-
const
|
|
3695
|
-
if (isNull(
|
|
3696
|
-
const
|
|
3697
|
-
if (get(j, "__isHidden", !1) && !includes(a, g._id))
|
|
3698
|
-
return null;
|
|
3699
|
-
const w = i && isDescendant(i._id, g._id, r), C = {
|
|
3668
|
+
const b = getRegisteredChaiBlock(m._type), k = get(b, "component", null);
|
|
3669
|
+
if (isNull(k)) return /* @__PURE__ */ jsxRuntimeExports.jsx("noscript", { children: `<!-- ${m == null ? void 0 : m._type} not registered -->` });
|
|
3670
|
+
const _ = p(m), A = l && isDescendant(l._id, m._id, r), v = {
|
|
3700
3671
|
blockProps: {
|
|
3701
|
-
|
|
3702
|
-
"data-block-
|
|
3703
|
-
|
|
3704
|
-
...i ? (
|
|
3672
|
+
"data-block-id": m._id,
|
|
3673
|
+
"data-block-type": m._type,
|
|
3674
|
+
...l ? (
|
|
3705
3675
|
// @ts-ignore
|
|
3706
3676
|
{
|
|
3707
|
-
"data-dnd": canAcceptChildBlock(
|
|
3708
|
-
"data-dnd-dragged":
|
|
3677
|
+
"data-dnd": canAcceptChildBlock(m._type, l == null ? void 0 : l._type) ? "yes" : "no",
|
|
3678
|
+
"data-dnd-dragged": l._id === m._id || A ? "yes" : "no"
|
|
3709
3679
|
}
|
|
3710
3680
|
) : {},
|
|
3711
|
-
...
|
|
3712
|
-
...includes(
|
|
3681
|
+
...i === m._id && !A ? { "data-drop": "yes" } : {},
|
|
3682
|
+
...includes(a, m._id) ? { "data-cut-block": "yes" } : {}
|
|
3713
3683
|
},
|
|
3714
|
-
index:
|
|
3715
|
-
...applyBindings(applyLanguage(
|
|
3716
|
-
...omit(j, ["__isHidden"]),
|
|
3684
|
+
index: g,
|
|
3685
|
+
...applyBindings(applyLanguage(m, n, b), u),
|
|
3717
3686
|
..._,
|
|
3687
|
+
...E,
|
|
3718
3688
|
inBuilder: !0,
|
|
3719
|
-
blockState: f,
|
|
3720
3689
|
lang: n
|
|
3721
3690
|
};
|
|
3722
|
-
if (has(
|
|
3691
|
+
if (has(b, "dataProvider"))
|
|
3723
3692
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3724
3693
|
AsyncPropsBlock,
|
|
3725
3694
|
{
|
|
3726
3695
|
lang: n,
|
|
3727
|
-
dataProvider:
|
|
3728
|
-
block:
|
|
3729
|
-
component:
|
|
3730
|
-
props:
|
|
3696
|
+
dataProvider: b.dataProvider,
|
|
3697
|
+
block: m,
|
|
3698
|
+
component: k,
|
|
3699
|
+
props: v
|
|
3731
3700
|
}
|
|
3732
3701
|
) });
|
|
3733
|
-
const
|
|
3734
|
-
return
|
|
3702
|
+
const R = getRuntimeProps(m._type);
|
|
3703
|
+
return R ? /* @__PURE__ */ jsxRuntimeExports.jsx(RuntimePropsBlock, { runtimeProps: R, block: m, component: k, props: v }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(k, v) });
|
|
3735
3704
|
})
|
|
3736
3705
|
) });
|
|
3737
3706
|
}
|
|
@@ -3791,23 +3760,23 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
3791
3760
|
};
|
|
3792
3761
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "main-content", onClick: d, className: "h-full w-full p-8 pb-0", ref: i, children: o });
|
|
3793
3762
|
}, getElementByStyleId = (o, r) => o.querySelector(`[data-style-id="${r}"]`), StaticCanvas = () => {
|
|
3794
|
-
const [o] = useAtom$1(networkModeAtom), [r] = useCanvasWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x,
|
|
3795
|
-
p((
|
|
3763
|
+
const [o] = useAtom$1(networkModeAtom), [r] = useCanvasWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x, m] = useState([]), [, g] = useState([]), [, E] = useAtom$1(canvasIframeAtom), [y, b] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), _ = useBuilderProp("htmlDir", "ltr"), A = (R) => {
|
|
3764
|
+
p((h) => ({ ...h, width: R }));
|
|
3796
3765
|
};
|
|
3797
3766
|
useEffect(() => {
|
|
3798
3767
|
if (!c.current) return;
|
|
3799
|
-
const { clientWidth: R, clientHeight:
|
|
3800
|
-
p({ width: R, height:
|
|
3768
|
+
const { clientWidth: R, clientHeight: h } = c.current;
|
|
3769
|
+
p({ width: R, height: h });
|
|
3801
3770
|
}, [c, r]);
|
|
3802
|
-
const S = (R,
|
|
3771
|
+
const S = (R, h = 0) => {
|
|
3803
3772
|
const { top: j } = R.getBoundingClientRect();
|
|
3804
|
-
return j +
|
|
3773
|
+
return j + h >= 0 && j - h <= window.innerHeight;
|
|
3805
3774
|
};
|
|
3806
3775
|
useEffect(() => {
|
|
3807
|
-
var R,
|
|
3776
|
+
var R, h;
|
|
3808
3777
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3809
3778
|
const j = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3810
|
-
j && (S(j) || (
|
|
3779
|
+
j && (S(j) || (h = (R = i.current) == null ? void 0 : R.contentWindow) == null || h.scrollTo({ top: j.offsetTop, behavior: "smooth" }), m([j]));
|
|
3811
3780
|
}
|
|
3812
3781
|
}, [a]), useEffect(() => {
|
|
3813
3782
|
if (!isEmpty(y) && i.current) {
|
|
@@ -3815,9 +3784,9 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
3815
3784
|
i.current.contentDocument,
|
|
3816
3785
|
first(y).id
|
|
3817
3786
|
);
|
|
3818
|
-
|
|
3787
|
+
g(R ? [R] : [null]);
|
|
3819
3788
|
} else
|
|
3820
|
-
|
|
3789
|
+
g([null]);
|
|
3821
3790
|
}, [y]);
|
|
3822
3791
|
const v = useMemo(() => {
|
|
3823
3792
|
let R = IframeInitialContent;
|
|
@@ -3830,7 +3799,7 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
3830
3799
|
"div",
|
|
3831
3800
|
{
|
|
3832
3801
|
onClick: () => {
|
|
3833
|
-
n([]),
|
|
3802
|
+
n([]), b([]);
|
|
3834
3803
|
},
|
|
3835
3804
|
onMouseLeave: () => setTimeout(() => l(""), 300),
|
|
3836
3805
|
className: "relative mx-auto h-full w-full overflow-hidden",
|
|
@@ -4084,52 +4053,52 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
4084
4053
|
}
|
|
4085
4054
|
);
|
|
4086
4055
|
}, ThemeConfigPanel$1 = React.memo(({ className: o = "" }) => {
|
|
4087
|
-
const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), [i, c] = useTheme(), d = useThemeOptions(), { t: p } = useTranslation(), u = (
|
|
4088
|
-
a(
|
|
4056
|
+
const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), [i, c] = useTheme(), d = useThemeOptions(), { t: p } = useTranslation(), u = (b) => {
|
|
4057
|
+
a(b);
|
|
4089
4058
|
}, x = () => {
|
|
4090
|
-
const
|
|
4091
|
-
if (
|
|
4092
|
-
const k = Object.values(
|
|
4059
|
+
const b = l.find((k) => Object.keys(k)[0] === n);
|
|
4060
|
+
if (b) {
|
|
4061
|
+
const k = Object.values(b)[0];
|
|
4093
4062
|
k && typeof k == "object" && "fontFamily" in k && "borderRadius" in k && "colors" in k ? c(k) : console.error("Invalid preset structure:", k);
|
|
4094
4063
|
} else
|
|
4095
4064
|
console.error("Preset not found:", n);
|
|
4096
|
-
},
|
|
4097
|
-
(
|
|
4065
|
+
}, m = useDebouncedCallback(
|
|
4066
|
+
(b, k) => {
|
|
4098
4067
|
c(() => ({
|
|
4099
4068
|
...i,
|
|
4100
4069
|
fontFamily: {
|
|
4101
4070
|
...i.fontFamily,
|
|
4102
|
-
[
|
|
4071
|
+
[b.replace(/font-/g, "")]: k
|
|
4103
4072
|
}
|
|
4104
4073
|
}));
|
|
4105
4074
|
},
|
|
4106
4075
|
[i],
|
|
4107
4076
|
200
|
|
4108
|
-
),
|
|
4109
|
-
(
|
|
4077
|
+
), g = useDebouncedCallback(
|
|
4078
|
+
(b) => {
|
|
4110
4079
|
c(() => ({
|
|
4111
4080
|
...i,
|
|
4112
|
-
borderRadius: `${
|
|
4081
|
+
borderRadius: `${b}px`
|
|
4113
4082
|
}));
|
|
4114
4083
|
},
|
|
4115
4084
|
[i],
|
|
4116
4085
|
200
|
|
4117
4086
|
), E = useDebouncedCallback(
|
|
4118
|
-
(
|
|
4087
|
+
(b, k) => {
|
|
4119
4088
|
c(() => {
|
|
4120
|
-
const _ = get(i, `colors.${
|
|
4089
|
+
const _ = get(i, `colors.${b}`);
|
|
4121
4090
|
return r ? set(_, 1, k) : set(_, 0, k), {
|
|
4122
4091
|
...i,
|
|
4123
4092
|
colors: {
|
|
4124
4093
|
...i.colors,
|
|
4125
|
-
[
|
|
4094
|
+
[b]: _
|
|
4126
4095
|
}
|
|
4127
4096
|
};
|
|
4128
4097
|
});
|
|
4129
4098
|
},
|
|
4130
4099
|
[i],
|
|
4131
4100
|
200
|
|
4132
|
-
), y = (
|
|
4101
|
+
), y = (b) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1", children: Object.entries(b.items).map(([k]) => {
|
|
4133
4102
|
const _ = get(i, `colors.${k}.${r ? 1 : 0}`);
|
|
4134
4103
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4135
4104
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -4150,11 +4119,11 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
4150
4119
|
"select",
|
|
4151
4120
|
{
|
|
4152
4121
|
value: n,
|
|
4153
|
-
onChange: (
|
|
4122
|
+
onChange: (b) => u(b.target.value),
|
|
4154
4123
|
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
4124
|
children: [
|
|
4156
4125
|
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select preset" }),
|
|
4157
|
-
Array.isArray(l) && l.map((
|
|
4126
|
+
Array.isArray(l) && l.map((b) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: Object.keys(b)[0], children: capitalize(Object.keys(b)[0]) }, Object.keys(b)[0]))
|
|
4158
4127
|
]
|
|
4159
4128
|
}
|
|
4160
4129
|
)
|
|
@@ -4162,25 +4131,25 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
|
|
|
4162
4131
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-[30%] items-end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "w-full text-sm", disabled: n === "", variant: "default", onClick: x, children: p("Apply") }) })
|
|
4163
4132
|
] }),
|
|
4164
4133
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("space-y-2", o), children: [
|
|
4165
|
-
(d == null ? void 0 : d.fontFamily) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-4", children: Object.entries(d.fontFamily).map(([
|
|
4134
|
+
(d == null ? void 0 : d.fontFamily) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-4", children: Object.entries(d.fontFamily).map(([b, k]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4166
4135
|
FontSelector,
|
|
4167
4136
|
{
|
|
4168
|
-
label:
|
|
4169
|
-
value: i.fontFamily[
|
|
4170
|
-
onChange: (_) =>
|
|
4137
|
+
label: b,
|
|
4138
|
+
value: i.fontFamily[b.replace(/font-/g, "")] || k[Object.keys(k)[0]],
|
|
4139
|
+
onChange: (_) => m(b, _)
|
|
4171
4140
|
},
|
|
4172
|
-
|
|
4141
|
+
b
|
|
4173
4142
|
)) }),
|
|
4174
4143
|
(d == null ? void 0 : d.borderRadius) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4175
4144
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-sm text-slate-800", children: p("Border Radius") }),
|
|
4176
4145
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4177
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(BorderRadiusInput, { value: i.borderRadius, onChange:
|
|
4146
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(BorderRadiusInput, { value: i.borderRadius, onChange: g }),
|
|
4178
4147
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-12 text-sm", children: i.borderRadius })
|
|
4179
4148
|
] })
|
|
4180
4149
|
] }),
|
|
4181
4150
|
(d == null ? void 0 : d.colors) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4182
4151
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-sm text-slate-800", children: p("Colors") }),
|
|
4183
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full space-y-4 pt-2", children: d.colors.map((
|
|
4152
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full space-y-4 pt-2", children: d.colors.map((b) => y(b)) }, r ? "dark" : "light")
|
|
4184
4153
|
] })
|
|
4185
4154
|
] }),
|
|
4186
4155
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -4404,26 +4373,26 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4404
4373
|
var I;
|
|
4405
4374
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
4406
4375
|
let p = null;
|
|
4407
|
-
const u = o.children.length > 0, { highlightBlock: x, clearHighlight:
|
|
4408
|
-
T.stopPropagation(), !i.includes(
|
|
4376
|
+
const u = o.children.length > 0, { highlightBlock: x, clearHighlight: m } = useBlockHighlight(), { id: g, data: E, isSelected: y, willReceiveDrop: b, isDragging: k, isEditing: _, handleClick: A } = o, S = (T) => {
|
|
4377
|
+
T.stopPropagation(), !i.includes(g) && o.toggle();
|
|
4409
4378
|
}, v = (T) => {
|
|
4410
4379
|
T.isInternal && (p = T.isOpen, T.isOpen && T.close());
|
|
4411
4380
|
}, R = (T) => {
|
|
4412
4381
|
T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
|
|
4413
|
-
}, [
|
|
4382
|
+
}, [h, j] = useAtom$1(currentAddSelection), w = () => {
|
|
4414
4383
|
var T;
|
|
4415
|
-
|
|
4416
|
-
},
|
|
4384
|
+
f(), o.parent.isSelected || j((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
|
|
4385
|
+
}, f = () => {
|
|
4417
4386
|
j(null);
|
|
4418
4387
|
}, C = (T) => {
|
|
4419
|
-
|
|
4388
|
+
f(), T.stopPropagation(), !o.isOpen && !i.includes(g) && o.toggle(), A(T);
|
|
4420
4389
|
};
|
|
4421
4390
|
useEffect(() => {
|
|
4422
4391
|
const T = setTimeout(() => {
|
|
4423
|
-
|
|
4392
|
+
b && !o.isOpen && !k && !i.includes(g) && o.toggle();
|
|
4424
4393
|
}, 500);
|
|
4425
4394
|
return () => clearTimeout(T);
|
|
4426
|
-
}, [
|
|
4395
|
+
}, [b, o, k]);
|
|
4427
4396
|
const B = useMemo(() => {
|
|
4428
4397
|
const T = Object.keys(E), L = [];
|
|
4429
4398
|
for (let P = 0; P < T.length; P++)
|
|
@@ -4438,11 +4407,11 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4438
4407
|
const $ = M.getBoundingClientRect(), H = d.getBoundingClientRect();
|
|
4439
4408
|
$.top >= H.top && $.left >= H.left && $.bottom <= H.bottom && $.right <= H.right || (P.documentElement.scrollTop = M.offsetTop - H.top);
|
|
4440
4409
|
}, D = (T) => {
|
|
4441
|
-
|
|
4410
|
+
f();
|
|
4442
4411
|
const L = get(o, "parent.id");
|
|
4443
4412
|
L !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: L, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
|
|
4444
4413
|
};
|
|
4445
|
-
return
|
|
4414
|
+
return g === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
4446
4415
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
4447
4416
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4448
4417
|
"div",
|
|
@@ -4457,25 +4426,25 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4457
4426
|
}
|
|
4458
4427
|
),
|
|
4459
4428
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
|
|
4460
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id:
|
|
4429
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id: g, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4461
4430
|
"div",
|
|
4462
4431
|
{
|
|
4463
|
-
onMouseEnter: () => x(
|
|
4464
|
-
onMouseLeave: () =>
|
|
4432
|
+
onMouseEnter: () => x(g),
|
|
4433
|
+
onMouseLeave: () => m(),
|
|
4465
4434
|
onClick: C,
|
|
4466
4435
|
style: r,
|
|
4467
|
-
"data-node-id":
|
|
4468
|
-
ref: i.includes(
|
|
4436
|
+
"data-node-id": g,
|
|
4437
|
+
ref: i.includes(g) ? null : n,
|
|
4469
4438
|
onDragStart: () => v(o),
|
|
4470
4439
|
onDragEnd: () => R(o),
|
|
4471
4440
|
onDragOver: (T) => {
|
|
4472
|
-
T.preventDefault(), N(
|
|
4441
|
+
T.preventDefault(), N(g, "yes");
|
|
4473
4442
|
},
|
|
4474
4443
|
onDragLeave: (T) => {
|
|
4475
|
-
T.preventDefault(), N(
|
|
4444
|
+
T.preventDefault(), N(g, "no");
|
|
4476
4445
|
},
|
|
4477
4446
|
onDrop: (T) => {
|
|
4478
|
-
T.preventDefault(), N(
|
|
4447
|
+
T.preventDefault(), N(g, "no");
|
|
4479
4448
|
},
|
|
4480
4449
|
children: [
|
|
4481
4450
|
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((I = o == null ? void 0 : o.parent) == null ? void 0 : I.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -4485,7 +4454,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4485
4454
|
T.stopPropagation(), D(o.childIndex);
|
|
4486
4455
|
},
|
|
4487
4456
|
onMouseEnter: w,
|
|
4488
|
-
onMouseLeave:
|
|
4457
|
+
onMouseLeave: f,
|
|
4489
4458
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
4490
4459
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
|
|
4491
4460
|
}
|
|
@@ -4496,10 +4465,10 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4496
4465
|
className: cn(
|
|
4497
4466
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
4498
4467
|
y ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
4499
|
-
|
|
4500
|
-
(o == null ? void 0 : o.id) ===
|
|
4468
|
+
b && canAcceptChildBlock(E._type, "Icon") ? "bg-green-200" : "",
|
|
4469
|
+
(o == null ? void 0 : o.id) === h ? "bg-purple-100" : "",
|
|
4501
4470
|
k && "opacity-20",
|
|
4502
|
-
i.includes(
|
|
4471
|
+
i.includes(g) ? "opacity-50" : ""
|
|
4503
4472
|
),
|
|
4504
4473
|
children: [
|
|
4505
4474
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
|
@@ -4535,22 +4504,22 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4535
4504
|
] })
|
|
4536
4505
|
] }),
|
|
4537
4506
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
4538
|
-
!i.includes(
|
|
4507
|
+
!i.includes(g) && a.map((T) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
4539
4508
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4540
4509
|
TooltipTrigger,
|
|
4541
4510
|
{
|
|
4542
4511
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
4543
4512
|
asChild: !0,
|
|
4544
|
-
children: React__default.createElement(T.item, { blockId:
|
|
4513
|
+
children: React__default.createElement(T.item, { blockId: g })
|
|
4545
4514
|
}
|
|
4546
4515
|
),
|
|
4547
4516
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: T.tooltip })
|
|
4548
4517
|
] })),
|
|
4549
|
-
canAddChildBlock(E == null ? void 0 : E._type) && !i.includes(
|
|
4518
|
+
canAddChildBlock(E == null ? void 0 : E._type) && !i.includes(g) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
4550
4519
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4551
4520
|
TooltipTrigger,
|
|
4552
4521
|
{
|
|
4553
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
4522
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: g }),
|
|
4554
4523
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
4555
4524
|
asChild: !0,
|
|
4556
4525
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { size: "15" })
|
|
@@ -4563,7 +4532,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4563
4532
|
TooltipTrigger,
|
|
4564
4533
|
{
|
|
4565
4534
|
onClick: (T) => {
|
|
4566
|
-
T.stopPropagation(), c(
|
|
4535
|
+
T.stopPropagation(), c(g), o.isOpen && o.toggle();
|
|
4567
4536
|
},
|
|
4568
4537
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
4569
4538
|
asChild: !0,
|
|
@@ -4921,7 +4890,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4921
4890
|
}
|
|
4922
4891
|
}
|
|
4923
4892
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
4924
|
-
var
|
|
4893
|
+
var m, g, E, y, b, k, _, A;
|
|
4925
4894
|
if (n.type === "comment") return [];
|
|
4926
4895
|
console.log("node ===>", n);
|
|
4927
4896
|
let a = { _id: generateUUID() };
|
|
@@ -4962,10 +4931,10 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4962
4931
|
];
|
|
4963
4932
|
a = {
|
|
4964
4933
|
...a,
|
|
4965
|
-
href: ((
|
|
4966
|
-
hrefType: ((
|
|
4934
|
+
href: ((m = l.find((v) => v.key === "href")) == null ? void 0 : m.value) || "",
|
|
4935
|
+
hrefType: ((g = l.find((v) => v.key === "data-vbtype")) == null ? void 0 : g.value) || "video",
|
|
4967
4936
|
autoplay: ((E = l.find((v) => v.key === "data-autoplay")) == null ? void 0 : E.value) === "true" ? "true" : "false",
|
|
4968
|
-
maxWidth: ((
|
|
4937
|
+
maxWidth: ((b = (y = l.find((v) => v.key === "data-maxwidth")) == null ? void 0 : y.value) == null ? void 0 : b.replace("px", "")) || "",
|
|
4969
4938
|
backdropColor: ((k = l.find((v) => v.key === "data-overlay")) == null ? void 0 : k.value) || "",
|
|
4970
4939
|
galleryName: ((_ = l.find((v) => v.key === "data-gall")) == null ? void 0 : _.value) || ""
|
|
4971
4940
|
}, forEach(S, (v) => {
|
|
@@ -4978,14 +4947,14 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4978
4947
|
a.content = getTextContent(S);
|
|
4979
4948
|
const v = find(
|
|
4980
4949
|
n.children || [],
|
|
4981
|
-
(R) => (R == null ? void 0 : R.tagName) === "span" && some(R.children || [], (
|
|
4950
|
+
(R) => (R == null ? void 0 : R.tagName) === "span" && some(R.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
|
|
4982
4951
|
);
|
|
4983
4952
|
if (v) {
|
|
4984
|
-
const R = find(v.children || [], (
|
|
4953
|
+
const R = find(v.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
|
|
4985
4954
|
if (R) {
|
|
4986
4955
|
a.icon = stringify([R]);
|
|
4987
|
-
const { height:
|
|
4988
|
-
a.iconHeight =
|
|
4956
|
+
const { height: h, width: j } = getSvgDimensions(R, "16px", "16px");
|
|
4957
|
+
a.iconHeight = h, a.iconWidth = j;
|
|
4989
4958
|
}
|
|
4990
4959
|
}
|
|
4991
4960
|
return [a];
|
|
@@ -4997,8 +4966,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
4997
4966
|
const S = stringify([n]);
|
|
4998
4967
|
return hasVideoEmbed(S) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(S)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = S, [a];
|
|
4999
4968
|
} else if (n.tagName === "svg") {
|
|
5000
|
-
const S = find(n.attributes, { key: "height" }), v = find(n.attributes, { key: "width" }), R = get(S, "value") ? `[${get(S, "value")}px]` : "24px",
|
|
5001
|
-
return a.styles = `${STYLES_KEY}, ${cn(`w-${
|
|
4969
|
+
const S = find(n.attributes, { key: "height" }), v = find(n.attributes, { key: "width" }), R = get(S, "value") ? `[${get(S, "value")}px]` : "24px", h = get(v, "value") ? `[${get(v, "value")}px]` : "24px", j = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
|
|
4970
|
+
return a.styles = `${STYLES_KEY}, ${cn(`w-${h} h-${R}`, j)}`.trim(), n.attributes = filter(n.attributes, (w) => !includes(["style", "width", "height", "class"], w.key)), a.icon = stringify([n]), [a];
|
|
5002
4971
|
} else if (n.tagName == "option" && r && ((A = r.block) == null ? void 0 : A._type) === "Select")
|
|
5003
4972
|
return r.block.options.push({
|
|
5004
4973
|
label: getTextContent(n.children),
|
|
@@ -5047,6 +5016,37 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
|
|
|
5047
5016
|
] }) }),
|
|
5048
5017
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: a.trim() === "", onClick: () => c(), size: "sm", className: "w-fit", children: n("Import HTML") }) })
|
|
5049
5018
|
] });
|
|
5019
|
+
}, GlobalBlockSettings = () => {
|
|
5020
|
+
const o = useSelectedBlock(), { data: r, refetch: n, isLoading: a } = useGlobalBlocksList(), l = useUpdateBlocksProps();
|
|
5021
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
5022
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-sm", children: "Choose a global block" }),
|
|
5023
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5024
|
+
"select",
|
|
5025
|
+
{
|
|
5026
|
+
className: "h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",
|
|
5027
|
+
value: (o == null ? void 0 : o.globalBlock) || "",
|
|
5028
|
+
onChange: (i) => {
|
|
5029
|
+
var c;
|
|
5030
|
+
l([o._id], {
|
|
5031
|
+
globalBlock: i.target.value,
|
|
5032
|
+
_name: `Global: ${startCase((c = get(r, i.target.value, "")) == null ? void 0 : c.name)}`
|
|
5033
|
+
});
|
|
5034
|
+
},
|
|
5035
|
+
children: [
|
|
5036
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select a global block" }),
|
|
5037
|
+
Object.keys(r).map((i) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: i, children: r[i].name || i }, i))
|
|
5038
|
+
]
|
|
5039
|
+
}
|
|
5040
|
+
),
|
|
5041
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5042
|
+
"button",
|
|
5043
|
+
{
|
|
5044
|
+
onClick: n,
|
|
5045
|
+
className: "rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",
|
|
5046
|
+
children: a ? "Loading..." : "Refresh List"
|
|
5047
|
+
}
|
|
5048
|
+
) })
|
|
5049
|
+
] });
|
|
5050
5050
|
}, BindingWidget = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100", children: "Data binding is set for this field" }), getSvgMarkup = (o) => {
|
|
5051
5051
|
try {
|
|
5052
5052
|
const r = document.getElementById("icon-picker-field"), n = document.createElement("div");
|
|
@@ -5195,73 +5195,73 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
5195
5195
|
onChange: n
|
|
5196
5196
|
}) => {
|
|
5197
5197
|
var w;
|
|
5198
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (
|
|
5198
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (f, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, x] = useState("page"), [m, g] = useState(""), [E, y] = useState([]), [b, k] = useState(-1), _ = useRef(null), A = (w = r == null ? void 0 : r.find((f) => f.key === u)) == null ? void 0 : w.name;
|
|
5199
5199
|
useEffect(() => {
|
|
5200
|
-
if (
|
|
5201
|
-
const
|
|
5200
|
+
if (g(""), y([]), k(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
5201
|
+
const f = split(o, ":"), C = get(f, 1, "page") || "page";
|
|
5202
5202
|
x(C), (async () => {
|
|
5203
|
-
const B = await l(C, [get(
|
|
5204
|
-
B && Array.isArray(B) &&
|
|
5203
|
+
const B = await l(C, [get(f, 2, "page")]);
|
|
5204
|
+
B && Array.isArray(B) && g(get(B, [0, "name"], ""));
|
|
5205
5205
|
})();
|
|
5206
5206
|
}, [o]);
|
|
5207
5207
|
const S = useDebouncedCallback(
|
|
5208
|
-
async (
|
|
5209
|
-
if (isEmpty(
|
|
5208
|
+
async (f) => {
|
|
5209
|
+
if (isEmpty(f))
|
|
5210
5210
|
y([]);
|
|
5211
5211
|
else {
|
|
5212
|
-
const C = await l(u,
|
|
5212
|
+
const C = await l(u, f);
|
|
5213
5213
|
y(C);
|
|
5214
5214
|
}
|
|
5215
5215
|
c(!1), k(-1);
|
|
5216
5216
|
},
|
|
5217
5217
|
[u],
|
|
5218
5218
|
300
|
|
5219
|
-
), v = (
|
|
5220
|
-
const C = ["pageType", u,
|
|
5221
|
-
C[1] && (n(C.join(":")),
|
|
5222
|
-
}, R = (
|
|
5223
|
-
switch (
|
|
5219
|
+
), v = (f) => {
|
|
5220
|
+
const C = ["pageType", u, f.id];
|
|
5221
|
+
C[1] && (n(C.join(":")), g(f.name), p(!1), y([]), k(-1));
|
|
5222
|
+
}, R = (f) => {
|
|
5223
|
+
switch (f.key) {
|
|
5224
5224
|
case "ArrowDown":
|
|
5225
|
-
|
|
5225
|
+
f.preventDefault(), k((C) => C < E.length - 1 ? C + 1 : C);
|
|
5226
5226
|
break;
|
|
5227
5227
|
case "ArrowUp":
|
|
5228
|
-
|
|
5228
|
+
f.preventDefault(), k((C) => C > 0 ? C - 1 : C);
|
|
5229
5229
|
break;
|
|
5230
5230
|
case "Enter":
|
|
5231
|
-
if (
|
|
5232
|
-
|
|
5231
|
+
if (f.preventDefault(), E.length === 0) return;
|
|
5232
|
+
b >= 0 && v(E[b]);
|
|
5233
5233
|
break;
|
|
5234
5234
|
case "Escape":
|
|
5235
|
-
|
|
5235
|
+
f.preventDefault(), h();
|
|
5236
5236
|
break;
|
|
5237
5237
|
}
|
|
5238
5238
|
};
|
|
5239
5239
|
useEffect(() => {
|
|
5240
|
-
if (
|
|
5241
|
-
const
|
|
5242
|
-
|
|
5240
|
+
if (b >= 0 && _.current) {
|
|
5241
|
+
const f = _.current.children[b];
|
|
5242
|
+
f == null || f.scrollIntoView({ block: "nearest" });
|
|
5243
5243
|
}
|
|
5244
|
-
}, [
|
|
5245
|
-
const
|
|
5246
|
-
|
|
5247
|
-
}, j = (
|
|
5248
|
-
|
|
5244
|
+
}, [b]);
|
|
5245
|
+
const h = () => {
|
|
5246
|
+
g(""), y([]), k(-1), p(!1), n("");
|
|
5247
|
+
}, j = (f) => {
|
|
5248
|
+
g(f), p(!isEmpty(f)), c(!0), S(f);
|
|
5249
5249
|
};
|
|
5250
5250
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
5251
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "pageType", value: u, onChange: (
|
|
5251
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "pageType", value: u, onChange: (f) => x(f.target.value), children: map(r, (f) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: f.key, children: f.name }, f.key)) }),
|
|
5252
5252
|
u && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group relative mt-2 flex items-center", children: [
|
|
5253
5253
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5254
5254
|
"input",
|
|
5255
5255
|
{
|
|
5256
5256
|
type: "text",
|
|
5257
|
-
value:
|
|
5258
|
-
onChange: (
|
|
5257
|
+
value: m,
|
|
5258
|
+
onChange: (f) => j(f.target.value),
|
|
5259
5259
|
onKeyDown: R,
|
|
5260
5260
|
placeholder: a(`Search ${A ?? ""}`),
|
|
5261
5261
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
5262
5262
|
}
|
|
5263
5263
|
),
|
|
5264
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
5264
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: h, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-4 w-4" }) }) })
|
|
5265
5265
|
] }),
|
|
5266
5266
|
(i || !isEmpty(E) || d && isEmpty(E)) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1 p-2", children: [
|
|
5267
5267
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -5269,24 +5269,24 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
5269
5269
|
] }) : d && isEmpty(E) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
5270
5270
|
a("No results found for"),
|
|
5271
5271
|
' "',
|
|
5272
|
-
|
|
5272
|
+
m,
|
|
5273
5273
|
'"'
|
|
5274
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: _, children: map(E == null ? void 0 : E.slice(0, 20), (
|
|
5274
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: _, children: map(E == null ? void 0 : E.slice(0, 20), (f, C) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5275
5275
|
"li",
|
|
5276
5276
|
{
|
|
5277
|
-
onClick: () => v(
|
|
5278
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(
|
|
5277
|
+
onClick: () => v(f),
|
|
5278
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(f.id) ? "bg-blue-200" : C === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
5279
5279
|
children: [
|
|
5280
|
-
|
|
5280
|
+
f.name,
|
|
5281
5281
|
" ",
|
|
5282
|
-
|
|
5282
|
+
f.slug && /* @__PURE__ */ jsxRuntimeExports.jsxs("small", { className: "font-light text-gray-500", children: [
|
|
5283
5283
|
"( ",
|
|
5284
|
-
|
|
5284
|
+
f.slug,
|
|
5285
5285
|
" )"
|
|
5286
5286
|
] })
|
|
5287
5287
|
]
|
|
5288
5288
|
},
|
|
5289
|
-
|
|
5289
|
+
f.id
|
|
5290
5290
|
)) }) })
|
|
5291
5291
|
] });
|
|
5292
5292
|
}, LinkField = ({ schema: o, formData: r, onChange: n }) => {
|
|
@@ -5388,11 +5388,11 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
5388
5388
|
schema: u,
|
|
5389
5389
|
formData: x
|
|
5390
5390
|
}) => {
|
|
5391
|
-
const { selectedLang:
|
|
5391
|
+
const { selectedLang: m, fallbackLang: g, languages: E } = useLanguages(), y = isEmpty(E) ? "" : isEmpty(m) ? g : m, b = get(LANGUAGES, y, y), k = useSelectedBlock(), _ = useRegisteredChaiBlocks(), A = get(_, [k == null ? void 0 : k._type, "i18nProps"], []) || [], [S, v] = useState(null);
|
|
5392
5392
|
if (d)
|
|
5393
5393
|
return null;
|
|
5394
5394
|
if (u.type === "boolean") return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: r, children: a });
|
|
5395
|
-
const
|
|
5395
|
+
const h = A == null ? void 0 : A.includes(o.replace("root.", ""));
|
|
5396
5396
|
if (u.type === "array") {
|
|
5397
5397
|
const j = S === o;
|
|
5398
5398
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${r} relative`, children: [
|
|
@@ -5423,9 +5423,9 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
5423
5423
|
u.title && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
|
|
5424
5424
|
n,
|
|
5425
5425
|
" ",
|
|
5426
|
-
|
|
5426
|
+
h && /* @__PURE__ */ jsxRuntimeExports.jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5427
5427
|
" ",
|
|
5428
|
-
|
|
5428
|
+
b
|
|
5429
5429
|
] }),
|
|
5430
5430
|
p && u.type !== "object" ? " *" : null
|
|
5431
5431
|
] }),
|
|
@@ -5486,62 +5486,7 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
5486
5486
|
},
|
|
5487
5487
|
d
|
|
5488
5488
|
);
|
|
5489
|
-
}),
|
|
5490
|
-
const [o, r] = useAtom$1(xShowBlocksAtom), n = useSelectedBlock(), [, a] = useSelectedBlockIds(), { t: l } = useTranslation(), i = useMemo(() => (n ? JSON.stringify(n) : "").includes('"x-show"'), [n]);
|
|
5491
|
-
if (!n || !i) return null;
|
|
5492
|
-
const c = o.includes(n._id);
|
|
5493
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "py-2 text-xs hover:no-underline", children: [
|
|
5494
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2 border-b border-border bg-background py-2 font-normal text-muted-foreground", children: [
|
|
5495
|
-
n._name || n._type,
|
|
5496
|
-
" ",
|
|
5497
|
-
l("Visibility settings")
|
|
5498
|
-
] }),
|
|
5499
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2 pt-2", children: [
|
|
5500
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5501
|
-
Switch,
|
|
5502
|
-
{
|
|
5503
|
-
id: "show-on-canvas",
|
|
5504
|
-
checked: c,
|
|
5505
|
-
onCheckedChange: (d) => {
|
|
5506
|
-
d ? (r((p) => [...p, n._id]), a([n._id])) : r((p) => p.filter((u) => u !== n._id));
|
|
5507
|
-
}
|
|
5508
|
-
}
|
|
5509
|
-
),
|
|
5510
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "show-on-canvas", children: l("Show on canvas") })
|
|
5511
|
-
] })
|
|
5512
|
-
] });
|
|
5513
|
-
}, GlobalBlockSettings = () => {
|
|
5514
|
-
const o = useSelectedBlock(), { data: r, refetch: n, isLoading: a } = useGlobalBlocksList(), l = useUpdateBlocksProps();
|
|
5515
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
5516
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "text-sm", children: "Choose a global block" }),
|
|
5517
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5518
|
-
"select",
|
|
5519
|
-
{
|
|
5520
|
-
className: "h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",
|
|
5521
|
-
value: (o == null ? void 0 : o.globalBlock) || "",
|
|
5522
|
-
onChange: (i) => {
|
|
5523
|
-
var c;
|
|
5524
|
-
l([o._id], {
|
|
5525
|
-
globalBlock: i.target.value,
|
|
5526
|
-
_name: `Global: ${startCase((c = get(r, i.target.value, "")) == null ? void 0 : c.name)}`
|
|
5527
|
-
});
|
|
5528
|
-
},
|
|
5529
|
-
children: [
|
|
5530
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select a global block" }),
|
|
5531
|
-
Object.keys(r).map((i) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: i, children: r[i].name || i }, i))
|
|
5532
|
-
]
|
|
5533
|
-
}
|
|
5534
|
-
),
|
|
5535
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5536
|
-
"button",
|
|
5537
|
-
{
|
|
5538
|
-
onClick: n,
|
|
5539
|
-
className: "rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",
|
|
5540
|
-
children: a ? "Loading..." : "Refresh List"
|
|
5541
|
-
}
|
|
5542
|
-
) })
|
|
5543
|
-
] });
|
|
5544
|
-
}, formDataWithSelectedLang = (o, r, n) => {
|
|
5489
|
+
}), formDataWithSelectedLang = (o, r, n) => {
|
|
5545
5490
|
const a = cloneDeep(o);
|
|
5546
5491
|
return forEach(keys(o), (l) => {
|
|
5547
5492
|
includes(get(n, "i18nProps", []), l) && !isEmpty(r) && (a[l] = get(o, `${l}-${r}`));
|
|
@@ -5551,31 +5496,31 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
5551
5496
|
return set(n, o, r), n;
|
|
5552
5497
|
};
|
|
5553
5498
|
function BlockSettings() {
|
|
5554
|
-
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), x = useWrapperBlock(),
|
|
5555
|
-
if (
|
|
5556
|
-
const w =
|
|
5499
|
+
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), x = useWrapperBlock(), m = getRegisteredChaiBlock(x == null ? void 0 : x._type), g = formDataWithSelectedLang(x, o, m), E = ({ formData: R }, h, j) => {
|
|
5500
|
+
if (h && (c == null ? void 0 : c._id) === r._id) {
|
|
5501
|
+
const w = h.replace("root.", "");
|
|
5557
5502
|
a([r._id], { [w]: get(R, w) }, j);
|
|
5558
5503
|
}
|
|
5559
5504
|
}, y = useCallback(
|
|
5560
|
-
debounce(({ formData: R },
|
|
5561
|
-
E({ formData: R },
|
|
5505
|
+
debounce(({ formData: R }, h, j) => {
|
|
5506
|
+
E({ formData: R }, h, j), d(R);
|
|
5562
5507
|
}, 1500),
|
|
5563
5508
|
[r == null ? void 0 : r._id, o]
|
|
5564
|
-
),
|
|
5565
|
-
if (
|
|
5566
|
-
const j =
|
|
5509
|
+
), b = ({ formData: R }, h) => {
|
|
5510
|
+
if (h) {
|
|
5511
|
+
const j = h.replace("root.", "");
|
|
5567
5512
|
n(
|
|
5568
5513
|
[r._id],
|
|
5569
5514
|
convertDotNotationToObject(j, get(R, j.split(".")))
|
|
5570
|
-
), y({ formData: R },
|
|
5515
|
+
), y({ formData: R }, h, { [j]: get(c, j) });
|
|
5571
5516
|
}
|
|
5572
|
-
}, k = ({ formData: R },
|
|
5573
|
-
if (
|
|
5574
|
-
const j =
|
|
5517
|
+
}, k = ({ formData: R }, h) => {
|
|
5518
|
+
if (h) {
|
|
5519
|
+
const j = h.replace("root.", "");
|
|
5575
5520
|
n(
|
|
5576
5521
|
[x._id],
|
|
5577
5522
|
convertDotNotationToObject(j, get(R, j.split(".")))
|
|
5578
|
-
), y({ formData: R },
|
|
5523
|
+
), y({ formData: R }, h, { [j]: get(c, j) });
|
|
5579
5524
|
}
|
|
5580
5525
|
};
|
|
5581
5526
|
keys(get(i, "_bindings", {}));
|
|
@@ -5586,8 +5531,8 @@ function BlockSettings() {
|
|
|
5586
5531
|
}, [r]), { wrapperSchema: S, wrapperUiSchema: v } = useMemo(() => {
|
|
5587
5532
|
if (!x || !(x != null && x._type))
|
|
5588
5533
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5589
|
-
const R = x == null ? void 0 : x._type, { schema:
|
|
5590
|
-
return { wrapperSchema:
|
|
5534
|
+
const R = x == null ? void 0 : x._type, { schema: h = {}, uiSchema: j = {} } = getBlockFormSchemas(R);
|
|
5535
|
+
return { wrapperSchema: h, wrapperUiSchema: j };
|
|
5591
5536
|
}, [x]);
|
|
5592
5537
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5593
5538
|
!isEmpty(x) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
@@ -5614,7 +5559,7 @@ function BlockSettings() {
|
|
|
5614
5559
|
{
|
|
5615
5560
|
id: x == null ? void 0 : x._id,
|
|
5616
5561
|
onChange: k,
|
|
5617
|
-
formData:
|
|
5562
|
+
formData: g,
|
|
5618
5563
|
schema: S,
|
|
5619
5564
|
uiSchema: v
|
|
5620
5565
|
}
|
|
@@ -5624,14 +5569,13 @@ function BlockSettings() {
|
|
|
5624
5569
|
JSONForm,
|
|
5625
5570
|
{
|
|
5626
5571
|
id: r == null ? void 0 : r._id,
|
|
5627
|
-
onChange:
|
|
5572
|
+
onChange: b,
|
|
5628
5573
|
formData: i,
|
|
5629
5574
|
schema: _,
|
|
5630
5575
|
uiSchema: A
|
|
5631
5576
|
}
|
|
5632
5577
|
),
|
|
5633
|
-
(r == null ? void 0 : r._type) === "GlobalBlock" ? /* @__PURE__ */ jsxRuntimeExports.jsx(GlobalBlockSettings, {}) : null
|
|
5634
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(CanvasSettings, {})
|
|
5578
|
+
(r == null ? void 0 : r._type) === "GlobalBlock" ? /* @__PURE__ */ jsxRuntimeExports.jsx(GlobalBlockSettings, {}) : null
|
|
5635
5579
|
] });
|
|
5636
5580
|
}
|
|
5637
5581
|
function FaLanguage(o) {
|
|
@@ -5700,11 +5644,11 @@ function Countdown() {
|
|
|
5700
5644
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5701
5645
|
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, x] = useState();
|
|
5702
5646
|
useEffect(() => {
|
|
5703
|
-
var
|
|
5704
|
-
(
|
|
5647
|
+
var g;
|
|
5648
|
+
(g = d.current) == null || g.focus();
|
|
5705
5649
|
}, []);
|
|
5706
|
-
const
|
|
5707
|
-
const { usage: E } =
|
|
5650
|
+
const m = (g) => {
|
|
5651
|
+
const { usage: E } = g || {};
|
|
5708
5652
|
!l && E && x(E), p.current = setTimeout(() => x(void 0), 1e4), l || c("");
|
|
5709
5653
|
};
|
|
5710
5654
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
|
|
@@ -5714,12 +5658,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5714
5658
|
{
|
|
5715
5659
|
ref: d,
|
|
5716
5660
|
value: i,
|
|
5717
|
-
onChange: (
|
|
5661
|
+
onChange: (g) => c(g.target.value),
|
|
5718
5662
|
placeholder: r("Ask AI to edit styles"),
|
|
5719
5663
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5720
5664
|
rows: 4,
|
|
5721
|
-
onKeyDown: (
|
|
5722
|
-
|
|
5665
|
+
onKeyDown: (g) => {
|
|
5666
|
+
g.key === "Enter" && (g.preventDefault(), p.current && clearTimeout(p.current), x(void 0), n("styles", o, i, m));
|
|
5723
5667
|
}
|
|
5724
5668
|
}
|
|
5725
5669
|
),
|
|
@@ -5729,7 +5673,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5729
5673
|
{
|
|
5730
5674
|
disabled: i.trim().length < 5 || a,
|
|
5731
5675
|
onClick: () => {
|
|
5732
|
-
p.current && clearTimeout(p.current), x(void 0), n("styles", o, i,
|
|
5676
|
+
p.current && clearTimeout(p.current), x(void 0), n("styles", o, i, m);
|
|
5733
5677
|
},
|
|
5734
5678
|
variant: "default",
|
|
5735
5679
|
className: "w-fit",
|
|
@@ -5760,24 +5704,24 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5760
5704
|
] });
|
|
5761
5705
|
};
|
|
5762
5706
|
function ManualClasses() {
|
|
5763
|
-
var
|
|
5764
|
-
const o = useFuseSearch(), { t: r } = useTranslation(), [n] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(),
|
|
5707
|
+
var h;
|
|
5708
|
+
const o = useFuseSearch(), { t: r } = useTranslation(), [n] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(), m = (h = first(n)) == null ? void 0 : h.prop, g = reject((get(a, m, "").replace(STYLES_KEY, "").split(",").pop() || "").split(" "), isEmpty), E = () => {
|
|
5765
5709
|
const j = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5766
5710
|
l(c, j, !0), u("");
|
|
5767
|
-
}, [y,
|
|
5768
|
-
const w = j.trim().toLowerCase(),
|
|
5711
|
+
}, [y, b] = useState([]), k = ({ value: j }) => {
|
|
5712
|
+
const w = j.trim().toLowerCase(), f = w.match(/.+:/g);
|
|
5769
5713
|
let C = [];
|
|
5770
|
-
if (
|
|
5771
|
-
const [B] =
|
|
5714
|
+
if (f && f.length > 0) {
|
|
5715
|
+
const [B] = f, N = w.replace(B, "");
|
|
5772
5716
|
C = o.search(N).map((I) => ({
|
|
5773
5717
|
...I,
|
|
5774
5718
|
item: { ...I.item, name: B + I.item.name }
|
|
5775
5719
|
}));
|
|
5776
5720
|
} else
|
|
5777
5721
|
C = o.search(w);
|
|
5778
|
-
return
|
|
5722
|
+
return b(map(C, "item"));
|
|
5779
5723
|
}, _ = () => {
|
|
5780
|
-
|
|
5724
|
+
b([]);
|
|
5781
5725
|
}, A = (j) => j.name, S = (j) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md p-1", children: j.name }), v = {
|
|
5782
5726
|
autoComplete: "off",
|
|
5783
5727
|
autoCorrect: "off",
|
|
@@ -5799,7 +5743,7 @@ function ManualClasses() {
|
|
|
5799
5743
|
});
|
|
5800
5744
|
return;
|
|
5801
5745
|
}
|
|
5802
|
-
navigator.clipboard.writeText(
|
|
5746
|
+
navigator.clipboard.writeText(g.join(" ")), x({
|
|
5803
5747
|
title: r("Copied"),
|
|
5804
5748
|
description: r("Classes copied to clipboard")
|
|
5805
5749
|
});
|
|
@@ -5858,7 +5802,7 @@ function ManualClasses() {
|
|
|
5858
5802
|
)
|
|
5859
5803
|
] }),
|
|
5860
5804
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: React.Children.toArray(
|
|
5861
|
-
|
|
5805
|
+
g.map((j) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5862
5806
|
"div",
|
|
5863
5807
|
{
|
|
5864
5808
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate 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",
|
|
@@ -6264,10 +6208,10 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6264
6208
|
ringColor: "ring",
|
|
6265
6209
|
ringOffsetColor: "ring-offset"
|
|
6266
6210
|
}, ColorChoice = ({ property: o, onChange: r }) => {
|
|
6267
|
-
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), x = get(u, "1", ""),
|
|
6211
|
+
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), x = get(u, "1", ""), m = get(u, "2", ""), g = useCallback(
|
|
6268
6212
|
// eslint-disable-next-line no-shadow
|
|
6269
|
-
(
|
|
6270
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
6213
|
+
(b) => {
|
|
6214
|
+
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((k) => ({ ...k, color: b, shade: k.shade ? k.shade : "500" })));
|
|
6271
6215
|
},
|
|
6272
6216
|
[c, p]
|
|
6273
6217
|
);
|
|
@@ -6278,8 +6222,8 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6278
6222
|
}, [x]);
|
|
6279
6223
|
const E = useCallback(
|
|
6280
6224
|
// eslint-disable-next-line no-shadow
|
|
6281
|
-
(
|
|
6282
|
-
p({ color: x, shade:
|
|
6225
|
+
(b) => {
|
|
6226
|
+
p({ color: x, shade: b });
|
|
6283
6227
|
},
|
|
6284
6228
|
[x]
|
|
6285
6229
|
);
|
|
@@ -6297,7 +6241,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6297
6241
|
disabled: !l,
|
|
6298
6242
|
rounded: !0,
|
|
6299
6243
|
selected: x,
|
|
6300
|
-
onChange:
|
|
6244
|
+
onChange: g,
|
|
6301
6245
|
options: [
|
|
6302
6246
|
"current",
|
|
6303
6247
|
"transparent",
|
|
@@ -6330,7 +6274,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6330
6274
|
]
|
|
6331
6275
|
}
|
|
6332
6276
|
) }),
|
|
6333
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected:
|
|
6277
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: m, disabled: !x || !l, onChange: E, options: i }) })
|
|
6334
6278
|
] });
|
|
6335
6279
|
}, getUserInputValues = (o, r) => {
|
|
6336
6280
|
o = o.toLowerCase();
|
|
@@ -6477,23 +6421,23 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6477
6421
|
},
|
|
6478
6422
|
a
|
|
6479
6423
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6480
|
-
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [
|
|
6424
|
+
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [m, g] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [E, y] = useState(!1), [b, k] = useState(""), [_, A] = useState(!1), [S, v] = useState(!1);
|
|
6481
6425
|
useEffect(() => {
|
|
6482
|
-
const { value:
|
|
6426
|
+
const { value: f, unit: C } = getClassValueAndUnit(i);
|
|
6483
6427
|
if (C === "") {
|
|
6484
|
-
l(
|
|
6428
|
+
l(f), g(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
6485
6429
|
return;
|
|
6486
6430
|
}
|
|
6487
|
-
|
|
6431
|
+
g(C), l(C === "class" || isEmpty(f) ? "" : f);
|
|
6488
6432
|
}, [i, p, u]);
|
|
6489
|
-
const R = useThrottledCallback((
|
|
6490
|
-
(
|
|
6433
|
+
const R = useThrottledCallback((f) => c(f), [c], THROTTLE_TIME), h = useThrottledCallback((f) => c(f, !1), [c], THROTTLE_TIME), j = useCallback(
|
|
6434
|
+
(f = !1) => {
|
|
6491
6435
|
const C = getUserInputValues(`${a}`, u);
|
|
6492
6436
|
if (get(C, "error", !1)) {
|
|
6493
6437
|
y(!0);
|
|
6494
6438
|
return;
|
|
6495
6439
|
}
|
|
6496
|
-
const B = get(C, "unit") !== "" ? get(C, "unit") :
|
|
6440
|
+
const B = get(C, "unit") !== "" ? get(C, "unit") : m;
|
|
6497
6441
|
if (B === "auto" || B === "none") {
|
|
6498
6442
|
R(`${d}${B}`);
|
|
6499
6443
|
return;
|
|
@@ -6501,28 +6445,28 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6501
6445
|
if (get(C, "value") === "")
|
|
6502
6446
|
return;
|
|
6503
6447
|
const D = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
|
|
6504
|
-
|
|
6448
|
+
f ? h(D) : R(D);
|
|
6505
6449
|
},
|
|
6506
|
-
[R,
|
|
6450
|
+
[R, h, a, m, d, u]
|
|
6507
6451
|
), w = useCallback(
|
|
6508
|
-
(
|
|
6452
|
+
(f) => {
|
|
6509
6453
|
const C = getUserInputValues(`${a}`, u);
|
|
6510
6454
|
if (get(C, "error", !1)) {
|
|
6511
6455
|
y(!0);
|
|
6512
6456
|
return;
|
|
6513
6457
|
}
|
|
6514
|
-
if (
|
|
6515
|
-
R(`${d}${
|
|
6458
|
+
if (f === "auto" || f === "none") {
|
|
6459
|
+
R(`${d}${f}`);
|
|
6516
6460
|
return;
|
|
6517
6461
|
}
|
|
6518
6462
|
if (get(C, "value") === "")
|
|
6519
6463
|
return;
|
|
6520
|
-
const B = get(C, "unit") !== "" ? get(C, "unit") :
|
|
6464
|
+
const B = get(C, "unit") !== "" ? get(C, "unit") : f, D = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
|
|
6521
6465
|
R(D);
|
|
6522
6466
|
},
|
|
6523
6467
|
[R, a, d, u]
|
|
6524
6468
|
);
|
|
6525
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children:
|
|
6469
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6526
6470
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6527
6471
|
"input",
|
|
6528
6472
|
{
|
|
@@ -6537,35 +6481,35 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6537
6481
|
] })
|
|
6538
6482
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${_ ? "z-auto" : ""}`, children: [
|
|
6539
6483
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6540
|
-
["none", "auto"].indexOf(
|
|
6484
|
+
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6541
6485
|
"input",
|
|
6542
6486
|
{
|
|
6543
|
-
readOnly:
|
|
6544
|
-
onKeyPress: (
|
|
6545
|
-
|
|
6487
|
+
readOnly: m === "class",
|
|
6488
|
+
onKeyPress: (f) => {
|
|
6489
|
+
f.key === "Enter" && j();
|
|
6546
6490
|
},
|
|
6547
|
-
onKeyDown: (
|
|
6548
|
-
if (
|
|
6491
|
+
onKeyDown: (f) => {
|
|
6492
|
+
if (f.keyCode !== 38 && f.keyCode !== 40)
|
|
6549
6493
|
return;
|
|
6550
|
-
|
|
6551
|
-
const C = parseInt$1(
|
|
6494
|
+
f.preventDefault(), v(!0);
|
|
6495
|
+
const C = parseInt$1(f.target.value);
|
|
6552
6496
|
let B = isNaN$1(C) ? 0 : C;
|
|
6553
|
-
|
|
6554
|
-
const N = `${B}`, I = `${N.startsWith("-") ? "-" : ""}${d}[${N.replace("-", "")}${
|
|
6555
|
-
|
|
6497
|
+
f.keyCode === 38 && (B += 1), f.keyCode === 40 && (B -= 1);
|
|
6498
|
+
const N = `${B}`, I = `${N.startsWith("-") ? "-" : ""}${d}[${N.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6499
|
+
h(I);
|
|
6556
6500
|
},
|
|
6557
|
-
onKeyUp: (
|
|
6558
|
-
S && (
|
|
6501
|
+
onKeyUp: (f) => {
|
|
6502
|
+
S && (f.preventDefault(), v(!1));
|
|
6559
6503
|
},
|
|
6560
6504
|
onBlur: () => j(),
|
|
6561
|
-
onChange: (
|
|
6562
|
-
y(!1), l(
|
|
6505
|
+
onChange: (f) => {
|
|
6506
|
+
y(!1), l(f.target.value);
|
|
6563
6507
|
},
|
|
6564
|
-
onClick: (
|
|
6508
|
+
onClick: (f) => {
|
|
6565
6509
|
var C;
|
|
6566
|
-
(C =
|
|
6510
|
+
(C = f == null ? void 0 : f.target) == null || C.select(), n(!1);
|
|
6567
6511
|
},
|
|
6568
|
-
value: _ ?
|
|
6512
|
+
value: _ ? b : a,
|
|
6569
6513
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6570
6514
|
" ",
|
|
6571
6515
|
E ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
@@ -6580,7 +6524,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6580
6524
|
onClick: () => n(!r),
|
|
6581
6525
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
6582
6526
|
children: [
|
|
6583
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
6527
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
|
|
6584
6528
|
u.length > 1 ? /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleDownIcon, {}) : null
|
|
6585
6529
|
]
|
|
6586
6530
|
}
|
|
@@ -6589,33 +6533,33 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6589
6533
|
UnitSelection,
|
|
6590
6534
|
{
|
|
6591
6535
|
units: u,
|
|
6592
|
-
current:
|
|
6593
|
-
onSelect: (
|
|
6594
|
-
n(!1),
|
|
6536
|
+
current: m,
|
|
6537
|
+
onSelect: (f) => {
|
|
6538
|
+
n(!1), g(f), w(f);
|
|
6595
6539
|
}
|
|
6596
6540
|
}
|
|
6597
6541
|
) }) })
|
|
6598
6542
|
] })
|
|
6599
6543
|
] }),
|
|
6600
|
-
["none", "auto"].indexOf(
|
|
6544
|
+
["none", "auto"].indexOf(m) !== -1 || _ ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6601
6545
|
DragStyleButton,
|
|
6602
6546
|
{
|
|
6603
6547
|
onDragStart: () => A(!0),
|
|
6604
|
-
onDragEnd: (
|
|
6605
|
-
if (k(() => ""), A(!1), isEmpty(
|
|
6548
|
+
onDragEnd: (f) => {
|
|
6549
|
+
if (k(() => ""), A(!1), isEmpty(f))
|
|
6606
6550
|
return;
|
|
6607
|
-
const C = `${
|
|
6551
|
+
const C = `${f}`, N = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6608
6552
|
R(N);
|
|
6609
6553
|
},
|
|
6610
|
-
onDrag: (
|
|
6611
|
-
if (isEmpty(
|
|
6554
|
+
onDrag: (f) => {
|
|
6555
|
+
if (isEmpty(f))
|
|
6612
6556
|
return;
|
|
6613
|
-
k(
|
|
6614
|
-
const C = `${
|
|
6615
|
-
|
|
6557
|
+
k(f);
|
|
6558
|
+
const C = `${f}`, N = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6559
|
+
h(N);
|
|
6616
6560
|
},
|
|
6617
6561
|
currentValue: a,
|
|
6618
|
-
unit:
|
|
6562
|
+
unit: m,
|
|
6619
6563
|
negative: x,
|
|
6620
6564
|
cssProperty: p
|
|
6621
6565
|
}
|
|
@@ -6709,22 +6653,22 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6709
6653
|
"2xl": "1536px"
|
|
6710
6654
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6711
6655
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6712
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(),
|
|
6713
|
-
(
|
|
6714
|
-
const w = { dark: p, mq: x, mod: u, cls:
|
|
6656
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(), m = useCurrentClassByProperty(l), g = useAddClassesToBlocks(), E = useRemoveClassesFromBlocks(), [y] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), k = useCallback(
|
|
6657
|
+
(h, j = !0) => {
|
|
6658
|
+
const w = { dark: p, mq: x, mod: u, cls: h, property: l, fullCls: "" };
|
|
6715
6659
|
(p || u !== "") && (w.mq = "xs");
|
|
6716
|
-
const
|
|
6717
|
-
|
|
6660
|
+
const f = generateFullClsName(w);
|
|
6661
|
+
g(y, [f], j);
|
|
6718
6662
|
},
|
|
6719
|
-
[y, p, x, u, l,
|
|
6663
|
+
[y, p, x, u, l, g]
|
|
6720
6664
|
), _ = useCallback(() => {
|
|
6721
|
-
E(y, [
|
|
6722
|
-
}, [y,
|
|
6665
|
+
E(y, [b]);
|
|
6666
|
+
}, [y, b, E]), A = useMemo(() => canChangeClass(m, x), [m, x]);
|
|
6723
6667
|
useEffect(() => {
|
|
6724
|
-
i(A,
|
|
6725
|
-
}, [A, i,
|
|
6668
|
+
i(A, m);
|
|
6669
|
+
}, [A, i, m]);
|
|
6726
6670
|
const [, , S] = useCanvasWidth(), v = useCallback(
|
|
6727
|
-
(
|
|
6671
|
+
(h) => {
|
|
6728
6672
|
S({
|
|
6729
6673
|
xs: 400,
|
|
6730
6674
|
sm: 640,
|
|
@@ -6732,18 +6676,18 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6732
6676
|
lg: 1024,
|
|
6733
6677
|
xl: 1420,
|
|
6734
6678
|
"2xl": 1920
|
|
6735
|
-
}[
|
|
6679
|
+
}[h]);
|
|
6736
6680
|
},
|
|
6737
6681
|
[S]
|
|
6738
|
-
), R = get(
|
|
6739
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: A, canReset:
|
|
6740
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${
|
|
6682
|
+
), R = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === x;
|
|
6683
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: A, canReset: m && R, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6684
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${m && !R ? "text-foreground" : ""}`, children: r(a) }) }),
|
|
6741
6685
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6742
6686
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-[150px]", children: [
|
|
6743
6687
|
n === "arbitrary" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6744
6688
|
AdvanceChoices,
|
|
6745
6689
|
{
|
|
6746
|
-
currentClass: get(
|
|
6690
|
+
currentClass: get(m, "cls", ""),
|
|
6747
6691
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6748
6692
|
units: c || [],
|
|
6749
6693
|
onChange: k,
|
|
@@ -6756,7 +6700,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6756
6700
|
n === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange: k }),
|
|
6757
6701
|
n === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange: k })
|
|
6758
6702
|
] }),
|
|
6759
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
6703
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: R ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => _(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : A && m ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6760
6704
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6761
6705
|
"button",
|
|
6762
6706
|
{
|
|
@@ -6768,19 +6712,19 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6768
6712
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
6769
6713
|
"Current style is set at ",
|
|
6770
6714
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold", children: [
|
|
6771
|
-
getBreakpoint(get(
|
|
6772
|
-
p && !
|
|
6715
|
+
getBreakpoint(get(m, "mq")),
|
|
6716
|
+
p && !m.dark ? "(Light mode)" : ""
|
|
6773
6717
|
] }),
|
|
6774
6718
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
6775
6719
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6776
6720
|
"button",
|
|
6777
6721
|
{
|
|
6778
6722
|
type: "button",
|
|
6779
|
-
onClick: () => v(get(
|
|
6723
|
+
onClick: () => v(get(m, "mq")),
|
|
6780
6724
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6781
6725
|
children: [
|
|
6782
6726
|
"Switch to ",
|
|
6783
|
-
get(
|
|
6727
|
+
get(m, "mq").toUpperCase()
|
|
6784
6728
|
]
|
|
6785
6729
|
}
|
|
6786
6730
|
)
|
|
@@ -6797,7 +6741,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6797
6741
|
units: i = basicUnits,
|
|
6798
6742
|
negative: c = !1
|
|
6799
6743
|
}) => {
|
|
6800
|
-
const { t: d } = useTranslation(), [p, u] = useState(r[0].key), x = useSelectedBlockCurrentClasses(),
|
|
6744
|
+
const { t: d } = useTranslation(), [p, u] = useState(r[0].key), x = useSelectedBlockCurrentClasses(), m = useCallback((g) => map(x, "property").includes(g), [x]);
|
|
6801
6745
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6802
6746
|
"div",
|
|
6803
6747
|
{
|
|
@@ -6806,7 +6750,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6806
6750
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6807
6751
|
o && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6808
6752
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6809
|
-
r.map(({ label:
|
|
6753
|
+
r.map(({ label: g, key: E }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
6810
6754
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6811
6755
|
"button",
|
|
6812
6756
|
{
|
|
@@ -6815,13 +6759,13 @@ const RangeChoices = ({ property: o, onChange: r }) => {
|
|
|
6815
6759
|
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${E === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6816
6760
|
children: [
|
|
6817
6761
|
React__default.createElement("div", {
|
|
6818
|
-
className:
|
|
6762
|
+
className: m(E) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6819
6763
|
}),
|
|
6820
6764
|
React__default.createElement(get(EDITOR_ICONS, E, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6821
6765
|
]
|
|
6822
6766
|
}
|
|
6823
6767
|
) }),
|
|
6824
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(
|
|
6768
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(g)) })
|
|
6825
6769
|
] }) }))
|
|
6826
6770
|
) })
|
|
6827
6771
|
] }),
|
|
@@ -6960,13 +6904,13 @@ function BlockStyling() {
|
|
|
6960
6904
|
cssProperty: ""
|
|
6961
6905
|
}), d = useThrottledCallback(
|
|
6962
6906
|
(u) => {
|
|
6963
|
-
const x = !get(i, "negative", !1),
|
|
6964
|
-
let
|
|
6965
|
-
|
|
6907
|
+
const x = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6908
|
+
let g = parseFloat(i.dragStartValue);
|
|
6909
|
+
g = isNaN(g) ? 0 : g;
|
|
6966
6910
|
let E = MAPPER[i.dragUnit];
|
|
6967
|
-
(startsWith(
|
|
6968
|
-
let
|
|
6969
|
-
x &&
|
|
6911
|
+
(startsWith(m, "scale") || m === "opacity") && (E = 10);
|
|
6912
|
+
let b = (i.dragStartY - u.pageY) / E + g;
|
|
6913
|
+
x && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6970
6914
|
},
|
|
6971
6915
|
[i],
|
|
6972
6916
|
50
|
|
@@ -7054,10 +6998,10 @@ const BlockCard = ({
|
|
|
7054
6998
|
parentId: n = void 0,
|
|
7055
6999
|
position: a = -1
|
|
7056
7000
|
}) => {
|
|
7057
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(),
|
|
7001
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(), m = get(o, "name", get(o, "label")), g = useFeature("dnd"), [, E] = useAtom$1(draggedBlockAtom), y = (_) => {
|
|
7058
7002
|
const A = has(_, "styles_attrs.data-page-section");
|
|
7059
7003
|
return _._type === "Box" && A;
|
|
7060
|
-
},
|
|
7004
|
+
}, b = useCallback(
|
|
7061
7005
|
async (_) => {
|
|
7062
7006
|
if (_.stopPropagation(), has(o, "component")) {
|
|
7063
7007
|
d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
@@ -7090,8 +7034,8 @@ const BlockCard = ({
|
|
|
7090
7034
|
"div",
|
|
7091
7035
|
{
|
|
7092
7036
|
onClick: l ? () => {
|
|
7093
|
-
} :
|
|
7094
|
-
draggable:
|
|
7037
|
+
} : b,
|
|
7038
|
+
draggable: g ? "true" : "false",
|
|
7095
7039
|
onDragStart: k,
|
|
7096
7040
|
className: clsx(
|
|
7097
7041
|
"relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
|
|
@@ -7101,11 +7045,11 @@ const BlockCard = ({
|
|
|
7101
7045
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
|
|
7102
7046
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
7103
7047
|
] }),
|
|
7104
|
-
o.preview ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
7048
|
+
o.preview ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: m }) })
|
|
7105
7049
|
]
|
|
7106
7050
|
}
|
|
7107
7051
|
) }),
|
|
7108
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children:
|
|
7052
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: m }) })
|
|
7109
7053
|
] });
|
|
7110
7054
|
}, libraryBlocksAtom = atom$1(
|
|
7111
7055
|
{}
|
|
@@ -7120,9 +7064,9 @@ const BlockCard = ({
|
|
|
7120
7064
|
})();
|
|
7121
7065
|
}, [o, l, i, c, n, a]), { data: l || [], isLoading: i === "loading" };
|
|
7122
7066
|
}, UILibrarySection = ({ parentId: o, position: r }) => {
|
|
7123
|
-
const [n, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((S) => S.category === "custom"), d = l.find((S) => S.uuid === n) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), x = groupBy([...p, ...c], "group"), [
|
|
7067
|
+
const [n, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((S) => S.category === "custom"), d = l.find((S) => S.uuid === n) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), x = groupBy([...p, ...c], "group"), [m, g] = useState("Hero"), E = get(x, m, []), y = useRef(null), { t: b } = useTranslation(), k = (S) => {
|
|
7124
7068
|
y.current && (clearTimeout(y.current), y.current = null), y.current = setTimeout(() => {
|
|
7125
|
-
y.current &&
|
|
7069
|
+
y.current && g(S);
|
|
7126
7070
|
}, 300);
|
|
7127
7071
|
};
|
|
7128
7072
|
if (u)
|
|
@@ -7135,7 +7079,7 @@ const BlockCard = ({
|
|
|
7135
7079
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7136
7080
|
/* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
7137
7081
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7138
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7082
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
|
|
7139
7083
|
/* @__PURE__ */ jsxRuntimeExports.jsx("hr", { className: "mt-1 border-border" }),
|
|
7140
7084
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
|
|
7141
7085
|
map(x, (S, v) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
@@ -7143,13 +7087,13 @@ const BlockCard = ({
|
|
|
7143
7087
|
{
|
|
7144
7088
|
onMouseEnter: () => k(v),
|
|
7145
7089
|
onMouseLeave: () => clearTimeout(y.current),
|
|
7146
|
-
onClick: () =>
|
|
7090
|
+
onClick: () => g(v),
|
|
7147
7091
|
className: cn(
|
|
7148
7092
|
"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",
|
|
7149
|
-
v ===
|
|
7093
|
+
v === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7150
7094
|
),
|
|
7151
7095
|
children: [
|
|
7152
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(
|
|
7096
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(b(v.toLowerCase())) }),
|
|
7153
7097
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7154
7098
|
]
|
|
7155
7099
|
},
|
|
@@ -7678,10 +7622,10 @@ const CoreBlock = ({
|
|
|
7678
7622
|
parentId: n,
|
|
7679
7623
|
position: a
|
|
7680
7624
|
}) => {
|
|
7681
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, x] = useSelectedBlockIds(), { clearHighlight:
|
|
7625
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, x] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), g = () => {
|
|
7682
7626
|
if (has(o, "blocks")) {
|
|
7683
|
-
const
|
|
7684
|
-
u(syncBlocksWithDefaults(
|
|
7627
|
+
const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
7628
|
+
u(syncBlocksWithDefaults(b), n || null, a);
|
|
7685
7629
|
} else
|
|
7686
7630
|
p(o, n || null, a);
|
|
7687
7631
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
@@ -7691,11 +7635,11 @@ const CoreBlock = ({
|
|
|
7691
7635
|
"button",
|
|
7692
7636
|
{
|
|
7693
7637
|
disabled: r,
|
|
7694
|
-
onClick:
|
|
7638
|
+
onClick: g,
|
|
7695
7639
|
type: "button",
|
|
7696
|
-
onDragStart: (
|
|
7697
|
-
|
|
7698
|
-
x([]),
|
|
7640
|
+
onDragStart: (b) => {
|
|
7641
|
+
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
7642
|
+
x([]), m();
|
|
7699
7643
|
}, 200);
|
|
7700
7644
|
},
|
|
7701
7645
|
draggable: E ? "true" : "false",
|
|
@@ -7763,8 +7707,8 @@ const CoreBlock = ({
|
|
|
7763
7707
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7764
7708
|
Tabs,
|
|
7765
7709
|
{
|
|
7766
|
-
onValueChange: (
|
|
7767
|
-
d(""), c(
|
|
7710
|
+
onValueChange: (m) => {
|
|
7711
|
+
d(""), c(m);
|
|
7768
7712
|
},
|
|
7769
7713
|
value: i,
|
|
7770
7714
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -7773,12 +7717,12 @@ const CoreBlock = ({
|
|
|
7773
7717
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7774
7718
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7775
7719
|
p ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7776
|
-
map(u, (
|
|
7720
|
+
map(u, (m) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: m.key, children: React__default.createElement(m.tab) }))
|
|
7777
7721
|
] }),
|
|
7778
7722
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { className: "-mx-1.5 h-full max-h-full overflow-y-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
|
|
7779
7723
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesPanel, { parentId: n, position: a }) }),
|
|
7780
7724
|
p ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ImportHTML, { parentId: n, position: a }) }) : null,
|
|
7781
|
-
map(u, (
|
|
7725
|
+
map(u, (m) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: m.key, children: React__default.createElement(m.tabContent, { close: x, parentId: n, position: a }) }))
|
|
7782
7726
|
]
|
|
7783
7727
|
}
|
|
7784
7728
|
)
|
|
@@ -7893,14 +7837,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
7893
7837
|
) }) });
|
|
7894
7838
|
}
|
|
7895
7839
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
7896
|
-
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, x] = useState(),
|
|
7840
|
+
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, x] = useState(), m = useRef(null), g = useRef(null);
|
|
7897
7841
|
useEffect(() => {
|
|
7898
7842
|
var y;
|
|
7899
|
-
(y =
|
|
7843
|
+
(y = m.current) == null || y.focus();
|
|
7900
7844
|
}, []);
|
|
7901
7845
|
const E = (y) => {
|
|
7902
|
-
const { usage:
|
|
7903
|
-
!l &&
|
|
7846
|
+
const { usage: b } = y || {};
|
|
7847
|
+
!l && b && x(b), g.current = setTimeout(() => x(void 0), 1e4), l || c("");
|
|
7904
7848
|
};
|
|
7905
7849
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
|
|
7906
7850
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
@@ -7918,14 +7862,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7918
7862
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7919
7863
|
Textarea,
|
|
7920
7864
|
{
|
|
7921
|
-
ref:
|
|
7865
|
+
ref: m,
|
|
7922
7866
|
value: i,
|
|
7923
7867
|
onChange: (y) => c(y.target.value),
|
|
7924
7868
|
placeholder: r("Ask AI to edit content"),
|
|
7925
7869
|
className: "w-full",
|
|
7926
7870
|
rows: 3,
|
|
7927
7871
|
onKeyDown: (y) => {
|
|
7928
|
-
y.key === "Enter" && (y.preventDefault(),
|
|
7872
|
+
y.key === "Enter" && (y.preventDefault(), g.current && clearTimeout(g.current), x(void 0), n("content", o, i, E));
|
|
7929
7873
|
}
|
|
7930
7874
|
}
|
|
7931
7875
|
),
|
|
@@ -7935,7 +7879,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7935
7879
|
{
|
|
7936
7880
|
disabled: i.trim().length < 5 || a,
|
|
7937
7881
|
onClick: () => {
|
|
7938
|
-
|
|
7882
|
+
g.current && clearTimeout(g.current), x(void 0), n("content", o, i, E);
|
|
7939
7883
|
},
|
|
7940
7884
|
variant: "default",
|
|
7941
7885
|
className: "w-fit",
|
|
@@ -7968,7 +7912,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7968
7912
|
QuickPrompts,
|
|
7969
7913
|
{
|
|
7970
7914
|
onClick: (y) => {
|
|
7971
|
-
|
|
7915
|
+
g.current && clearTimeout(g.current), x(void 0), n("content", o, y, E);
|
|
7972
7916
|
}
|
|
7973
7917
|
}
|
|
7974
7918
|
)
|
|
@@ -7978,17 +7922,17 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7978
7922
|
] }) }) : null
|
|
7979
7923
|
] });
|
|
7980
7924
|
}, AISetContext = () => {
|
|
7981
|
-
const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, x] = useState(!1), { toast:
|
|
7925
|
+
const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, x] = useState(!1), { toast: m } = useToast(), g = useRef(null);
|
|
7982
7926
|
useEffect(() => {
|
|
7983
7927
|
r && a(r);
|
|
7984
7928
|
}, [r]);
|
|
7985
7929
|
const E = async () => {
|
|
7986
7930
|
try {
|
|
7987
|
-
d(!0), u(null), await i(n),
|
|
7931
|
+
d(!0), u(null), await i(n), m({
|
|
7988
7932
|
title: o("Updated AI Context"),
|
|
7989
7933
|
description: o("You can now Ask AI to edit your content"),
|
|
7990
7934
|
variant: "default"
|
|
7991
|
-
}),
|
|
7935
|
+
}), g.current.click();
|
|
7992
7936
|
} catch (y) {
|
|
7993
7937
|
u(y);
|
|
7994
7938
|
} finally {
|
|
@@ -8004,7 +7948,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8004
7948
|
type: "single",
|
|
8005
7949
|
collapsible: !0,
|
|
8006
7950
|
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8007
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { ref:
|
|
7951
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { ref: g, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
8008
7952
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionContent, { children: [
|
|
8009
7953
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8010
7954
|
Textarea,
|
|
@@ -8078,42 +8022,42 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8078
8022
|
/* @__PURE__ */ jsxRuntimeExports.jsx(AIUserPrompt, { blockId: first(o) })
|
|
8079
8023
|
] });
|
|
8080
8024
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: r = [], onAttributesChange: n }) {
|
|
8081
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [
|
|
8025
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [m, g] = useState(""), E = useRef(null), y = useRef(null);
|
|
8082
8026
|
useEffect(() => {
|
|
8083
8027
|
l(r);
|
|
8084
8028
|
}, [r]);
|
|
8085
|
-
const
|
|
8029
|
+
const b = () => {
|
|
8086
8030
|
if (i.startsWith("@")) {
|
|
8087
|
-
|
|
8031
|
+
g("Attribute keys cannot start with '@'");
|
|
8088
8032
|
return;
|
|
8089
8033
|
}
|
|
8090
8034
|
if (i) {
|
|
8091
8035
|
const v = [...a, { key: i, value: d }];
|
|
8092
|
-
n(v), l(a), c(""), p(""),
|
|
8036
|
+
n(v), l(a), c(""), p(""), g("");
|
|
8093
8037
|
}
|
|
8094
8038
|
}, k = (v) => {
|
|
8095
|
-
const R = a.filter((
|
|
8039
|
+
const R = a.filter((h, j) => j !== v);
|
|
8096
8040
|
n(R), l(R);
|
|
8097
8041
|
}, _ = (v) => {
|
|
8098
8042
|
x(v), c(a[v].key), p(a[v].value);
|
|
8099
8043
|
}, A = () => {
|
|
8100
8044
|
if (i.startsWith("@")) {
|
|
8101
|
-
|
|
8045
|
+
g("Attribute keys cannot start with '@'");
|
|
8102
8046
|
return;
|
|
8103
8047
|
}
|
|
8104
8048
|
if (u !== null && i) {
|
|
8105
8049
|
const v = [...a];
|
|
8106
|
-
v[u] = { key: i, value: d }, n(v), l(v), x(null), c(""), p(""),
|
|
8050
|
+
v[u] = { key: i, value: d }, n(v), l(v), x(null), c(""), p(""), g("");
|
|
8107
8051
|
}
|
|
8108
8052
|
}, S = (v) => {
|
|
8109
|
-
v.key === "Enter" && !v.shiftKey && (v.preventDefault(), u !== null ? A() :
|
|
8053
|
+
v.key === "Enter" && !v.shiftKey && (v.preventDefault(), u !== null ? A() : b());
|
|
8110
8054
|
};
|
|
8111
8055
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
|
|
8112
8056
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8113
8057
|
"form",
|
|
8114
8058
|
{
|
|
8115
8059
|
onSubmit: (v) => {
|
|
8116
|
-
v.preventDefault(), u !== null ? A() :
|
|
8060
|
+
v.preventDefault(), u !== null ? A() : b();
|
|
8117
8061
|
},
|
|
8118
8062
|
className: "space-y-3",
|
|
8119
8063
|
children: [
|
|
@@ -8156,7 +8100,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8156
8100
|
] })
|
|
8157
8101
|
] }),
|
|
8158
8102
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
|
|
8159
|
-
|
|
8103
|
+
m && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-500", children: m })
|
|
8160
8104
|
]
|
|
8161
8105
|
}
|
|
8162
8106
|
),
|
|
@@ -8572,7 +8516,7 @@ const RootLayout = () => {
|
|
|
8572
8516
|
y.preventDefault();
|
|
8573
8517
|
}, u = (y) => {
|
|
8574
8518
|
r(o === y ? null : y);
|
|
8575
|
-
}, x = useSidebarMenuItems(), { t:
|
|
8519
|
+
}, x = useSidebarMenuItems(), { t: m } = useTranslation(), g = [...x, ...c], E = useBuilderProp("htmlDir", "ltr");
|
|
8576
8520
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dir: E, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipProvider, { children: [
|
|
8577
8521
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8578
8522
|
"div",
|
|
@@ -8583,21 +8527,21 @@ const RootLayout = () => {
|
|
|
8583
8527
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TopBar, {}) }) }),
|
|
8584
8528
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8585
8529
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
8586
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children:
|
|
8530
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: g.map((y, b) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
8587
8531
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8588
8532
|
Button,
|
|
8589
8533
|
{
|
|
8590
|
-
variant: o ===
|
|
8534
|
+
variant: o === b ? "default" : "ghost",
|
|
8591
8535
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
8592
|
-
onClick: () => u(
|
|
8536
|
+
onClick: () => u(b),
|
|
8593
8537
|
children: get(y, "icon", null)
|
|
8594
8538
|
},
|
|
8595
|
-
|
|
8539
|
+
b
|
|
8596
8540
|
) }),
|
|
8597
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children:
|
|
8598
|
-
] }, "button" +
|
|
8541
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: m(y.label) }) })
|
|
8542
|
+
] }, "button" + b)) }),
|
|
8599
8543
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col space-y-1" }),
|
|
8600
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((y,
|
|
8544
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((y, b) => /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", {}), children: React__default.createElement(y, { key: b }) })) })
|
|
8601
8545
|
] }),
|
|
8602
8546
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8603
8547
|
motion.div,
|
|
@@ -8608,10 +8552,10 @@ const RootLayout = () => {
|
|
|
8608
8552
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
8609
8553
|
children: o !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar overflow h-full overflow-x-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col p-3", children: [
|
|
8610
8554
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { className: "-mt-1 flex h-10 items-center space-x-1 text-base font-bold", children: [
|
|
8611
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
8612
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children:
|
|
8555
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(g, `${o}.icon`, null) }),
|
|
8556
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: m(g[o].label) })
|
|
8613
8557
|
] }),
|
|
8614
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: React__default.createElement(get(
|
|
8558
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: React__default.createElement(get(g, `${o}.component`, null), {}) }) })
|
|
8615
8559
|
] }) })
|
|
8616
8560
|
}
|
|
8617
8561
|
),
|
|
@@ -8630,11 +8574,11 @@ const RootLayout = () => {
|
|
|
8630
8574
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8631
8575
|
/* @__PURE__ */ jsxRuntimeExports.jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
8632
8576
|
" ",
|
|
8633
|
-
|
|
8577
|
+
m("AI Assistant")
|
|
8634
8578
|
] }) }) : l === "theme" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
8635
8579
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8636
8580
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
|
|
8637
|
-
|
|
8581
|
+
m("Theme Settings")
|
|
8638
8582
|
] }),
|
|
8639
8583
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8640
8584
|
Button,
|
|
@@ -8696,7 +8640,7 @@ const RootLayout = () => {
|
|
|
8696
8640
|
);
|
|
8697
8641
|
}, [o]), useEffect(() => {
|
|
8698
8642
|
setTimeout(() => {
|
|
8699
|
-
r(o.blocks || []), i({ type: "blocks-updated", blocks: o.blocks || [] }), n();
|
|
8643
|
+
r(o.blocks || []), o.blocks && o.blocks.length > 0 && i({ type: "blocks-updated", blocks: o.blocks || [] }), n();
|
|
8700
8644
|
}, 400);
|
|
8701
8645
|
}, [o.blocks]), useEffect(() => {
|
|
8702
8646
|
i18n.changeLanguage(o.locale || "en");
|