@chaibuilder/sdk 2.0.0-beta.102 → 2.0.0-beta.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +4 -4
- package/dist/core.d.ts +10 -5
- package/dist/core.js +1441 -1373
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +5 -2
- package/dist/render.js +128 -122
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -4,16 +4,16 @@ var U = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
|
|
|
4
4
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, Suspense, createElement, memo, lazy } from "react";
|
|
7
|
-
import { ag as useToast, S as Skeleton, B as Button, L as Label, D as Dialog, r as DialogTrigger, s as DialogContent, V as Popover, O as Tooltip, P as TooltipTrigger, W as PopoverTrigger, Q as TooltipContent, X as PopoverContent, aj as Command, al as CommandInput, am as CommandList, an as CommandEmpty, ao as CommandGroup, ap as CommandItem, g as Badge,
|
|
8
|
-
import { atom as atom$1,
|
|
9
|
-
import {
|
|
7
|
+
import { ag as useToast, S as Skeleton, B as Button, L as Label, D as Dialog, r as DialogTrigger, s as DialogContent, V as Popover, O as Tooltip, P as TooltipTrigger, W as PopoverTrigger, Q as TooltipContent, X as PopoverContent, aj as Command, al as CommandInput, am as CommandList, an as CommandEmpty, ao as CommandGroup, ap as CommandItem, g as Badge, $ as DropdownMenu, a0 as DropdownMenuTrigger, a1 as DropdownMenuContent, a5 as DropdownMenuLabel, a6 as DropdownMenuSeparator, a3 as DropdownMenuCheckboxItem, Y as HoverCard, Z as HoverCardTrigger, _ as HoverCardContent, T as Textarea, I as Input$1, U as TooltipPortal, d as AccordionItem, e as AccordionTrigger, f as AccordionContent, G as ScrollArea, a8 as DropdownMenuGroup, a2 as DropdownMenuItem, a7 as DropdownMenuShortcut, A as Accordion, C as Card, x as CardHeader, E as CardDescription, F as CardContent, y as CardFooter, J as Tabs, K as TabsList, M as TabsTrigger, N as TabsContent, as as ContextMenu, at as ContextMenuTrigger, au as ContextMenuContent, av as ContextMenuItem, i as AlertDialog, j as AlertDialogTrigger, k as AlertDialogContent, l as AlertDialogHeader, n as AlertDialogTitle, o as AlertDialogDescription, m as AlertDialogFooter, q as AlertDialogCancel, p as AlertDialogAction, a as Switch, ae as Separator, R as TooltipProvider, ai as Toaster } from "./context-menu-iqXuo9Yt.js";
|
|
8
|
+
import { atom as atom$1, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
9
|
+
import { find, filter, flatten, map, omit, isString, has, each, set, first, get, isObject, memoize, compact, isEmpty, noop, includes, without, keys, range, values, flattenDeep, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, findIndex, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
|
|
10
10
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
11
|
-
import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
|
|
12
11
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
13
12
|
import { useTranslation as De } from "react-i18next";
|
|
13
|
+
import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
|
|
14
14
|
import { flip } from "@floating-ui/dom";
|
|
15
15
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
16
|
-
import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, ReaderIcon, DropdownMenuIcon, BoxIcon, DragHandleHorizontalIcon, ViewHorizontalIcon, BorderAllIcon, BorderTopIcon, TableIcon, RadiobuttonIcon, InputIcon, ButtonIcon, CheckboxIcon, GroupIcon, SpaceBetweenVerticallyIcon, ColumnsIcon, TextIcon, RowsIcon, SketchLogoIcon, DividerHorizontalIcon, CodeIcon, CursorTextIcon, VideoIcon, Link1Icon, HeadingIcon, ImageIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon,
|
|
16
|
+
import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, ReaderIcon, DropdownMenuIcon, BoxIcon, DragHandleHorizontalIcon, ViewHorizontalIcon, BorderAllIcon, BorderTopIcon, TableIcon, RadiobuttonIcon, InputIcon, ButtonIcon, CheckboxIcon, GroupIcon, SpaceBetweenVerticallyIcon, ColumnsIcon, TextIcon, RowsIcon, SketchLogoIcon, DividerHorizontalIcon, CodeIcon, CursorTextIcon, VideoIcon, Link1Icon, HeadingIcon, ImageIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
|
|
17
17
|
import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
|
|
18
18
|
import { useFeature, FlagsProvider } from "flagged";
|
|
19
19
|
import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
@@ -89,221 +89,221 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
89
89
|
for (const i of n.p)
|
|
90
90
|
l.add(i);
|
|
91
91
|
return l;
|
|
92
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (
|
|
93
|
-
var
|
|
94
|
-
return (
|
|
95
|
-
}, g = (
|
|
96
|
-
var
|
|
97
|
-
return (
|
|
92
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (f, ...b) => f.read(...b), p = (f, ...b) => f.write(...b), u = (f, b) => {
|
|
93
|
+
var x;
|
|
94
|
+
return (x = f.unstable_onInit) == null ? void 0 : x.call(f, b);
|
|
95
|
+
}, g = (f, b) => {
|
|
96
|
+
var x;
|
|
97
|
+
return (x = f.onMount) == null ? void 0 : x.call(f, b);
|
|
98
98
|
}, ...m) => {
|
|
99
|
-
const
|
|
100
|
-
let
|
|
101
|
-
return
|
|
102
|
-
}),
|
|
103
|
-
let C,
|
|
99
|
+
const f = m[0] || ((C) => {
|
|
100
|
+
let T = o.get(C);
|
|
101
|
+
return T || (T = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, T), u == null || u(C, _)), T;
|
|
102
|
+
}), b = m[1] || (() => {
|
|
103
|
+
let C, T;
|
|
104
104
|
const k = (v) => {
|
|
105
105
|
try {
|
|
106
106
|
v();
|
|
107
|
-
} catch (
|
|
108
|
-
C || (C = !0,
|
|
107
|
+
} catch (N) {
|
|
108
|
+
C || (C = !0, T = N);
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
do {
|
|
112
112
|
c.f && k(c.f);
|
|
113
|
-
const v = /* @__PURE__ */ new Set(),
|
|
114
|
-
a.forEach((
|
|
115
|
-
var
|
|
116
|
-
return (
|
|
117
|
-
}), a.clear(), i.forEach(
|
|
113
|
+
const v = /* @__PURE__ */ new Set(), N = v.add.bind(v);
|
|
114
|
+
a.forEach((I) => {
|
|
115
|
+
var M;
|
|
116
|
+
return (M = n.get(I)) == null ? void 0 : M.l.forEach(N);
|
|
117
|
+
}), a.clear(), i.forEach(N), i.clear(), l.forEach(N), l.clear(), v.forEach(k), a.size && x();
|
|
118
118
|
} while (a.size || i.size || l.size);
|
|
119
119
|
if (C)
|
|
120
|
-
throw
|
|
121
|
-
}),
|
|
122
|
-
const C = [],
|
|
120
|
+
throw T;
|
|
121
|
+
}), x = m[2] || (() => {
|
|
122
|
+
const C = [], T = /* @__PURE__ */ new WeakSet(), k = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
|
|
123
123
|
for (; v.length; ) {
|
|
124
|
-
const
|
|
125
|
-
if (k.has(
|
|
124
|
+
const N = v[v.length - 1], I = f(N);
|
|
125
|
+
if (k.has(N)) {
|
|
126
126
|
v.pop();
|
|
127
127
|
continue;
|
|
128
128
|
}
|
|
129
|
-
if (
|
|
130
|
-
r.get(
|
|
129
|
+
if (T.has(N)) {
|
|
130
|
+
r.get(N) === I.n && C.push([N, I]), k.add(N), v.pop();
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
for (const
|
|
135
|
-
|
|
133
|
+
T.add(N);
|
|
134
|
+
for (const M of getMountedOrPendingDependents(N, I, n))
|
|
135
|
+
T.has(M) || v.push(M);
|
|
136
136
|
}
|
|
137
|
-
for (let
|
|
138
|
-
const [
|
|
139
|
-
let
|
|
140
|
-
for (const
|
|
141
|
-
if (
|
|
142
|
-
|
|
137
|
+
for (let N = C.length - 1; N >= 0; --N) {
|
|
138
|
+
const [I, M] = C[N];
|
|
139
|
+
let P = !1;
|
|
140
|
+
for (const j of M.d.keys())
|
|
141
|
+
if (j !== I && a.has(j)) {
|
|
142
|
+
P = !0;
|
|
143
143
|
break;
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
P && (h(I), E(I)), r.delete(I);
|
|
146
146
|
}
|
|
147
|
-
}),
|
|
148
|
-
var
|
|
149
|
-
const v =
|
|
147
|
+
}), h = m[3] || ((C) => {
|
|
148
|
+
var T, k;
|
|
149
|
+
const v = f(C);
|
|
150
150
|
if (isAtomStateInitialized(v) && (n.has(C) && r.get(C) !== v.n || Array.from(v.d).every(
|
|
151
151
|
([L, $]) => (
|
|
152
152
|
// Recursively, read the atom state of the dependency, and
|
|
153
153
|
// check if the atom epoch number is unchanged
|
|
154
|
-
|
|
154
|
+
h(L).n === $
|
|
155
155
|
)
|
|
156
156
|
)))
|
|
157
157
|
return v;
|
|
158
158
|
v.d.clear();
|
|
159
|
-
let
|
|
160
|
-
const
|
|
161
|
-
n.has(C) && (E(C),
|
|
162
|
-
},
|
|
159
|
+
let N = !0;
|
|
160
|
+
const I = () => {
|
|
161
|
+
n.has(C) && (E(C), x(), b());
|
|
162
|
+
}, M = (L) => {
|
|
163
163
|
var $;
|
|
164
164
|
if (isSelfAtom(C, L)) {
|
|
165
|
-
const H =
|
|
165
|
+
const H = f(L);
|
|
166
166
|
if (!isAtomStateInitialized(H))
|
|
167
167
|
if (hasInitialValue(L))
|
|
168
|
-
setAtomStateValueOrPromise(L, L.init,
|
|
168
|
+
setAtomStateValueOrPromise(L, L.init, f);
|
|
169
169
|
else
|
|
170
170
|
throw new Error("no atom init");
|
|
171
171
|
return returnAtomValue(H);
|
|
172
172
|
}
|
|
173
|
-
const O =
|
|
173
|
+
const O = h(L);
|
|
174
174
|
try {
|
|
175
175
|
return returnAtomValue(O);
|
|
176
176
|
} finally {
|
|
177
|
-
v.d.set(L, O.n), isPendingPromise(v.v) && addPendingPromiseToDependency(C, v.v, O), ($ = n.get(L)) == null || $.t.add(C),
|
|
177
|
+
v.d.set(L, O.n), isPendingPromise(v.v) && addPendingPromiseToDependency(C, v.v, O), ($ = n.get(L)) == null || $.t.add(C), N || I();
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
|
-
let
|
|
181
|
-
const
|
|
180
|
+
let P, j;
|
|
181
|
+
const R = {
|
|
182
182
|
get signal() {
|
|
183
|
-
return
|
|
183
|
+
return P || (P = new AbortController()), P.signal;
|
|
184
184
|
},
|
|
185
185
|
get setSelf() {
|
|
186
|
-
return !
|
|
187
|
-
if (!
|
|
186
|
+
return !j && isActuallyWritableAtom(C) && (j = (...L) => {
|
|
187
|
+
if (!N)
|
|
188
188
|
try {
|
|
189
189
|
return B(C, ...L);
|
|
190
190
|
} finally {
|
|
191
|
-
|
|
191
|
+
x(), b();
|
|
192
192
|
}
|
|
193
|
-
}),
|
|
193
|
+
}), j;
|
|
194
194
|
}
|
|
195
195
|
}, D = v.n;
|
|
196
196
|
try {
|
|
197
|
-
const L = d(C,
|
|
198
|
-
return setAtomStateValueOrPromise(C, L,
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
const L = d(C, M, R);
|
|
198
|
+
return setAtomStateValueOrPromise(C, L, f), isPromiseLike$2(L) && ((T = L.onCancel) == null || T.call(L, () => P == null ? void 0 : P.abort()), L.then(
|
|
199
|
+
I,
|
|
200
|
+
I
|
|
201
201
|
)), v;
|
|
202
202
|
} catch (L) {
|
|
203
203
|
return delete v.v, v.e = L, ++v.n, v;
|
|
204
204
|
} finally {
|
|
205
|
-
|
|
205
|
+
N = !1, D !== v.n && r.get(C) === D && (r.set(C, v.n), a.add(C), (k = c.c) == null || k.call(c, C));
|
|
206
206
|
}
|
|
207
207
|
}), y = m[4] || ((C) => {
|
|
208
|
-
const
|
|
209
|
-
for (;
|
|
210
|
-
const k =
|
|
211
|
-
for (const
|
|
212
|
-
const
|
|
213
|
-
r.set(
|
|
208
|
+
const T = [C];
|
|
209
|
+
for (; T.length; ) {
|
|
210
|
+
const k = T.pop(), v = f(k);
|
|
211
|
+
for (const N of getMountedOrPendingDependents(k, v, n)) {
|
|
212
|
+
const I = f(N);
|
|
213
|
+
r.set(N, I.n), T.push(N);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
}), B = m[5] || ((C, ...
|
|
216
|
+
}), B = m[5] || ((C, ...T) => {
|
|
217
217
|
let k = !0;
|
|
218
|
-
const v = (
|
|
219
|
-
var
|
|
220
|
-
const
|
|
218
|
+
const v = (I) => returnAtomValue(h(I)), N = (I, ...M) => {
|
|
219
|
+
var P;
|
|
220
|
+
const j = f(I);
|
|
221
221
|
try {
|
|
222
|
-
if (isSelfAtom(C,
|
|
223
|
-
if (!hasInitialValue(
|
|
222
|
+
if (isSelfAtom(C, I)) {
|
|
223
|
+
if (!hasInitialValue(I))
|
|
224
224
|
throw new Error("atom not writable");
|
|
225
|
-
const
|
|
226
|
-
setAtomStateValueOrPromise(
|
|
225
|
+
const R = j.n, D = M[0];
|
|
226
|
+
setAtomStateValueOrPromise(I, D, f), E(I), R !== j.n && (a.add(I), (P = c.c) == null || P.call(c, I), y(I));
|
|
227
227
|
return;
|
|
228
228
|
} else
|
|
229
|
-
return B(
|
|
229
|
+
return B(I, ...M);
|
|
230
230
|
} finally {
|
|
231
|
-
k || (
|
|
231
|
+
k || (x(), b());
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
234
|
try {
|
|
235
|
-
return p(C, v,
|
|
235
|
+
return p(C, v, N, ...T);
|
|
236
236
|
} finally {
|
|
237
237
|
k = !1;
|
|
238
238
|
}
|
|
239
239
|
}), E = m[6] || ((C) => {
|
|
240
|
-
var
|
|
241
|
-
const k =
|
|
240
|
+
var T;
|
|
241
|
+
const k = f(C), v = n.get(C);
|
|
242
242
|
if (v && !isPendingPromise(k.v)) {
|
|
243
|
-
for (const [
|
|
244
|
-
if (!v.d.has(
|
|
245
|
-
const
|
|
246
|
-
w(
|
|
243
|
+
for (const [N, I] of k.d)
|
|
244
|
+
if (!v.d.has(N)) {
|
|
245
|
+
const M = f(N);
|
|
246
|
+
w(N).t.add(C), v.d.add(N), I !== M.n && (a.add(N), (T = c.c) == null || T.call(c, N), y(N));
|
|
247
247
|
}
|
|
248
|
-
for (const
|
|
249
|
-
if (!k.d.has(
|
|
250
|
-
v.d.delete(
|
|
251
|
-
const
|
|
252
|
-
|
|
248
|
+
for (const N of v.d || [])
|
|
249
|
+
if (!k.d.has(N)) {
|
|
250
|
+
v.d.delete(N);
|
|
251
|
+
const I = S(N);
|
|
252
|
+
I == null || I.t.delete(C);
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
}), w = m[7] || ((C) => {
|
|
256
|
-
var
|
|
257
|
-
const k =
|
|
256
|
+
var T;
|
|
257
|
+
const k = f(C);
|
|
258
258
|
let v = n.get(C);
|
|
259
259
|
if (!v) {
|
|
260
|
-
|
|
261
|
-
for (const
|
|
262
|
-
w(
|
|
260
|
+
h(C);
|
|
261
|
+
for (const N of k.d.keys())
|
|
262
|
+
w(N).t.add(C);
|
|
263
263
|
if (v = {
|
|
264
264
|
l: /* @__PURE__ */ new Set(),
|
|
265
265
|
d: new Set(k.d.keys()),
|
|
266
266
|
t: /* @__PURE__ */ new Set()
|
|
267
|
-
}, n.set(C, v), (
|
|
268
|
-
const
|
|
269
|
-
let
|
|
270
|
-
const
|
|
267
|
+
}, n.set(C, v), (T = c.m) == null || T.call(c, C), isActuallyWritableAtom(C)) {
|
|
268
|
+
const N = () => {
|
|
269
|
+
let I = !0;
|
|
270
|
+
const M = (...P) => {
|
|
271
271
|
try {
|
|
272
|
-
return B(C, ...
|
|
272
|
+
return B(C, ...P);
|
|
273
273
|
} finally {
|
|
274
|
-
|
|
274
|
+
I || (x(), b());
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
277
|
try {
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
const P = g(C, M);
|
|
279
|
+
P && (v.u = () => {
|
|
280
|
+
I = !0;
|
|
281
281
|
try {
|
|
282
|
-
|
|
282
|
+
P();
|
|
283
283
|
} finally {
|
|
284
|
-
|
|
284
|
+
I = !1;
|
|
285
285
|
}
|
|
286
286
|
});
|
|
287
287
|
} finally {
|
|
288
|
-
|
|
288
|
+
I = !1;
|
|
289
289
|
}
|
|
290
290
|
};
|
|
291
|
-
l.add(
|
|
291
|
+
l.add(N);
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
return v;
|
|
295
295
|
}), S = m[8] || ((C) => {
|
|
296
|
-
var
|
|
297
|
-
const k =
|
|
296
|
+
var T;
|
|
297
|
+
const k = f(C);
|
|
298
298
|
let v = n.get(C);
|
|
299
|
-
if (v && !v.l.size && !Array.from(v.t).some((
|
|
300
|
-
var
|
|
301
|
-
return (
|
|
299
|
+
if (v && !v.l.size && !Array.from(v.t).some((N) => {
|
|
300
|
+
var I;
|
|
301
|
+
return (I = n.get(N)) == null ? void 0 : I.d.has(C);
|
|
302
302
|
})) {
|
|
303
|
-
v.u && i.add(v.u), v = void 0, n.delete(C), (
|
|
304
|
-
for (const
|
|
305
|
-
const
|
|
306
|
-
|
|
303
|
+
v.u && i.add(v.u), v = void 0, n.delete(C), (T = c.u) == null || T.call(c, C);
|
|
304
|
+
for (const N of k.d.keys()) {
|
|
305
|
+
const I = S(N);
|
|
306
|
+
I == null || I.t.delete(C);
|
|
307
307
|
}
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
@@ -323,32 +323,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
323
323
|
u,
|
|
324
324
|
g,
|
|
325
325
|
// building-block functions
|
|
326
|
-
h,
|
|
327
|
-
x,
|
|
328
326
|
f,
|
|
329
327
|
b,
|
|
328
|
+
x,
|
|
329
|
+
h,
|
|
330
330
|
y,
|
|
331
331
|
B,
|
|
332
332
|
E,
|
|
333
333
|
w,
|
|
334
334
|
S
|
|
335
|
-
],
|
|
336
|
-
get: (C) => returnAtomValue(
|
|
337
|
-
set: (C, ...
|
|
335
|
+
], _ = {
|
|
336
|
+
get: (C) => returnAtomValue(h(C)),
|
|
337
|
+
set: (C, ...T) => {
|
|
338
338
|
try {
|
|
339
|
-
return B(C, ...
|
|
339
|
+
return B(C, ...T);
|
|
340
340
|
} finally {
|
|
341
|
-
|
|
341
|
+
x(), b();
|
|
342
342
|
}
|
|
343
343
|
},
|
|
344
|
-
sub: (C,
|
|
344
|
+
sub: (C, T) => {
|
|
345
345
|
const v = w(C).l;
|
|
346
|
-
return v.add(
|
|
347
|
-
v.delete(
|
|
346
|
+
return v.add(T), b(), () => {
|
|
347
|
+
v.delete(T), S(C), b();
|
|
348
348
|
};
|
|
349
349
|
}
|
|
350
350
|
};
|
|
351
|
-
return Object.defineProperty(
|
|
351
|
+
return Object.defineProperty(_, BUILDING_BLOCKS, { value: A }), _;
|
|
352
352
|
}, INTERNAL_buildStoreRev1 = buildStore;
|
|
353
353
|
let keyCount = 0;
|
|
354
354
|
function atom(o, n) {
|
|
@@ -384,36 +384,36 @@ function splitAtom(o, n) {
|
|
|
384
384
|
if (p)
|
|
385
385
|
return p;
|
|
386
386
|
const u = d && r.get(d), g = [], m = [];
|
|
387
|
-
return c.forEach((
|
|
388
|
-
const
|
|
389
|
-
m[
|
|
390
|
-
const
|
|
391
|
-
if (
|
|
392
|
-
g[
|
|
387
|
+
return c.forEach((f, b) => {
|
|
388
|
+
const x = b;
|
|
389
|
+
m[b] = x;
|
|
390
|
+
const h = u && u.atomList[u.keyList.indexOf(x)];
|
|
391
|
+
if (h) {
|
|
392
|
+
g[b] = h;
|
|
393
393
|
return;
|
|
394
394
|
}
|
|
395
395
|
const y = (E) => {
|
|
396
|
-
const w = E(l), S = E(o),
|
|
397
|
-
if (
|
|
398
|
-
const C = c[a(c).keyList.indexOf(
|
|
396
|
+
const w = E(l), S = E(o), _ = a(S, w == null ? void 0 : w.arr).keyList.indexOf(x);
|
|
397
|
+
if (_ < 0 || _ >= S.length) {
|
|
398
|
+
const C = c[a(c).keyList.indexOf(x)];
|
|
399
399
|
if (C)
|
|
400
400
|
return C;
|
|
401
401
|
throw new Error("splitAtom: index out of bounds for read");
|
|
402
402
|
}
|
|
403
|
-
return S[
|
|
403
|
+
return S[_];
|
|
404
404
|
}, B = (E, w, S) => {
|
|
405
|
-
const A = E(l),
|
|
406
|
-
if (
|
|
405
|
+
const A = E(l), _ = E(o), T = a(_, A == null ? void 0 : A.arr).keyList.indexOf(x);
|
|
406
|
+
if (T < 0 || T >= _.length)
|
|
407
407
|
throw new Error("splitAtom: index out of bounds for write");
|
|
408
|
-
const k = isFunction(S) ? S(
|
|
409
|
-
Object.is(
|
|
410
|
-
...
|
|
408
|
+
const k = isFunction(S) ? S(_[T]) : S;
|
|
409
|
+
Object.is(_[T], k) || w(o, [
|
|
410
|
+
..._.slice(0, T),
|
|
411
411
|
k,
|
|
412
|
-
...
|
|
412
|
+
..._.slice(T + 1)
|
|
413
413
|
]);
|
|
414
414
|
};
|
|
415
|
-
g[
|
|
416
|
-
}), u && u.keyList.length === m.length && u.keyList.every((
|
|
415
|
+
g[b] = isWritable(o) ? atom(y, B) : atom(y);
|
|
416
|
+
}), u && u.keyList.length === m.length && u.keyList.every((f, b) => f === m[b]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
|
|
417
417
|
}, l = atom((c) => {
|
|
418
418
|
const d = c(l), p = c(o);
|
|
419
419
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -486,18 +486,18 @@ function createJSONStorage(o = () => {
|
|
|
486
486
|
const i = {
|
|
487
487
|
getItem: (p, u) => {
|
|
488
488
|
var g, m;
|
|
489
|
-
const
|
|
490
|
-
if (
|
|
489
|
+
const f = (x) => {
|
|
490
|
+
if (x = x || "", a !== x) {
|
|
491
491
|
try {
|
|
492
|
-
l = JSON.parse(
|
|
492
|
+
l = JSON.parse(x, n == null ? void 0 : n.reviver);
|
|
493
493
|
} catch {
|
|
494
494
|
return u;
|
|
495
495
|
}
|
|
496
|
-
a =
|
|
496
|
+
a = x;
|
|
497
497
|
}
|
|
498
498
|
return l;
|
|
499
|
-
},
|
|
500
|
-
return isPromiseLike$1(
|
|
499
|
+
}, b = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
500
|
+
return isPromiseLike$1(b) ? b.then(f) : f(b);
|
|
501
501
|
},
|
|
502
502
|
setItem: (p, u) => {
|
|
503
503
|
var g;
|
|
@@ -510,14 +510,14 @@ function createJSONStorage(o = () => {
|
|
|
510
510
|
var u;
|
|
511
511
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
512
512
|
}
|
|
513
|
-
}, c = (p) => (u, g, m) => p(u, (
|
|
514
|
-
let
|
|
513
|
+
}, c = (p) => (u, g, m) => p(u, (f) => {
|
|
514
|
+
let b;
|
|
515
515
|
try {
|
|
516
|
-
|
|
516
|
+
b = JSON.parse(f || "");
|
|
517
517
|
} catch {
|
|
518
|
-
|
|
518
|
+
b = m;
|
|
519
519
|
}
|
|
520
|
-
g(
|
|
520
|
+
g(b);
|
|
521
521
|
});
|
|
522
522
|
let d;
|
|
523
523
|
try {
|
|
@@ -746,35 +746,7 @@ U(Frame, "defaultProps", {
|
|
|
746
746
|
},
|
|
747
747
|
initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
|
|
748
748
|
});
|
|
749
|
-
const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n }))
|
|
750
|
-
if (!o) return !0;
|
|
751
|
-
const r = getRegisteredChaiBlock(o);
|
|
752
|
-
return r && has(r, "canAcceptBlock") ? r.canAcceptBlock(n) : !1;
|
|
753
|
-
}, canAddChildBlock = (o) => {
|
|
754
|
-
const n = getRegisteredChaiBlock(o);
|
|
755
|
-
return n ? has(n, "canAcceptBlock") : !1;
|
|
756
|
-
}, canBeNestedInside = (o, n) => {
|
|
757
|
-
const r = getRegisteredChaiBlock(n);
|
|
758
|
-
return r && has(r, "canBeNested") ? r.canBeNested(o) : !0;
|
|
759
|
-
}, canDuplicateBlock = (o) => {
|
|
760
|
-
const n = getRegisteredChaiBlock(o);
|
|
761
|
-
return n && has(n, "canDuplicate") ? n.canDuplicate() : !0;
|
|
762
|
-
}, canDeleteBlock = (o) => {
|
|
763
|
-
const n = getRegisteredChaiBlock(o);
|
|
764
|
-
return n && has(n, "canDelete") ? n.canDelete() : !0;
|
|
765
|
-
}, canDropBlock = (o, { dragSource: n, dropTarget: r }) => {
|
|
766
|
-
const a = get(n, "data._type", ""), l = get(r, "data._type", "");
|
|
767
|
-
return canAcceptChildBlock(l, a);
|
|
768
|
-
};
|
|
769
|
-
import.meta.vitest && describe("canDropBlock Function", () => {
|
|
770
|
-
it('should return false if dragSourceType is "Slot"', () => {
|
|
771
|
-
const o = { data: { _type: "Slot" } }, n = { data: {} };
|
|
772
|
-
expect(canDropBlock({}, { dragSource: o, dropTarget: n })).toBe(!0);
|
|
773
|
-
}), it("should return true if dropTargetType is empty", () => {
|
|
774
|
-
const o = { data: { _type: "Box" } }, n = { data: {} };
|
|
775
|
-
expect(canDropBlock({}, { dragSource: o, dropTarget: n })).toBe(!0);
|
|
776
|
-
});
|
|
777
|
-
});
|
|
749
|
+
const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n }));
|
|
778
750
|
function duplicateBlocks(o, n, r) {
|
|
779
751
|
const a = filter(o, (i) => i._parent === n), l = [];
|
|
780
752
|
for (let i = 0; i < a.length; i++) {
|
|
@@ -846,58 +818,6 @@ const globalBlocksAtom = atom$1((o) => {
|
|
|
846
818
|
return filter(n, (r) => has(r, "blockId"));
|
|
847
819
|
});
|
|
848
820
|
globalBlocksAtom.debugLabel = "globalBlocksAtom";
|
|
849
|
-
const selectedBlockIdsAtom = atom$1([]);
|
|
850
|
-
selectedBlockIdsAtom.debugLabel = "selectedBlockIdsAtom";
|
|
851
|
-
const selectedBlocksAtom = atom$1((o) => {
|
|
852
|
-
const n = o(presentBlocksAtom), r = o(selectedBlockIdsAtom);
|
|
853
|
-
return map(
|
|
854
|
-
filter(n, ({ _id: a }) => includes(r, a)),
|
|
855
|
-
(a) => ({ ...a })
|
|
856
|
-
);
|
|
857
|
-
});
|
|
858
|
-
selectedBlocksAtom.debugLabel = "selectedBlocksAtom";
|
|
859
|
-
const selectedBlockAtom = atom$1((o) => {
|
|
860
|
-
const n = o(selectedBlocksAtom);
|
|
861
|
-
if (n.length === 0)
|
|
862
|
-
return null;
|
|
863
|
-
if (n.length === 1)
|
|
864
|
-
return n[0];
|
|
865
|
-
});
|
|
866
|
-
selectedBlockAtom.debugLabel = "selectedBlockAtom";
|
|
867
|
-
const getParentId = (o) => get(o, "_parent", null), selectedBlocksParentsAtom = atom$1((o) => {
|
|
868
|
-
const n = o(selectedBlocksAtom), r = map(n, getParentId);
|
|
869
|
-
return filter(o(presentBlocksAtom), (a) => includes(r, a._id));
|
|
870
|
-
});
|
|
871
|
-
selectedBlocksParentsAtom.debugLabel = "selectedBlocksParentsAtom";
|
|
872
|
-
const selectedBlockFlexChildAtom = atom$1(() => !1);
|
|
873
|
-
selectedBlockFlexChildAtom.debugLabel = "selectedBlockFlexChildAtom";
|
|
874
|
-
const selectedBlockGridChildAtom = atom$1(() => !1);
|
|
875
|
-
selectedBlockGridChildAtom.debugLabel = "selectedBlockGridChildAtom";
|
|
876
|
-
const styleStateAtom = atom$1("");
|
|
877
|
-
styleStateAtom.debugLabel = "styleStateAtom";
|
|
878
|
-
const styleBreakpointAtom = atomWithStorage("styleBreakpoint", "xs");
|
|
879
|
-
styleBreakpointAtom.debugLabel = "styleBreakpointAtom";
|
|
880
|
-
const useSelectedBlocksDisplayChild = () => ({
|
|
881
|
-
flexChild: useAtomValue$1(selectedBlockFlexChildAtom),
|
|
882
|
-
gridChild: useAtomValue$1(selectedBlockGridChildAtom)
|
|
883
|
-
}), useSelectedBlock = () => useAtomValue$1(selectedBlockAtom), selectedBlockHierarchy = atom$1((o) => {
|
|
884
|
-
const n = o(selectedBlockAtom), r = o(presentBlocksAtom);
|
|
885
|
-
let a = n;
|
|
886
|
-
const l = [n];
|
|
887
|
-
do {
|
|
888
|
-
const i = r.find(({ _id: c }) => c === (a == null ? void 0 : a._parent));
|
|
889
|
-
a = i, i && l.push(i);
|
|
890
|
-
} while (a != null && a._parent);
|
|
891
|
-
return l;
|
|
892
|
-
}), useSelectedBlockHierarchy = () => compact(useAtomValue$1(selectedBlockHierarchy)), useSelectedBlockIds = () => {
|
|
893
|
-
const [o, n] = useAtom$1(selectedBlockIdsAtom), r = useCallback(
|
|
894
|
-
(a) => {
|
|
895
|
-
n((l) => includes(l, a) ? without(l, a) : [...l, a]);
|
|
896
|
-
},
|
|
897
|
-
[n]
|
|
898
|
-
);
|
|
899
|
-
return [o, n, r];
|
|
900
|
-
};
|
|
901
821
|
var undomanager = { exports: {} }, hasRequiredUndomanager;
|
|
902
822
|
function requireUndomanager() {
|
|
903
823
|
return hasRequiredUndomanager || (hasRequiredUndomanager = 1, function(o) {
|
|
@@ -1223,6 +1143,57 @@ const useUndoManager = () => {
|
|
|
1223
1143
|
}, () => {
|
|
1224
1144
|
broadcastChannel.onmessage = null, broadcastChannel.onmessageerror = null;
|
|
1225
1145
|
}), [o, n]);
|
|
1146
|
+
}, selectedBlockIdsAtom = atom$1([]);
|
|
1147
|
+
selectedBlockIdsAtom.debugLabel = "selectedBlockIdsAtom";
|
|
1148
|
+
const selectedBlocksAtom = atom$1((o) => {
|
|
1149
|
+
const n = o(presentBlocksAtom), r = o(selectedBlockIdsAtom);
|
|
1150
|
+
return map(
|
|
1151
|
+
filter(n, ({ _id: a }) => includes(r, a)),
|
|
1152
|
+
(a) => ({ ...a })
|
|
1153
|
+
);
|
|
1154
|
+
});
|
|
1155
|
+
selectedBlocksAtom.debugLabel = "selectedBlocksAtom";
|
|
1156
|
+
const selectedBlockAtom = atom$1((o) => {
|
|
1157
|
+
const n = o(selectedBlocksAtom);
|
|
1158
|
+
if (n.length === 0)
|
|
1159
|
+
return null;
|
|
1160
|
+
if (n.length === 1)
|
|
1161
|
+
return n[0];
|
|
1162
|
+
});
|
|
1163
|
+
selectedBlockAtom.debugLabel = "selectedBlockAtom";
|
|
1164
|
+
const getParentId = (o) => get(o, "_parent", null), selectedBlocksParentsAtom = atom$1((o) => {
|
|
1165
|
+
const n = o(selectedBlocksAtom), r = map(n, getParentId);
|
|
1166
|
+
return filter(o(presentBlocksAtom), (a) => includes(r, a._id));
|
|
1167
|
+
});
|
|
1168
|
+
selectedBlocksParentsAtom.debugLabel = "selectedBlocksParentsAtom";
|
|
1169
|
+
const selectedBlockFlexChildAtom = atom$1(() => !1);
|
|
1170
|
+
selectedBlockFlexChildAtom.debugLabel = "selectedBlockFlexChildAtom";
|
|
1171
|
+
const selectedBlockGridChildAtom = atom$1(() => !1);
|
|
1172
|
+
selectedBlockGridChildAtom.debugLabel = "selectedBlockGridChildAtom";
|
|
1173
|
+
const styleStateAtom = atom$1("");
|
|
1174
|
+
styleStateAtom.debugLabel = "styleStateAtom";
|
|
1175
|
+
const styleBreakpointAtom = atomWithStorage("styleBreakpoint", "xs");
|
|
1176
|
+
styleBreakpointAtom.debugLabel = "styleBreakpointAtom";
|
|
1177
|
+
const useSelectedBlocksDisplayChild = () => ({
|
|
1178
|
+
flexChild: useAtomValue$1(selectedBlockFlexChildAtom),
|
|
1179
|
+
gridChild: useAtomValue$1(selectedBlockGridChildAtom)
|
|
1180
|
+
}), useSelectedBlock = () => useAtomValue$1(selectedBlockAtom), selectedBlockHierarchy = atom$1((o) => {
|
|
1181
|
+
const n = o(selectedBlockAtom), r = o(presentBlocksAtom);
|
|
1182
|
+
let a = n;
|
|
1183
|
+
const l = [n];
|
|
1184
|
+
do {
|
|
1185
|
+
const i = r.find(({ _id: c }) => c === (a == null ? void 0 : a._parent));
|
|
1186
|
+
a = i, i && l.push(i);
|
|
1187
|
+
} while (a != null && a._parent);
|
|
1188
|
+
return l;
|
|
1189
|
+
}), useSelectedBlockHierarchy = () => compact(useAtomValue$1(selectedBlockHierarchy)), useSelectedBlockIds = () => {
|
|
1190
|
+
const [o, n] = useAtom$1(selectedBlockIdsAtom), r = useCallback(
|
|
1191
|
+
(a) => {
|
|
1192
|
+
n((l) => includes(l, a) ? without(l, a) : [...l, a]);
|
|
1193
|
+
},
|
|
1194
|
+
[n]
|
|
1195
|
+
);
|
|
1196
|
+
return [o, n, r];
|
|
1226
1197
|
}, removeNestedBlocks = (o, n) => {
|
|
1227
1198
|
const r = [], a = filter(o, (l) => includes(n, l._id) || includes(n, l._parent) ? (r.push(l._id), !1) : !0);
|
|
1228
1199
|
return isEmpty(r) ? a : removeNestedBlocks(a, r);
|
|
@@ -1368,98 +1339,127 @@ const useBlocksStoreManager = () => {
|
|
|
1368
1339
|
updateBlocksProps: c
|
|
1369
1340
|
} = useBlocksStoreManager();
|
|
1370
1341
|
return {
|
|
1371
|
-
moveBlocks: (
|
|
1372
|
-
const B = map(
|
|
1373
|
-
const A = n.find((
|
|
1342
|
+
moveBlocks: (x, h, y) => {
|
|
1343
|
+
const B = map(x, (w) => {
|
|
1344
|
+
const A = n.find((T) => T._id === w)._parent || null, C = n.filter((T) => A ? T._parent === A : !T._parent).map((T) => T._id).indexOf(w);
|
|
1374
1345
|
return { _id: w, oldParent: A, oldPosition: C };
|
|
1375
|
-
}), E = B.find(({ _id: w }) => w ===
|
|
1376
|
-
E && E.oldParent ===
|
|
1346
|
+
}), E = B.find(({ _id: w }) => w === x[0]);
|
|
1347
|
+
E && E.oldParent === h && E.oldPosition === y || (i(x, h, y), o({
|
|
1377
1348
|
undo: () => each(B, ({ _id: w, oldParent: S, oldPosition: A }) => {
|
|
1378
1349
|
i([w], S, A);
|
|
1379
1350
|
}),
|
|
1380
|
-
redo: () => i(
|
|
1351
|
+
redo: () => i(x, h, y)
|
|
1381
1352
|
}));
|
|
1382
1353
|
},
|
|
1383
|
-
addBlocks: (
|
|
1384
|
-
a(
|
|
1385
|
-
undo: () => l(map(
|
|
1386
|
-
redo: () => a(
|
|
1354
|
+
addBlocks: (x, h, y) => {
|
|
1355
|
+
a(x, h, y), o({
|
|
1356
|
+
undo: () => l(map(x, "_id")),
|
|
1357
|
+
redo: () => a(x, h, y)
|
|
1387
1358
|
});
|
|
1388
1359
|
},
|
|
1389
|
-
removeBlocks: (
|
|
1360
|
+
removeBlocks: (x) => {
|
|
1390
1361
|
var E;
|
|
1391
|
-
const
|
|
1392
|
-
l(map(
|
|
1393
|
-
undo: () => a(
|
|
1394
|
-
redo: () => l(map(
|
|
1362
|
+
const h = (E = first(x)) == null ? void 0 : E._parent, B = n.filter((w) => h ? w._parent === h : !w._parent).indexOf(first(x));
|
|
1363
|
+
l(map(x, "_id")), o({
|
|
1364
|
+
undo: () => a(x, h, B),
|
|
1365
|
+
redo: () => l(map(x, "_id"))
|
|
1395
1366
|
});
|
|
1396
1367
|
},
|
|
1397
|
-
updateBlocks: (
|
|
1368
|
+
updateBlocks: (x, h, y) => {
|
|
1398
1369
|
let B = [];
|
|
1399
1370
|
if (y)
|
|
1400
|
-
B = map(
|
|
1371
|
+
B = map(x, (E) => ({ _id: E, ...y }));
|
|
1401
1372
|
else {
|
|
1402
|
-
const E = keys(
|
|
1403
|
-
B = map(
|
|
1404
|
-
const S = n.find((
|
|
1405
|
-
return each(E, (
|
|
1373
|
+
const E = keys(h);
|
|
1374
|
+
B = map(x, (w) => {
|
|
1375
|
+
const S = n.find((_) => _._id === w), A = { _id: w };
|
|
1376
|
+
return each(E, (_) => A[_] = S[_]), A;
|
|
1406
1377
|
});
|
|
1407
1378
|
}
|
|
1408
|
-
c(map(
|
|
1379
|
+
c(map(x, (E) => ({ _id: E, ...h }))), o({
|
|
1409
1380
|
undo: () => c(B),
|
|
1410
|
-
redo: () => c(map(
|
|
1381
|
+
redo: () => c(map(x, (E) => ({ _id: E, ...h })))
|
|
1411
1382
|
});
|
|
1412
1383
|
},
|
|
1413
|
-
updateBlocksRuntime: (
|
|
1414
|
-
c(map(
|
|
1384
|
+
updateBlocksRuntime: (x, h) => {
|
|
1385
|
+
c(map(x, (y) => ({ _id: y, ...h })));
|
|
1415
1386
|
},
|
|
1416
|
-
setNewBlocks: (
|
|
1417
|
-
r(
|
|
1387
|
+
setNewBlocks: (x) => {
|
|
1388
|
+
r(x), o({
|
|
1418
1389
|
undo: () => r(n),
|
|
1419
|
-
redo: () => r(
|
|
1390
|
+
redo: () => r(x)
|
|
1420
1391
|
});
|
|
1421
1392
|
},
|
|
1422
|
-
updateMultipleBlocksProps: (
|
|
1423
|
-
let
|
|
1424
|
-
|
|
1393
|
+
updateMultipleBlocksProps: (x) => {
|
|
1394
|
+
let h = [];
|
|
1395
|
+
h = map(x, (y) => {
|
|
1425
1396
|
const B = keys(y), E = n.find((S) => S._id === y._id), w = {};
|
|
1426
1397
|
return each(B, (S) => w[S] = E[S]), w;
|
|
1427
|
-
}), c(
|
|
1428
|
-
undo: () => c(
|
|
1429
|
-
redo: () => c(
|
|
1398
|
+
}), c(x), o({
|
|
1399
|
+
undo: () => c(h),
|
|
1400
|
+
redo: () => c(x)
|
|
1430
1401
|
});
|
|
1431
1402
|
}
|
|
1432
1403
|
};
|
|
1433
|
-
},
|
|
1404
|
+
}, canAcceptChildBlock = (o, n) => {
|
|
1405
|
+
if (!o) return !0;
|
|
1406
|
+
const r = getRegisteredChaiBlock(o);
|
|
1407
|
+
return r && has(r, "canAcceptBlock") ? r.canAcceptBlock(n) : !1;
|
|
1408
|
+
}, canAddChildBlock = (o) => {
|
|
1409
|
+
const n = getRegisteredChaiBlock(o);
|
|
1410
|
+
return n ? has(n, "canAcceptBlock") : !1;
|
|
1411
|
+
}, canBeNestedInside = (o, n) => {
|
|
1412
|
+
const r = getRegisteredChaiBlock(n);
|
|
1413
|
+
return r && has(r, "canBeNested") ? r.canBeNested(o) : !0;
|
|
1414
|
+
}, canDuplicateBlock = (o) => {
|
|
1415
|
+
const n = getRegisteredChaiBlock(o);
|
|
1416
|
+
return n && has(n, "canDuplicate") ? n.canDuplicate() : !0;
|
|
1417
|
+
}, canDeleteBlock = (o) => {
|
|
1418
|
+
const n = getRegisteredChaiBlock(o);
|
|
1419
|
+
return n && has(n, "canDelete") ? n.canDelete() : !0;
|
|
1420
|
+
}, canDropBlock = (o, { dragSource: n, dropTarget: r }) => {
|
|
1421
|
+
const a = get(n, "data._type", ""), l = get(r, "data._type", "");
|
|
1422
|
+
return canAcceptChildBlock(l, a);
|
|
1423
|
+
};
|
|
1424
|
+
import.meta.vitest && describe("canDropBlock Function", () => {
|
|
1425
|
+
it('should return false if dragSourceType is "Slot"', () => {
|
|
1426
|
+
const o = { data: { _type: "Slot" } }, n = { data: {} };
|
|
1427
|
+
expect(canDropBlock({}, { dragSource: o, dropTarget: n })).toBe(!0);
|
|
1428
|
+
}), it("should return true if dropTargetType is empty", () => {
|
|
1429
|
+
const o = { data: { _type: "Box" } }, n = { data: {} };
|
|
1430
|
+
expect(canDropBlock({}, { dragSource: o, dropTarget: n })).toBe(!0);
|
|
1431
|
+
});
|
|
1432
|
+
});
|
|
1433
|
+
const useAddBlock = () => {
|
|
1434
1434
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1435
1435
|
(i, c, d) => {
|
|
1436
|
-
var
|
|
1437
|
-
for (let
|
|
1438
|
-
const { _id:
|
|
1439
|
-
i[
|
|
1440
|
-
const
|
|
1441
|
-
for (let y = 0; y <
|
|
1442
|
-
|
|
1436
|
+
var f;
|
|
1437
|
+
for (let b = 0; b < i.length; b++) {
|
|
1438
|
+
const { _id: x } = i[b];
|
|
1439
|
+
i[b]._id = generateUUID();
|
|
1440
|
+
const h = filter(i, { _parent: x });
|
|
1441
|
+
for (let y = 0; y < h.length; y++)
|
|
1442
|
+
h[y]._parent = i[b]._id;
|
|
1443
1443
|
}
|
|
1444
1444
|
const p = first(i);
|
|
1445
1445
|
let u, g;
|
|
1446
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(
|
|
1446
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(f = first(i)) == null ? void 0 : f._id]), first(i);
|
|
1447
1447
|
},
|
|
1448
1448
|
[r, o, n]
|
|
1449
1449
|
);
|
|
1450
1450
|
return { addCoreBlock: useCallback(
|
|
1451
1451
|
(i, c, d) => {
|
|
1452
1452
|
if (has(i, "blocks")) {
|
|
1453
|
-
const
|
|
1454
|
-
return a(
|
|
1453
|
+
const h = i.blocks;
|
|
1454
|
+
return a(h, c, d);
|
|
1455
1455
|
}
|
|
1456
1456
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
1457
1457
|
_type: i.type,
|
|
1458
1458
|
_id: p,
|
|
1459
1459
|
...u
|
|
1460
1460
|
};
|
|
1461
|
-
let m,
|
|
1462
|
-
return c && (m = find(o, { _id: c }), g._parent = c,
|
|
1461
|
+
let m, f;
|
|
1462
|
+
return c && (m = find(o, { _id: c }), g._parent = c, f = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, f = m._parent), r([g], f, d), n([g._id]), g;
|
|
1463
1463
|
},
|
|
1464
1464
|
[r, a, o, n]
|
|
1465
1465
|
), addPredefinedBlock: a };
|
|
@@ -2622,359 +2622,7 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
|
|
|
2622
2622
|
},
|
|
2623
2623
|
[o, n, r]
|
|
2624
2624
|
);
|
|
2625
|
-
},
|
|
2626
|
-
const n = o(canvasWidthAtom);
|
|
2627
|
-
return getBreakpointValue(n).toLowerCase();
|
|
2628
|
-
}), useCanvasWidth = () => {
|
|
2629
|
-
const [o, n] = useAtom$1(canvasWidthAtom), r = useAtomValue$1(canvasBreakpointAtom), [a, l] = useStylingBreakpoint();
|
|
2630
|
-
return useEffect(() => {
|
|
2631
|
-
a !== "xs" && l(r);
|
|
2632
|
-
}, [r, a, l]), [o, r, n];
|
|
2633
|
-
}, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), cutBlockIdsAtom = atom$1([]), useCutBlockIds = () => {
|
|
2634
|
-
const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
|
|
2635
|
-
(l) => {
|
|
2636
|
-
n(l), r([]);
|
|
2637
|
-
},
|
|
2638
|
-
[n, r]
|
|
2639
|
-
);
|
|
2640
|
-
return [o, a];
|
|
2641
|
-
}, copiedBlockIdsAtom = atom$1([]), useCopyBlockIds = () => {
|
|
2642
|
-
const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), l = useCallback(
|
|
2643
|
-
async (i) => {
|
|
2644
|
-
try {
|
|
2645
|
-
r(i), a([]);
|
|
2646
|
-
const c = {
|
|
2647
|
-
_chai_copied_blocks: i.flatMap((d) => getDuplicatedBlocks(o, d, null))
|
|
2648
|
-
};
|
|
2649
|
-
await navigator.clipboard.writeText(JSON.stringify(c));
|
|
2650
|
-
} catch (c) {
|
|
2651
|
-
console.error("Failed to copy blocks to clipboard:", c);
|
|
2652
|
-
}
|
|
2653
|
-
},
|
|
2654
|
-
[r, a, o]
|
|
2655
|
-
);
|
|
2656
|
-
return [n, l];
|
|
2657
|
-
}, darkModeAtom = atomWithStorage("darkMode", !1), useDarkMode = () => {
|
|
2658
|
-
const [o, n] = useAtom$1(darkModeAtom);
|
|
2659
|
-
return [o, n];
|
|
2660
|
-
}, useDuplicateBlocks = () => {
|
|
2661
|
-
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions();
|
|
2662
|
-
return useCallback(
|
|
2663
|
-
(a, l = null) => {
|
|
2664
|
-
const i = [];
|
|
2665
|
-
each(a, (c) => {
|
|
2666
|
-
const d = o.find((h) => h._id === c);
|
|
2667
|
-
l ? l === "root" && (l = null) : l = d._parent;
|
|
2668
|
-
const g = filter(
|
|
2669
|
-
o,
|
|
2670
|
-
(h) => isString(l) ? h._parent === l : !h._parent
|
|
2671
|
-
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
2672
|
-
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
2673
|
-
}), n(i);
|
|
2674
|
-
},
|
|
2675
|
-
[o, n]
|
|
2676
|
-
);
|
|
2677
|
-
}, hiddenBlockIdsAtom = atom$1([]), useHiddenBlockIds = () => {
|
|
2678
|
-
const [o, n] = useAtom$1(hiddenBlockIdsAtom), r = useCallback(
|
|
2679
|
-
(a) => {
|
|
2680
|
-
n((l) => includes(l, a) ? without(l, a) : [...l, a]);
|
|
2681
|
-
},
|
|
2682
|
-
[n]
|
|
2683
|
-
);
|
|
2684
|
-
return [o, n, r];
|
|
2685
|
-
}, highlightBlockIdAtom = atom$1(""), useHighlightBlockId = () => useAtom$1(highlightBlockIdAtom), useCanPaste = () => {
|
|
2686
|
-
const [o] = useBlocksStore();
|
|
2687
|
-
return (n, r) => {
|
|
2688
|
-
var i;
|
|
2689
|
-
const a = ((i = find(o, { _id: r })) == null ? void 0 : i._type) || null, l = first(n.map((c) => {
|
|
2690
|
-
var d;
|
|
2691
|
-
return (d = find(o, { _id: c })) == null ? void 0 : d._type;
|
|
2692
|
-
}));
|
|
2693
|
-
return canAcceptChildBlock(a, l);
|
|
2694
|
-
};
|
|
2695
|
-
}, useMoveCutBlocks = () => {
|
|
2696
|
-
const o = useAtomValue$1(presentBlocksAtom), { moveBlocks: n } = useBlocksStoreUndoableActions();
|
|
2697
|
-
return useCallback(
|
|
2698
|
-
(r, a) => {
|
|
2699
|
-
const l = Array.isArray(a) ? a[0] : a;
|
|
2700
|
-
if (a === "root") {
|
|
2701
|
-
const i = o == null ? void 0 : o.filter((c) => !c._parent);
|
|
2702
|
-
n(r, null, (i == null ? void 0 : i.length) || 0);
|
|
2703
|
-
} else {
|
|
2704
|
-
const i = o == null ? void 0 : o.filter((c) => c._parent === l);
|
|
2705
|
-
n(r, l, (i == null ? void 0 : i.length) || 0);
|
|
2706
|
-
}
|
|
2707
|
-
},
|
|
2708
|
-
[n, o]
|
|
2709
|
-
);
|
|
2710
|
-
}, usePasteBlocks = () => {
|
|
2711
|
-
const [o, n] = useCutBlockIds(), r = useMoveCutBlocks(), a = useCanPaste(), { toast: l } = useToast(), { addPredefinedBlock: i } = useAddBlock();
|
|
2712
|
-
return {
|
|
2713
|
-
canPaste: useCallback(
|
|
2714
|
-
async (d) => {
|
|
2715
|
-
if (o.length > 0)
|
|
2716
|
-
return a(o, d);
|
|
2717
|
-
try {
|
|
2718
|
-
const p = await navigator.clipboard.readText();
|
|
2719
|
-
if (p) {
|
|
2720
|
-
const u = JSON.parse(p);
|
|
2721
|
-
return has(u, "_chai_copied_blocks");
|
|
2722
|
-
}
|
|
2723
|
-
} catch {
|
|
2724
|
-
return !1;
|
|
2725
|
-
}
|
|
2726
|
-
return !1;
|
|
2727
|
-
},
|
|
2728
|
-
[a, o]
|
|
2729
|
-
),
|
|
2730
|
-
pasteBlocks: useCallback(
|
|
2731
|
-
async (d) => {
|
|
2732
|
-
const p = Array.isArray(d) ? d[0] : d;
|
|
2733
|
-
if (!isEmpty(o)) {
|
|
2734
|
-
r(o, d), n([]), await navigator.clipboard.writeText("");
|
|
2735
|
-
return;
|
|
2736
|
-
}
|
|
2737
|
-
try {
|
|
2738
|
-
const u = await navigator.clipboard.readText();
|
|
2739
|
-
if (u) {
|
|
2740
|
-
const g = JSON.parse(u);
|
|
2741
|
-
has(g, "_chai_copied_blocks") ? i(g._chai_copied_blocks, p === "root" ? null : p) : l({ title: "Error", description: "Nothing to paste" });
|
|
2742
|
-
} else
|
|
2743
|
-
l({ title: "Error", description: "Nothing to paste" });
|
|
2744
|
-
} catch {
|
|
2745
|
-
l({ title: "Error", description: "Failed to paste blocks from clipboard" });
|
|
2746
|
-
}
|
|
2747
|
-
},
|
|
2748
|
-
[o, i, r, n, l]
|
|
2749
|
-
)
|
|
2750
|
-
};
|
|
2751
|
-
}, previewModeAtom = atom$1(!1), usePreviewMode = () => {
|
|
2752
|
-
const [o, n] = useAtom$1(previewModeAtom);
|
|
2753
|
-
return [o, n];
|
|
2754
|
-
}, removeClassFromBlocksAtom = atom$1(null, (o, n, { blockIds: r, fullClasses: a }) => {
|
|
2755
|
-
const l = first(o(selectedStylingBlocksAtom)), i = filter(
|
|
2756
|
-
o(pageBlocksAtomsAtom),
|
|
2757
|
-
(c) => (
|
|
2758
|
-
// @ts-ignore
|
|
2759
|
-
r.includes(o(c)._id)
|
|
2760
|
-
)
|
|
2761
|
-
);
|
|
2762
|
-
return map(i, (c) => {
|
|
2763
|
-
const d = o(c), p = a;
|
|
2764
|
-
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2765
|
-
return each(p, (m) => {
|
|
2766
|
-
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2767
|
-
u = u.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2768
|
-
const f = first(m.split(":"));
|
|
2769
|
-
includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(m.split(":").pop().trim());
|
|
2770
|
-
}), each(p, (m) => {
|
|
2771
|
-
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2772
|
-
g = g.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2773
|
-
}), {
|
|
2774
|
-
ids: [d._id],
|
|
2775
|
-
props: {
|
|
2776
|
-
[l.prop]: `${STYLES_KEY}${g},${u}`
|
|
2777
|
-
}
|
|
2778
|
-
};
|
|
2779
|
-
});
|
|
2780
|
-
}), useRemoveClassesFromBlocks = () => {
|
|
2781
|
-
const { updateBlocks: o } = useBlocksStoreUndoableActions(), n = useSetAtom$1(removeClassFromBlocksAtom);
|
|
2782
|
-
return useCallback(
|
|
2783
|
-
(r, a) => {
|
|
2784
|
-
const l = n({ blockIds: r, fullClasses: a });
|
|
2785
|
-
o(r, l[0].props);
|
|
2786
|
-
},
|
|
2787
|
-
[n]
|
|
2788
|
-
);
|
|
2789
|
-
}, selectedBlockAllClassesAtom = atom$1((o) => {
|
|
2790
|
-
const n = first(o(selectedStylingBlocksAtom)), r = o(selectedBlockAtom);
|
|
2791
|
-
if (!n || n.blockId !== get(r, "_id", null)) return [];
|
|
2792
|
-
const a = get(r, n.prop, `${STYLES_KEY},`), { classes: l } = getSplitChaiClasses(a);
|
|
2793
|
-
return console.log("classes", l), filter(map(l.trim().split(" "), constructClassObject), (i) => !isNull(i));
|
|
2794
|
-
}), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom$1((o) => {
|
|
2795
|
-
const n = o(canvasBreakpointAtom), r = o(styleStateAtom), a = o(darkModeAtom), l = getQueries(n);
|
|
2796
|
-
let i = filter(o(selectedBlockAllClassesAtom), { mod: r });
|
|
2797
|
-
return startsWith(r, "_") || (i = filter(i, (c) => l.includes(c.mq))), i = i.sort((c, d) => MQ[c.mq] - MQ[d.mq]), a || (i = filter(i, { dark: !1 })), i;
|
|
2798
|
-
}), getQueries = (o) => {
|
|
2799
|
-
let n = [];
|
|
2800
|
-
switch (o) {
|
|
2801
|
-
case "xs":
|
|
2802
|
-
n = ["xs"];
|
|
2803
|
-
break;
|
|
2804
|
-
case "sm":
|
|
2805
|
-
n = ["xs", "sm"];
|
|
2806
|
-
break;
|
|
2807
|
-
case "md":
|
|
2808
|
-
n = ["xs", "sm", "md"];
|
|
2809
|
-
break;
|
|
2810
|
-
case "lg":
|
|
2811
|
-
n = ["xs", "sm", "md", "lg"];
|
|
2812
|
-
break;
|
|
2813
|
-
case "xl":
|
|
2814
|
-
n = ["xs", "sm", "md", "lg", "xl"];
|
|
2815
|
-
break;
|
|
2816
|
-
case "2xl":
|
|
2817
|
-
n = ["xs", "sm", "md", "lg", "xl", "2xl"];
|
|
2818
|
-
break;
|
|
2819
|
-
default:
|
|
2820
|
-
n = ["xs"];
|
|
2821
|
-
break;
|
|
2822
|
-
}
|
|
2823
|
-
return n;
|
|
2824
|
-
}, useSelectedBlockCurrentClasses = () => useAtomValue$1(selectedBlockCurrentClassesAtom), useStylingState = () => useAtom$1(styleStateAtom), languageAtom = atom$1("");
|
|
2825
|
-
languageAtom.debugLabel = "selectedLanguageAtom";
|
|
2826
|
-
const useLanguages = () => {
|
|
2827
|
-
const o = useBuilderProp("languages", []), n = useBuilderProp("fallbackLang", "en"), [r, a] = useAtom$1(languageAtom), l = (i) => {
|
|
2828
|
-
a(n === i ? "" : i);
|
|
2829
|
-
};
|
|
2830
|
-
return {
|
|
2831
|
-
languages: o == null ? void 0 : o.filter((i) => i !== n),
|
|
2832
|
-
fallbackLang: n,
|
|
2833
|
-
selectedLang: r,
|
|
2834
|
-
setSelectedLang: l
|
|
2835
|
-
};
|
|
2836
|
-
}, updatePropsForLanguage = (o, n, r) => {
|
|
2837
|
-
const a = getRegisteredChaiBlock(get(r, "_type"));
|
|
2838
|
-
if (!a) return o;
|
|
2839
|
-
const l = { ...o };
|
|
2840
|
-
return forEach(keys(o), (i) => {
|
|
2841
|
-
if (includes(get(a, "i18nProps", []), i) && !isEmpty(n)) {
|
|
2842
|
-
const c = `${i}-${n}`;
|
|
2843
|
-
set(l, c, o[i]), unset(l, i);
|
|
2844
|
-
}
|
|
2845
|
-
}), l;
|
|
2846
|
-
}, useUpdateBlocksProps = () => {
|
|
2847
|
-
const { updateBlocks: o } = useBlocksStoreUndoableActions(), { selectedLang: n } = useLanguages(), r = useSelectedBlock();
|
|
2848
|
-
return useCallback(
|
|
2849
|
-
(a, l, i) => {
|
|
2850
|
-
const c = updatePropsForLanguage(l, n, r);
|
|
2851
|
-
o(a, c, i);
|
|
2852
|
-
},
|
|
2853
|
-
[n, r, o]
|
|
2854
|
-
);
|
|
2855
|
-
}, useUpdateMultipleBlocksProps = () => {
|
|
2856
|
-
const { updateMultipleBlocksProps: o } = useBlocksStoreUndoableActions();
|
|
2857
|
-
return useCallback(
|
|
2858
|
-
(n) => {
|
|
2859
|
-
o(n);
|
|
2860
|
-
},
|
|
2861
|
-
[o]
|
|
2862
|
-
);
|
|
2863
|
-
}, useFakeStreamEffect = () => {
|
|
2864
|
-
const { updateBlocksRuntime: o } = useBlocksStoreUndoableActions();
|
|
2865
|
-
return useCallback(
|
|
2866
|
-
async (n, r, a = 30) => {
|
|
2867
|
-
const l = keys(omit(r, ["_id"]));
|
|
2868
|
-
for (const i of l) {
|
|
2869
|
-
const c = r[i];
|
|
2870
|
-
if (isString(c)) {
|
|
2871
|
-
const d = chunk(c.split(""), 12);
|
|
2872
|
-
let p = "";
|
|
2873
|
-
o([n], { [i]: "" });
|
|
2874
|
-
for (let u = 0; u < d.length; u++)
|
|
2875
|
-
p += d[u].join(""), o([n], { [i]: p }), await new Promise((g) => setTimeout(g, a));
|
|
2876
|
-
}
|
|
2877
|
-
}
|
|
2878
|
-
},
|
|
2879
|
-
[o]
|
|
2880
|
-
);
|
|
2881
|
-
}, useStreamMultipleBlocksProps = () => {
|
|
2882
|
-
const { updateMultipleBlocksProps: o } = useBlocksStoreUndoableActions(), n = useFakeStreamEffect();
|
|
2883
|
-
return useCallback(
|
|
2884
|
-
async (r) => {
|
|
2885
|
-
for (const a of r)
|
|
2886
|
-
await n(a._id, a);
|
|
2887
|
-
o(r);
|
|
2888
|
-
},
|
|
2889
|
-
[n, o]
|
|
2890
|
-
);
|
|
2891
|
-
}, useUpdateBlocksPropsRealtime = () => {
|
|
2892
|
-
const { updateBlocksRuntime: o } = useBlocksStoreUndoableActions(), { selectedLang: n } = useLanguages(), r = useSelectedBlock();
|
|
2893
|
-
return useCallback(
|
|
2894
|
-
(a, l) => {
|
|
2895
|
-
const i = updatePropsForLanguage(l, n, r);
|
|
2896
|
-
o(a, i);
|
|
2897
|
-
},
|
|
2898
|
-
[n, r, o]
|
|
2899
|
-
);
|
|
2900
|
-
}, selectedBreakpointsAtom = atomWithStorage("selectedBreakpoints", ["XS", "MD", "XL"]), useSelectedBreakpoints = () => {
|
|
2901
|
-
const [o, n] = useAtom$1(selectedBreakpointsAtom);
|
|
2902
|
-
return [o, n];
|
|
2903
|
-
};
|
|
2904
|
-
let lastHighlighted = null;
|
|
2905
|
-
const useBlockHighlight = () => {
|
|
2906
|
-
const [o] = useAtom$1(canvasIframeAtom), n = useMemo(() => {
|
|
2907
|
-
var l;
|
|
2908
|
-
return (o == null ? void 0 : o.contentDocument) || ((l = o == null ? void 0 : o.contentWindow) == null ? void 0 : l.document);
|
|
2909
|
-
}, [o]);
|
|
2910
|
-
return { highlightBlock: useCallback(
|
|
2911
|
-
(l) => {
|
|
2912
|
-
if (n)
|
|
2913
|
-
if (lastHighlighted && lastHighlighted.removeAttribute("data-highlighted"), typeof l != "string")
|
|
2914
|
-
l.setAttribute("data-highlighted", "true"), lastHighlighted = l;
|
|
2915
|
-
else if (typeof l == "string") {
|
|
2916
|
-
const i = n.querySelector(`[data-block-id="${l}"]`);
|
|
2917
|
-
i && (i.setAttribute("data-highlighted", "true"), lastHighlighted = i);
|
|
2918
|
-
} else
|
|
2919
|
-
lastHighlighted = null;
|
|
2920
|
-
},
|
|
2921
|
-
[n]
|
|
2922
|
-
), clearHighlight: () => {
|
|
2923
|
-
lastHighlighted && (lastHighlighted.removeAttribute("data-highlighted"), lastHighlighted = null);
|
|
2924
|
-
}, lastHighlighted };
|
|
2925
|
-
}, globalBlocksStoreAtom = atom({}), globalBlocksLoadingStateAtom = atom({}), useGlobalBlocksStore = () => {
|
|
2926
|
-
const [o, n] = useAtom(globalBlocksStoreAtom), r = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => n({}), [n]);
|
|
2927
|
-
return { getGlobalBlocks: r, reset: a };
|
|
2928
|
-
}, useWatchGlobalBlocks = () => {
|
|
2929
|
-
const [o] = useBlocksStore(), [n, r] = useAtom(globalBlocksStoreAtom), [a, l] = useAtom(globalBlocksLoadingStateAtom), i = useBuilderProp("getGlobalBlockBlocks", async (d) => []), c = useMemo(() => o.filter((p) => p._type === "GlobalBlock").filter((p) => p._type === "GlobalBlock").map((p) => p.globalBlock), [o]);
|
|
2930
|
-
useEffect(() => {
|
|
2931
|
-
forEach(c, (d) => {
|
|
2932
|
-
has(n, d) || get(a, `${d}.loading`, !1) || (l((p) => ({ ...p, [d]: { loading: !0, error: null } })), i(d).then((p) => {
|
|
2933
|
-
r((u) => ({ ...u, [d]: p })), l((u) => ({
|
|
2934
|
-
...u,
|
|
2935
|
-
[d]: { loading: !1, error: null }
|
|
2936
|
-
}));
|
|
2937
|
-
}).catch((p) => {
|
|
2938
|
-
l((u) => ({
|
|
2939
|
-
...u,
|
|
2940
|
-
[d]: { loading: !1, error: p.message }
|
|
2941
|
-
}));
|
|
2942
|
-
}));
|
|
2943
|
-
});
|
|
2944
|
-
}, [
|
|
2945
|
-
i,
|
|
2946
|
-
n,
|
|
2947
|
-
c,
|
|
2948
|
-
a,
|
|
2949
|
-
r,
|
|
2950
|
-
l
|
|
2951
|
-
]);
|
|
2952
|
-
}, globalBlocksListAtom = atom({}), useGlobalBlocksList = () => {
|
|
2953
|
-
const [o, n] = useState(!1), [r, a] = useAtom(globalBlocksListAtom), l = useBuilderProp("getGlobalBlocks", async () => []), i = useCallback(async () => {
|
|
2954
|
-
n(!0);
|
|
2955
|
-
const c = await l();
|
|
2956
|
-
a(c), n(!1);
|
|
2957
|
-
}, [l, a]);
|
|
2958
|
-
return useEffect(() => {
|
|
2959
|
-
i();
|
|
2960
|
-
}, []), { data: r, isLoading: o, refetch: i };
|
|
2961
|
-
}, useBuilderReset = () => {
|
|
2962
|
-
const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: a } = useBlockHighlight(), [, l] = useSelectedStylingBlocks(), [, i] = useAtom(aiAssistantActiveAtom), { reset: c } = useGlobalBlocksStore();
|
|
2963
|
-
return () => {
|
|
2964
|
-
r([]), l([]), a(), n(), i(!1), o({ undoCount: 0, redoCount: 0 }), c();
|
|
2965
|
-
};
|
|
2966
|
-
}, useUILibraryBlocks = () => ({ data: useBuilderProp("uiLibraries", []), isLoading: !1 }), useCopyToClipboard = () => {
|
|
2967
|
-
const [o, n] = useState(null), r = useCallback(async (a) => {
|
|
2968
|
-
if (!(navigator != null && navigator.clipboard))
|
|
2969
|
-
return console.warn("Clipboard not supported"), !1;
|
|
2970
|
-
try {
|
|
2971
|
-
return await navigator.clipboard.writeText(a), n(a), !0;
|
|
2972
|
-
} catch (l) {
|
|
2973
|
-
return console.warn("Copy failed", l), n(null), !1;
|
|
2974
|
-
}
|
|
2975
|
-
}, []);
|
|
2976
|
-
return [o, r];
|
|
2977
|
-
}, codeEditorAtom = atom$1(null), useCodeEditor = () => useAtom$1(codeEditorAtom), LANGUAGES = {
|
|
2625
|
+
}, LANGUAGES = {
|
|
2978
2626
|
ab: "Abkhazian",
|
|
2979
2627
|
aa: "Afar",
|
|
2980
2628
|
af: "Afrikaans",
|
|
@@ -3162,6 +2810,82 @@ const useBlockHighlight = () => {
|
|
|
3162
2810
|
yo: "Yoruba",
|
|
3163
2811
|
za: "Zhuang, Chuang",
|
|
3164
2812
|
zu: "Zulu"
|
|
2813
|
+
}, languageAtom = atom$1("");
|
|
2814
|
+
languageAtom.debugLabel = "selectedLanguageAtom";
|
|
2815
|
+
const useLanguages = () => {
|
|
2816
|
+
const o = useBuilderProp("languages", []), n = useBuilderProp("fallbackLang", "en"), [r, a] = useAtom$1(languageAtom), l = (i) => {
|
|
2817
|
+
a(n === i ? "" : i);
|
|
2818
|
+
};
|
|
2819
|
+
return {
|
|
2820
|
+
languages: o == null ? void 0 : o.filter((i) => i !== n),
|
|
2821
|
+
fallbackLang: n,
|
|
2822
|
+
selectedLang: r,
|
|
2823
|
+
setSelectedLang: l
|
|
2824
|
+
};
|
|
2825
|
+
}, updatePropsForLanguage = (o, n, r) => {
|
|
2826
|
+
const a = getRegisteredChaiBlock(get(r, "_type"));
|
|
2827
|
+
if (!a) return o;
|
|
2828
|
+
const l = { ...o };
|
|
2829
|
+
return forEach(keys(o), (i) => {
|
|
2830
|
+
if (includes(get(a, "i18nProps", []), i) && !isEmpty(n)) {
|
|
2831
|
+
const c = `${i}-${n}`;
|
|
2832
|
+
set(l, c, o[i]), unset(l, i);
|
|
2833
|
+
}
|
|
2834
|
+
}), l;
|
|
2835
|
+
}, useUpdateBlocksProps = () => {
|
|
2836
|
+
const { updateBlocks: o } = useBlocksStoreUndoableActions(), { selectedLang: n } = useLanguages(), r = useSelectedBlock();
|
|
2837
|
+
return useCallback(
|
|
2838
|
+
(a, l, i) => {
|
|
2839
|
+
const c = updatePropsForLanguage(l, n, r);
|
|
2840
|
+
o(a, c, i);
|
|
2841
|
+
},
|
|
2842
|
+
[n, r, o]
|
|
2843
|
+
);
|
|
2844
|
+
}, useUpdateMultipleBlocksProps = () => {
|
|
2845
|
+
const { updateMultipleBlocksProps: o } = useBlocksStoreUndoableActions();
|
|
2846
|
+
return useCallback(
|
|
2847
|
+
(n) => {
|
|
2848
|
+
o(n);
|
|
2849
|
+
},
|
|
2850
|
+
[o]
|
|
2851
|
+
);
|
|
2852
|
+
}, useFakeStreamEffect = () => {
|
|
2853
|
+
const { updateBlocksRuntime: o } = useBlocksStoreUndoableActions();
|
|
2854
|
+
return useCallback(
|
|
2855
|
+
async (n, r, a = 30) => {
|
|
2856
|
+
const l = keys(omit(r, ["_id"]));
|
|
2857
|
+
for (const i of l) {
|
|
2858
|
+
const c = r[i];
|
|
2859
|
+
if (isString(c)) {
|
|
2860
|
+
const d = chunk(c.split(""), 12);
|
|
2861
|
+
let p = "";
|
|
2862
|
+
o([n], { [i]: "" });
|
|
2863
|
+
for (let u = 0; u < d.length; u++)
|
|
2864
|
+
p += d[u].join(""), o([n], { [i]: p }), await new Promise((g) => setTimeout(g, a));
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
},
|
|
2868
|
+
[o]
|
|
2869
|
+
);
|
|
2870
|
+
}, useStreamMultipleBlocksProps = () => {
|
|
2871
|
+
const { updateMultipleBlocksProps: o } = useBlocksStoreUndoableActions(), n = useFakeStreamEffect();
|
|
2872
|
+
return useCallback(
|
|
2873
|
+
async (r) => {
|
|
2874
|
+
for (const a of r)
|
|
2875
|
+
await n(a._id, a);
|
|
2876
|
+
o(r);
|
|
2877
|
+
},
|
|
2878
|
+
[n, o]
|
|
2879
|
+
);
|
|
2880
|
+
}, useUpdateBlocksPropsRealtime = () => {
|
|
2881
|
+
const { updateBlocksRuntime: o } = useBlocksStoreUndoableActions(), { selectedLang: n } = useLanguages(), r = useSelectedBlock();
|
|
2882
|
+
return useCallback(
|
|
2883
|
+
(a, l) => {
|
|
2884
|
+
const i = updatePropsForLanguage(l, n, r);
|
|
2885
|
+
o(a, i);
|
|
2886
|
+
},
|
|
2887
|
+
[n, r, o]
|
|
2888
|
+
);
|
|
3165
2889
|
};
|
|
3166
2890
|
function getChildBlocks(o, n, r) {
|
|
3167
2891
|
r.push(find(o, { _id: n }));
|
|
@@ -3181,69 +2905,348 @@ const getBlockWithChildren = (o, n) => {
|
|
|
3181
2905
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
3182
2906
|
})
|
|
3183
2907
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
3184
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (
|
|
3185
|
-
const
|
|
3186
|
-
for (const
|
|
3187
|
-
const y =
|
|
2908
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f, b) => {
|
|
2909
|
+
const x = cloneDeep(b.find((h) => h._id === f));
|
|
2910
|
+
for (const h in x) {
|
|
2911
|
+
const y = x[h];
|
|
3188
2912
|
if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
|
|
3189
2913
|
const { baseClasses: B, classes: E } = getSplitChaiClasses(y);
|
|
3190
|
-
|
|
2914
|
+
x[h] = compact(flattenDeep([B, E])).join(" ");
|
|
3191
2915
|
} else
|
|
3192
|
-
|
|
2916
|
+
h !== "_id" && delete x[h];
|
|
2917
|
+
}
|
|
2918
|
+
return x;
|
|
2919
|
+
};
|
|
2920
|
+
return {
|
|
2921
|
+
askAi: useCallback(
|
|
2922
|
+
async (f, b, x, h) => {
|
|
2923
|
+
if (l) {
|
|
2924
|
+
n(!0), a(null);
|
|
2925
|
+
try {
|
|
2926
|
+
const y = p === u ? "" : p, B = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(b, d)), p) : [m(b, d)], E = await l(f, addLangToPrompt(x, g, f), B, y), { blocks: w, error: S } = E;
|
|
2927
|
+
if (S) {
|
|
2928
|
+
a(S);
|
|
2929
|
+
return;
|
|
2930
|
+
}
|
|
2931
|
+
if (f === "styles") {
|
|
2932
|
+
const A = w.map((_) => {
|
|
2933
|
+
for (const C in _)
|
|
2934
|
+
C !== "_id" && (_[C] = `${STYLES_KEY},${_[C]}`);
|
|
2935
|
+
return _;
|
|
2936
|
+
});
|
|
2937
|
+
c(A);
|
|
2938
|
+
} else
|
|
2939
|
+
i(w);
|
|
2940
|
+
h && h(E);
|
|
2941
|
+
} catch (y) {
|
|
2942
|
+
a(y);
|
|
2943
|
+
} finally {
|
|
2944
|
+
n(!1), h && h();
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
},
|
|
2948
|
+
[
|
|
2949
|
+
l,
|
|
2950
|
+
n,
|
|
2951
|
+
p,
|
|
2952
|
+
u,
|
|
2953
|
+
d,
|
|
2954
|
+
g,
|
|
2955
|
+
c,
|
|
2956
|
+
i
|
|
2957
|
+
]
|
|
2958
|
+
),
|
|
2959
|
+
loading: o,
|
|
2960
|
+
error: r
|
|
2961
|
+
};
|
|
2962
|
+
}, useAiAssistant = () => {
|
|
2963
|
+
const [, o] = useRightPanel();
|
|
2964
|
+
return useCallback(
|
|
2965
|
+
(n) => {
|
|
2966
|
+
o(n ? "ai" : "block");
|
|
2967
|
+
},
|
|
2968
|
+
[o]
|
|
2969
|
+
);
|
|
2970
|
+
};
|
|
2971
|
+
let lastHighlighted = null;
|
|
2972
|
+
const useBlockHighlight = () => {
|
|
2973
|
+
const [o] = useAtom$1(canvasIframeAtom), n = useMemo(() => {
|
|
2974
|
+
var l;
|
|
2975
|
+
return (o == null ? void 0 : o.contentDocument) || ((l = o == null ? void 0 : o.contentWindow) == null ? void 0 : l.document);
|
|
2976
|
+
}, [o]);
|
|
2977
|
+
return { highlightBlock: useCallback(
|
|
2978
|
+
(l) => {
|
|
2979
|
+
if (n)
|
|
2980
|
+
if (lastHighlighted && lastHighlighted.removeAttribute("data-highlighted"), typeof l != "string")
|
|
2981
|
+
l.setAttribute("data-highlighted", "true"), lastHighlighted = l;
|
|
2982
|
+
else if (typeof l == "string") {
|
|
2983
|
+
const i = n.querySelector(`[data-block-id="${l}"]`);
|
|
2984
|
+
i && (i.setAttribute("data-highlighted", "true"), lastHighlighted = i);
|
|
2985
|
+
} else
|
|
2986
|
+
lastHighlighted = null;
|
|
2987
|
+
},
|
|
2988
|
+
[n]
|
|
2989
|
+
), clearHighlight: () => {
|
|
2990
|
+
lastHighlighted && (lastHighlighted.removeAttribute("data-highlighted"), lastHighlighted = null);
|
|
2991
|
+
}, lastHighlighted };
|
|
2992
|
+
}, globalBlocksStoreAtom = atom({}), globalBlocksLoadingStateAtom = atom({}), useGlobalBlocksStore = () => {
|
|
2993
|
+
const [o, n] = useAtom(globalBlocksStoreAtom), r = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => n({}), [n]);
|
|
2994
|
+
return { getGlobalBlocks: r, reset: a };
|
|
2995
|
+
}, useWatchGlobalBlocks = () => {
|
|
2996
|
+
const [o] = useBlocksStore(), [n, r] = useAtom(globalBlocksStoreAtom), [a, l] = useAtom(globalBlocksLoadingStateAtom), i = useBuilderProp("getGlobalBlockBlocks", async (d) => []), c = useMemo(() => o.filter((p) => p._type === "GlobalBlock").filter((p) => p._type === "GlobalBlock").map((p) => p.globalBlock), [o]);
|
|
2997
|
+
useEffect(() => {
|
|
2998
|
+
forEach(c, (d) => {
|
|
2999
|
+
has(n, d) || get(a, `${d}.loading`, !1) || (l((p) => ({ ...p, [d]: { loading: !0, error: null } })), i(d).then((p) => {
|
|
3000
|
+
r((u) => ({ ...u, [d]: p })), l((u) => ({
|
|
3001
|
+
...u,
|
|
3002
|
+
[d]: { loading: !1, error: null }
|
|
3003
|
+
}));
|
|
3004
|
+
}).catch((p) => {
|
|
3005
|
+
l((u) => ({
|
|
3006
|
+
...u,
|
|
3007
|
+
[d]: { loading: !1, error: p.message }
|
|
3008
|
+
}));
|
|
3009
|
+
}));
|
|
3010
|
+
});
|
|
3011
|
+
}, [
|
|
3012
|
+
i,
|
|
3013
|
+
n,
|
|
3014
|
+
c,
|
|
3015
|
+
a,
|
|
3016
|
+
r,
|
|
3017
|
+
l
|
|
3018
|
+
]);
|
|
3019
|
+
}, globalBlocksListAtom = atom({}), useGlobalBlocksList = () => {
|
|
3020
|
+
const [o, n] = useState(!1), [r, a] = useAtom(globalBlocksListAtom), l = useBuilderProp("getGlobalBlocks", async () => []), i = useCallback(async () => {
|
|
3021
|
+
n(!0);
|
|
3022
|
+
const c = await l();
|
|
3023
|
+
a(c), n(!1);
|
|
3024
|
+
}, [l, a]);
|
|
3025
|
+
return useEffect(() => {
|
|
3026
|
+
i();
|
|
3027
|
+
}, []), { data: r, isLoading: o, refetch: i };
|
|
3028
|
+
}, useBuilderReset = () => {
|
|
3029
|
+
const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: a } = useBlockHighlight(), [, l] = useSelectedStylingBlocks(), [, i] = useAtom(aiAssistantActiveAtom), { reset: c } = useGlobalBlocksStore();
|
|
3030
|
+
return () => {
|
|
3031
|
+
r([]), l([]), a(), n(), i(!1), o({ undoCount: 0, redoCount: 0 }), c();
|
|
3032
|
+
};
|
|
3033
|
+
}, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom$1(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom$1([]), useCutBlockIds = () => {
|
|
3034
|
+
const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
|
|
3035
|
+
(l) => {
|
|
3036
|
+
n(l), r([]);
|
|
3037
|
+
},
|
|
3038
|
+
[n, r]
|
|
3039
|
+
);
|
|
3040
|
+
return [o, a];
|
|
3041
|
+
}, copiedBlockIdsAtom = atom$1([]), useCopyBlockIds = () => {
|
|
3042
|
+
const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), l = useCallback(
|
|
3043
|
+
async (i) => {
|
|
3044
|
+
try {
|
|
3045
|
+
r(i), a([]);
|
|
3046
|
+
const c = {
|
|
3047
|
+
_chai_copied_blocks: i.flatMap((d) => getDuplicatedBlocks(o, d, null))
|
|
3048
|
+
};
|
|
3049
|
+
await navigator.clipboard.writeText(JSON.stringify(c));
|
|
3050
|
+
} catch (c) {
|
|
3051
|
+
console.error("Failed to copy blocks to clipboard:", c);
|
|
3052
|
+
}
|
|
3053
|
+
},
|
|
3054
|
+
[r, a, o]
|
|
3055
|
+
);
|
|
3056
|
+
return [n, l];
|
|
3057
|
+
}, useCopyToClipboard = () => {
|
|
3058
|
+
const [o, n] = useState(null), r = useCallback(async (a) => {
|
|
3059
|
+
if (!(navigator != null && navigator.clipboard))
|
|
3060
|
+
return console.warn("Clipboard not supported"), !1;
|
|
3061
|
+
try {
|
|
3062
|
+
return await navigator.clipboard.writeText(a), n(a), !0;
|
|
3063
|
+
} catch (l) {
|
|
3064
|
+
return console.warn("Copy failed", l), n(null), !1;
|
|
3193
3065
|
}
|
|
3194
|
-
|
|
3066
|
+
}, []);
|
|
3067
|
+
return [o, r];
|
|
3068
|
+
}, darkModeAtom = atomWithStorage("darkMode", !1), useDarkMode = () => {
|
|
3069
|
+
const [o, n] = useAtom$1(darkModeAtom);
|
|
3070
|
+
return [o, n];
|
|
3071
|
+
}, useDuplicateBlocks = () => {
|
|
3072
|
+
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions();
|
|
3073
|
+
return useCallback(
|
|
3074
|
+
(a, l = null) => {
|
|
3075
|
+
const i = [];
|
|
3076
|
+
each(a, (c) => {
|
|
3077
|
+
const d = o.find((f) => f._id === c);
|
|
3078
|
+
l ? l === "root" && (l = null) : l = d._parent;
|
|
3079
|
+
const g = filter(
|
|
3080
|
+
o,
|
|
3081
|
+
(f) => isString(l) ? f._parent === l : !f._parent
|
|
3082
|
+
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
3083
|
+
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
3084
|
+
}), n(i);
|
|
3085
|
+
},
|
|
3086
|
+
[o, n]
|
|
3087
|
+
);
|
|
3088
|
+
}, hiddenBlockIdsAtom = atom$1([]), useHiddenBlockIds = () => {
|
|
3089
|
+
const [o, n] = useAtom$1(hiddenBlockIdsAtom), r = useCallback(
|
|
3090
|
+
(a) => {
|
|
3091
|
+
n((l) => includes(l, a) ? without(l, a) : [...l, a]);
|
|
3092
|
+
},
|
|
3093
|
+
[n]
|
|
3094
|
+
);
|
|
3095
|
+
return [o, n, r];
|
|
3096
|
+
}, highlightBlockIdAtom = atom$1(""), useHighlightBlockId = () => useAtom$1(highlightBlockIdAtom), useCanPaste = () => {
|
|
3097
|
+
const [o] = useBlocksStore();
|
|
3098
|
+
return (n, r) => {
|
|
3099
|
+
var i;
|
|
3100
|
+
const a = ((i = find(o, { _id: r })) == null ? void 0 : i._type) || null, l = first(n.map((c) => {
|
|
3101
|
+
var d;
|
|
3102
|
+
return (d = find(o, { _id: c })) == null ? void 0 : d._type;
|
|
3103
|
+
}));
|
|
3104
|
+
return canAcceptChildBlock(a, l);
|
|
3195
3105
|
};
|
|
3106
|
+
}, useMoveCutBlocks = () => {
|
|
3107
|
+
const o = useAtomValue$1(presentBlocksAtom), { moveBlocks: n } = useBlocksStoreUndoableActions();
|
|
3108
|
+
return useCallback(
|
|
3109
|
+
(r, a) => {
|
|
3110
|
+
const l = Array.isArray(a) ? a[0] : a;
|
|
3111
|
+
if (a === "root") {
|
|
3112
|
+
const i = o == null ? void 0 : o.filter((c) => !c._parent);
|
|
3113
|
+
n(r, null, (i == null ? void 0 : i.length) || 0);
|
|
3114
|
+
} else {
|
|
3115
|
+
const i = o == null ? void 0 : o.filter((c) => c._parent === l);
|
|
3116
|
+
n(r, l, (i == null ? void 0 : i.length) || 0);
|
|
3117
|
+
}
|
|
3118
|
+
},
|
|
3119
|
+
[n, o]
|
|
3120
|
+
);
|
|
3121
|
+
}, usePasteBlocks = () => {
|
|
3122
|
+
const [o, n] = useCutBlockIds(), r = useMoveCutBlocks(), a = useCanPaste(), { toast: l } = useToast(), { addPredefinedBlock: i } = useAddBlock();
|
|
3196
3123
|
return {
|
|
3197
|
-
|
|
3198
|
-
async (
|
|
3199
|
-
if (
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
}
|
|
3207
|
-
if (h === "styles") {
|
|
3208
|
-
const A = w.map((j) => {
|
|
3209
|
-
for (const C in j)
|
|
3210
|
-
C !== "_id" && (j[C] = `${STYLES_KEY},${j[C]}`);
|
|
3211
|
-
return j;
|
|
3212
|
-
});
|
|
3213
|
-
c(A);
|
|
3214
|
-
} else
|
|
3215
|
-
i(w);
|
|
3216
|
-
b && b(E);
|
|
3217
|
-
} catch (y) {
|
|
3218
|
-
a(y);
|
|
3219
|
-
} finally {
|
|
3220
|
-
n(!1), b && b();
|
|
3124
|
+
canPaste: useCallback(
|
|
3125
|
+
async (d) => {
|
|
3126
|
+
if (o.length > 0)
|
|
3127
|
+
return a(o, d);
|
|
3128
|
+
try {
|
|
3129
|
+
const p = await navigator.clipboard.readText();
|
|
3130
|
+
if (p) {
|
|
3131
|
+
const u = JSON.parse(p);
|
|
3132
|
+
return has(u, "_chai_copied_blocks");
|
|
3221
3133
|
}
|
|
3134
|
+
} catch {
|
|
3135
|
+
return !1;
|
|
3222
3136
|
}
|
|
3137
|
+
return !1;
|
|
3223
3138
|
},
|
|
3224
|
-
[
|
|
3225
|
-
l,
|
|
3226
|
-
n,
|
|
3227
|
-
p,
|
|
3228
|
-
u,
|
|
3229
|
-
d,
|
|
3230
|
-
g,
|
|
3231
|
-
c,
|
|
3232
|
-
i
|
|
3233
|
-
]
|
|
3139
|
+
[a, o]
|
|
3234
3140
|
),
|
|
3235
|
-
|
|
3236
|
-
|
|
3141
|
+
pasteBlocks: useCallback(
|
|
3142
|
+
async (d) => {
|
|
3143
|
+
const p = Array.isArray(d) ? d[0] : d;
|
|
3144
|
+
if (!isEmpty(o)) {
|
|
3145
|
+
r(o, d), n([]), await navigator.clipboard.writeText("");
|
|
3146
|
+
return;
|
|
3147
|
+
}
|
|
3148
|
+
try {
|
|
3149
|
+
const u = await navigator.clipboard.readText();
|
|
3150
|
+
if (u) {
|
|
3151
|
+
const g = JSON.parse(u);
|
|
3152
|
+
has(g, "_chai_copied_blocks") ? i(g._chai_copied_blocks, p === "root" ? null : p) : l({ title: "Error", description: "Nothing to paste" });
|
|
3153
|
+
} else
|
|
3154
|
+
l({ title: "Error", description: "Nothing to paste" });
|
|
3155
|
+
} catch {
|
|
3156
|
+
l({ title: "Error", description: "Failed to paste blocks from clipboard" });
|
|
3157
|
+
}
|
|
3158
|
+
},
|
|
3159
|
+
[o, i, r, n, l]
|
|
3160
|
+
)
|
|
3237
3161
|
};
|
|
3238
|
-
},
|
|
3239
|
-
const [,
|
|
3162
|
+
}, previewModeAtom = atom$1(!1), usePreviewMode = () => {
|
|
3163
|
+
const [o, n] = useAtom$1(previewModeAtom);
|
|
3164
|
+
return [o, n];
|
|
3165
|
+
}, removeClassFromBlocksAtom = atom$1(null, (o, n, { blockIds: r, fullClasses: a }) => {
|
|
3166
|
+
const l = first(o(selectedStylingBlocksAtom)), i = filter(
|
|
3167
|
+
o(pageBlocksAtomsAtom),
|
|
3168
|
+
(c) => (
|
|
3169
|
+
// @ts-ignore
|
|
3170
|
+
r.includes(o(c)._id)
|
|
3171
|
+
)
|
|
3172
|
+
);
|
|
3173
|
+
return map(i, (c) => {
|
|
3174
|
+
const d = o(c), p = a;
|
|
3175
|
+
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3176
|
+
return each(p, (m) => {
|
|
3177
|
+
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), b = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
|
|
3178
|
+
u = u.replace(b, " ").replace(/\s+/g, " ").trim();
|
|
3179
|
+
const x = first(m.split(":"));
|
|
3180
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
|
|
3181
|
+
}), each(p, (m) => {
|
|
3182
|
+
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), b = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
|
|
3183
|
+
g = g.replace(b, " ").replace(/\s+/g, " ").trim();
|
|
3184
|
+
}), {
|
|
3185
|
+
ids: [d._id],
|
|
3186
|
+
props: {
|
|
3187
|
+
[l.prop]: `${STYLES_KEY}${g},${u}`
|
|
3188
|
+
}
|
|
3189
|
+
};
|
|
3190
|
+
});
|
|
3191
|
+
}), useRemoveClassesFromBlocks = () => {
|
|
3192
|
+
const { updateBlocks: o, updateBlocksRuntime: n } = useBlocksStoreUndoableActions(), r = useSetAtom$1(removeClassFromBlocksAtom);
|
|
3240
3193
|
return useCallback(
|
|
3241
|
-
(
|
|
3242
|
-
|
|
3194
|
+
(a, l, i = !1) => {
|
|
3195
|
+
const c = r({ blockIds: a, fullClasses: l });
|
|
3196
|
+
i ? o(a, c[0].props) : n(a, c[0].props);
|
|
3243
3197
|
},
|
|
3244
|
-
[
|
|
3198
|
+
[r]
|
|
3245
3199
|
);
|
|
3246
|
-
},
|
|
3200
|
+
}, useStylingBreakpoint = () => useAtom$1(styleBreakpointAtom), canvasWidthAtom = atomWithStorage("canvasWidth", 800), canvasDisplayWidthAtom = atomWithStorage("canvasDisplayWidth", 800), canvasBreakpointAtom = atom$1((o) => {
|
|
3201
|
+
const n = o(canvasWidthAtom);
|
|
3202
|
+
return getBreakpointValue(n).toLowerCase();
|
|
3203
|
+
}), useScreenSizeWidth = () => {
|
|
3204
|
+
const [o, n] = useAtom$1(canvasWidthAtom), r = useAtomValue$1(canvasBreakpointAtom), [a, l] = useStylingBreakpoint();
|
|
3205
|
+
return useEffect(() => {
|
|
3206
|
+
a !== "xs" && l(r);
|
|
3207
|
+
}, [r, a, l]), [o, r, n];
|
|
3208
|
+
}, useCanvasDisplayWidth = () => {
|
|
3209
|
+
const [o, n] = useAtom$1(canvasDisplayWidthAtom);
|
|
3210
|
+
return [o, n];
|
|
3211
|
+
}, selectedBlockAllClassesAtom = atom$1((o) => {
|
|
3212
|
+
const n = first(o(selectedStylingBlocksAtom)), r = o(selectedBlockAtom);
|
|
3213
|
+
if (!n || n.blockId !== get(r, "_id", null)) return [];
|
|
3214
|
+
const a = get(r, n.prop, `${STYLES_KEY},`), { classes: l } = getSplitChaiClasses(a);
|
|
3215
|
+
return console.log("classes", l), filter(map(l.trim().split(" "), constructClassObject), (i) => !isNull(i));
|
|
3216
|
+
}), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom$1((o) => {
|
|
3217
|
+
const n = o(canvasBreakpointAtom), r = o(styleStateAtom), a = o(darkModeAtom), l = getQueries(n);
|
|
3218
|
+
let i = filter(o(selectedBlockAllClassesAtom), { mod: r });
|
|
3219
|
+
return startsWith(r, "_") || (i = filter(i, (c) => l.includes(c.mq))), i = i.sort((c, d) => MQ[c.mq] - MQ[d.mq]), a || (i = filter(i, { dark: !1 })), i;
|
|
3220
|
+
}), getQueries = (o) => {
|
|
3221
|
+
let n = [];
|
|
3222
|
+
switch (o) {
|
|
3223
|
+
case "xs":
|
|
3224
|
+
n = ["xs"];
|
|
3225
|
+
break;
|
|
3226
|
+
case "sm":
|
|
3227
|
+
n = ["xs", "sm"];
|
|
3228
|
+
break;
|
|
3229
|
+
case "md":
|
|
3230
|
+
n = ["xs", "sm", "md"];
|
|
3231
|
+
break;
|
|
3232
|
+
case "lg":
|
|
3233
|
+
n = ["xs", "sm", "md", "lg"];
|
|
3234
|
+
break;
|
|
3235
|
+
case "xl":
|
|
3236
|
+
n = ["xs", "sm", "md", "lg", "xl"];
|
|
3237
|
+
break;
|
|
3238
|
+
case "2xl":
|
|
3239
|
+
n = ["xs", "sm", "md", "lg", "xl", "2xl"];
|
|
3240
|
+
break;
|
|
3241
|
+
default:
|
|
3242
|
+
n = ["xs"];
|
|
3243
|
+
break;
|
|
3244
|
+
}
|
|
3245
|
+
return n;
|
|
3246
|
+
}, useSelectedBlockCurrentClasses = () => useAtomValue$1(selectedBlockCurrentClassesAtom), selectedBreakpointsAtom = atomWithStorage("selectedBreakpoints", ["XS", "MD", "XL"]), useSelectedBreakpoints = () => {
|
|
3247
|
+
const [o, n] = useAtom$1(selectedBreakpointsAtom);
|
|
3248
|
+
return [o, n];
|
|
3249
|
+
}, useStylingState = () => useAtom$1(styleStateAtom), useUILibraryBlocks = () => ({ data: useBuilderProp("uiLibraries", []), isLoading: !1 }), wrapperBlockAtom = atom$1((o) => {
|
|
3247
3250
|
var c;
|
|
3248
3251
|
const n = o(presentBlocksAtom), r = o(selectedBlockIdsAtom), a = r.length === 1 ? r[0] : null;
|
|
3249
3252
|
if (!a) return null;
|
|
@@ -3310,7 +3313,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3310
3313
|
}
|
|
3311
3314
|
});
|
|
3312
3315
|
useResizeObserver(o, () => g(), o !== null);
|
|
3313
|
-
const m = get(n, "_parent", null),
|
|
3316
|
+
const m = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3314
3317
|
return !o || !n || d ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
3315
3318
|
"div",
|
|
3316
3319
|
{
|
|
@@ -3318,13 +3321,13 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3318
3321
|
tabIndex: 0,
|
|
3319
3322
|
ref: u.setFloating,
|
|
3320
3323
|
style: p,
|
|
3321
|
-
onClick: (
|
|
3322
|
-
|
|
3324
|
+
onClick: (b) => {
|
|
3325
|
+
b.stopPropagation(), b.preventDefault();
|
|
3323
3326
|
},
|
|
3324
|
-
onMouseEnter: (
|
|
3325
|
-
|
|
3327
|
+
onMouseEnter: (b) => {
|
|
3328
|
+
b.stopPropagation(), i(null);
|
|
3326
3329
|
},
|
|
3327
|
-
onKeyDown: (
|
|
3330
|
+
onKeyDown: (b) => b.stopPropagation(),
|
|
3328
3331
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3329
3332
|
children: [
|
|
3330
3333
|
m && /* @__PURE__ */ jsx(
|
|
@@ -3336,7 +3339,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3336
3339
|
}
|
|
3337
3340
|
}
|
|
3338
3341
|
),
|
|
3339
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3342
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: n }),
|
|
3340
3343
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-2 px-1", children: [
|
|
3341
3344
|
canAddChildBlock(get(n, "_type", "")) && /* @__PURE__ */ jsx(
|
|
3342
3345
|
PlusIcon,
|
|
@@ -3408,23 +3411,23 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3408
3411
|
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
|
|
3409
3412
|
</body>
|
|
3410
3413
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3411
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(),
|
|
3414
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), f = o ? { document: o } : {};
|
|
3412
3415
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
|
|
3413
3416
|
"ctrl+v,command+v",
|
|
3414
3417
|
() => {
|
|
3415
3418
|
g(n[0]) && m(n);
|
|
3416
3419
|
},
|
|
3417
|
-
{ ...
|
|
3420
|
+
{ ...f, preventDefault: !0 },
|
|
3418
3421
|
[n, g, m]
|
|
3419
|
-
), useHotkeys("esc", () => r([]),
|
|
3422
|
+
), useHotkeys("esc", () => r([]), f, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...f, preventDefault: !0 }, [
|
|
3420
3423
|
n,
|
|
3421
3424
|
i
|
|
3422
3425
|
]), useHotkeys(
|
|
3423
3426
|
"del, backspace",
|
|
3424
|
-
(
|
|
3425
|
-
|
|
3427
|
+
(b) => {
|
|
3428
|
+
b.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3426
3429
|
},
|
|
3427
|
-
|
|
3430
|
+
f,
|
|
3428
3431
|
[n, l]
|
|
3429
3432
|
);
|
|
3430
3433
|
}, KeyboardHandler = () => {
|
|
@@ -3515,14 +3518,14 @@ const useDnd = () => {
|
|
|
3515
3518
|
};
|
|
3516
3519
|
return iframeDocument = o, {
|
|
3517
3520
|
isDragging: n,
|
|
3518
|
-
onDragOver: (
|
|
3519
|
-
|
|
3521
|
+
onDragOver: (f) => {
|
|
3522
|
+
f.preventDefault(), f.stopPropagation(), throttledDragOver(f);
|
|
3520
3523
|
},
|
|
3521
|
-
onDrop: (
|
|
3524
|
+
onDrop: (f) => {
|
|
3522
3525
|
var S;
|
|
3523
|
-
const
|
|
3524
|
-
dropIndex = calculateDropIndex(
|
|
3525
|
-
const y = d, B =
|
|
3526
|
+
const b = dropTarget, h = getOrientation(b) === "vertical" ? f.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : f.clientX;
|
|
3527
|
+
dropIndex = calculateDropIndex(h, possiblePositions);
|
|
3528
|
+
const y = d, B = b.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3526
3529
|
if ((y == null ? void 0 : y._id) === B || !E) {
|
|
3527
3530
|
m();
|
|
3528
3531
|
return;
|
|
@@ -3531,17 +3534,17 @@ const useDnd = () => {
|
|
|
3531
3534
|
a(y, B === "canvas" ? null : B, dropIndex), setTimeout(m, 300);
|
|
3532
3535
|
return;
|
|
3533
3536
|
}
|
|
3534
|
-
let w =
|
|
3535
|
-
w === null && (w =
|
|
3537
|
+
let w = b.getAttribute("data-block-id");
|
|
3538
|
+
w === null && (w = f.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3536
3539
|
},
|
|
3537
|
-
onDragEnter: (
|
|
3538
|
-
const
|
|
3539
|
-
dropTarget =
|
|
3540
|
-
const
|
|
3541
|
-
u(
|
|
3540
|
+
onDragEnter: (f) => {
|
|
3541
|
+
const b = f, x = b.target;
|
|
3542
|
+
dropTarget = x;
|
|
3543
|
+
const h = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
|
|
3544
|
+
u(h), b.stopPropagation(), b.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
|
|
3542
3545
|
},
|
|
3543
|
-
onDragLeave: (
|
|
3544
|
-
|
|
3546
|
+
onDragLeave: (f) => {
|
|
3547
|
+
f.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3545
3548
|
}
|
|
3546
3549
|
};
|
|
3547
3550
|
};
|
|
@@ -3562,25 +3565,25 @@ const useHandleCanvasDblClick = () => {
|
|
|
3562
3565
|
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight(), i = useGetBlockAtomValue(pageBlocksAtomsAtom);
|
|
3563
3566
|
return useCallback(
|
|
3564
3567
|
(c) => {
|
|
3565
|
-
var
|
|
3568
|
+
var x;
|
|
3566
3569
|
if (r) return;
|
|
3567
3570
|
const d = getTargetedBlock(c.target), p = d.getAttribute("data-block-type");
|
|
3568
3571
|
if (!p || !o.includes(p))
|
|
3569
3572
|
return;
|
|
3570
3573
|
const u = d.getAttribute("data-block-id"), g = i(u).content, m = d.cloneNode(!0);
|
|
3571
|
-
m.innerHTML = g, d.style.display = "none", Array.from(m.attributes).forEach((
|
|
3572
|
-
|
|
3574
|
+
m.innerHTML = g, d.style.display = "none", Array.from(m.attributes).forEach((h) => {
|
|
3575
|
+
h.name !== "class" && m.removeAttribute(h.name);
|
|
3573
3576
|
}), p === "Text" && (m.style.display = "inline-block"), d.parentNode.insertBefore(m, d.nextSibling);
|
|
3574
|
-
const
|
|
3575
|
-
function
|
|
3576
|
-
const
|
|
3577
|
-
n([u], { content:
|
|
3577
|
+
const f = new Quill(m, { placeholder: "Type here..." });
|
|
3578
|
+
function b() {
|
|
3579
|
+
const h = f.getText(0, f.getLength());
|
|
3580
|
+
n([u], { content: h }), d.removeAttribute("style"), m.removeEventListener("blur", b, !0), destroyQuill(f), a(""), l(), m.remove();
|
|
3578
3581
|
}
|
|
3579
|
-
m.addEventListener("blur",
|
|
3580
|
-
|
|
3581
|
-
}), m.addEventListener("keydown", (
|
|
3582
|
-
(
|
|
3583
|
-
}),
|
|
3582
|
+
m.addEventListener("blur", b, !0), m.addEventListener("click", (h) => {
|
|
3583
|
+
h.stopPropagation();
|
|
3584
|
+
}), m.addEventListener("keydown", (h) => {
|
|
3585
|
+
(h.key === "Enter" || h.key === "Escape") && b();
|
|
3586
|
+
}), f.focus(), (x = m.querySelector(".ql-clipboard")) == null || x.remove(), a(d.getAttribute("data-block-id"));
|
|
3584
3587
|
},
|
|
3585
3588
|
[r, a, n, l]
|
|
3586
3589
|
);
|
|
@@ -3621,10 +3624,10 @@ const useHandleCanvasDblClick = () => {
|
|
|
3621
3624
|
return;
|
|
3622
3625
|
const m = getElementByDataBlockId(n, first(r));
|
|
3623
3626
|
if (m) {
|
|
3624
|
-
const
|
|
3625
|
-
if (
|
|
3626
|
-
const
|
|
3627
|
-
l([{ id:
|
|
3627
|
+
const f = m.getAttribute("data-style-prop");
|
|
3628
|
+
if (f) {
|
|
3629
|
+
const b = m.getAttribute("data-style-id"), x = m.getAttribute("data-block-parent");
|
|
3630
|
+
l([{ id: b, prop: f, blockId: x }]);
|
|
3628
3631
|
}
|
|
3629
3632
|
}
|
|
3630
3633
|
}, 100);
|
|
@@ -3649,7 +3652,7 @@ const useHandleCanvasDblClick = () => {
|
|
|
3649
3652
|
d == null ? void 0 : d.getElementById("selected-block")
|
|
3650
3653
|
), [m] = useState(
|
|
3651
3654
|
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3652
|
-
), [
|
|
3655
|
+
), [f] = useState(
|
|
3653
3656
|
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3654
3657
|
);
|
|
3655
3658
|
useEffect(() => {
|
|
@@ -3674,8 +3677,8 @@ const useHandleCanvasDblClick = () => {
|
|
|
3674
3677
|
forms,
|
|
3675
3678
|
aspectRatio,
|
|
3676
3679
|
containerQueries,
|
|
3677
|
-
plugin(function({ addBase:
|
|
3678
|
-
|
|
3680
|
+
plugin(function({ addBase: h, theme: y }) {
|
|
3681
|
+
h({
|
|
3679
3682
|
"h1,h2,h3,h4,h5,h6": {
|
|
3680
3683
|
fontFamily: y("fontFamily.heading")
|
|
3681
3684
|
},
|
|
@@ -3689,27 +3692,27 @@ const useHandleCanvasDblClick = () => {
|
|
|
3689
3692
|
]
|
|
3690
3693
|
});
|
|
3691
3694
|
}, [o, n, p]), useEffect(() => {
|
|
3692
|
-
g && (g.textContent = `${map(r, (
|
|
3695
|
+
g && (g.textContent = `${map(r, (h) => `[data-block-id="${h}"]`).join(",")}{
|
|
3693
3696
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3694
3697
|
}`);
|
|
3695
3698
|
}, [r, g]), useEffect(() => {
|
|
3696
|
-
|
|
3697
|
-
}, [i,
|
|
3699
|
+
f.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3700
|
+
}, [i, f]), useEffect(() => {
|
|
3698
3701
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3699
3702
|
}, [u]), useEffect(() => {
|
|
3700
|
-
m && (m.textContent = `${map(l, ({ id:
|
|
3703
|
+
m && (m.textContent = `${map(l, ({ id: h }) => `[data-style-id="${h}"]`).join(",")}{
|
|
3701
3704
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3702
3705
|
}`);
|
|
3703
3706
|
}, [l, m]), useEffect(() => {
|
|
3704
3707
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3705
3708
|
}, [c, d]);
|
|
3706
|
-
const
|
|
3709
|
+
const b = useMemo(
|
|
3707
3710
|
() => getChaiThemeCssVariables(o),
|
|
3708
3711
|
[o]
|
|
3709
|
-
),
|
|
3712
|
+
), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3710
3713
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3711
|
-
/* @__PURE__ */ jsx("style", { id: "chai-theme", children:
|
|
3712
|
-
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html:
|
|
3714
|
+
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: b }),
|
|
3715
|
+
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
|
|
3713
3716
|
] });
|
|
3714
3717
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
3715
3718
|
const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
|
|
@@ -3786,10 +3789,10 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3786
3789
|
[o]
|
|
3787
3790
|
);
|
|
3788
3791
|
}, BlockRenderer = ({ blockAtom: o, children: n }) => {
|
|
3789
|
-
const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(inlineEditingActiveAtom), [g] = useAtom$1(dataBindingActiveAtom), m = get(a, "component", null),
|
|
3792
|
+
const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(inlineEditingActiveAtom), [g] = useAtom$1(dataBindingActiveAtom), m = get(a, "component", null), f = useMemo(
|
|
3790
3793
|
() => g ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3791
3794
|
[r, l, a, d, g]
|
|
3792
|
-
),
|
|
3795
|
+
), b = useMemo(() => getBlockTagAttributes(r), [r]), x = useMemo(() => c(r._id, getBlockRuntimeProps(r._type)), [r]), h = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), y = useMemo(
|
|
3793
3796
|
() => ({
|
|
3794
3797
|
blockProps: {
|
|
3795
3798
|
"data-block-id": r._id,
|
|
@@ -3797,12 +3800,12 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3797
3800
|
},
|
|
3798
3801
|
inBuilder: !0,
|
|
3799
3802
|
lang: l || i,
|
|
3800
|
-
...h,
|
|
3801
|
-
...x,
|
|
3802
3803
|
...f,
|
|
3803
|
-
...b
|
|
3804
|
+
...b,
|
|
3805
|
+
...x,
|
|
3806
|
+
...h
|
|
3804
3807
|
}),
|
|
3805
|
-
[r, l, i,
|
|
3808
|
+
[r, l, i, f, b, x, h]
|
|
3806
3809
|
);
|
|
3807
3810
|
return isNull(m) || p.includes(r._id) || u === r._id ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(m, { ...y, children: n }) });
|
|
3808
3811
|
}, GlobalBlocksRenderer = ({ globalBlockId: o }) => {
|
|
@@ -3828,16 +3831,16 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3828
3831
|
const [o] = useBlocksStore(), n = isEmpty(o) ? null : /* @__PURE__ */ jsx(PageBlocksRenderer, {});
|
|
3829
3832
|
return /* @__PURE__ */ jsx(Fragment, { children: n });
|
|
3830
3833
|
}, useCanvasScale = (o) => {
|
|
3831
|
-
const [n] =
|
|
3834
|
+
const [n] = useCanvasDisplayWidth(), [, r] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), c = useCallback(() => {
|
|
3832
3835
|
const { width: d, height: p } = o;
|
|
3833
3836
|
if (d < n) {
|
|
3834
3837
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
3835
3838
|
let g = {};
|
|
3836
|
-
const m = p * u,
|
|
3839
|
+
const m = p * u, f = d * u;
|
|
3837
3840
|
p && (g = {
|
|
3838
3841
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3839
3842
|
height: 100 + (p - m) / m * 100 + "%",
|
|
3840
|
-
width: 100 + (d -
|
|
3843
|
+
width: 100 + (d - f) / f * 100 + "%"
|
|
3841
3844
|
}), i({
|
|
3842
3845
|
position: "relative",
|
|
3843
3846
|
top: 0,
|
|
@@ -3854,34 +3857,34 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3854
3857
|
c();
|
|
3855
3858
|
}, [n, o, r, c]), l;
|
|
3856
3859
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3857
|
-
const [o] = useAtom$1(networkModeAtom), [n] =
|
|
3858
|
-
p((
|
|
3860
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, f] = useState([]), [, b] = useAtom$1(canvasIframeAtom), [x, h] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), E = (A) => {
|
|
3861
|
+
p((_) => ({ ..._, width: A }));
|
|
3859
3862
|
};
|
|
3860
|
-
useEffect(() => {
|
|
3863
|
+
console.log("width", n), useEffect(() => {
|
|
3861
3864
|
if (!c.current) return;
|
|
3862
|
-
const { clientWidth: A, clientHeight:
|
|
3863
|
-
p({ width: A, height:
|
|
3865
|
+
const { clientWidth: A, clientHeight: _ } = c.current;
|
|
3866
|
+
p({ width: A, height: _ });
|
|
3864
3867
|
}, [c, n]);
|
|
3865
|
-
const w = (A,
|
|
3868
|
+
const w = (A, _ = 0) => {
|
|
3866
3869
|
const { top: C } = A.getBoundingClientRect();
|
|
3867
|
-
return C +
|
|
3870
|
+
return C + _ >= 0 && C - _ <= window.innerHeight;
|
|
3868
3871
|
};
|
|
3869
3872
|
useEffect(() => {
|
|
3870
|
-
var A,
|
|
3873
|
+
var A, _;
|
|
3871
3874
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3872
3875
|
const C = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3873
|
-
C && (w(C) || (
|
|
3876
|
+
C && (w(C) || (_ = (A = i.current) == null ? void 0 : A.contentWindow) == null || _.scrollTo({ top: C.offsetTop, behavior: "smooth" }), m([C]));
|
|
3874
3877
|
}
|
|
3875
3878
|
}, [a]), useEffect(() => {
|
|
3876
|
-
if (!isEmpty(
|
|
3879
|
+
if (!isEmpty(x) && i.current) {
|
|
3877
3880
|
const A = getElementByStyleId(
|
|
3878
3881
|
i.current.contentDocument,
|
|
3879
|
-
first(
|
|
3882
|
+
first(x).id
|
|
3880
3883
|
);
|
|
3881
|
-
|
|
3884
|
+
f(A ? [A] : [null]);
|
|
3882
3885
|
} else
|
|
3883
|
-
|
|
3884
|
-
}, [
|
|
3886
|
+
f([null]);
|
|
3887
|
+
}, [x]);
|
|
3885
3888
|
const S = useMemo(() => {
|
|
3886
3889
|
let A = IframeInitialContent;
|
|
3887
3890
|
return A = A.replace("__HTML_DIR__", B), o === "offline" && (A = A.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), A;
|
|
@@ -3890,7 +3893,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3890
3893
|
"div",
|
|
3891
3894
|
{
|
|
3892
3895
|
onClick: () => {
|
|
3893
|
-
r([]),
|
|
3896
|
+
r([]), h([]);
|
|
3894
3897
|
},
|
|
3895
3898
|
onMouseLeave: () => setTimeout(() => l(""), 300),
|
|
3896
3899
|
className: "relative mx-auto h-full w-full overflow-hidden",
|
|
@@ -3898,7 +3901,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3898
3901
|
children: /* @__PURE__ */ jsxs(
|
|
3899
3902
|
ChaiFrame,
|
|
3900
3903
|
{
|
|
3901
|
-
contentDidMount: () =>
|
|
3904
|
+
contentDidMount: () => b(i.current),
|
|
3902
3905
|
ref: i,
|
|
3903
3906
|
id: "canvas-iframe",
|
|
3904
3907
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
@@ -4163,7 +4166,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4163
4166
|
B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? d(B) : console.error("Invalid preset structure:", B);
|
|
4164
4167
|
} else
|
|
4165
4168
|
console.error("Preset not found:", r);
|
|
4166
|
-
},
|
|
4169
|
+
}, f = useDebouncedCallback(
|
|
4167
4170
|
(y, B) => {
|
|
4168
4171
|
d(() => ({
|
|
4169
4172
|
...c,
|
|
@@ -4175,7 +4178,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4175
4178
|
},
|
|
4176
4179
|
[c],
|
|
4177
4180
|
200
|
|
4178
|
-
),
|
|
4181
|
+
), b = useDebouncedCallback(
|
|
4179
4182
|
(y) => {
|
|
4180
4183
|
d(() => ({
|
|
4181
4184
|
...c,
|
|
@@ -4184,7 +4187,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4184
4187
|
},
|
|
4185
4188
|
[c],
|
|
4186
4189
|
200
|
|
4187
|
-
),
|
|
4190
|
+
), x = useDebouncedCallback(
|
|
4188
4191
|
(y, B) => {
|
|
4189
4192
|
d(() => {
|
|
4190
4193
|
const E = get(c, `colors.${y}`);
|
|
@@ -4199,14 +4202,14 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4199
4202
|
},
|
|
4200
4203
|
[c],
|
|
4201
4204
|
200
|
|
4202
|
-
),
|
|
4205
|
+
), h = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([B]) => {
|
|
4203
4206
|
const E = get(c, `colors.${B}.${n ? 1 : 0}`);
|
|
4204
4207
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4205
4208
|
/* @__PURE__ */ jsx(
|
|
4206
4209
|
ColorPickerInput,
|
|
4207
4210
|
{
|
|
4208
4211
|
value: E,
|
|
4209
|
-
onChange: (w) =>
|
|
4212
|
+
onChange: (w) => x(B, w)
|
|
4210
4213
|
}
|
|
4211
4214
|
),
|
|
4212
4215
|
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
|
|
@@ -4247,20 +4250,20 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4247
4250
|
{
|
|
4248
4251
|
label: y,
|
|
4249
4252
|
value: c.fontFamily[y.replace(/font-/g, "")] || B[Object.keys(B)[0]],
|
|
4250
|
-
onChange: (E) =>
|
|
4253
|
+
onChange: (E) => f(y, E)
|
|
4251
4254
|
},
|
|
4252
4255
|
y
|
|
4253
4256
|
)) }),
|
|
4254
4257
|
(p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4255
4258
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
|
|
4256
4259
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4257
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange:
|
|
4260
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: b }),
|
|
4258
4261
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
|
|
4259
4262
|
] })
|
|
4260
4263
|
] }),
|
|
4261
4264
|
(p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4262
4265
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
|
|
4263
|
-
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) =>
|
|
4266
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => h(y)) }, n ? "dark" : "light")
|
|
4264
4267
|
] })
|
|
4265
4268
|
] }),
|
|
4266
4269
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4473,23 +4476,23 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4473
4476
|
pageTypes: n,
|
|
4474
4477
|
onChange: r
|
|
4475
4478
|
}) => {
|
|
4476
|
-
var
|
|
4477
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (k, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m,
|
|
4479
|
+
var T;
|
|
4480
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (k, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [b, x] = useState([]), [h, y] = useState(-1), B = useRef(null), E = (T = n == null ? void 0 : n.find((k) => k.key === u)) == null ? void 0 : T.name;
|
|
4478
4481
|
useEffect(() => {
|
|
4479
|
-
if (
|
|
4482
|
+
if (f(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4480
4483
|
const k = split(o, ":"), v = get(k, 1, "page") || "page";
|
|
4481
4484
|
g(v), (async () => {
|
|
4482
|
-
const
|
|
4483
|
-
|
|
4485
|
+
const N = await l(v, [get(k, 2, "page")]);
|
|
4486
|
+
N && Array.isArray(N) && f(get(N, [0, "name"], ""));
|
|
4484
4487
|
})();
|
|
4485
4488
|
}, [o]);
|
|
4486
4489
|
const w = useDebouncedCallback(
|
|
4487
4490
|
async (k) => {
|
|
4488
4491
|
if (isEmpty(k))
|
|
4489
|
-
|
|
4492
|
+
x([]);
|
|
4490
4493
|
else {
|
|
4491
4494
|
const v = await l(u, k);
|
|
4492
|
-
|
|
4495
|
+
x(v);
|
|
4493
4496
|
}
|
|
4494
4497
|
c(!1), y(-1);
|
|
4495
4498
|
},
|
|
@@ -4497,34 +4500,34 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4497
4500
|
300
|
|
4498
4501
|
), S = (k) => {
|
|
4499
4502
|
const v = ["pageType", u, k.id];
|
|
4500
|
-
v[1] && (r(v.join(":")),
|
|
4503
|
+
v[1] && (r(v.join(":")), f(k.name), p(!1), x([]), y(-1));
|
|
4501
4504
|
}, A = (k) => {
|
|
4502
4505
|
switch (k.key) {
|
|
4503
4506
|
case "ArrowDown":
|
|
4504
|
-
k.preventDefault(), y((v) => v <
|
|
4507
|
+
k.preventDefault(), y((v) => v < b.length - 1 ? v + 1 : v);
|
|
4505
4508
|
break;
|
|
4506
4509
|
case "ArrowUp":
|
|
4507
4510
|
k.preventDefault(), y((v) => v > 0 ? v - 1 : v);
|
|
4508
4511
|
break;
|
|
4509
4512
|
case "Enter":
|
|
4510
|
-
if (k.preventDefault(),
|
|
4511
|
-
|
|
4513
|
+
if (k.preventDefault(), b.length === 0) return;
|
|
4514
|
+
h >= 0 && S(b[h]);
|
|
4512
4515
|
break;
|
|
4513
4516
|
case "Escape":
|
|
4514
|
-
k.preventDefault(),
|
|
4517
|
+
k.preventDefault(), _();
|
|
4515
4518
|
break;
|
|
4516
4519
|
}
|
|
4517
4520
|
};
|
|
4518
4521
|
useEffect(() => {
|
|
4519
|
-
if (
|
|
4520
|
-
const k = B.current.children[
|
|
4522
|
+
if (h >= 0 && B.current) {
|
|
4523
|
+
const k = B.current.children[h];
|
|
4521
4524
|
k == null || k.scrollIntoView({ block: "nearest" });
|
|
4522
4525
|
}
|
|
4523
|
-
}, [
|
|
4524
|
-
const
|
|
4525
|
-
|
|
4526
|
+
}, [h]);
|
|
4527
|
+
const _ = () => {
|
|
4528
|
+
f(""), x([]), y(-1), p(!1), r("");
|
|
4526
4529
|
}, C = (k) => {
|
|
4527
|
-
|
|
4530
|
+
f(k), p(!isEmpty(k)), c(!0), w(k);
|
|
4528
4531
|
};
|
|
4529
4532
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4530
4533
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (k) => g(k.target.value), children: map(n, (k) => /* @__PURE__ */ jsx("option", { value: k.key, children: k.name }, k.key)) }),
|
|
@@ -4540,21 +4543,21 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4540
4543
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4541
4544
|
}
|
|
4542
4545
|
),
|
|
4543
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick:
|
|
4546
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4544
4547
|
] }),
|
|
4545
|
-
(i || !isEmpty(
|
|
4548
|
+
(i || !isEmpty(b) || d && isEmpty(b)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4546
4549
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4547
4550
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4548
|
-
] }) : d && isEmpty(
|
|
4551
|
+
] }) : d && isEmpty(b) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4549
4552
|
a("No results found for"),
|
|
4550
4553
|
' "',
|
|
4551
4554
|
m,
|
|
4552
4555
|
'"'
|
|
4553
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(
|
|
4556
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(b == null ? void 0 : b.slice(0, 20), (k, v) => /* @__PURE__ */ jsxs(
|
|
4554
4557
|
"li",
|
|
4555
4558
|
{
|
|
4556
4559
|
onClick: () => S(k),
|
|
4557
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(k.id) ? "bg-blue-200" : v ===
|
|
4560
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(k.id) ? "bg-blue-200" : v === h ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4558
4561
|
children: [
|
|
4559
4562
|
k.name,
|
|
4560
4563
|
" ",
|
|
@@ -4648,29 +4651,29 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4648
4651
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4649
4652
|
}, [o, u]);
|
|
4650
4653
|
const m = () => {
|
|
4651
|
-
const
|
|
4652
|
-
if (
|
|
4653
|
-
const
|
|
4654
|
+
const x = findIndex(u, { _id: g });
|
|
4655
|
+
if (x > -1) {
|
|
4656
|
+
const h = (x + 1) % u.length, y = get(u, [h, "_id"]);
|
|
4654
4657
|
if (!y) return;
|
|
4655
4658
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4656
4659
|
}
|
|
4657
|
-
},
|
|
4658
|
-
const
|
|
4659
|
-
if (
|
|
4660
|
-
const
|
|
4660
|
+
}, f = () => {
|
|
4661
|
+
const x = findIndex(u, { _id: g });
|
|
4662
|
+
if (x > -1) {
|
|
4663
|
+
const h = (x - 1 + u.length) % u.length, y = get(u, [h, "_id"]);
|
|
4661
4664
|
if (!y) return;
|
|
4662
4665
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4663
4666
|
}
|
|
4664
|
-
},
|
|
4665
|
-
const
|
|
4667
|
+
}, b = () => {
|
|
4668
|
+
const x = i(
|
|
4666
4669
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4667
4670
|
p == null ? void 0 : p._id
|
|
4668
|
-
),
|
|
4669
|
-
|
|
4671
|
+
), h = x == null ? void 0 : x._id;
|
|
4672
|
+
h && (n({ ...o, currentSlide: h }), c([h]));
|
|
4670
4673
|
};
|
|
4671
4674
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4672
4675
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4673
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4676
|
+
/* @__PURE__ */ jsx("button", { onClick: f, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4674
4677
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4675
4678
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4676
4679
|
" ",
|
|
@@ -4683,7 +4686,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4683
4686
|
/* @__PURE__ */ jsxs(
|
|
4684
4687
|
"button",
|
|
4685
4688
|
{
|
|
4686
|
-
onClick:
|
|
4689
|
+
onClick: b,
|
|
4687
4690
|
className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
|
|
4688
4691
|
children: [
|
|
4689
4692
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4744,9 +4747,9 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4744
4747
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4745
4748
|
className: "text-xs",
|
|
4746
4749
|
pattern: "[0-9]*",
|
|
4747
|
-
onChange: (
|
|
4748
|
-
let
|
|
4749
|
-
|
|
4750
|
+
onChange: (x) => {
|
|
4751
|
+
let h = x.target.value;
|
|
4752
|
+
h.length && (h = h.replace("-", "")), n({ ...o, autoplayInterval: h });
|
|
4750
4753
|
}
|
|
4751
4754
|
}
|
|
4752
4755
|
)
|
|
@@ -4777,22 +4780,22 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4777
4780
|
useEffect(() => {
|
|
4778
4781
|
a || c([]), p(o);
|
|
4779
4782
|
}, [a, o]);
|
|
4780
|
-
const u = (
|
|
4781
|
-
(
|
|
4782
|
-
const
|
|
4783
|
-
|
|
4783
|
+
const u = (b) => Array.isArray(b) ? "array" : typeof b == "object" && b !== null ? "object" : "value", g = React.useCallback(
|
|
4784
|
+
(b) => {
|
|
4785
|
+
const x = (h) => r === "value" ? h === "value" || h === "object" : r === "array" ? h === "array" : h === r;
|
|
4786
|
+
b.type === "object" ? (c((h) => [...h, b.key]), p(b.value)) : x(b.type) && (n([...i, b.key].join(".")), l(!1));
|
|
4784
4787
|
},
|
|
4785
4788
|
[i, n, r]
|
|
4786
4789
|
), m = React.useCallback(() => {
|
|
4787
4790
|
if (i.length > 0) {
|
|
4788
|
-
const
|
|
4789
|
-
c(
|
|
4791
|
+
const b = i.slice(0, -1);
|
|
4792
|
+
c(b), p(b.reduce((x, h) => x[h], o));
|
|
4790
4793
|
}
|
|
4791
|
-
}, [i, o]),
|
|
4792
|
-
key:
|
|
4793
|
-
value:
|
|
4794
|
-
type: u(
|
|
4795
|
-
})).filter((
|
|
4794
|
+
}, [i, o]), f = React.useMemo(() => Object.entries(d).map(([b, x]) => ({
|
|
4795
|
+
key: b,
|
|
4796
|
+
value: x,
|
|
4797
|
+
type: u(x)
|
|
4798
|
+
})).filter((b) => r === "value" ? b.type === "value" || b.type === "object" : r === "array" ? b.type === "array" || b.type === "object" : r === "object" ? b.type === "object" : !0), [d, r]);
|
|
4796
4799
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4797
4800
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4798
4801
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
@@ -4817,33 +4820,33 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4817
4820
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4818
4821
|
"Back"
|
|
4819
4822
|
] }),
|
|
4820
|
-
|
|
4823
|
+
f.map((b) => /* @__PURE__ */ jsxs(
|
|
4821
4824
|
CommandItem,
|
|
4822
4825
|
{
|
|
4823
|
-
value:
|
|
4826
|
+
value: b.key,
|
|
4824
4827
|
disabled: !1,
|
|
4825
|
-
onSelect: () => g(
|
|
4828
|
+
onSelect: () => g(b),
|
|
4826
4829
|
className: "flex items-center justify-between",
|
|
4827
4830
|
children: [
|
|
4828
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
4831
|
+
/* @__PURE__ */ jsx("span", { children: b.key }),
|
|
4829
4832
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4830
|
-
r === "object" &&
|
|
4833
|
+
r === "object" && b.type === "object" && /* @__PURE__ */ jsx(
|
|
4831
4834
|
Button,
|
|
4832
4835
|
{
|
|
4833
4836
|
size: "sm",
|
|
4834
4837
|
variant: "ghost",
|
|
4835
4838
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4836
|
-
onClick: (
|
|
4837
|
-
|
|
4839
|
+
onClick: (x) => {
|
|
4840
|
+
x.stopPropagation(), n([...i, b.key].join(".")), l(!1);
|
|
4838
4841
|
},
|
|
4839
4842
|
children: "Select"
|
|
4840
4843
|
}
|
|
4841
4844
|
),
|
|
4842
|
-
(
|
|
4845
|
+
(b.type === "object" || b.type === "array") && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
|
|
4843
4846
|
] })
|
|
4844
4847
|
]
|
|
4845
4848
|
},
|
|
4846
|
-
|
|
4849
|
+
b.key
|
|
4847
4850
|
))
|
|
4848
4851
|
] })
|
|
4849
4852
|
] })
|
|
@@ -4864,66 +4867,66 @@ const CustomFieldTemplate = ({
|
|
|
4864
4867
|
formData: g,
|
|
4865
4868
|
onChange: m
|
|
4866
4869
|
}) => {
|
|
4867
|
-
const { selectedLang:
|
|
4870
|
+
const { selectedLang: f, fallbackLang: b, languages: x } = useLanguages(), h = isEmpty(x) ? "" : isEmpty(f) ? b : f, y = get(LANGUAGES, h, h), B = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), S = get(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [A, _] = useState(null), C = useCallback(
|
|
4868
4871
|
(v) => {
|
|
4869
|
-
const
|
|
4872
|
+
const N = (j) => /[.,!?;:]/.test(j), I = (j, R, D) => {
|
|
4870
4873
|
let L = "", $ = "";
|
|
4871
|
-
const O =
|
|
4872
|
-
return
|
|
4874
|
+
const O = R > 0 ? j[R - 1] : "", H = R < j.length ? j[R] : "";
|
|
4875
|
+
return R > 0 && (O === "." || !N(O) && O !== " ") && (L = " "), R < j.length && !N(H) && H !== " " && ($ = " "), {
|
|
4873
4876
|
text: L + D + $,
|
|
4874
4877
|
prefixLength: L.length,
|
|
4875
4878
|
suffixLength: $.length
|
|
4876
4879
|
};
|
|
4877
|
-
},
|
|
4878
|
-
if (!
|
|
4879
|
-
const
|
|
4880
|
-
if (
|
|
4881
|
-
const
|
|
4882
|
-
if (
|
|
4883
|
-
const
|
|
4884
|
-
|
|
4885
|
-
let D =
|
|
4886
|
-
if (D || (D =
|
|
4880
|
+
}, M = document.getElementById(o);
|
|
4881
|
+
if (!M) return;
|
|
4882
|
+
const P = document.getElementById(`quill.${o}`);
|
|
4883
|
+
if (P && "__quill" in P) {
|
|
4884
|
+
const j = P.__quill;
|
|
4885
|
+
if (j) {
|
|
4886
|
+
const R = `{{${v}}}`;
|
|
4887
|
+
j.focus();
|
|
4888
|
+
let D = j.getSelection();
|
|
4889
|
+
if (D || (D = j.getSelection(!0)), D)
|
|
4887
4890
|
if (D.length > 0) {
|
|
4888
4891
|
const L = D.index;
|
|
4889
|
-
|
|
4890
|
-
const $ =
|
|
4892
|
+
j.deleteText(D.index, D.length), j.setSelection(L, 0);
|
|
4893
|
+
const $ = j.getText(), {
|
|
4891
4894
|
text: O,
|
|
4892
4895
|
prefixLength: H,
|
|
4893
4896
|
suffixLength: V
|
|
4894
|
-
} =
|
|
4895
|
-
|
|
4897
|
+
} = I($, L, R);
|
|
4898
|
+
j.insertText(L, O), j.setSelection(L + H + R.length + V, 0);
|
|
4896
4899
|
} else {
|
|
4897
4900
|
const L = D.index;
|
|
4898
|
-
|
|
4899
|
-
const $ =
|
|
4901
|
+
j.setSelection(L, 0);
|
|
4902
|
+
const $ = j.getText(), {
|
|
4900
4903
|
text: O,
|
|
4901
4904
|
prefixLength: H,
|
|
4902
4905
|
suffixLength: V
|
|
4903
|
-
} =
|
|
4904
|
-
|
|
4906
|
+
} = I($, L, R);
|
|
4907
|
+
j.insertText(L, O), j.setSelection(L + H + R.length + V, 0);
|
|
4905
4908
|
}
|
|
4906
4909
|
else {
|
|
4907
|
-
const L =
|
|
4908
|
-
|
|
4909
|
-
const $ =
|
|
4910
|
+
const L = j.getLength();
|
|
4911
|
+
j.setSelection(L - 1, 0);
|
|
4912
|
+
const $ = j.getText(), {
|
|
4910
4913
|
text: O,
|
|
4911
4914
|
prefixLength: H,
|
|
4912
4915
|
suffixLength: V
|
|
4913
|
-
} =
|
|
4914
|
-
|
|
4916
|
+
} = I($, L - 1, R);
|
|
4917
|
+
j.insertText(L - 1, O), j.setSelection(L - 1 + H + R.length + V, 0);
|
|
4915
4918
|
}
|
|
4916
|
-
setTimeout(() => m(
|
|
4919
|
+
setTimeout(() => m(j.root.innerHTML, {}, o), 200);
|
|
4917
4920
|
return;
|
|
4918
4921
|
}
|
|
4919
4922
|
} else {
|
|
4920
|
-
const
|
|
4921
|
-
if (L >
|
|
4922
|
-
const F = `{{${v}}}`, { text: z } =
|
|
4923
|
+
const j = M, R = j.selectionStart || 0, D = j.value || "", L = j.selectionEnd || R;
|
|
4924
|
+
if (L > R) {
|
|
4925
|
+
const F = `{{${v}}}`, { text: z } = I(D, R, F), W = D.slice(0, R) + z + D.slice(L);
|
|
4923
4926
|
m(W, {}, o);
|
|
4924
4927
|
return;
|
|
4925
4928
|
}
|
|
4926
|
-
const O = `{{${v}}}`, { text: H } =
|
|
4929
|
+
const O = `{{${v}}}`, { text: H } = I(D, R, O), V = D.slice(0, R) + H + D.slice(R);
|
|
4927
4930
|
m(V, {}, o);
|
|
4928
4931
|
}
|
|
4929
4932
|
},
|
|
@@ -4940,7 +4943,7 @@ const CustomFieldTemplate = ({
|
|
|
4940
4943
|
"label",
|
|
4941
4944
|
{
|
|
4942
4945
|
htmlFor: o,
|
|
4943
|
-
onClick: () =>
|
|
4946
|
+
onClick: () => _(v ? null : o),
|
|
4944
4947
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4945
4948
|
children: [
|
|
4946
4949
|
v ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
@@ -5025,8 +5028,8 @@ const CustomFieldTemplate = ({
|
|
|
5025
5028
|
formData: a,
|
|
5026
5029
|
onChange: ({ formData: g }, m) => {
|
|
5027
5030
|
if (console.log(g, m), !m || o !== (g == null ? void 0 : g._id)) return;
|
|
5028
|
-
const
|
|
5029
|
-
u({ formData: g },
|
|
5031
|
+
const f = take(m.split("."), 2).join(".").replace("root.", "");
|
|
5032
|
+
u({ formData: g }, f);
|
|
5030
5033
|
}
|
|
5031
5034
|
},
|
|
5032
5035
|
i
|
|
@@ -5038,17 +5041,17 @@ const CustomFieldTemplate = ({
|
|
|
5038
5041
|
}), a;
|
|
5039
5042
|
};
|
|
5040
5043
|
function BlockSettings() {
|
|
5041
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type),
|
|
5042
|
-
|
|
5043
|
-
},
|
|
5044
|
-
debounce(({ formData: A },
|
|
5045
|
-
|
|
5044
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m), b = ({ formData: A }, _, C) => {
|
|
5045
|
+
_ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(A, _) }, C);
|
|
5046
|
+
}, x = useCallback(
|
|
5047
|
+
debounce(({ formData: A }, _, C) => {
|
|
5048
|
+
b({ formData: A }, _, C), d(A);
|
|
5046
5049
|
}, 1500),
|
|
5047
5050
|
[n == null ? void 0 : n._id, o]
|
|
5048
|
-
),
|
|
5049
|
-
|
|
5050
|
-
}, y = ({ formData: A },
|
|
5051
|
-
|
|
5051
|
+
), h = ({ formData: A }, _) => {
|
|
5052
|
+
_ && (r([n._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
|
|
5053
|
+
}, y = ({ formData: A }, _) => {
|
|
5054
|
+
_ && (r([g._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
|
|
5052
5055
|
};
|
|
5053
5056
|
keys(get(i, "_bindings", {}));
|
|
5054
5057
|
const { schema: B, uiSchema: E } = useMemo(() => {
|
|
@@ -5058,8 +5061,8 @@ function BlockSettings() {
|
|
|
5058
5061
|
}, [n]), { wrapperSchema: w, wrapperUiSchema: S } = useMemo(() => {
|
|
5059
5062
|
if (!g || !(g != null && g._type))
|
|
5060
5063
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5061
|
-
const A = g == null ? void 0 : g._type, { schema:
|
|
5062
|
-
return { wrapperSchema:
|
|
5064
|
+
const A = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: C = {} } = getBlockFormSchemas(A);
|
|
5065
|
+
return { wrapperSchema: _, wrapperUiSchema: C };
|
|
5063
5066
|
}, [g]);
|
|
5064
5067
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5065
5068
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
@@ -5084,25 +5087,171 @@ function BlockSettings() {
|
|
|
5084
5087
|
/* @__PURE__ */ jsx("div", { className: p ? "h-auto" : "invisible h-0", children: /* @__PURE__ */ jsx(
|
|
5085
5088
|
JSONForm,
|
|
5086
5089
|
{
|
|
5087
|
-
blockId: g == null ? void 0 : g._id,
|
|
5088
|
-
onChange: y,
|
|
5089
|
-
formData:
|
|
5090
|
-
schema: w,
|
|
5091
|
-
uiSchema: S
|
|
5090
|
+
blockId: g == null ? void 0 : g._id,
|
|
5091
|
+
onChange: y,
|
|
5092
|
+
formData: f,
|
|
5093
|
+
schema: w,
|
|
5094
|
+
uiSchema: S
|
|
5095
|
+
}
|
|
5096
|
+
) })
|
|
5097
|
+
] }),
|
|
5098
|
+
isEmpty(B) ? null : /* @__PURE__ */ jsx(
|
|
5099
|
+
JSONForm,
|
|
5100
|
+
{
|
|
5101
|
+
blockId: n == null ? void 0 : n._id,
|
|
5102
|
+
onChange: h,
|
|
5103
|
+
formData: i,
|
|
5104
|
+
schema: B,
|
|
5105
|
+
uiSchema: E
|
|
5106
|
+
}
|
|
5107
|
+
),
|
|
5108
|
+
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
5109
|
+
] });
|
|
5110
|
+
}
|
|
5111
|
+
const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
5112
|
+
"svg",
|
|
5113
|
+
{
|
|
5114
|
+
className: o ? "rotate-90" : "",
|
|
5115
|
+
stroke: "currentColor",
|
|
5116
|
+
fill: "currentColor",
|
|
5117
|
+
strokeWidth: "0",
|
|
5118
|
+
viewBox: "0 0 448 512",
|
|
5119
|
+
height: "14px",
|
|
5120
|
+
width: "14px",
|
|
5121
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5122
|
+
children: /* @__PURE__ */ jsx("path", { d: "M400 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM224 480c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm176-108c0 6.6-5.4 12-12 12H60c-6.6 0-12-5.4-12-12V60c0-6.6 5.4-12 12-12h328c6.6 0 12 5.4 12 12v312z" })
|
|
5123
|
+
}
|
|
5124
|
+
), WEB_BREAKPOINTS = [
|
|
5125
|
+
{
|
|
5126
|
+
title: "Mobile (Base)",
|
|
5127
|
+
content: "Styles set here are applied to all screen unless edited at higher breakpoint",
|
|
5128
|
+
breakpoint: "xs",
|
|
5129
|
+
icon: /* @__PURE__ */ jsx(MobileIcon, {}),
|
|
5130
|
+
width: 400
|
|
5131
|
+
},
|
|
5132
|
+
{
|
|
5133
|
+
title: "Mobile landscape (SM)",
|
|
5134
|
+
content: "Styles set here are applied at 640px and up unless edited at higher breakpoint",
|
|
5135
|
+
breakpoint: "sm",
|
|
5136
|
+
icon: /* @__PURE__ */ jsx(MobileIcon, { className: "rotate-90" }),
|
|
5137
|
+
width: 640
|
|
5138
|
+
},
|
|
5139
|
+
{
|
|
5140
|
+
title: "Tablet (MD)",
|
|
5141
|
+
content: "Styles set here are applied at 768px and up",
|
|
5142
|
+
breakpoint: "md",
|
|
5143
|
+
icon: /* @__PURE__ */ jsx(TabletIcon, {}),
|
|
5144
|
+
width: 800
|
|
5145
|
+
},
|
|
5146
|
+
{
|
|
5147
|
+
title: "Tablet Landscape (LG)",
|
|
5148
|
+
content: "Styles set here are applied at 1024px and up unless edited at higher breakpoint",
|
|
5149
|
+
breakpoint: "lg",
|
|
5150
|
+
icon: /* @__PURE__ */ jsx(TabletIcon, { landscape: !0 }),
|
|
5151
|
+
width: 1024
|
|
5152
|
+
},
|
|
5153
|
+
{
|
|
5154
|
+
title: "Desktop (XL)",
|
|
5155
|
+
content: "Styles set here are applied at 1280px and up unless edited at higher breakpoint",
|
|
5156
|
+
breakpoint: "xl",
|
|
5157
|
+
icon: /* @__PURE__ */ jsx(LaptopIcon, {}),
|
|
5158
|
+
width: 1420
|
|
5159
|
+
},
|
|
5160
|
+
{
|
|
5161
|
+
title: "Large Desktop (2XL)",
|
|
5162
|
+
content: "Styles set here are applied at 1536px and up",
|
|
5163
|
+
breakpoint: "2xl",
|
|
5164
|
+
icon: /* @__PURE__ */ jsx(DesktopIcon, {}),
|
|
5165
|
+
width: 1920
|
|
5166
|
+
}
|
|
5167
|
+
], BreakpointCard = ({
|
|
5168
|
+
canvas: o = !1,
|
|
5169
|
+
openDelay: n = 400,
|
|
5170
|
+
title: r,
|
|
5171
|
+
content: a,
|
|
5172
|
+
currentBreakpoint: l,
|
|
5173
|
+
breakpoint: i,
|
|
5174
|
+
width: c,
|
|
5175
|
+
icon: d,
|
|
5176
|
+
onClick: p
|
|
5177
|
+
}) => {
|
|
5178
|
+
const { t: u } = useTranslation();
|
|
5179
|
+
return /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
|
|
5180
|
+
/* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5181
|
+
Button,
|
|
5182
|
+
{
|
|
5183
|
+
onClick: () => p(c),
|
|
5184
|
+
size: "sm",
|
|
5185
|
+
className: "h-7 w-7 rounded-md p-1",
|
|
5186
|
+
variant: i === l ? "outline" : "ghost",
|
|
5187
|
+
children: d
|
|
5188
|
+
}
|
|
5189
|
+
) }),
|
|
5190
|
+
/* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
5191
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: u(r) }),
|
|
5192
|
+
o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: u(a) })
|
|
5193
|
+
] }) }) })
|
|
5194
|
+
] });
|
|
5195
|
+
}, Breakpoints$1 = ({ openDelay: o = 400, canvas: n = !1 }) => {
|
|
5196
|
+
const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (h) => {
|
|
5197
|
+
p.includes(h) ? p.length > 2 && u(p.filter((y) => y !== h)) : u((y) => [...y, h]);
|
|
5198
|
+
}, b = (h) => {
|
|
5199
|
+
n || a(h), i(h);
|
|
5200
|
+
}, x = getBreakpointValue(n ? l : r).toLowerCase();
|
|
5201
|
+
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (h) => /* @__PURE__ */ createElement(
|
|
5202
|
+
BreakpointCard,
|
|
5203
|
+
{
|
|
5204
|
+
canvas: n,
|
|
5205
|
+
...h,
|
|
5206
|
+
onClick: b,
|
|
5207
|
+
key: h.breakpoint,
|
|
5208
|
+
currentBreakpoint: x
|
|
5209
|
+
}
|
|
5210
|
+
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5211
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5212
|
+
m.filter((h) => includes(p, toUpper(h.breakpoint))),
|
|
5213
|
+
(h) => /* @__PURE__ */ createElement(
|
|
5214
|
+
BreakpointCard,
|
|
5215
|
+
{
|
|
5216
|
+
canvas: n,
|
|
5217
|
+
openDelay: o,
|
|
5218
|
+
...h,
|
|
5219
|
+
onClick: b,
|
|
5220
|
+
key: h.breakpoint,
|
|
5221
|
+
currentBreakpoint: x
|
|
5092
5222
|
}
|
|
5093
|
-
)
|
|
5223
|
+
)
|
|
5224
|
+
) }),
|
|
5225
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5226
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
|
|
5227
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5228
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
|
|
5229
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5230
|
+
map(m, (h) => /* @__PURE__ */ jsx(
|
|
5231
|
+
DropdownMenuCheckboxItem,
|
|
5232
|
+
{
|
|
5233
|
+
disabled: h.breakpoint === "xs",
|
|
5234
|
+
onCheckedChange: () => f(toUpper(h.breakpoint)),
|
|
5235
|
+
checked: includes(p, toUpper(h.breakpoint)),
|
|
5236
|
+
children: g(h.title)
|
|
5237
|
+
},
|
|
5238
|
+
h.breakpoint
|
|
5239
|
+
))
|
|
5240
|
+
] })
|
|
5241
|
+
] })
|
|
5242
|
+
] });
|
|
5243
|
+
};
|
|
5244
|
+
function BreakpointSelector() {
|
|
5245
|
+
const [, o] = useScreenSizeWidth(), n = useMemo(() => {
|
|
5246
|
+
const r = WEB_BREAKPOINTS.find((a) => a.breakpoint === o);
|
|
5247
|
+
return r == null ? void 0 : r.content;
|
|
5248
|
+
}, [o, WEB_BREAKPOINTS]);
|
|
5249
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5250
|
+
/* @__PURE__ */ jsxs("div", { className: "sticky top-0 z-10 flex items-center justify-start bg-muted px-2 py-1 shadow-sm", children: [
|
|
5251
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Screen: " }),
|
|
5252
|
+
/* @__PURE__ */ jsx(Breakpoints$1, { openDelay: 500 })
|
|
5094
5253
|
] }),
|
|
5095
|
-
|
|
5096
|
-
JSONForm,
|
|
5097
|
-
{
|
|
5098
|
-
blockId: n == null ? void 0 : n._id,
|
|
5099
|
-
onChange: b,
|
|
5100
|
-
formData: i,
|
|
5101
|
-
schema: B,
|
|
5102
|
-
uiSchema: E
|
|
5103
|
-
}
|
|
5104
|
-
),
|
|
5105
|
-
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
5254
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between rounded-md rounded-t-none border border-border p-1", children: /* @__PURE__ */ jsx("p", { className: "flex-1 text-[10px] text-muted-foreground", children: n }) })
|
|
5106
5255
|
] });
|
|
5107
5256
|
}
|
|
5108
5257
|
function FaLanguage(o) {
|
|
@@ -5171,12 +5320,12 @@ function Countdown() {
|
|
|
5171
5320
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5172
5321
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
5173
5322
|
useEffect(() => {
|
|
5174
|
-
var
|
|
5175
|
-
(
|
|
5323
|
+
var f;
|
|
5324
|
+
(f = d.current) == null || f.focus();
|
|
5176
5325
|
}, []);
|
|
5177
|
-
const m = (
|
|
5178
|
-
const { usage:
|
|
5179
|
-
!l &&
|
|
5326
|
+
const m = (f) => {
|
|
5327
|
+
const { usage: b } = f || {};
|
|
5328
|
+
!l && b && g(b), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5180
5329
|
};
|
|
5181
5330
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
5182
5331
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -5185,12 +5334,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5185
5334
|
{
|
|
5186
5335
|
ref: d,
|
|
5187
5336
|
value: i,
|
|
5188
|
-
onChange: (
|
|
5337
|
+
onChange: (f) => c(f.target.value),
|
|
5189
5338
|
placeholder: n("Ask AI to edit styles"),
|
|
5190
5339
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5191
5340
|
rows: 4,
|
|
5192
|
-
onKeyDown: (
|
|
5193
|
-
|
|
5341
|
+
onKeyDown: (f) => {
|
|
5342
|
+
f.key === "Enter" && (f.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
|
|
5194
5343
|
}
|
|
5195
5344
|
}
|
|
5196
5345
|
),
|
|
@@ -5231,77 +5380,85 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5231
5380
|
] });
|
|
5232
5381
|
};
|
|
5233
5382
|
function ManualClasses() {
|
|
5234
|
-
var
|
|
5235
|
-
const o = useFuseSearch(), { t:
|
|
5236
|
-
const
|
|
5237
|
-
|
|
5238
|
-
}, [
|
|
5239
|
-
const
|
|
5240
|
-
let
|
|
5241
|
-
if (
|
|
5242
|
-
const [
|
|
5243
|
-
|
|
5244
|
-
...
|
|
5245
|
-
item: { ...
|
|
5383
|
+
var M;
|
|
5384
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), f = useBuilderProp("askAiCallBack", null), [b, x] = useState(""), { toast: h } = useToast(), y = (M = first(d)) == null ? void 0 : M.prop, { classes: B } = getSplitChaiClasses(get(p, y, "")), E = B.split(" ").filter((P) => !isEmpty(P)), w = () => {
|
|
5385
|
+
const P = b.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5386
|
+
u(m, P, !0), x("");
|
|
5387
|
+
}, [S, A] = useState([]), _ = ({ value: P }) => {
|
|
5388
|
+
const j = P.trim().toLowerCase(), R = j.match(/.+:/g);
|
|
5389
|
+
let D = [];
|
|
5390
|
+
if (R && R.length > 0) {
|
|
5391
|
+
const [L] = R, $ = j.replace(L, "");
|
|
5392
|
+
D = i.search($).map((H) => ({
|
|
5393
|
+
...H,
|
|
5394
|
+
item: { ...H.item, name: L + H.item.name }
|
|
5246
5395
|
}));
|
|
5247
5396
|
} else
|
|
5248
|
-
|
|
5249
|
-
return
|
|
5250
|
-
},
|
|
5251
|
-
|
|
5252
|
-
},
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5397
|
+
D = i.search(j);
|
|
5398
|
+
return A(map(D, "item"));
|
|
5399
|
+
}, C = () => {
|
|
5400
|
+
A([]);
|
|
5401
|
+
}, T = (P) => P.name, k = (P) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: P.name }), v = useMemo(
|
|
5402
|
+
() => ({
|
|
5403
|
+
ref: o,
|
|
5404
|
+
autoComplete: "off",
|
|
5405
|
+
autoCorrect: "off",
|
|
5406
|
+
autoCapitalize: "off",
|
|
5407
|
+
spellCheck: !1,
|
|
5408
|
+
placeholder: c("Enter classes separated by space"),
|
|
5409
|
+
value: b,
|
|
5410
|
+
onKeyDown: (P) => {
|
|
5411
|
+
P.key === "Enter" && b.trim() !== "" && w();
|
|
5412
|
+
},
|
|
5413
|
+
onChange: (P, { newValue: j }) => x(j),
|
|
5414
|
+
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5415
|
+
}),
|
|
5416
|
+
[b, c, o]
|
|
5417
|
+
), N = (P) => {
|
|
5418
|
+
debugger;
|
|
5419
|
+
const j = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5420
|
+
g(m, [P]), u(m, j, !0), r(""), l(-1);
|
|
5421
|
+
}, I = () => {
|
|
5265
5422
|
if (navigator.clipboard === void 0) {
|
|
5266
|
-
|
|
5267
|
-
title:
|
|
5268
|
-
description:
|
|
5423
|
+
h({
|
|
5424
|
+
title: c("Clipboard not supported"),
|
|
5425
|
+
description: c("Please use Chrome, Firefox or Safari"),
|
|
5269
5426
|
variant: "destructive"
|
|
5270
5427
|
});
|
|
5271
5428
|
return;
|
|
5272
5429
|
}
|
|
5273
|
-
navigator.clipboard.writeText(
|
|
5274
|
-
title:
|
|
5275
|
-
description:
|
|
5430
|
+
navigator.clipboard.writeText(E.join(" ")), h({
|
|
5431
|
+
title: c("Copied"),
|
|
5432
|
+
description: c("Classes copied to clipboard")
|
|
5276
5433
|
});
|
|
5277
5434
|
};
|
|
5278
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 pb-4", children: [
|
|
5435
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5279
5436
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
5280
5437
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5281
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
5438
|
+
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
5282
5439
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5283
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
5284
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
5440
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: I, className: "cursor-pointer" }) }),
|
|
5441
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
5285
5442
|
] })
|
|
5286
5443
|
] }),
|
|
5287
|
-
|
|
5444
|
+
f ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
5288
5445
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
5289
|
-
/* @__PURE__ */ jsx(SparklesIcon, { className: "
|
|
5290
|
-
/* @__PURE__ */ jsx("span", { className: "ml-2", children:
|
|
5446
|
+
/* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
|
|
5447
|
+
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
5291
5448
|
] }) }),
|
|
5292
|
-
/* @__PURE__ */ jsx(PopoverContent, { side: "left", className: "p-2", children: /* @__PURE__ */ jsx(AskAIStyles, { blockId:
|
|
5449
|
+
/* @__PURE__ */ jsx(PopoverContent, { side: "left", className: "p-2", children: /* @__PURE__ */ jsx(AskAIStyles, { blockId: p == null ? void 0 : p._id }) })
|
|
5293
5450
|
] }) : null
|
|
5294
5451
|
] }),
|
|
5295
5452
|
/* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-x-3", children: [
|
|
5296
|
-
/* @__PURE__ */ jsx("div", { className: "relative flex items-center
|
|
5453
|
+
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5297
5454
|
Autosuggest,
|
|
5298
5455
|
{
|
|
5299
|
-
suggestions:
|
|
5300
|
-
onSuggestionsFetchRequested:
|
|
5301
|
-
onSuggestionsClearRequested:
|
|
5302
|
-
getSuggestionValue:
|
|
5303
|
-
renderSuggestion:
|
|
5304
|
-
inputProps:
|
|
5456
|
+
suggestions: S,
|
|
5457
|
+
onSuggestionsFetchRequested: _,
|
|
5458
|
+
onSuggestionsClearRequested: C,
|
|
5459
|
+
getSuggestionValue: T,
|
|
5460
|
+
renderSuggestion: k,
|
|
5461
|
+
inputProps: v,
|
|
5305
5462
|
containerProps: {
|
|
5306
5463
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
5307
5464
|
},
|
|
@@ -5317,30 +5474,47 @@ function ManualClasses() {
|
|
|
5317
5474
|
{
|
|
5318
5475
|
variant: "outline",
|
|
5319
5476
|
className: "h-6 border-border",
|
|
5320
|
-
onClick:
|
|
5321
|
-
disabled:
|
|
5477
|
+
onClick: w,
|
|
5478
|
+
disabled: b.trim() === "",
|
|
5322
5479
|
size: "sm",
|
|
5323
5480
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5324
5481
|
}
|
|
5325
5482
|
)
|
|
5326
5483
|
] }),
|
|
5327
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5484
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: E.map(
|
|
5485
|
+
(P, j) => a === j ? /* @__PURE__ */ jsx(
|
|
5486
|
+
"input",
|
|
5487
|
+
{
|
|
5488
|
+
ref: o,
|
|
5489
|
+
value: n,
|
|
5490
|
+
onChange: (R) => r(R.target.value),
|
|
5491
|
+
onBlur: () => {
|
|
5492
|
+
N(P);
|
|
5493
|
+
},
|
|
5494
|
+
onKeyDown: (R) => {
|
|
5495
|
+
R.key === "Enter" && N(P);
|
|
5496
|
+
},
|
|
5497
|
+
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
|
|
5498
|
+
},
|
|
5499
|
+
P
|
|
5500
|
+
) : /* @__PURE__ */ jsxs(
|
|
5501
|
+
"button",
|
|
5502
|
+
{
|
|
5503
|
+
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
|
|
5504
|
+
children: [
|
|
5505
|
+
P,
|
|
5506
|
+
n !== P && /* @__PURE__ */ jsx(
|
|
5507
|
+
Cross2Icon,
|
|
5508
|
+
{
|
|
5509
|
+
onClick: () => g(m, [P], !0),
|
|
5510
|
+
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
5511
|
+
}
|
|
5512
|
+
)
|
|
5513
|
+
]
|
|
5514
|
+
},
|
|
5515
|
+
P
|
|
5516
|
+
)
|
|
5517
|
+
) })
|
|
5344
5518
|
] });
|
|
5345
5519
|
}
|
|
5346
5520
|
const BASIC_UNITS = ["px", "%", "em", "rem", "ch", "vh", "vw"], FLEX_CHILD_SECTION = {
|
|
@@ -5368,6 +5542,7 @@ const BASIC_UNITS = ["px", "%", "em", "rem", "ch", "vh", "vw"], FLEX_CHILD_SECTI
|
|
|
5368
5542
|
heading: "Styles",
|
|
5369
5543
|
items: [
|
|
5370
5544
|
{ component: ManualClasses },
|
|
5545
|
+
{ component: BreakpointSelector },
|
|
5371
5546
|
{ type: "arbitrary", label: "layout.width", units: BASIC_UNITS.concat("auto"), property: "width" },
|
|
5372
5547
|
{ type: "arbitrary", label: "layout.height", units: BASIC_UNITS.concat("auto"), property: "height" },
|
|
5373
5548
|
{
|
|
@@ -5664,57 +5839,7 @@ function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disab
|
|
|
5664
5839
|
}
|
|
5665
5840
|
);
|
|
5666
5841
|
}
|
|
5667
|
-
const
|
|
5668
|
-
const { canReset: r, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), { getClasses: c } = useTailwindClassList(), d = c(o, [""]), p = d.indexOf(i) > -1 ? d.indexOf(i) : 0, u = /\[.*\]/g.test(i);
|
|
5669
|
-
return /* @__PURE__ */ jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: u ? /* @__PURE__ */ jsx("div", { className: "px-2 py-[5px]", children: i }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5670
|
-
/* @__PURE__ */ jsx(
|
|
5671
|
-
"button",
|
|
5672
|
-
{
|
|
5673
|
-
type: "button",
|
|
5674
|
-
className: "hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
|
|
5675
|
-
disabled: !a && (!r || p - 1 < 0),
|
|
5676
|
-
onClick: () => n(nth(d, p - 1), o),
|
|
5677
|
-
children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
5678
|
-
MinusIcon,
|
|
5679
|
-
{
|
|
5680
|
-
className: !a && (!r || p - 1 < 0) ? "text-gray-500" : "text-black/60 dark:text-white/60"
|
|
5681
|
-
}
|
|
5682
|
-
) })
|
|
5683
|
-
}
|
|
5684
|
-
),
|
|
5685
|
-
/* @__PURE__ */ jsx("div", { className: "w-8/12 text-center", children: /* @__PURE__ */ jsx(DropDownChoices, { label: !1, property: o, onChange: n }) }),
|
|
5686
|
-
/* @__PURE__ */ jsx(
|
|
5687
|
-
"button",
|
|
5688
|
-
{
|
|
5689
|
-
type: "button",
|
|
5690
|
-
className: "hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
|
|
5691
|
-
disabled: !a && (!r || p + 1 >= d.length),
|
|
5692
|
-
onClick: () => n(nth(d, p + 1), o),
|
|
5693
|
-
children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
5694
|
-
PlusIcon,
|
|
5695
|
-
{
|
|
5696
|
-
className: !a && (!r || p + 1 >= d.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
|
|
5697
|
-
}
|
|
5698
|
-
) })
|
|
5699
|
-
}
|
|
5700
|
-
)
|
|
5701
|
-
] }) });
|
|
5702
|
-
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
5703
|
-
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
5704
|
-
return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (d) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5705
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5706
|
-
"button",
|
|
5707
|
-
{
|
|
5708
|
-
type: "button",
|
|
5709
|
-
disabled: !l,
|
|
5710
|
-
onClick: () => n(d, o),
|
|
5711
|
-
className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${c === d ? "bg-blue-500 text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
|
|
5712
|
-
children: React__default.createElement(get(EDITOR_ICONS, d, BoxIcon))
|
|
5713
|
-
}
|
|
5714
|
-
) }),
|
|
5715
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(d)) })
|
|
5716
|
-
] })) });
|
|
5717
|
-
}, COLOR_PROP = {
|
|
5842
|
+
const COLOR_PROP = {
|
|
5718
5843
|
backgroundColor: "bg",
|
|
5719
5844
|
textColor: "text",
|
|
5720
5845
|
borderColor: "border",
|
|
@@ -5727,10 +5852,10 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5727
5852
|
ringColor: "ring",
|
|
5728
5853
|
ringOffsetColor: "ring-offset"
|
|
5729
5854
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5730
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""),
|
|
5855
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), f = useCallback(
|
|
5731
5856
|
// eslint-disable-next-line no-shadow
|
|
5732
|
-
(
|
|
5733
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
5857
|
+
(h) => {
|
|
5858
|
+
["current", "inherit", "transparent", "black", "white"].includes(h) ? (c([]), p({ color: h })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: h, shade: y.shade ? y.shade : "500" })));
|
|
5734
5859
|
},
|
|
5735
5860
|
[c, p]
|
|
5736
5861
|
);
|
|
@@ -5739,28 +5864,28 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5739
5864
|
return c([]);
|
|
5740
5865
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5741
5866
|
}, [g]);
|
|
5742
|
-
const
|
|
5867
|
+
const b = useCallback(
|
|
5743
5868
|
// eslint-disable-next-line no-shadow
|
|
5744
|
-
(
|
|
5745
|
-
p({ color: g, shade:
|
|
5869
|
+
(h) => {
|
|
5870
|
+
p({ color: g, shade: h });
|
|
5746
5871
|
},
|
|
5747
5872
|
[g]
|
|
5748
5873
|
);
|
|
5749
5874
|
useEffect(() => {
|
|
5750
5875
|
p({ color: "", shade: "" });
|
|
5751
5876
|
}, [r]);
|
|
5752
|
-
const { match:
|
|
5877
|
+
const { match: x } = useTailwindClassList();
|
|
5753
5878
|
return useEffect(() => {
|
|
5754
5879
|
const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5755
|
-
|
|
5756
|
-
}, [
|
|
5880
|
+
x(o, y) && n(y, o);
|
|
5881
|
+
}, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5757
5882
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5758
5883
|
DropDown,
|
|
5759
5884
|
{
|
|
5760
5885
|
disabled: !l,
|
|
5761
5886
|
rounded: !0,
|
|
5762
5887
|
selected: g,
|
|
5763
|
-
onChange:
|
|
5888
|
+
onChange: f,
|
|
5764
5889
|
options: [
|
|
5765
5890
|
"current",
|
|
5766
5891
|
"transparent",
|
|
@@ -5793,8 +5918,58 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5793
5918
|
]
|
|
5794
5919
|
}
|
|
5795
5920
|
) }),
|
|
5796
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange:
|
|
5921
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: b, options: i }) })
|
|
5797
5922
|
] });
|
|
5923
|
+
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
5924
|
+
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
5925
|
+
return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (d) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5926
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5927
|
+
"button",
|
|
5928
|
+
{
|
|
5929
|
+
type: "button",
|
|
5930
|
+
disabled: !l,
|
|
5931
|
+
onClick: () => n(d, o),
|
|
5932
|
+
className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${c === d ? "bg-blue-500 text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
|
|
5933
|
+
children: React__default.createElement(get(EDITOR_ICONS, d, BoxIcon))
|
|
5934
|
+
}
|
|
5935
|
+
) }),
|
|
5936
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(d)) })
|
|
5937
|
+
] })) });
|
|
5938
|
+
}, RangeChoices = ({ property: o, onChange: n }) => {
|
|
5939
|
+
const { canReset: r, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), { getClasses: c } = useTailwindClassList(), d = c(o, [""]), p = d.indexOf(i) > -1 ? d.indexOf(i) : 0, u = /\[.*\]/g.test(i);
|
|
5940
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: u ? /* @__PURE__ */ jsx("div", { className: "px-2 py-[5px]", children: i }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5941
|
+
/* @__PURE__ */ jsx(
|
|
5942
|
+
"button",
|
|
5943
|
+
{
|
|
5944
|
+
type: "button",
|
|
5945
|
+
className: "hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
|
|
5946
|
+
disabled: !a && (!r || p - 1 < 0),
|
|
5947
|
+
onClick: () => n(nth(d, p - 1), o),
|
|
5948
|
+
children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
5949
|
+
MinusIcon,
|
|
5950
|
+
{
|
|
5951
|
+
className: !a && (!r || p - 1 < 0) ? "text-gray-500" : "text-black/60 dark:text-white/60"
|
|
5952
|
+
}
|
|
5953
|
+
) })
|
|
5954
|
+
}
|
|
5955
|
+
),
|
|
5956
|
+
/* @__PURE__ */ jsx("div", { className: "w-8/12 text-center", children: /* @__PURE__ */ jsx(DropDownChoices, { label: !1, property: o, onChange: n }) }),
|
|
5957
|
+
/* @__PURE__ */ jsx(
|
|
5958
|
+
"button",
|
|
5959
|
+
{
|
|
5960
|
+
type: "button",
|
|
5961
|
+
className: "hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
|
|
5962
|
+
disabled: !a && (!r || p + 1 >= d.length),
|
|
5963
|
+
onClick: () => n(nth(d, p + 1), o),
|
|
5964
|
+
children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
5965
|
+
PlusIcon,
|
|
5966
|
+
{
|
|
5967
|
+
className: !a && (!r || p + 1 >= d.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
|
|
5968
|
+
}
|
|
5969
|
+
) })
|
|
5970
|
+
}
|
|
5971
|
+
)
|
|
5972
|
+
] }) });
|
|
5798
5973
|
}, getUserInputValues = (o, n) => {
|
|
5799
5974
|
o = o.toLowerCase();
|
|
5800
5975
|
let r = o.trim().replace(/ |\+/g, "");
|
|
@@ -5940,38 +6115,38 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5940
6115
|
},
|
|
5941
6116
|
a
|
|
5942
6117
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5943
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m,
|
|
6118
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [b, x] = useState(!1), [h, y] = useState(""), [B, E] = useState(!1), [w, S] = useState(!1);
|
|
5944
6119
|
useEffect(() => {
|
|
5945
6120
|
const { value: k, unit: v } = getClassValueAndUnit(i);
|
|
5946
6121
|
if (v === "") {
|
|
5947
|
-
l(k),
|
|
6122
|
+
l(k), f(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5948
6123
|
return;
|
|
5949
6124
|
}
|
|
5950
|
-
|
|
6125
|
+
f(v), l(v === "class" || isEmpty(k) ? "" : k);
|
|
5951
6126
|
}, [i, p, u]);
|
|
5952
|
-
const A = useThrottledCallback((k) => c(k), [c], THROTTLE_TIME),
|
|
6127
|
+
const A = useThrottledCallback((k) => c(k), [c], THROTTLE_TIME), _ = useThrottledCallback((k) => c(k, !1), [c], THROTTLE_TIME), C = useCallback(
|
|
5953
6128
|
(k = !1) => {
|
|
5954
6129
|
const v = getUserInputValues(`${a}`, u);
|
|
5955
6130
|
if (get(v, "error", !1)) {
|
|
5956
|
-
|
|
6131
|
+
x(!0);
|
|
5957
6132
|
return;
|
|
5958
6133
|
}
|
|
5959
|
-
const
|
|
5960
|
-
if (
|
|
5961
|
-
A(`${d}${
|
|
6134
|
+
const N = get(v, "unit") !== "" ? get(v, "unit") : m;
|
|
6135
|
+
if (N === "auto" || N === "none") {
|
|
6136
|
+
A(`${d}${N}`);
|
|
5962
6137
|
return;
|
|
5963
6138
|
}
|
|
5964
6139
|
if (get(v, "value") === "")
|
|
5965
6140
|
return;
|
|
5966
|
-
const
|
|
5967
|
-
k ?
|
|
6141
|
+
const M = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
|
|
6142
|
+
k ? _(M) : A(M);
|
|
5968
6143
|
},
|
|
5969
|
-
[A,
|
|
5970
|
-
),
|
|
6144
|
+
[A, _, a, m, d, u]
|
|
6145
|
+
), T = useCallback(
|
|
5971
6146
|
(k) => {
|
|
5972
6147
|
const v = getUserInputValues(`${a}`, u);
|
|
5973
6148
|
if (get(v, "error", !1)) {
|
|
5974
|
-
|
|
6149
|
+
x(!0);
|
|
5975
6150
|
return;
|
|
5976
6151
|
}
|
|
5977
6152
|
if (k === "auto" || k === "none") {
|
|
@@ -5980,8 +6155,8 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5980
6155
|
}
|
|
5981
6156
|
if (get(v, "value") === "")
|
|
5982
6157
|
return;
|
|
5983
|
-
const
|
|
5984
|
-
A(
|
|
6158
|
+
const N = get(v, "unit") !== "" ? get(v, "unit") : k, M = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
|
|
6159
|
+
A(M);
|
|
5985
6160
|
},
|
|
5986
6161
|
[A, a, d, u]
|
|
5987
6162
|
);
|
|
@@ -6012,26 +6187,26 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6012
6187
|
return;
|
|
6013
6188
|
k.preventDefault(), S(!0);
|
|
6014
6189
|
const v = parseInt$1(k.target.value);
|
|
6015
|
-
let
|
|
6016
|
-
k.keyCode === 38 && (
|
|
6017
|
-
const
|
|
6018
|
-
|
|
6190
|
+
let N = isNaN$1(v) ? 0 : v;
|
|
6191
|
+
k.keyCode === 38 && (N += 1), k.keyCode === 40 && (N -= 1);
|
|
6192
|
+
const I = `${N}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6193
|
+
_(P);
|
|
6019
6194
|
},
|
|
6020
6195
|
onKeyUp: (k) => {
|
|
6021
6196
|
w && (k.preventDefault(), S(!1));
|
|
6022
6197
|
},
|
|
6023
6198
|
onBlur: () => C(),
|
|
6024
6199
|
onChange: (k) => {
|
|
6025
|
-
|
|
6200
|
+
x(!1), l(k.target.value);
|
|
6026
6201
|
},
|
|
6027
6202
|
onClick: (k) => {
|
|
6028
6203
|
var v;
|
|
6029
6204
|
(v = k == null ? void 0 : k.target) == null || v.select(), r(!1);
|
|
6030
6205
|
},
|
|
6031
|
-
value: B ?
|
|
6206
|
+
value: B ? h : a,
|
|
6032
6207
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6033
6208
|
" ",
|
|
6034
|
-
|
|
6209
|
+
b ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
6035
6210
|
)
|
|
6036
6211
|
}
|
|
6037
6212
|
),
|
|
@@ -6054,7 +6229,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6054
6229
|
units: u,
|
|
6055
6230
|
current: m,
|
|
6056
6231
|
onSelect: (k) => {
|
|
6057
|
-
r(!1),
|
|
6232
|
+
r(!1), f(k), T(k);
|
|
6058
6233
|
}
|
|
6059
6234
|
}
|
|
6060
6235
|
) }) })
|
|
@@ -6067,15 +6242,15 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6067
6242
|
onDragEnd: (k) => {
|
|
6068
6243
|
if (y(() => ""), E(!1), isEmpty(k))
|
|
6069
6244
|
return;
|
|
6070
|
-
const v = `${k}`,
|
|
6071
|
-
A(
|
|
6245
|
+
const v = `${k}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6246
|
+
A(I);
|
|
6072
6247
|
},
|
|
6073
6248
|
onDrag: (k) => {
|
|
6074
6249
|
if (isEmpty(k))
|
|
6075
6250
|
return;
|
|
6076
6251
|
y(k);
|
|
6077
|
-
const v = `${k}`,
|
|
6078
|
-
|
|
6252
|
+
const v = `${k}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6253
|
+
_(I);
|
|
6079
6254
|
},
|
|
6080
6255
|
currentValue: a,
|
|
6081
6256
|
unit: m,
|
|
@@ -6172,22 +6347,22 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6172
6347
|
"2xl": "1536px"
|
|
6173
6348
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6174
6349
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6175
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] =
|
|
6176
|
-
(
|
|
6177
|
-
const
|
|
6178
|
-
(p || u !== "") && (
|
|
6179
|
-
const k = generateFullClsName(
|
|
6180
|
-
|
|
6350
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(), b = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), h = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
|
|
6351
|
+
(_, C = !0) => {
|
|
6352
|
+
const T = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
|
|
6353
|
+
(p || u !== "") && (T.mq = "xs");
|
|
6354
|
+
const k = generateFullClsName(T);
|
|
6355
|
+
f(x, [k], C);
|
|
6181
6356
|
},
|
|
6182
|
-
[
|
|
6357
|
+
[x, p, g, u, l, f]
|
|
6183
6358
|
), B = useCallback(() => {
|
|
6184
|
-
x
|
|
6185
|
-
}, [
|
|
6359
|
+
b(x, [h], !0);
|
|
6360
|
+
}, [x, h, b]), E = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6186
6361
|
useEffect(() => {
|
|
6187
6362
|
i(E, m);
|
|
6188
6363
|
}, [E, i, m]);
|
|
6189
|
-
const [, , w] =
|
|
6190
|
-
(
|
|
6364
|
+
const [, , w] = useScreenSizeWidth(), S = useCallback(
|
|
6365
|
+
(_) => {
|
|
6191
6366
|
w({
|
|
6192
6367
|
xs: 400,
|
|
6193
6368
|
sm: 640,
|
|
@@ -6195,7 +6370,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6195
6370
|
lg: 1024,
|
|
6196
6371
|
xl: 1420,
|
|
6197
6372
|
"2xl": 1920
|
|
6198
|
-
}[
|
|
6373
|
+
}[_]);
|
|
6199
6374
|
},
|
|
6200
6375
|
[w]
|
|
6201
6376
|
), A = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
@@ -6219,7 +6394,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6219
6394
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
|
|
6220
6395
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6221
6396
|
] }),
|
|
6222
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
6397
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${h ? "visible" : "invisible"}`, children: A ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => B(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6223
6398
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6224
6399
|
"button",
|
|
6225
6400
|
{
|
|
@@ -6260,7 +6435,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6260
6435
|
units: i = basicUnits,
|
|
6261
6436
|
negative: c = !1
|
|
6262
6437
|
}) => {
|
|
6263
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((
|
|
6438
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((f) => map(g, "property").includes(f), [g]);
|
|
6264
6439
|
return /* @__PURE__ */ jsxs(
|
|
6265
6440
|
"div",
|
|
6266
6441
|
{
|
|
@@ -6269,22 +6444,22 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6269
6444
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6270
6445
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6271
6446
|
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6272
|
-
n.map(({ label:
|
|
6447
|
+
n.map(({ label: f, key: b }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6273
6448
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6274
6449
|
"button",
|
|
6275
6450
|
{
|
|
6276
6451
|
type: "button",
|
|
6277
|
-
onClick: () => u(
|
|
6278
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6452
|
+
onClick: () => u(b),
|
|
6453
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${b === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6279
6454
|
children: [
|
|
6280
6455
|
React__default.createElement("div", {
|
|
6281
|
-
className: m(
|
|
6456
|
+
className: m(b) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6282
6457
|
}),
|
|
6283
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6458
|
+
React__default.createElement(get(EDITOR_ICONS, b, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6284
6459
|
]
|
|
6285
6460
|
}
|
|
6286
6461
|
) }),
|
|
6287
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
6462
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(f)) })
|
|
6288
6463
|
] }) }))
|
|
6289
6464
|
) })
|
|
6290
6465
|
] }),
|
|
@@ -6424,12 +6599,12 @@ function BlockStyling() {
|
|
|
6424
6599
|
}), d = useThrottledCallback(
|
|
6425
6600
|
(u) => {
|
|
6426
6601
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6427
|
-
let
|
|
6428
|
-
|
|
6429
|
-
let
|
|
6430
|
-
(startsWith(m, "scale") || m === "opacity") && (
|
|
6431
|
-
let
|
|
6432
|
-
g &&
|
|
6602
|
+
let f = parseFloat(i.dragStartValue);
|
|
6603
|
+
f = isNaN(f) ? 0 : f;
|
|
6604
|
+
let b = MAPPER[i.dragUnit];
|
|
6605
|
+
(startsWith(m, "scale") || m === "opacity") && (b = 10);
|
|
6606
|
+
let h = (i.dragStartY - u.pageY) / b + f;
|
|
6607
|
+
g && h < 0 && (h = 0), m === "opacity" && h > 1 && (h = 1), i.onDrag(`${h}`), l(`${h}`);
|
|
6433
6608
|
},
|
|
6434
6609
|
[i],
|
|
6435
6610
|
50
|
|
@@ -6471,35 +6646,35 @@ const CoreBlock = ({
|
|
|
6471
6646
|
parentId: r,
|
|
6472
6647
|
position: a
|
|
6473
6648
|
}) => {
|
|
6474
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(),
|
|
6649
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), f = () => {
|
|
6475
6650
|
if (has(o, "blocks")) {
|
|
6476
|
-
const
|
|
6477
|
-
u(syncBlocksWithDefaults(
|
|
6651
|
+
const h = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6652
|
+
u(syncBlocksWithDefaults(h), r || null, a);
|
|
6478
6653
|
} else
|
|
6479
6654
|
p(o, r || null, a);
|
|
6480
6655
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6481
|
-
},
|
|
6656
|
+
}, b = useFeature("dnd"), { t: x } = useTranslation();
|
|
6482
6657
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6483
6658
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6484
6659
|
"button",
|
|
6485
6660
|
{
|
|
6486
6661
|
disabled: n,
|
|
6487
|
-
onClick:
|
|
6662
|
+
onClick: f,
|
|
6488
6663
|
type: "button",
|
|
6489
|
-
onDragStart: (
|
|
6490
|
-
|
|
6664
|
+
onDragStart: (h) => {
|
|
6665
|
+
h.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), h.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6491
6666
|
g([]), m();
|
|
6492
6667
|
}, 200);
|
|
6493
6668
|
},
|
|
6494
|
-
draggable:
|
|
6669
|
+
draggable: b ? "true" : "false",
|
|
6495
6670
|
className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
|
|
6496
6671
|
children: [
|
|
6497
6672
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6498
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6673
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
|
|
6499
6674
|
]
|
|
6500
6675
|
}
|
|
6501
6676
|
) }),
|
|
6502
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6677
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
|
|
6503
6678
|
] }) });
|
|
6504
6679
|
}, DefaultChaiBlocks = ({
|
|
6505
6680
|
parentId: o,
|
|
@@ -6684,7 +6859,7 @@ const CoreBlock = ({
|
|
|
6684
6859
|
}
|
|
6685
6860
|
}
|
|
6686
6861
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6687
|
-
var m,
|
|
6862
|
+
var m, f, b, x, h, y, B, E;
|
|
6688
6863
|
if (r.type === "comment") return [];
|
|
6689
6864
|
console.log("node ===>", r);
|
|
6690
6865
|
let a = { _id: generateUUID() };
|
|
@@ -6726,9 +6901,9 @@ const CoreBlock = ({
|
|
|
6726
6901
|
a = {
|
|
6727
6902
|
...a,
|
|
6728
6903
|
href: ((m = l.find((S) => S.key === "href")) == null ? void 0 : m.value) || "",
|
|
6729
|
-
hrefType: ((
|
|
6730
|
-
autoplay: ((
|
|
6731
|
-
maxWidth: ((
|
|
6904
|
+
hrefType: ((f = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
|
|
6905
|
+
autoplay: ((b = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : b.value) === "true" ? "true" : "false",
|
|
6906
|
+
maxWidth: ((h = (x = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : h.replace("px", "")) || "",
|
|
6732
6907
|
backdropColor: ((y = l.find((S) => S.key === "data-overlay")) == null ? void 0 : y.value) || "",
|
|
6733
6908
|
galleryName: ((B = l.find((S) => S.key === "data-gall")) == null ? void 0 : B.value) || ""
|
|
6734
6909
|
}, forEach(w, (S) => {
|
|
@@ -6741,14 +6916,14 @@ const CoreBlock = ({
|
|
|
6741
6916
|
a.content = getTextContent(w);
|
|
6742
6917
|
const S = find(
|
|
6743
6918
|
r.children || [],
|
|
6744
|
-
(A) => (A == null ? void 0 : A.tagName) === "span" && some(A.children || [], (
|
|
6919
|
+
(A) => (A == null ? void 0 : A.tagName) === "span" && some(A.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
|
|
6745
6920
|
);
|
|
6746
6921
|
if (S) {
|
|
6747
|
-
const A = find(S.children || [], (
|
|
6922
|
+
const A = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
|
|
6748
6923
|
if (A) {
|
|
6749
6924
|
a.icon = stringify([A]);
|
|
6750
|
-
const { height:
|
|
6751
|
-
a.iconHeight =
|
|
6925
|
+
const { height: _, width: C } = getSvgDimensions(A, "16px", "16px");
|
|
6926
|
+
a.iconHeight = _, a.iconWidth = C;
|
|
6752
6927
|
}
|
|
6753
6928
|
}
|
|
6754
6929
|
return [a];
|
|
@@ -6760,8 +6935,8 @@ const CoreBlock = ({
|
|
|
6760
6935
|
const w = stringify([r]);
|
|
6761
6936
|
return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
|
|
6762
6937
|
} else if (r.tagName === "svg") {
|
|
6763
|
-
const w = find(r.attributes, { key: "height" }), S = find(r.attributes, { key: "width" }), A = get(w, "value") ? `[${get(w, "value")}px]` : "24px",
|
|
6764
|
-
return a.styles = `${STYLES_KEY}, ${cn(`w-${
|
|
6938
|
+
const w = find(r.attributes, { key: "height" }), S = find(r.attributes, { key: "width" }), A = get(w, "value") ? `[${get(w, "value")}px]` : "24px", _ = get(S, "value") ? `[${get(S, "value")}px]` : "24px", C = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
6939
|
+
return a.styles = `${STYLES_KEY}, ${cn(`w-${_} h-${A}`, C)}`.trim(), r.attributes = filter(r.attributes, (T) => !includes(["style", "width", "height", "class"], T.key)), a.icon = stringify([r]), [a];
|
|
6765
6940
|
} else if (r.tagName == "option" && n && ((E = n.block) == null ? void 0 : E._type) === "Select")
|
|
6766
6941
|
return n.block.options.push({
|
|
6767
6942
|
label: getTextContent(r.children),
|
|
@@ -6811,21 +6986,21 @@ const CoreBlock = ({
|
|
|
6811
6986
|
/* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: a.trim() === "", onClick: () => c(), size: "sm", className: "w-fit", children: r("Import HTML") }) })
|
|
6812
6987
|
] });
|
|
6813
6988
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
6814
|
-
var
|
|
6815
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (
|
|
6989
|
+
var x;
|
|
6990
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (x = find(c, (h) => h._id === r)) == null ? void 0 : x._type;
|
|
6816
6991
|
useEffect(() => {
|
|
6817
|
-
const
|
|
6992
|
+
const h = setTimeout(() => {
|
|
6818
6993
|
var y;
|
|
6819
6994
|
(y = u.current) == null || y.focus();
|
|
6820
6995
|
}, 0);
|
|
6821
|
-
return () => clearTimeout(
|
|
6996
|
+
return () => clearTimeout(h);
|
|
6822
6997
|
}, [g]);
|
|
6823
|
-
const
|
|
6824
|
-
(
|
|
6998
|
+
const f = d ? values(n).filter(
|
|
6999
|
+
(h) => {
|
|
6825
7000
|
var y, B;
|
|
6826
|
-
return (((y =
|
|
7001
|
+
return (((y = h.label) == null ? void 0 : y.toLowerCase()) + " " + ((B = h.type) == null ? void 0 : B.toLowerCase())).includes(d.toLowerCase());
|
|
6827
7002
|
}
|
|
6828
|
-
) : n,
|
|
7003
|
+
) : n, b = d ? o.filter((h) => reject(filter(values(f), { group: h }), { hidden: !0 }).length > 0) : o.filter((h) => reject(filter(values(n), { group: h }), { hidden: !0 }).length > 0);
|
|
6829
7004
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-2xl flex-col", children: [
|
|
6830
7005
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
6831
7006
|
Input$1,
|
|
@@ -6834,21 +7009,21 @@ const CoreBlock = ({
|
|
|
6834
7009
|
type: "search",
|
|
6835
7010
|
placeholder: i("Search blocks..."),
|
|
6836
7011
|
value: d,
|
|
6837
|
-
onChange: (
|
|
7012
|
+
onChange: (h) => p(h.target.value)
|
|
6838
7013
|
}
|
|
6839
7014
|
) }),
|
|
6840
|
-
/* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children:
|
|
7015
|
+
/* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: b.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
6841
7016
|
i("No blocks found matching"),
|
|
6842
7017
|
' "',
|
|
6843
7018
|
d,
|
|
6844
7019
|
'"'
|
|
6845
7020
|
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: sortBy(
|
|
6846
|
-
|
|
6847
|
-
(
|
|
6848
|
-
).map((
|
|
6849
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7021
|
+
b,
|
|
7022
|
+
(h) => CORE_GROUPS.indexOf(h) === -1 ? 99 : CORE_GROUPS.indexOf(h)
|
|
7023
|
+
).map((h) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7024
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(h.toLowerCase())) }),
|
|
6850
7025
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
|
|
6851
|
-
reject(filter(values(
|
|
7026
|
+
reject(filter(values(f), { group: h }), { hidden: !0 }).map((y) => /* @__PURE__ */ jsx(
|
|
6852
7027
|
CoreBlock,
|
|
6853
7028
|
{
|
|
6854
7029
|
parentId: r,
|
|
@@ -6859,7 +7034,7 @@ const CoreBlock = ({
|
|
|
6859
7034
|
y.type
|
|
6860
7035
|
))
|
|
6861
7036
|
) })
|
|
6862
|
-
] },
|
|
7037
|
+
] }, h)) }) })
|
|
6863
7038
|
] });
|
|
6864
7039
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
6865
7040
|
className: o,
|
|
@@ -6950,10 +7125,10 @@ const BlockCard = ({
|
|
|
6950
7125
|
parentId: r = void 0,
|
|
6951
7126
|
position: a = -1
|
|
6952
7127
|
}) => {
|
|
6953
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")),
|
|
7128
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), f = useFeature("dnd"), [, b] = useAtom$1(draggedBlockAtom), x = (B) => {
|
|
6954
7129
|
const E = has(B, "styles_attrs.data-page-section");
|
|
6955
7130
|
return B._type === "Box" && E;
|
|
6956
|
-
},
|
|
7131
|
+
}, h = useCallback(
|
|
6957
7132
|
async (B) => {
|
|
6958
7133
|
if (B.stopPropagation(), has(o, "component")) {
|
|
6959
7134
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
@@ -6970,12 +7145,12 @@ const BlockCard = ({
|
|
|
6970
7145
|
"div",
|
|
6971
7146
|
{
|
|
6972
7147
|
onClick: l ? () => {
|
|
6973
|
-
} :
|
|
6974
|
-
draggable:
|
|
7148
|
+
} : h,
|
|
7149
|
+
draggable: f ? "true" : "false",
|
|
6975
7150
|
onDragStart: async (B) => {
|
|
6976
7151
|
const E = await c(n, o);
|
|
6977
7152
|
let w = r;
|
|
6978
|
-
if (
|
|
7153
|
+
if (x(first(E)) && (w = null), !isEmpty(E)) {
|
|
6979
7154
|
const S = { blocks: E, uiLibrary: !0, parent: w };
|
|
6980
7155
|
if (B.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
|
|
6981
7156
|
const A = new Image();
|
|
@@ -6984,7 +7159,7 @@ const BlockCard = ({
|
|
|
6984
7159
|
};
|
|
6985
7160
|
} else
|
|
6986
7161
|
B.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
6987
|
-
|
|
7162
|
+
b(S), setTimeout(() => {
|
|
6988
7163
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6989
7164
|
}, 200);
|
|
6990
7165
|
}
|
|
@@ -7016,9 +7191,9 @@ const BlockCard = ({
|
|
|
7016
7191
|
})();
|
|
7017
7192
|
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
7018
7193
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7019
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m,
|
|
7020
|
-
|
|
7021
|
-
|
|
7194
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, f] = useState("Hero"), b = get(g, m, []), x = useRef(null), { t: h } = useTranslation(), y = (w) => {
|
|
7195
|
+
x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
|
|
7196
|
+
x.current && f(w);
|
|
7022
7197
|
}, 300);
|
|
7023
7198
|
};
|
|
7024
7199
|
if (u)
|
|
@@ -7026,26 +7201,26 @@ const BlockCard = ({
|
|
|
7026
7201
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7027
7202
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7028
7203
|
] });
|
|
7029
|
-
const B = filter(
|
|
7204
|
+
const B = filter(b, (w, S) => S % 2 === 0), E = filter(b, (w, S) => S % 2 === 1);
|
|
7030
7205
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
|
|
7031
7206
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7032
7207
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
7033
7208
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7034
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7209
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: h("Groups") }),
|
|
7035
7210
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7036
7211
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
|
|
7037
7212
|
map(g, (w, S) => /* @__PURE__ */ jsxs(
|
|
7038
7213
|
"div",
|
|
7039
7214
|
{
|
|
7040
7215
|
onMouseEnter: () => y(S),
|
|
7041
|
-
onMouseLeave: () => clearTimeout(
|
|
7042
|
-
onClick: () =>
|
|
7216
|
+
onMouseLeave: () => clearTimeout(x.current),
|
|
7217
|
+
onClick: () => f(S),
|
|
7043
7218
|
className: cn(
|
|
7044
7219
|
"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",
|
|
7045
7220
|
S === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7046
7221
|
),
|
|
7047
7222
|
children: [
|
|
7048
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(
|
|
7223
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(h(S.toLowerCase())) }),
|
|
7049
7224
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7050
7225
|
]
|
|
7051
7226
|
},
|
|
@@ -7057,7 +7232,7 @@ const BlockCard = ({
|
|
|
7057
7232
|
/* @__PURE__ */ jsxs(
|
|
7058
7233
|
ScrollArea,
|
|
7059
7234
|
{
|
|
7060
|
-
onMouseEnter: () =>
|
|
7235
|
+
onMouseEnter: () => x.current ? clearTimeout(x.current) : null,
|
|
7061
7236
|
className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
|
|
7062
7237
|
children: [
|
|
7063
7238
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
@@ -7285,53 +7460,53 @@ function BiExpandVertical(o) {
|
|
|
7285
7460
|
return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z" }, child: [] }] })(o);
|
|
7286
7461
|
}
|
|
7287
7462
|
const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
7288
|
-
var
|
|
7463
|
+
var P;
|
|
7289
7464
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7290
7465
|
let p = null;
|
|
7291
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id:
|
|
7292
|
-
|
|
7293
|
-
}, S = (
|
|
7294
|
-
|
|
7295
|
-
}, A = (
|
|
7296
|
-
|
|
7297
|
-
}, [
|
|
7298
|
-
var
|
|
7299
|
-
k(), o.parent.isSelected || C((
|
|
7466
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data: b, isSelected: x, willReceiveDrop: h, isDragging: y, isEditing: B, handleClick: E } = o, w = (j) => {
|
|
7467
|
+
j.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7468
|
+
}, S = (j) => {
|
|
7469
|
+
j.isInternal && (p = j.isOpen, j.isOpen && j.close());
|
|
7470
|
+
}, A = (j) => {
|
|
7471
|
+
j.isInternal && p !== null && (p ? j.open() : j.close(), p = null);
|
|
7472
|
+
}, [_, C] = useAtom$1(currentAddSelection), T = () => {
|
|
7473
|
+
var j;
|
|
7474
|
+
k(), o.parent.isSelected || C((j = o == null ? void 0 : o.parent) == null ? void 0 : j.id);
|
|
7300
7475
|
}, k = () => {
|
|
7301
7476
|
C(null);
|
|
7302
|
-
}, v = (
|
|
7303
|
-
k(),
|
|
7477
|
+
}, v = (j) => {
|
|
7478
|
+
k(), j.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), E(j);
|
|
7304
7479
|
};
|
|
7305
7480
|
useEffect(() => {
|
|
7306
|
-
const
|
|
7307
|
-
|
|
7481
|
+
const j = setTimeout(() => {
|
|
7482
|
+
h && !o.isOpen && !y && !i.includes(f) && o.toggle();
|
|
7308
7483
|
}, 500);
|
|
7309
|
-
return () => clearTimeout(
|
|
7310
|
-
}, [
|
|
7311
|
-
const
|
|
7312
|
-
const
|
|
7313
|
-
for (let D = 0; D <
|
|
7314
|
-
if (
|
|
7315
|
-
const L =
|
|
7316
|
-
$.match(/x-data/) &&
|
|
7484
|
+
return () => clearTimeout(j);
|
|
7485
|
+
}, [h, o, y]);
|
|
7486
|
+
const N = useMemo(() => {
|
|
7487
|
+
const j = Object.keys(b), R = [];
|
|
7488
|
+
for (let D = 0; D < j.length; D++)
|
|
7489
|
+
if (j[D].endsWith("_attrs")) {
|
|
7490
|
+
const L = b[j[D]], $ = Object.keys(L).join("|");
|
|
7491
|
+
$.match(/x-data/) && R.push("data"), $.match(/x-on/) && R.push("event"), $.match(/x-show|x-if/) && R.push("show");
|
|
7317
7492
|
}
|
|
7318
|
-
return
|
|
7319
|
-
}, [
|
|
7320
|
-
const D = d.contentDocument || d.contentWindow.document, L = D.querySelector(`[data-block-id=${
|
|
7321
|
-
L && L.setAttribute("data-drop",
|
|
7493
|
+
return R;
|
|
7494
|
+
}, [b]), I = (j, R) => {
|
|
7495
|
+
const D = d.contentDocument || d.contentWindow.document, L = D.querySelector(`[data-block-id=${j}]`);
|
|
7496
|
+
L && L.setAttribute("data-drop", R);
|
|
7322
7497
|
const $ = L.getBoundingClientRect(), O = d.getBoundingClientRect();
|
|
7323
7498
|
$.top >= O.top && $.left >= O.left && $.bottom <= O.bottom && $.right <= O.right || (D.documentElement.scrollTop = L.offsetTop - O.top);
|
|
7324
|
-
},
|
|
7499
|
+
}, M = (j) => {
|
|
7325
7500
|
k();
|
|
7326
|
-
const
|
|
7327
|
-
|
|
7501
|
+
const R = get(o, "parent.id");
|
|
7502
|
+
R !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: R, position: j }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: j });
|
|
7328
7503
|
};
|
|
7329
|
-
return
|
|
7504
|
+
return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7330
7505
|
/* @__PURE__ */ jsx("br", {}),
|
|
7331
7506
|
/* @__PURE__ */ jsx(
|
|
7332
7507
|
"div",
|
|
7333
7508
|
{
|
|
7334
|
-
onClick: () =>
|
|
7509
|
+
onClick: () => M(-1),
|
|
7335
7510
|
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
7336
7511
|
children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
|
|
7337
7512
|
/* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7341,34 +7516,34 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7341
7516
|
}
|
|
7342
7517
|
),
|
|
7343
7518
|
/* @__PURE__ */ jsx("br", {})
|
|
7344
|
-
] }) : /* @__PURE__ */ jsx(BlockContextMenu, { id:
|
|
7519
|
+
] }) : /* @__PURE__ */ jsx(BlockContextMenu, { id: f, children: /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7345
7520
|
"div",
|
|
7346
7521
|
{
|
|
7347
|
-
onMouseEnter: () => g(
|
|
7522
|
+
onMouseEnter: () => g(f),
|
|
7348
7523
|
onMouseLeave: () => m(),
|
|
7349
7524
|
onClick: v,
|
|
7350
7525
|
style: n,
|
|
7351
|
-
"data-node-id":
|
|
7352
|
-
ref: i.includes(
|
|
7526
|
+
"data-node-id": f,
|
|
7527
|
+
ref: i.includes(f) ? null : r,
|
|
7353
7528
|
onDragStart: () => S(o),
|
|
7354
7529
|
onDragEnd: () => A(o),
|
|
7355
|
-
onDragOver: (
|
|
7356
|
-
|
|
7530
|
+
onDragOver: (j) => {
|
|
7531
|
+
j.preventDefault(), I(f, "yes");
|
|
7357
7532
|
},
|
|
7358
|
-
onDragLeave: (
|
|
7359
|
-
|
|
7533
|
+
onDragLeave: (j) => {
|
|
7534
|
+
j.preventDefault(), I(f, "no");
|
|
7360
7535
|
},
|
|
7361
|
-
onDrop: (
|
|
7362
|
-
|
|
7536
|
+
onDrop: (j) => {
|
|
7537
|
+
j.preventDefault(), I(f, "no");
|
|
7363
7538
|
},
|
|
7364
7539
|
children: [
|
|
7365
|
-
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((
|
|
7540
|
+
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
7366
7541
|
"div",
|
|
7367
7542
|
{
|
|
7368
|
-
onClick: (
|
|
7369
|
-
|
|
7543
|
+
onClick: (j) => {
|
|
7544
|
+
j.stopPropagation(), M(o.childIndex);
|
|
7370
7545
|
},
|
|
7371
|
-
onMouseEnter:
|
|
7546
|
+
onMouseEnter: T,
|
|
7372
7547
|
onMouseLeave: k,
|
|
7373
7548
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7374
7549
|
children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
|
|
@@ -7379,11 +7554,11 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7379
7554
|
{
|
|
7380
7555
|
className: cn(
|
|
7381
7556
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
(o == null ? void 0 : o.id) ===
|
|
7557
|
+
x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7558
|
+
h && canAcceptChildBlock(b._type, "Icon") ? "bg-green-200" : "",
|
|
7559
|
+
(o == null ? void 0 : o.id) === _ ? "bg-purple-100" : "",
|
|
7385
7560
|
y && "opacity-20",
|
|
7386
|
-
i.includes(
|
|
7561
|
+
i.includes(f) ? "opacity-50" : ""
|
|
7387
7562
|
),
|
|
7388
7563
|
children: [
|
|
7389
7564
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7394,47 +7569,47 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7394
7569
|
children: u && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(
|
|
7395
7570
|
ChevronRight,
|
|
7396
7571
|
{
|
|
7397
|
-
className: `h-3 w-3 stroke-[3] ${
|
|
7572
|
+
className: `h-3 w-3 stroke-[3] ${x ? "text-slate-200" : "text-slate-400"}`
|
|
7398
7573
|
}
|
|
7399
7574
|
) })
|
|
7400
7575
|
}
|
|
7401
7576
|
),
|
|
7402
7577
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7403
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7578
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: b == null ? void 0 : b._type }),
|
|
7404
7579
|
B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7405
7580
|
"div",
|
|
7406
7581
|
{
|
|
7407
7582
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
7408
|
-
onDoubleClick: (
|
|
7409
|
-
|
|
7583
|
+
onDoubleClick: (j) => {
|
|
7584
|
+
j.stopPropagation(), o.edit(), o.deselect();
|
|
7410
7585
|
},
|
|
7411
7586
|
children: [
|
|
7412
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7587
|
+
/* @__PURE__ */ jsx("span", { children: (b == null ? void 0 : b._name) || (b == null ? void 0 : b._type.split("/").pop()) }),
|
|
7588
|
+
N.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7589
|
+
N.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
|
|
7590
|
+
N.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
|
|
7416
7591
|
]
|
|
7417
7592
|
}
|
|
7418
7593
|
)
|
|
7419
7594
|
] })
|
|
7420
7595
|
] }),
|
|
7421
7596
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7422
|
-
!i.includes(
|
|
7597
|
+
!i.includes(f) && a.map((j) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7423
7598
|
/* @__PURE__ */ jsx(
|
|
7424
7599
|
TooltipTrigger,
|
|
7425
7600
|
{
|
|
7426
7601
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
7427
7602
|
asChild: !0,
|
|
7428
|
-
children: React__default.createElement(
|
|
7603
|
+
children: React__default.createElement(j.item, { blockId: f })
|
|
7429
7604
|
}
|
|
7430
7605
|
),
|
|
7431
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children:
|
|
7606
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: j.tooltip })
|
|
7432
7607
|
] })),
|
|
7433
|
-
canAddChildBlock(
|
|
7608
|
+
canAddChildBlock(b == null ? void 0 : b._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7434
7609
|
/* @__PURE__ */ jsx(
|
|
7435
7610
|
TooltipTrigger,
|
|
7436
7611
|
{
|
|
7437
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
7612
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: f }),
|
|
7438
7613
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7439
7614
|
asChild: !0,
|
|
7440
7615
|
children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
|
|
@@ -7446,8 +7621,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7446
7621
|
/* @__PURE__ */ jsx(
|
|
7447
7622
|
TooltipTrigger,
|
|
7448
7623
|
{
|
|
7449
|
-
onClick: (
|
|
7450
|
-
|
|
7624
|
+
onClick: (j) => {
|
|
7625
|
+
j.stopPropagation(), c(f), o.isOpen && o.toggle();
|
|
7451
7626
|
},
|
|
7452
7627
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7453
7628
|
asChild: !0,
|
|
@@ -7644,7 +7819,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7644
7819
|
) }),
|
|
7645
7820
|
/* @__PURE__ */ jsx(PasteAtRootContextMenu, { parentContext, setParentContext })
|
|
7646
7821
|
] });
|
|
7647
|
-
}, Core = "Core", Import = "Import", Breakpoints
|
|
7822
|
+
}, Core = "Core", Import = "Import", Breakpoints = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Styling", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", theme_config = { heading_font: "Heading Font", body_font: "Body Font", rounded_corner: "Rounded Corners", primary: "Primary", secondary: "Secondary", background: "Background", text_color: "Text Color", background_dark_mode: "Background (Dark Mode)", text_color_dark_mode: "Text Color (Dark Mode)" }, web_blocks = { box: "box", tag: "Tag", div: "div", level: "Level", header: "header", footer: "footer", section: "section", article: "article", aside: "aside", main: "main", nav: "navigation", figure: "figure", details: "details", summary: "summary", dialog: "dialog", strike: "strike", caption: "caption", legend: "legend", figcaption: "figure caption", mark: "mark", background_image: "Background Image", label: "Label", default: "default", icon_size: "Icon Size", icon_position: "Icon Position", start: "Start", end: "End", button: "Button", custom_html: "Custom HTML", html_code: "HTML Code", default_snippet: "The HTML snippet goes here...", placeholder: "Enter custom HTML code here", custom_script: "Custom Script", dark_mode: "Dark Mode", divider: "Divider", empty_box: "Empty Box", heading: "Heading", image: "Image", alt: "Alt", width: "Width", height: "Height", video: "Video", span: "Span", content: "Content", icon: "Icon", richtext: "Rich Text", list: "List", list_type: "List Type", listitem: "List Item", link: "Link", list_item: "List Item", none: "None", disc: "Disc", number: "Number", paragraph: "Paragraph", lightbox_link: "Lightbox Link", href: "Link", type: "Type", iframe: "iframe", inline: "inline", ajax: "ajax", autoplay: "Video autoplay", max_width: "Max Width", backdrop_color: "Background Color", gallery_name: "Gallery Name", slot: "Slot", empty_slot: "Empty Slot", text: "Text", video_url: "Video URL", controls: "Show Controls", loop: "Loop", muted: "Muted", checkbox: "Checkbox", required: "Required", checked: "Checked", submit_button: "Submit Button", form: "Form", submit_url: "Submit URL", error_message: "Error Message", success_message: "Success Message", input: "Input", value: "Value", show_label: "Show Label", field_name: "Field Name", radio: "Radio", multiple: "Multiple", options: "Options", select: "Select", multiple_choice: "Multiple Choice", textarea: "Textarea", rows: "Rows" }, Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", lngEn = {
|
|
7648
7823
|
"Add block": "Add Block",
|
|
7649
7824
|
"Add blocks": "Add blocks",
|
|
7650
7825
|
"Enter or paste TailwindCSS HTML snippet": "Enter or paste TailwindCSS HTML snippet",
|
|
@@ -7678,7 +7853,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7678
7853
|
"Styles set here are applied at 1280px and up unless edited at higher breakpoint": "Styles set here are applied at 1280px and up unless edited at higher breakpoint",
|
|
7679
7854
|
"Large Desktop (2XL)": "Large Desktop (2XL)",
|
|
7680
7855
|
"Styles set here are applied at 1536px and up": "Styles set here are applied at 1536px and up",
|
|
7681
|
-
Breakpoints
|
|
7856
|
+
Breakpoints,
|
|
7682
7857
|
Clear,
|
|
7683
7858
|
"Clear whole canvas?": "Clear whole canvas?",
|
|
7684
7859
|
"Are you sure you want to clear the whole canvas?": "Are you sure you want to clear the whole canvas?",
|
|
@@ -8107,14 +8282,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8107
8282
|
) }) });
|
|
8108
8283
|
}
|
|
8109
8284
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8110
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null),
|
|
8285
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), f = useRef(null);
|
|
8111
8286
|
useEffect(() => {
|
|
8112
|
-
var
|
|
8113
|
-
(
|
|
8287
|
+
var x;
|
|
8288
|
+
(x = m.current) == null || x.focus();
|
|
8114
8289
|
}, []);
|
|
8115
|
-
const
|
|
8116
|
-
const { usage:
|
|
8117
|
-
!l &&
|
|
8290
|
+
const b = (x) => {
|
|
8291
|
+
const { usage: h } = x || {};
|
|
8292
|
+
!l && h && g(h), f.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8118
8293
|
};
|
|
8119
8294
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8120
8295
|
/* @__PURE__ */ jsxs(
|
|
@@ -8134,12 +8309,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8134
8309
|
{
|
|
8135
8310
|
ref: m,
|
|
8136
8311
|
value: i,
|
|
8137
|
-
onChange: (
|
|
8312
|
+
onChange: (x) => c(x.target.value),
|
|
8138
8313
|
placeholder: n("Ask AI to edit content"),
|
|
8139
8314
|
className: "w-full",
|
|
8140
8315
|
rows: 3,
|
|
8141
|
-
onKeyDown: (
|
|
8142
|
-
|
|
8316
|
+
onKeyDown: (x) => {
|
|
8317
|
+
x.key === "Enter" && (x.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, b));
|
|
8143
8318
|
}
|
|
8144
8319
|
}
|
|
8145
8320
|
),
|
|
@@ -8149,7 +8324,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8149
8324
|
{
|
|
8150
8325
|
disabled: i.trim().length < 5 || a,
|
|
8151
8326
|
onClick: () => {
|
|
8152
|
-
|
|
8327
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, i, b);
|
|
8153
8328
|
},
|
|
8154
8329
|
variant: "default",
|
|
8155
8330
|
className: "w-fit",
|
|
@@ -8181,8 +8356,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8181
8356
|
/* @__PURE__ */ jsx(
|
|
8182
8357
|
QuickPrompts,
|
|
8183
8358
|
{
|
|
8184
|
-
onClick: (
|
|
8185
|
-
|
|
8359
|
+
onClick: (x) => {
|
|
8360
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, x, b);
|
|
8186
8361
|
}
|
|
8187
8362
|
}
|
|
8188
8363
|
)
|
|
@@ -8192,19 +8367,19 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8192
8367
|
] }) }) : null
|
|
8193
8368
|
] });
|
|
8194
8369
|
}, AISetContext = () => {
|
|
8195
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), { toast: m } = useToast(),
|
|
8370
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), { toast: m } = useToast(), f = useRef(null);
|
|
8196
8371
|
useEffect(() => {
|
|
8197
8372
|
n && a(n);
|
|
8198
8373
|
}, [n]);
|
|
8199
|
-
const
|
|
8374
|
+
const b = async () => {
|
|
8200
8375
|
try {
|
|
8201
8376
|
d(!0), u(null), await i(r), m({
|
|
8202
8377
|
title: o("Updated AI Context"),
|
|
8203
8378
|
description: o("You can now Ask AI to edit your content"),
|
|
8204
8379
|
variant: "default"
|
|
8205
|
-
}),
|
|
8206
|
-
} catch (
|
|
8207
|
-
u(
|
|
8380
|
+
}), f.current.click();
|
|
8381
|
+
} catch (x) {
|
|
8382
|
+
u(x);
|
|
8208
8383
|
} finally {
|
|
8209
8384
|
d(!1);
|
|
8210
8385
|
}
|
|
@@ -8212,25 +8387,25 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8212
8387
|
return /* @__PURE__ */ jsx(
|
|
8213
8388
|
Accordion,
|
|
8214
8389
|
{
|
|
8215
|
-
onValueChange: (
|
|
8216
|
-
g(
|
|
8390
|
+
onValueChange: (x) => {
|
|
8391
|
+
g(x !== "");
|
|
8217
8392
|
},
|
|
8218
8393
|
type: "single",
|
|
8219
8394
|
collapsible: !0,
|
|
8220
8395
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8221
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8396
|
+
/* @__PURE__ */ jsx(AccordionTrigger, { ref: f, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
8222
8397
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
8223
8398
|
/* @__PURE__ */ jsx(
|
|
8224
8399
|
Textarea,
|
|
8225
8400
|
{
|
|
8226
8401
|
ref: l,
|
|
8227
8402
|
value: r,
|
|
8228
|
-
onChange: (
|
|
8403
|
+
onChange: (x) => a(x.target.value),
|
|
8229
8404
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8230
8405
|
className: "mt-1 w-full",
|
|
8231
8406
|
rows: 10,
|
|
8232
|
-
onKeyDown: (
|
|
8233
|
-
|
|
8407
|
+
onKeyDown: (x) => {
|
|
8408
|
+
x.key === "Enter" && (x.preventDefault(), b());
|
|
8234
8409
|
}
|
|
8235
8410
|
}
|
|
8236
8411
|
),
|
|
@@ -8242,7 +8417,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8242
8417
|
Button,
|
|
8243
8418
|
{
|
|
8244
8419
|
disabled: r.trim().length < 5,
|
|
8245
|
-
onClick: () =>
|
|
8420
|
+
onClick: () => b(),
|
|
8246
8421
|
variant: "default",
|
|
8247
8422
|
className: "w-fit",
|
|
8248
8423
|
size: "sm",
|
|
@@ -8271,7 +8446,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8271
8446
|
AlertDialogAction,
|
|
8272
8447
|
{
|
|
8273
8448
|
onClick: () => {
|
|
8274
|
-
a(""),
|
|
8449
|
+
a(""), b();
|
|
8275
8450
|
},
|
|
8276
8451
|
children: o("Yes, Delete")
|
|
8277
8452
|
}
|
|
@@ -8291,114 +8466,6 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8291
8466
|
/* @__PURE__ */ jsx(AISetContext, {}),
|
|
8292
8467
|
/* @__PURE__ */ jsx(AIUserPrompt, { blockId: first(o) })
|
|
8293
8468
|
] });
|
|
8294
|
-
}, TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
8295
|
-
"svg",
|
|
8296
|
-
{
|
|
8297
|
-
className: o ? "rotate-90" : "",
|
|
8298
|
-
stroke: "currentColor",
|
|
8299
|
-
fill: "currentColor",
|
|
8300
|
-
strokeWidth: "0",
|
|
8301
|
-
viewBox: "0 0 448 512",
|
|
8302
|
-
height: "14px",
|
|
8303
|
-
width: "14px",
|
|
8304
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
8305
|
-
children: /* @__PURE__ */ jsx("path", { d: "M400 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM224 480c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm176-108c0 6.6-5.4 12-12 12H60c-6.6 0-12-5.4-12-12V60c0-6.6 5.4-12 12-12h328c6.6 0 12 5.4 12 12v312z" })
|
|
8306
|
-
}
|
|
8307
|
-
), WEB_BREAKPOINTS = [
|
|
8308
|
-
{
|
|
8309
|
-
title: "Mobile (XS)",
|
|
8310
|
-
content: "Styles set here are applied to all screen unless edited at higher breakpoint",
|
|
8311
|
-
breakpoint: "xs",
|
|
8312
|
-
icon: /* @__PURE__ */ jsx(MobileIcon, {}),
|
|
8313
|
-
width: 400
|
|
8314
|
-
},
|
|
8315
|
-
{
|
|
8316
|
-
title: "Mobile landscape (SM)",
|
|
8317
|
-
content: "Styles set here are applied at 640px and up unless edited at higher breakpoint",
|
|
8318
|
-
breakpoint: "sm",
|
|
8319
|
-
icon: /* @__PURE__ */ jsx(MobileIcon, { className: "rotate-90" }),
|
|
8320
|
-
width: 640
|
|
8321
|
-
},
|
|
8322
|
-
{
|
|
8323
|
-
title: "Tablet (MD)",
|
|
8324
|
-
content: "Styles set here are applied at 768px and up",
|
|
8325
|
-
breakpoint: "md",
|
|
8326
|
-
icon: /* @__PURE__ */ jsx(TabletIcon, {}),
|
|
8327
|
-
width: 800
|
|
8328
|
-
},
|
|
8329
|
-
{
|
|
8330
|
-
title: "Tablet Landscape (LG)",
|
|
8331
|
-
content: "Styles set here are applied at 1024px and up unless edited at higher breakpoint",
|
|
8332
|
-
breakpoint: "lg",
|
|
8333
|
-
icon: /* @__PURE__ */ jsx(TabletIcon, { landscape: !0 }),
|
|
8334
|
-
width: 1024
|
|
8335
|
-
},
|
|
8336
|
-
{
|
|
8337
|
-
title: "Desktop (XL)",
|
|
8338
|
-
content: "Styles set here are applied at 1280px and up unless edited at higher breakpoint",
|
|
8339
|
-
breakpoint: "xl",
|
|
8340
|
-
icon: /* @__PURE__ */ jsx(LaptopIcon, {}),
|
|
8341
|
-
width: 1420
|
|
8342
|
-
},
|
|
8343
|
-
{
|
|
8344
|
-
title: "Large Desktop (2XL)",
|
|
8345
|
-
content: "Styles set here are applied at 1536px and up",
|
|
8346
|
-
breakpoint: "2xl",
|
|
8347
|
-
icon: /* @__PURE__ */ jsx(DesktopIcon, {}),
|
|
8348
|
-
width: 1920
|
|
8349
|
-
}
|
|
8350
|
-
], BreakpointCard = ({
|
|
8351
|
-
title: o,
|
|
8352
|
-
content: n,
|
|
8353
|
-
currentBreakpoint: r,
|
|
8354
|
-
breakpoint: a,
|
|
8355
|
-
width: l,
|
|
8356
|
-
icon: i,
|
|
8357
|
-
onClick: c
|
|
8358
|
-
}) => {
|
|
8359
|
-
const { t: d } = useTranslation();
|
|
8360
|
-
return /* @__PURE__ */ jsxs(HoverCard, { children: [
|
|
8361
|
-
/* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
8362
|
-
Button,
|
|
8363
|
-
{
|
|
8364
|
-
onClick: () => c(l),
|
|
8365
|
-
size: "sm",
|
|
8366
|
-
variant: a === r ? "secondary" : "ghost",
|
|
8367
|
-
children: i
|
|
8368
|
-
}
|
|
8369
|
-
) }),
|
|
8370
|
-
/* @__PURE__ */ jsx(HoverCardContent, { className: "w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
8371
|
-
/* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: d(o) }),
|
|
8372
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs", children: d(n) })
|
|
8373
|
-
] }) }) })
|
|
8374
|
-
] });
|
|
8375
|
-
}, Breakpoints = () => {
|
|
8376
|
-
const [, o, n] = useCanvasWidth(), [r, a] = useSelectedBreakpoints(), { t: l } = useTranslation(), i = useBuilderProp("breakpoints", WEB_BREAKPOINTS), c = (d) => {
|
|
8377
|
-
r.includes(d) ? r.length > 2 && a(r.filter((p) => p !== d)) : a((p) => [...p, d]);
|
|
8378
|
-
};
|
|
8379
|
-
return i.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(i, (d) => /* @__PURE__ */ createElement(BreakpointCard, { ...d, onClick: n, key: d.breakpoint, currentBreakpoint: o })) }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md", children: [
|
|
8380
|
-
map(
|
|
8381
|
-
i.filter((d) => includes(r, toUpper(d.breakpoint))),
|
|
8382
|
-
(d) => /* @__PURE__ */ createElement(BreakpointCard, { ...d, onClick: n, key: d.breakpoint, currentBreakpoint: o })
|
|
8383
|
-
),
|
|
8384
|
-
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
8385
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
|
|
8386
|
-
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
8387
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: l("Breakpoints") }),
|
|
8388
|
-
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
8389
|
-
map(i, (d) => /* @__PURE__ */ jsx(
|
|
8390
|
-
DropdownMenuCheckboxItem,
|
|
8391
|
-
{
|
|
8392
|
-
disabled: d.breakpoint === "xs",
|
|
8393
|
-
onCheckedChange: () => c(toUpper(d.breakpoint)),
|
|
8394
|
-
checked: includes(r, toUpper(d.breakpoint)),
|
|
8395
|
-
children: l(d.title)
|
|
8396
|
-
},
|
|
8397
|
-
d.breakpoint
|
|
8398
|
-
))
|
|
8399
|
-
] })
|
|
8400
|
-
] })
|
|
8401
|
-
] });
|
|
8402
8469
|
};
|
|
8403
8470
|
function DarkMode() {
|
|
8404
8471
|
const [o, n] = useDarkMode();
|
|
@@ -8509,7 +8576,7 @@ const AiAssistant = () => {
|
|
|
8509
8576
|
const o = useBuilderProp("darkMode", !0), [n] = useCanvasZoom();
|
|
8510
8577
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-10 items-center justify-between border-b border-border bg-background/70 px-2", children: [
|
|
8511
8578
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full space-x-2", children: [
|
|
8512
|
-
/* @__PURE__ */ jsx(Breakpoints, {}),
|
|
8579
|
+
/* @__PURE__ */ jsx(Breakpoints$1, { canvas: !0, openDelay: 400 }),
|
|
8513
8580
|
/* @__PURE__ */ jsx(Separator, { orientation: "vertical" }),
|
|
8514
8581
|
o ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8515
8582
|
/* @__PURE__ */ jsx(DarkMode, {}),
|
|
@@ -8533,32 +8600,32 @@ const AiAssistant = () => {
|
|
|
8533
8600
|
] })
|
|
8534
8601
|
] });
|
|
8535
8602
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
|
|
8536
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m,
|
|
8603
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), b = useRef(null), x = useRef(null);
|
|
8537
8604
|
useEffect(() => {
|
|
8538
8605
|
l(n);
|
|
8539
8606
|
}, [n]);
|
|
8540
|
-
const
|
|
8607
|
+
const h = () => {
|
|
8541
8608
|
if (i.startsWith("@")) {
|
|
8542
|
-
|
|
8609
|
+
f("Attribute keys cannot start with '@'");
|
|
8543
8610
|
return;
|
|
8544
8611
|
}
|
|
8545
8612
|
if (i) {
|
|
8546
8613
|
const S = [...a, { key: i, value: d }];
|
|
8547
|
-
r(S), l(a), c(""), p(""),
|
|
8614
|
+
r(S), l(a), c(""), p(""), f("");
|
|
8548
8615
|
}
|
|
8549
8616
|
}, y = (S) => {
|
|
8550
|
-
const A = a.filter((
|
|
8617
|
+
const A = a.filter((_, C) => C !== S);
|
|
8551
8618
|
r(A), l(A);
|
|
8552
8619
|
}, B = (S) => {
|
|
8553
8620
|
g(S), c(a[S].key), p(a[S].value);
|
|
8554
8621
|
}, E = () => {
|
|
8555
8622
|
if (i.startsWith("@")) {
|
|
8556
|
-
|
|
8623
|
+
f("Attribute keys cannot start with '@'");
|
|
8557
8624
|
return;
|
|
8558
8625
|
}
|
|
8559
8626
|
if (u !== null && i) {
|
|
8560
8627
|
const S = [...a];
|
|
8561
|
-
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""),
|
|
8628
|
+
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), f("");
|
|
8562
8629
|
}
|
|
8563
8630
|
};
|
|
8564
8631
|
return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
|
|
@@ -8566,7 +8633,7 @@ const AiAssistant = () => {
|
|
|
8566
8633
|
"form",
|
|
8567
8634
|
{
|
|
8568
8635
|
onSubmit: (S) => {
|
|
8569
|
-
S.preventDefault(), u !== null ? E() :
|
|
8636
|
+
S.preventDefault(), u !== null ? E() : h();
|
|
8570
8637
|
},
|
|
8571
8638
|
className: "space-y-3",
|
|
8572
8639
|
children: [
|
|
@@ -8580,7 +8647,7 @@ const AiAssistant = () => {
|
|
|
8580
8647
|
autoCorrect: "off",
|
|
8581
8648
|
spellCheck: "false",
|
|
8582
8649
|
id: "attrKey",
|
|
8583
|
-
ref:
|
|
8650
|
+
ref: b,
|
|
8584
8651
|
value: i,
|
|
8585
8652
|
onChange: (S) => c(S.target.value),
|
|
8586
8653
|
placeholder: "Enter Key",
|
|
@@ -8598,11 +8665,11 @@ const AiAssistant = () => {
|
|
|
8598
8665
|
spellCheck: "false",
|
|
8599
8666
|
id: "attrValue",
|
|
8600
8667
|
rows: 2,
|
|
8601
|
-
ref:
|
|
8668
|
+
ref: x,
|
|
8602
8669
|
value: d,
|
|
8603
8670
|
onChange: (S) => p(S.target.value),
|
|
8604
8671
|
onKeyDown: (S) => {
|
|
8605
|
-
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? E() :
|
|
8672
|
+
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? E() : h());
|
|
8606
8673
|
},
|
|
8607
8674
|
placeholder: "Enter Value",
|
|
8608
8675
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
@@ -8818,12 +8885,12 @@ const RootLayout = () => {
|
|
|
8818
8885
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
8819
8886
|
n(1);
|
|
8820
8887
|
});
|
|
8821
|
-
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (
|
|
8822
|
-
|
|
8823
|
-
}, u = (
|
|
8824
|
-
n(o ===
|
|
8825
|
-
}, g = useSidebarMenuItems(), { t: m } = useTranslation(),
|
|
8826
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
8888
|
+
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
|
|
8889
|
+
x.preventDefault();
|
|
8890
|
+
}, u = (x) => {
|
|
8891
|
+
n(o === x ? null : x);
|
|
8892
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c], b = useBuilderProp("htmlDir", "ltr");
|
|
8893
|
+
return /* @__PURE__ */ jsx("div", { dir: b, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
8827
8894
|
/* @__PURE__ */ jsxs(
|
|
8828
8895
|
"div",
|
|
8829
8896
|
{
|
|
@@ -8833,21 +8900,21 @@ const RootLayout = () => {
|
|
|
8833
8900
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
8834
8901
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8835
8902
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
8836
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children:
|
|
8903
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((x, h) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8837
8904
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
8838
8905
|
Button,
|
|
8839
8906
|
{
|
|
8840
|
-
variant: o ===
|
|
8907
|
+
variant: o === h ? "default" : "ghost",
|
|
8841
8908
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
8842
|
-
onClick: () => u(
|
|
8843
|
-
children: get(
|
|
8909
|
+
onClick: () => u(h),
|
|
8910
|
+
children: get(x, "icon", null)
|
|
8844
8911
|
},
|
|
8845
|
-
|
|
8912
|
+
h
|
|
8846
8913
|
) }),
|
|
8847
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(
|
|
8848
|
-
] }, "button" +
|
|
8914
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(x.label) }) })
|
|
8915
|
+
] }, "button" + h)) }),
|
|
8849
8916
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
8850
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((
|
|
8917
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, h) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${h}`)) })
|
|
8851
8918
|
] }),
|
|
8852
8919
|
/* @__PURE__ */ jsx(
|
|
8853
8920
|
motion.div,
|
|
@@ -8860,14 +8927,14 @@ const RootLayout = () => {
|
|
|
8860
8927
|
/* @__PURE__ */ jsxs(
|
|
8861
8928
|
"div",
|
|
8862
8929
|
{
|
|
8863
|
-
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(
|
|
8930
|
+
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(f, `${o}.isInternal`, !1) ? "" : "w-64"}`,
|
|
8864
8931
|
children: [
|
|
8865
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
8866
|
-
/* @__PURE__ */ jsx("span", { children: m(
|
|
8932
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(f, `${o}.icon`, null) }),
|
|
8933
|
+
/* @__PURE__ */ jsx("span", { children: m(f[o].label) })
|
|
8867
8934
|
]
|
|
8868
8935
|
}
|
|
8869
8936
|
),
|
|
8870
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(
|
|
8937
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(f, `${o}.component`, null), {}) }) })
|
|
8871
8938
|
] })
|
|
8872
8939
|
}
|
|
8873
8940
|
),
|
|
@@ -9005,7 +9072,7 @@ export {
|
|
|
9005
9072
|
DefaultChaiBlocks,
|
|
9006
9073
|
ImportHTML,
|
|
9007
9074
|
ListTree as Outline,
|
|
9008
|
-
Breakpoints as ScreenSizes,
|
|
9075
|
+
Breakpoints$1 as ScreenSizes,
|
|
9009
9076
|
ThemeConfigPanel as ThemeOptions,
|
|
9010
9077
|
UILibrariesPanel as UILibraries,
|
|
9011
9078
|
UndoRedo,
|
|
@@ -9024,7 +9091,7 @@ export {
|
|
|
9024
9091
|
useBrandingOptions,
|
|
9025
9092
|
useBuilderProp,
|
|
9026
9093
|
useBuilderReset,
|
|
9027
|
-
|
|
9094
|
+
useCanvasDisplayWidth,
|
|
9028
9095
|
useCanvasZoom,
|
|
9029
9096
|
useCodeEditor,
|
|
9030
9097
|
useCopyBlockIds,
|
|
@@ -9045,6 +9112,7 @@ export {
|
|
|
9045
9112
|
useRemoveClassesFromBlocks,
|
|
9046
9113
|
useRightPanel,
|
|
9047
9114
|
useSavePage,
|
|
9115
|
+
useScreenSizeWidth,
|
|
9048
9116
|
useSelectedBlock,
|
|
9049
9117
|
useSelectedBlockAllClasses,
|
|
9050
9118
|
useSelectedBlockCurrentClasses,
|